blob: 65903812b307a392aa0acb9b4c8b70fa20184222 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
35
36/* ALC880 board config type */
37enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020043 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020044 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020045 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010050 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020051 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010052 ALC880_CLEVO,
53 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010054 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010055 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020056#ifdef CONFIG_SND_DEBUG
57 ALC880_TEST,
58#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020060 ALC880_MODEL_LAST /* last tag */
61};
62
63/* ALC260 models */
64enum {
65 ALC260_BASIC,
66 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC260_HP_3013,
68 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010069 ALC260_ACER,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010070#ifdef CONFIG_SND_DEBUG
71 ALC260_TEST,
72#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020074 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Kailang Yangdf694da2005-12-05 19:42:22 +010077/* ALC262 models */
78enum {
79 ALC262_BASIC,
Takashi Iwai834be882006-03-01 14:16:17 +010080 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020081 ALC262_HP_BPC,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020082 ALC262_BENQ_ED8,
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC262_AUTO,
84 ALC262_MODEL_LAST /* last tag */
85};
86
87/* ALC861 models */
88enum {
89 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020090 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010091 ALC861_3ST_DIG,
92 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +020093 ALC861_UNIWILL_M31,
Kailang Yangdf694da2005-12-05 19:42:22 +010094 ALC861_AUTO,
95 ALC861_MODEL_LAST,
96};
97
98/* ALC882 models */
99enum {
100 ALC882_3ST_DIG,
101 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200102 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100103 ALC882_AUTO,
104 ALC882_MODEL_LAST,
105};
106
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200107/* ALC883 models */
108enum {
109 ALC883_3ST_2ch_DIG,
110 ALC883_3ST_6ch_DIG,
111 ALC883_3ST_6ch,
112 ALC883_6ST_DIG,
113 ALC888_DEMO_BOARD,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200114 ALC883_ACER,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200115 ALC883_AUTO,
116 ALC883_MODEL_LAST,
117};
118
Kailang Yangdf694da2005-12-05 19:42:22 +0100119/* for GPIO Poll */
120#define GPIO_MASK 0x03
121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122struct alc_spec {
123 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100124 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 unsigned int num_mixers;
126
Kailang Yangdf694da2005-12-05 19:42:22 +0100127 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200128 * don't forget NULL
129 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200130 */
131 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
Takashi Iwai16ded522005-06-10 19:58:24 +0200133 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 struct hda_pcm_stream *stream_analog_playback;
135 struct hda_pcm_stream *stream_analog_capture;
136
Takashi Iwai16ded522005-06-10 19:58:24 +0200137 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 struct hda_pcm_stream *stream_digital_playback;
139 struct hda_pcm_stream *stream_digital_capture;
140
141 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200142 struct hda_multi_out multiout; /* playback set-up
143 * max_channels, dacs must be set
144 * dig_out_nid and hp_nid are optional
145 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147 /* capture */
148 unsigned int num_adc_nids;
149 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200150 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200153 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 const struct hda_input_mux *input_mux;
155 unsigned int cur_mux[3];
156
157 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100158 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200160 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100163 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200164
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200165 /* dynamic controls, init_verbs and input_mux */
166 struct auto_pin_cfg autocfg;
167 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100168 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200169 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100170 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100171
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100172 /* hooks */
173 void (*init_hook)(struct hda_codec *codec);
174 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
175
Takashi Iwai834be882006-03-01 14:16:17 +0100176 /* for pin sensing */
177 unsigned int sense_updated: 1;
178 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100179};
180
181/*
182 * configuration template - to be copied to the spec instance
183 */
184struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200185 struct snd_kcontrol_new *mixers[5]; /* should be identical size
186 * with spec
187 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100188 const struct hda_verb *init_verbs[5];
189 unsigned int num_dacs;
190 hda_nid_t *dac_nids;
191 hda_nid_t dig_out_nid; /* optional */
192 hda_nid_t hp_nid; /* optional */
193 unsigned int num_adc_nids;
194 hda_nid_t *adc_nids;
195 hda_nid_t dig_in_nid;
196 unsigned int num_channel_mode;
197 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200198 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200199 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100200 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100201 void (*unsol_event)(struct hda_codec *, unsigned int);
202 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203};
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206/*
207 * input MUX handling
208 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200209static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
210 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211{
212 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
213 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200214 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
215 if (mux_idx >= spec->num_mux_defs)
216 mux_idx = 0;
217 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218}
219
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
221 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
224 struct alc_spec *spec = codec->spec;
225 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
226
227 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
228 return 0;
229}
230
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200231static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
232 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
234 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
235 struct alc_spec *spec = codec->spec;
236 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200237 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
238 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200239 spec->adc_nids[adc_idx],
240 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241}
242
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244/*
245 * channel mode setting
246 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
248 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249{
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
251 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100252 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
253 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254}
255
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
257 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258{
259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
260 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100261 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200262 spec->num_channel_mode,
263 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264}
265
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200266static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
269 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
270 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200271 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
272 spec->num_channel_mode,
273 &spec->multiout.max_channels);
274 if (! err && spec->need_dac_fix)
275 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
276 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
278
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100280 * Control the mode of pin widget settings via the mixer. "pc" is used
281 * instead of "%" to avoid consequences of accidently treating the % as
282 * being part of a format specifier. Maximum allowed length of a value is
283 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100284 *
285 * Note: some retasking pin complexes seem to ignore requests for input
286 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
287 * are requested. Therefore order this list so that this behaviour will not
288 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200289 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
290 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200291 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100292static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100293 "Mic 50pc bias", "Mic 80pc bias",
294 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100295};
296static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100297 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100298};
299/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200300 * in the pin being assumed to be exclusively an input or an output pin. In
301 * addition, "input" pins may or may not process the mic bias option
302 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
303 * accept requests for bias as of chip versions up to March 2006) and/or
304 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100305 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200306#define ALC_PIN_DIR_IN 0x00
307#define ALC_PIN_DIR_OUT 0x01
308#define ALC_PIN_DIR_INOUT 0x02
309#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
310#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100311
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200312/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100313 * For each direction the minimum and maximum values are given.
314 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200315static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100316 { 0, 2 }, /* ALC_PIN_DIR_IN */
317 { 3, 4 }, /* ALC_PIN_DIR_OUT */
318 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200319 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
320 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100321};
322#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
323#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
324#define alc_pin_mode_n_items(_dir) \
325 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
326
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200327static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200329{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100330 unsigned int item_num = uinfo->value.enumerated.item;
331 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
332
333 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200334 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100335 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
336
337 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
338 item_num = alc_pin_mode_min(dir);
339 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200340 return 0;
341}
342
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200345{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100346 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100349 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200350 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200351 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
352 AC_VERB_GET_PIN_WIDGET_CONTROL,
353 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200354
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100355 /* Find enumerated value for current pinctl setting */
356 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100360 return 0;
361}
362
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365{
366 signed int change;
367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
368 hda_nid_t nid = kcontrol->private_value & 0xffff;
369 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
370 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200371 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
372 AC_VERB_GET_PIN_WIDGET_CONTROL,
373 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200375 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100376 val = alc_pin_mode_min(dir);
377
378 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100379 if (change) {
380 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200381 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200382 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100383
384 /* Also enable the retasking pin's input/output as required
385 * for the requested pin mode. Enum values of 2 or less are
386 * input modes.
387 *
388 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389 * reduces noise slightly (particularly on input) so we'll
390 * do it. However, having both input and output buffers
391 * enabled simultaneously doesn't seem to be problematic if
392 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100393 */
394 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200395 snd_hda_codec_write(codec, nid, 0,
396 AC_VERB_SET_AMP_GAIN_MUTE,
397 AMP_OUT_MUTE);
398 snd_hda_codec_write(codec, nid, 0,
399 AC_VERB_SET_AMP_GAIN_MUTE,
400 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100401 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402 snd_hda_codec_write(codec, nid, 0,
403 AC_VERB_SET_AMP_GAIN_MUTE,
404 AMP_IN_MUTE(0));
405 snd_hda_codec_write(codec, nid, 0,
406 AC_VERB_SET_AMP_GAIN_MUTE,
407 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100408 }
409 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200410 return change;
411}
412
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200414 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100415 .info = alc_pin_mode_info, \
416 .get = alc_pin_mode_get, \
417 .put = alc_pin_mode_put, \
418 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100419
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100420/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
421 * together using a mask with more than one bit set. This control is
422 * currently used only by the ALC260 test model. At this stage they are not
423 * needed for any "production" models.
424 */
425#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200426static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100428{
429 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
430 uinfo->count = 1;
431 uinfo->value.integer.min = 0;
432 uinfo->value.integer.max = 1;
433 return 0;
434}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 hda_nid_t nid = kcontrol->private_value & 0xffff;
440 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
441 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442 unsigned int val = snd_hda_codec_read(codec, nid, 0,
443 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100444
445 *valp = (val & mask) != 0;
446 return 0;
447}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100450{
451 signed int change;
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 hda_nid_t nid = kcontrol->private_value & 0xffff;
454 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
455 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
457 AC_VERB_GET_GPIO_DATA,
458 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100459
460 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
462 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100463 gpio_data &= ~mask;
464 else
465 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100467
468 return change;
469}
470#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
471 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
472 .info = alc_gpio_data_info, \
473 .get = alc_gpio_data_get, \
474 .put = alc_gpio_data_put, \
475 .private_value = nid | (mask<<16) }
476#endif /* CONFIG_SND_DEBUG */
477
Jonathan Woithe92621f12006-02-28 11:47:47 +0100478/* A switch control to allow the enabling of the digital IO pins on the
479 * ALC260. This is incredibly simplistic; the intention of this control is
480 * to provide something in the test model allowing digital outputs to be
481 * identified if present. If models are found which can utilise these
482 * outputs a more complete mixer control can be devised for those models if
483 * necessary.
484 */
485#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100488{
489 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
490 uinfo->count = 1;
491 uinfo->value.integer.min = 0;
492 uinfo->value.integer.max = 1;
493 return 0;
494}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 hda_nid_t nid = kcontrol->private_value & 0xffff;
500 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
501 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200502 unsigned int val = snd_hda_codec_read(codec, nid, 0,
503 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100504
505 *valp = (val & mask) != 0;
506 return 0;
507}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100510{
511 signed int change;
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 hda_nid_t nid = kcontrol->private_value & 0xffff;
514 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
515 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
517 AC_VERB_GET_DIGI_CONVERT,
518 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100519
520 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200521 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100522 if (val==0)
523 ctrl_data &= ~mask;
524 else
525 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
527 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100528
529 return change;
530}
531#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
532 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
533 .info = alc_spdif_ctrl_info, \
534 .get = alc_spdif_ctrl_get, \
535 .put = alc_spdif_ctrl_put, \
536 .private_value = nid | (mask<<16) }
537#endif /* CONFIG_SND_DEBUG */
538
Kailang Yangdf694da2005-12-05 19:42:22 +0100539/*
540 * set up from the preset table
541 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static void setup_preset(struct alc_spec *spec,
543 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100544{
545 int i;
546
547 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
548 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200549 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
550 i++)
551 spec->init_verbs[spec->num_init_verbs++] =
552 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100553
554 spec->channel_mode = preset->channel_mode;
555 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200556 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100557
558 spec->multiout.max_channels = spec->channel_mode[0].channels;
559
560 spec->multiout.num_dacs = preset->num_dacs;
561 spec->multiout.dac_nids = preset->dac_nids;
562 spec->multiout.dig_out_nid = preset->dig_out_nid;
563 spec->multiout.hp_nid = preset->hp_nid;
564
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200565 spec->num_mux_defs = preset->num_mux_defs;
566 if (! spec->num_mux_defs)
567 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100568 spec->input_mux = preset->input_mux;
569
570 spec->num_adc_nids = preset->num_adc_nids;
571 spec->adc_nids = preset->adc_nids;
572 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100573
574 spec->unsol_event = preset->unsol_event;
575 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100576}
577
Takashi Iwai41e41f12005-06-08 14:48:49 +0200578/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200579 * ALC880 3-stack model
580 *
581 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
583 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 */
585
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200586static hda_nid_t alc880_dac_nids[4] = {
587 /* front, rear, clfe, rear_surr */
588 0x02, 0x05, 0x04, 0x03
589};
590
591static hda_nid_t alc880_adc_nids[3] = {
592 /* ADC0-2 */
593 0x07, 0x08, 0x09,
594};
595
596/* The datasheet says the node 0x07 is connected from inputs,
597 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100598 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200600static hda_nid_t alc880_adc_nids_alt[2] = {
601 /* ADC1-2 */
602 0x08, 0x09,
603};
604
605#define ALC880_DIGOUT_NID 0x06
606#define ALC880_DIGIN_NID 0x0a
607
608static struct hda_input_mux alc880_capture_source = {
609 .num_items = 4,
610 .items = {
611 { "Mic", 0x0 },
612 { "Front Mic", 0x3 },
613 { "Line", 0x2 },
614 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200616};
617
618/* channel source setting (2/6 channel selection for 3-stack) */
619/* 2ch mode */
620static struct hda_verb alc880_threestack_ch2_init[] = {
621 /* set line-in to input, mute it */
622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
624 /* set mic-in to input vref 80%, mute it */
625 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
626 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 { } /* end */
628};
629
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200630/* 6ch mode */
631static struct hda_verb alc880_threestack_ch6_init[] = {
632 /* set line-in to output, unmute it */
633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
635 /* set mic-in to output, unmute it */
636 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
637 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
638 { } /* end */
639};
640
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100641static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200642 { 2, alc880_threestack_ch2_init },
643 { 6, alc880_threestack_ch6_init },
644};
645
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100646static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200647 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100648 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200649 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100650 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200651 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
652 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100653 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
654 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
656 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
663 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
664 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200666 {
667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
668 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100669 .info = alc_ch_mode_info,
670 .get = alc_ch_mode_get,
671 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200672 },
673 { } /* end */
674};
675
676/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100677static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200678 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
679 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
680 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
681 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
682 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
683 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
684 {
685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
686 /* The multiple "Capture Source" controls confuse alsamixer
687 * So call somewhat different..
688 * FIXME: the controls appear in the "playback" view!
689 */
690 /* .name = "Capture Source", */
691 .name = "Input Source",
692 .count = 3,
693 .info = alc_mux_enum_info,
694 .get = alc_mux_enum_get,
695 .put = alc_mux_enum_put,
696 },
697 { } /* end */
698};
699
700/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100701static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200702 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
703 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
704 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
705 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 {
707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
708 /* The multiple "Capture Source" controls confuse alsamixer
709 * So call somewhat different..
710 * FIXME: the controls appear in the "playback" view!
711 */
712 /* .name = "Capture Source", */
713 .name = "Input Source",
714 .count = 2,
715 .info = alc_mux_enum_info,
716 .get = alc_mux_enum_get,
717 .put = alc_mux_enum_put,
718 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 { } /* end */
720};
721
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200722
723
724/*
725 * ALC880 5-stack model
726 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
728 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200729 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
730 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
731 */
732
733/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100734static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200735 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100736 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 { } /* end */
738};
739
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200740/* channel source setting (6/8 channel selection for 5-stack) */
741/* 6ch mode */
742static struct hda_verb alc880_fivestack_ch6_init[] = {
743 /* set line-in to input, mute it */
744 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
745 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200746 { } /* end */
747};
748
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200749/* 8ch mode */
750static struct hda_verb alc880_fivestack_ch8_init[] = {
751 /* set line-in to output, unmute it */
752 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
753 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
754 { } /* end */
755};
756
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100757static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200758 { 6, alc880_fivestack_ch6_init },
759 { 8, alc880_fivestack_ch8_init },
760};
761
762
763/*
764 * ALC880 6-stack model
765 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
767 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200768 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
769 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
770 */
771
772static hda_nid_t alc880_6st_dac_nids[4] = {
773 /* front, rear, clfe, rear_surr */
774 0x02, 0x03, 0x04, 0x05
775};
776
777static struct hda_input_mux alc880_6stack_capture_source = {
778 .num_items = 4,
779 .items = {
780 { "Mic", 0x0 },
781 { "Front Mic", 0x1 },
782 { "Line", 0x2 },
783 { "CD", 0x4 },
784 },
785};
786
787/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100788static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200789 { 8, NULL },
790};
791
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100792static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100796 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200797 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
798 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100799 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
800 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200801 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100802 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
811 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
812 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200813 {
814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
815 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100816 .info = alc_ch_mode_info,
817 .get = alc_ch_mode_get,
818 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200819 },
820 { } /* end */
821};
822
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200823
824/*
825 * ALC880 W810 model
826 *
827 * W810 has rear IO for:
828 * Front (DAC 02)
829 * Surround (DAC 03)
830 * Center/LFE (DAC 04)
831 * Digital out (06)
832 *
833 * The system also has a pair of internal speakers, and a headphone jack.
834 * These are both connected to Line2 on the codec, hence to DAC 02.
835 *
836 * There is a variable resistor to control the speaker or headphone
837 * volume. This is a hardware-only device without a software API.
838 *
839 * Plugging headphones in will disable the internal speakers. This is
840 * implemented in hardware, not via the driver using jack sense. In
841 * a similar fashion, plugging into the rear socket marked "front" will
842 * disable both the speakers and headphones.
843 *
844 * For input, there's a microphone jack, and an "audio in" jack.
845 * These may not do anything useful with this driver yet, because I
846 * haven't setup any initialization verbs for these yet...
847 */
848
849static hda_nid_t alc880_w810_dac_nids[3] = {
850 /* front, rear/surround, clfe */
851 0x02, 0x03, 0x04
852};
853
854/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100855static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200856 { 6, NULL }
857};
858
859/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100860static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100864 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200869 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
870 { } /* end */
871};
872
873
874/*
875 * Z710V model
876 *
877 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200878 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
879 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200880 */
881
882static hda_nid_t alc880_z71v_dac_nids[1] = {
883 0x02
884};
885#define ALC880_Z71V_HP_DAC 0x03
886
887/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100888static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200889 { 2, NULL }
890};
891
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100892static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200895 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100896 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
901 { } /* end */
902};
903
904
905/* FIXME! */
906/*
907 * ALC880 F1734 model
908 *
909 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
910 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
911 */
912
913static hda_nid_t alc880_f1734_dac_nids[1] = {
914 0x03
915};
916#define ALC880_F1734_HP_DAC 0x02
917
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100918static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100920 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200921 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100922 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200927 { } /* end */
928};
929
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200930
931/* FIXME! */
932/*
933 * ALC880 ASUS model
934 *
935 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
936 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
937 * Mic = 0x18, Line = 0x1a
938 */
939
940#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
941#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
942
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100943static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200946 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100947 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
949 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100950 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
951 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200958 {
959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
960 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100961 .info = alc_ch_mode_info,
962 .get = alc_ch_mode_get,
963 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200964 },
965 { } /* end */
966};
967
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200968/* FIXME! */
969/*
970 * ALC880 ASUS W1V model
971 *
972 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
973 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
974 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
975 */
976
977/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100978static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200979 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
980 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200981 { } /* end */
982};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200983
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200984/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100985static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200986 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
987 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
988 { } /* end */
989};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200990
Kailang Yangdf694da2005-12-05 19:42:22 +0100991/* TCL S700 */
992static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
997 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1000 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1001 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1002 {
1003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1004 /* The multiple "Capture Source" controls confuse alsamixer
1005 * So call somewhat different..
1006 * FIXME: the controls appear in the "playback" view!
1007 */
1008 /* .name = "Capture Source", */
1009 .name = "Input Source",
1010 .count = 1,
1011 .info = alc_mux_enum_info,
1012 .get = alc_mux_enum_get,
1013 .put = alc_mux_enum_put,
1014 },
1015 { } /* end */
1016};
1017
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001019 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 */
1021static int alc_build_controls(struct hda_codec *codec)
1022{
1023 struct alc_spec *spec = codec->spec;
1024 int err;
1025 int i;
1026
1027 for (i = 0; i < spec->num_mixers; i++) {
1028 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1029 if (err < 0)
1030 return err;
1031 }
1032
1033 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001034 err = snd_hda_create_spdif_out_ctls(codec,
1035 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 if (err < 0)
1037 return err;
1038 }
1039 if (spec->dig_in_nid) {
1040 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1041 if (err < 0)
1042 return err;
1043 }
1044 return 0;
1045}
1046
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001047
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048/*
1049 * initialize the codec volumes, etc
1050 */
1051
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001052/*
1053 * generic initialization of ADC, input mixers and output mixers
1054 */
1055static struct hda_verb alc880_volume_init_verbs[] = {
1056 /*
1057 * Unmute ADC0-2 and set the default input to mic-in
1058 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001059 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001061 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001063 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001066 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1067 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001068 * Note: PASD motherboards uses the Line In 2 as the input for front
1069 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001078 /*
1079 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001081 /* set vol=0 to output mixers */
1082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1086 /* set up input amps for analog loopback */
1087 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001094 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096
1097 { }
1098};
1099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001100/*
1101 * 3-stack pin configuration:
1102 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1103 */
1104static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1105 /*
1106 * preset connection lists of input pins
1107 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1108 */
1109 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1110 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1111 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1112
1113 /*
1114 * Set pin mode and muting
1115 */
1116 /* set front pin widgets 0x14 for output */
1117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1118 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1119 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1122 /* Mic2 (as headphone out) for HP output */
1123 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1125 /* Line In pin widget for input */
1126 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1128 /* Line2 (as front mic) pin widget for input and vref at 80% */
1129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1131 /* CD pin widget for input */
1132 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1133
1134 { }
1135};
1136
1137/*
1138 * 5-stack pin configuration:
1139 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1140 * line-in/side = 0x1a, f-mic = 0x1b
1141 */
1142static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1143 /*
1144 * preset connection lists of input pins
1145 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1146 */
1147 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1148 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1149
1150 /*
1151 * Set pin mode and muting
1152 */
1153 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1157 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001158 /* unmute pins for output (no gain on this amp) */
1159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1162 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001166 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1167 /* Mic2 (as headphone out) for HP output */
1168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170 /* Line In pin widget for input */
1171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1173 /* Line2 (as front mic) pin widget for input and vref at 80% */
1174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1176 /* CD pin widget for input */
1177 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178
1179 { }
1180};
1181
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001182/*
1183 * W810 pin configuration:
1184 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1185 */
1186static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 /* hphone/speaker input selector: front DAC */
1188 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1189
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1195 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1196
1197 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001198 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 { }
1201};
1202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001203/*
1204 * Z71V pin configuration:
1205 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1206 */
1207static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001212
Takashi Iwai16ded522005-06-10 19:58:24 +02001213 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001217
1218 { }
1219};
1220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001221/*
1222 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001223 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1224 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001225 */
1226static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1227 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1228
Takashi Iwai16ded522005-06-10 19:58:24 +02001229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001234 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001235 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001236 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1237
Takashi Iwai16ded522005-06-10 19:58:24 +02001238 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001239 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001242 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001244 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001245 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001246 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001248 { }
1249};
Takashi Iwai16ded522005-06-10 19:58:24 +02001250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001251/* FIXME! */
1252/*
1253 * F1734 pin configuration:
1254 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1255 */
1256static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1257 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1258 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1259 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1260 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1261
1262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1266
1267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001276
1277 { }
1278};
1279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280/* FIXME! */
1281/*
1282 * ASUS pin configuration:
1283 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1284 */
1285static struct hda_verb alc880_pin_asus_init_verbs[] = {
1286 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1287 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1288 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1289 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1290
1291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1297 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299
1300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1309
1310 { }
1311};
1312
1313/* Enable GPIO mask and set output */
1314static struct hda_verb alc880_gpio1_init_verbs[] = {
1315 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1316 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1317 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001318
1319 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001320};
1321
1322/* Enable GPIO mask and set output */
1323static struct hda_verb alc880_gpio2_init_verbs[] = {
1324 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1325 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1326 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001327
1328 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001329};
1330
Kailang Yangdf694da2005-12-05 19:42:22 +01001331/* Clevo m520g init */
1332static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1333 /* headphone output */
1334 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1335 /* line-out */
1336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1338 /* Line-in */
1339 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1341 /* CD */
1342 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1343 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1344 /* Mic1 (rear panel) */
1345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1346 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1347 /* Mic2 (front panel) */
1348 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1349 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1350 /* headphone */
1351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 /* change to EAPD mode */
1354 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1355 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1356
1357 { }
1358};
1359
1360static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001361 /* change to EAPD mode */
1362 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1363 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1364
Kailang Yangdf694da2005-12-05 19:42:22 +01001365 /* Headphone output */
1366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1367 /* Front output*/
1368 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1370
1371 /* Line In pin widget for input */
1372 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 /* CD pin widget for input */
1374 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1375 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1377
1378 /* change to EAPD mode */
1379 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1380 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1381
1382 { }
1383};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384
1385/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001386 * LG m1 express dual
1387 *
1388 * Pin assignment:
1389 * Rear Line-In/Out (blue): 0x14
1390 * Build-in Mic-In: 0x15
1391 * Speaker-out: 0x17
1392 * HP-Out (green): 0x1b
1393 * Mic-In/Out (red): 0x19
1394 * SPDIF-Out: 0x1e
1395 */
1396
1397/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1398static hda_nid_t alc880_lg_dac_nids[3] = {
1399 0x05, 0x02, 0x03
1400};
1401
1402/* seems analog CD is not working */
1403static struct hda_input_mux alc880_lg_capture_source = {
1404 .num_items = 3,
1405 .items = {
1406 { "Mic", 0x1 },
1407 { "Line", 0x5 },
1408 { "Internal Mic", 0x6 },
1409 },
1410};
1411
1412/* 2,4,6 channel modes */
1413static struct hda_verb alc880_lg_ch2_init[] = {
1414 /* set line-in and mic-in to input */
1415 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1416 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1417 { }
1418};
1419
1420static struct hda_verb alc880_lg_ch4_init[] = {
1421 /* set line-in to out and mic-in to input */
1422 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1423 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1424 { }
1425};
1426
1427static struct hda_verb alc880_lg_ch6_init[] = {
1428 /* set line-in and mic-in to output */
1429 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1430 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1431 { }
1432};
1433
1434static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1435 { 2, alc880_lg_ch2_init },
1436 { 4, alc880_lg_ch4_init },
1437 { 6, alc880_lg_ch6_init },
1438};
1439
1440static struct snd_kcontrol_new alc880_lg_mixer[] = {
1441 /* FIXME: it's not really "master" but front channels */
1442 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1447 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1448 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1449 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1454 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1455 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1456 {
1457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1458 .name = "Channel Mode",
1459 .info = alc_ch_mode_info,
1460 .get = alc_ch_mode_get,
1461 .put = alc_ch_mode_put,
1462 },
1463 { } /* end */
1464};
1465
1466static struct hda_verb alc880_lg_init_verbs[] = {
1467 /* set capture source to mic-in */
1468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1471 /* mute all amp mixer inputs */
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1475 /* line-in to input */
1476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1478 /* built-in mic */
1479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1480 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 /* speaker-out */
1482 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1483 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 /* mic-in to input */
1485 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1486 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 /* HP-out */
1489 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1490 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 /* jack sense */
1493 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1494 { }
1495};
1496
1497/* toggle speaker-output according to the hp-jack state */
1498static void alc880_lg_automute(struct hda_codec *codec)
1499{
1500 unsigned int present;
1501
1502 present = snd_hda_codec_read(codec, 0x1b, 0,
1503 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1504 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1505 0x80, present ? 0x80 : 0);
1506 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1507 0x80, present ? 0x80 : 0);
1508}
1509
1510static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1511{
1512 /* Looks like the unsol event is incompatible with the standard
1513 * definition. 4bit tag is placed at 28 bit!
1514 */
1515 if ((res >> 28) == 0x01)
1516 alc880_lg_automute(codec);
1517}
1518
1519/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001520 * LG LW20
1521 *
1522 * Pin assignment:
1523 * Speaker-out: 0x14
1524 * Mic-In: 0x18
1525 * Built-in Mic-In: 0x19 (?)
1526 * HP-Out: 0x1b
1527 * SPDIF-Out: 0x1e
1528 */
1529
1530/* seems analog CD is not working */
1531static struct hda_input_mux alc880_lg_lw_capture_source = {
1532 .num_items = 2,
1533 .items = {
1534 { "Mic", 0x0 },
1535 { "Internal Mic", 0x1 },
1536 },
1537};
1538
1539static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1540 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1541 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1543 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1544 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1545 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1546 { } /* end */
1547};
1548
1549static struct hda_verb alc880_lg_lw_init_verbs[] = {
1550 /* set capture source to mic-in */
1551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1555 /* speaker-out */
1556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1558 /* HP-out */
1559 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1562 /* mic-in to input */
1563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1564 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1565 /* built-in mic */
1566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1568 /* jack sense */
1569 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1570 { }
1571};
1572
1573/* toggle speaker-output according to the hp-jack state */
1574static void alc880_lg_lw_automute(struct hda_codec *codec)
1575{
1576 unsigned int present;
1577
1578 present = snd_hda_codec_read(codec, 0x1b, 0,
1579 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1580 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1581 0x80, present ? 0x80 : 0);
1582 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1583 0x80, present ? 0x80 : 0);
1584}
1585
1586static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1587{
1588 /* Looks like the unsol event is incompatible with the standard
1589 * definition. 4bit tag is placed at 28 bit!
1590 */
1591 if ((res >> 28) == 0x01)
1592 alc880_lg_lw_automute(codec);
1593}
1594
1595/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001596 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001597 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001598
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599static int alc_init(struct hda_codec *codec)
1600{
1601 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001602 unsigned int i;
1603
1604 for (i = 0; i < spec->num_init_verbs; i++)
1605 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001606
1607 if (spec->init_hook)
1608 spec->init_hook(codec);
1609
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 return 0;
1611}
1612
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001613static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1614{
1615 struct alc_spec *spec = codec->spec;
1616
1617 if (spec->unsol_event)
1618 spec->unsol_event(codec, res);
1619}
1620
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621#ifdef CONFIG_PM
1622/*
1623 * resume
1624 */
1625static int alc_resume(struct hda_codec *codec)
1626{
1627 struct alc_spec *spec = codec->spec;
1628 int i;
1629
1630 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001631 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 if (spec->multiout.dig_out_nid)
1634 snd_hda_resume_spdif_out(codec);
1635 if (spec->dig_in_nid)
1636 snd_hda_resume_spdif_in(codec);
1637
1638 return 0;
1639}
1640#endif
1641
1642/*
1643 * Analog playback callbacks
1644 */
1645static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1646 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001647 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648{
1649 struct alc_spec *spec = codec->spec;
1650 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1651}
1652
1653static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1654 struct hda_codec *codec,
1655 unsigned int stream_tag,
1656 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001657 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658{
1659 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001660 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1661 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662}
1663
1664static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1665 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001666 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667{
1668 struct alc_spec *spec = codec->spec;
1669 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1670}
1671
1672/*
1673 * Digital out
1674 */
1675static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1676 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001677 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678{
1679 struct alc_spec *spec = codec->spec;
1680 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1681}
1682
1683static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1684 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001685 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686{
1687 struct alc_spec *spec = codec->spec;
1688 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1689}
1690
1691/*
1692 * Analog capture
1693 */
1694static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1695 struct hda_codec *codec,
1696 unsigned int stream_tag,
1697 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001698 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699{
1700 struct alc_spec *spec = codec->spec;
1701
1702 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1703 stream_tag, 0, format);
1704 return 0;
1705}
1706
1707static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1708 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001709 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710{
1711 struct alc_spec *spec = codec->spec;
1712
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001713 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1714 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 return 0;
1716}
1717
1718
1719/*
1720 */
1721static struct hda_pcm_stream alc880_pcm_analog_playback = {
1722 .substreams = 1,
1723 .channels_min = 2,
1724 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 .ops = {
1727 .open = alc880_playback_pcm_open,
1728 .prepare = alc880_playback_pcm_prepare,
1729 .cleanup = alc880_playback_pcm_cleanup
1730 },
1731};
1732
1733static struct hda_pcm_stream alc880_pcm_analog_capture = {
1734 .substreams = 2,
1735 .channels_min = 2,
1736 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 .ops = {
1739 .prepare = alc880_capture_pcm_prepare,
1740 .cleanup = alc880_capture_pcm_cleanup
1741 },
1742};
1743
1744static struct hda_pcm_stream alc880_pcm_digital_playback = {
1745 .substreams = 1,
1746 .channels_min = 2,
1747 .channels_max = 2,
1748 /* NID is set in alc_build_pcms */
1749 .ops = {
1750 .open = alc880_dig_playback_pcm_open,
1751 .close = alc880_dig_playback_pcm_close
1752 },
1753};
1754
1755static struct hda_pcm_stream alc880_pcm_digital_capture = {
1756 .substreams = 1,
1757 .channels_min = 2,
1758 .channels_max = 2,
1759 /* NID is set in alc_build_pcms */
1760};
1761
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001762/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1763static struct hda_pcm_stream alc_pcm_null_playback = {
1764 .substreams = 0,
1765 .channels_min = 0,
1766 .channels_max = 0,
1767};
1768
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769static int alc_build_pcms(struct hda_codec *codec)
1770{
1771 struct alc_spec *spec = codec->spec;
1772 struct hda_pcm *info = spec->pcm_rec;
1773 int i;
1774
1775 codec->num_pcms = 1;
1776 codec->pcm_info = info;
1777
1778 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001779 if (spec->stream_analog_playback) {
1780 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1781 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1782 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1783 }
1784 if (spec->stream_analog_capture) {
1785 snd_assert(spec->adc_nids, return -EINVAL);
1786 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1787 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1788 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001789
Takashi Iwai4a471b72005-12-07 13:56:29 +01001790 if (spec->channel_mode) {
1791 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1792 for (i = 0; i < spec->num_channel_mode; i++) {
1793 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1794 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1795 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 }
1797 }
1798
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001799 /* If the use of more than one ADC is requested for the current
1800 * model, configure a second analog capture-only PCM.
1801 */
1802 if (spec->num_adc_nids > 1) {
1803 codec->num_pcms++;
1804 info++;
1805 info->name = spec->stream_name_analog;
1806 /* No playback stream for second PCM */
1807 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1808 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1809 if (spec->stream_analog_capture) {
1810 snd_assert(spec->adc_nids, return -EINVAL);
1811 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1812 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1813 }
1814 }
1815
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1817 codec->num_pcms++;
1818 info++;
1819 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001820 if (spec->multiout.dig_out_nid &&
1821 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1823 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1824 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001825 if (spec->dig_in_nid &&
1826 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1828 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1829 }
1830 }
1831
1832 return 0;
1833}
1834
1835static void alc_free(struct hda_codec *codec)
1836{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001837 struct alc_spec *spec = codec->spec;
1838 unsigned int i;
1839
1840 if (! spec)
1841 return;
1842
1843 if (spec->kctl_alloc) {
1844 for (i = 0; i < spec->num_kctl_used; i++)
1845 kfree(spec->kctl_alloc[i].name);
1846 kfree(spec->kctl_alloc);
1847 }
1848 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849}
1850
1851/*
1852 */
1853static struct hda_codec_ops alc_patch_ops = {
1854 .build_controls = alc_build_controls,
1855 .build_pcms = alc_build_pcms,
1856 .init = alc_init,
1857 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001858 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859#ifdef CONFIG_PM
1860 .resume = alc_resume,
1861#endif
1862};
1863
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001864
1865/*
1866 * Test configuration for debugging
1867 *
1868 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1869 * enum controls.
1870 */
1871#ifdef CONFIG_SND_DEBUG
1872static hda_nid_t alc880_test_dac_nids[4] = {
1873 0x02, 0x03, 0x04, 0x05
1874};
1875
1876static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001877 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001878 .items = {
1879 { "In-1", 0x0 },
1880 { "In-2", 0x1 },
1881 { "In-3", 0x2 },
1882 { "In-4", 0x3 },
1883 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001884 { "Front", 0x5 },
1885 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001886 },
1887};
1888
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001889static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001890 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001891 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001892 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001893 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001894};
1895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001896static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1897 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001898{
1899 static char *texts[] = {
1900 "N/A", "Line Out", "HP Out",
1901 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1902 };
1903 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1904 uinfo->count = 1;
1905 uinfo->value.enumerated.items = 8;
1906 if (uinfo->value.enumerated.item >= 8)
1907 uinfo->value.enumerated.item = 7;
1908 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1909 return 0;
1910}
1911
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001912static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1913 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001914{
1915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1916 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1917 unsigned int pin_ctl, item = 0;
1918
1919 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1920 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1921 if (pin_ctl & AC_PINCTL_OUT_EN) {
1922 if (pin_ctl & AC_PINCTL_HP_EN)
1923 item = 2;
1924 else
1925 item = 1;
1926 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1927 switch (pin_ctl & AC_PINCTL_VREFEN) {
1928 case AC_PINCTL_VREF_HIZ: item = 3; break;
1929 case AC_PINCTL_VREF_50: item = 4; break;
1930 case AC_PINCTL_VREF_GRD: item = 5; break;
1931 case AC_PINCTL_VREF_80: item = 6; break;
1932 case AC_PINCTL_VREF_100: item = 7; break;
1933 }
1934 }
1935 ucontrol->value.enumerated.item[0] = item;
1936 return 0;
1937}
1938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001939static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001941{
1942 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1943 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1944 static unsigned int ctls[] = {
1945 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1949 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1950 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1951 };
1952 unsigned int old_ctl, new_ctl;
1953
1954 old_ctl = snd_hda_codec_read(codec, nid, 0,
1955 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1956 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1957 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001958 snd_hda_codec_write(codec, nid, 0,
1959 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001960 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001961 (ucontrol->value.enumerated.item[0] >= 3 ?
1962 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001963 return 1;
1964 }
1965 return 0;
1966}
1967
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001968static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1969 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001970{
1971 static char *texts[] = {
1972 "Front", "Surround", "CLFE", "Side"
1973 };
1974 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1975 uinfo->count = 1;
1976 uinfo->value.enumerated.items = 4;
1977 if (uinfo->value.enumerated.item >= 4)
1978 uinfo->value.enumerated.item = 3;
1979 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1980 return 0;
1981}
1982
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001983static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1984 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001985{
1986 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1987 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1988 unsigned int sel;
1989
1990 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1991 ucontrol->value.enumerated.item[0] = sel & 3;
1992 return 0;
1993}
1994
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001995static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1996 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001997{
1998 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1999 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2000 unsigned int sel;
2001
2002 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2003 if (ucontrol->value.enumerated.item[0] != sel) {
2004 sel = ucontrol->value.enumerated.item[0] & 3;
2005 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2006 return 1;
2007 }
2008 return 0;
2009}
2010
2011#define PIN_CTL_TEST(xname,nid) { \
2012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2013 .name = xname, \
2014 .info = alc_test_pin_ctl_info, \
2015 .get = alc_test_pin_ctl_get, \
2016 .put = alc_test_pin_ctl_put, \
2017 .private_value = nid \
2018 }
2019
2020#define PIN_SRC_TEST(xname,nid) { \
2021 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2022 .name = xname, \
2023 .info = alc_test_pin_src_info, \
2024 .get = alc_test_pin_src_get, \
2025 .put = alc_test_pin_src_put, \
2026 .private_value = nid \
2027 }
2028
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002029static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2032 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2033 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2036 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2037 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002038 PIN_CTL_TEST("Front Pin Mode", 0x14),
2039 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2040 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2041 PIN_CTL_TEST("Side Pin Mode", 0x17),
2042 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2043 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2044 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2045 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2046 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2047 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2048 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2049 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2050 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2051 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2052 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2053 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2054 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2055 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2056 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2057 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2058 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2059 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002060 {
2061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2062 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002063 .info = alc_ch_mode_info,
2064 .get = alc_ch_mode_get,
2065 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002066 },
2067 { } /* end */
2068};
2069
2070static struct hda_verb alc880_test_init_verbs[] = {
2071 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002080 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002085 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002086 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2089 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002090 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002091 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002095 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002098 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2100 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002101 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002102 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002106 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002108 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002111 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002112 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002113 /* Analog input/passthru */
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002119 { }
2120};
2121#endif
2122
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123/*
2124 */
2125
2126static struct hda_board_config alc880_cfg_tbl[] = {
2127 /* Back 3 jack, front 2 jack */
2128 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2159 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2160 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2161 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2162 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2163 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002164 /* TCL S700 */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002165 { .modelname = "tcl", .config = ALC880_TCL_S700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002166 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167
2168 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002169 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002170 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002171 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172
2173 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2174 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002175 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe32005-08-15 20:01:40 +02002176 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Takashi Iwai5a053d02006-07-25 14:51:15 +02002177
2178 /* Clevo laptops */
2179 { .modelname = "clevo", .config = ALC880_CLEVO },
2180 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2181 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2182 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2183 .config = ALC880_CLEVO }, /* Clevo m665n */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184
2185 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002186 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2187 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2188 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189
2190 /* Back 5 jack, front 2 jack */
2191 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002192 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2193 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2194 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2195 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002196 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197
2198 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2199 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2205 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2206 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2207 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002208 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002209 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2210 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002211 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002212 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002213 /* note subvendor = 0 below */
2214 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215
2216 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002217 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002219 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002220 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002221
Takashi Iwaib6482d42005-06-27 15:32:43 +02002222 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002223 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002224 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002225 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002226 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002227
2228 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002229 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002233 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2234 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2235 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2236 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002237 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002238 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002239 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
Danny Tholenf5a5ffa2006-08-08 18:59:07 +02002248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2251 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2252 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002253 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002255 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
Takashi Iwai84f34302006-03-21 19:12:53 +01002256 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002257 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002258 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002259
2260 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2261 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2262
2263 { .modelname = "F1734", .config = ALC880_F1734 },
2264 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002265 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002266
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002267 { .modelname = "lg", .config = ALC880_LG },
2268 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002269 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002270
Takashi Iwaid6815182006-03-23 16:06:23 +01002271 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2272 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2273
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002274#ifdef CONFIG_SND_DEBUG
2275 { .modelname = "test", .config = ALC880_TEST },
2276#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002277 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002278
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 {}
2280};
2281
Takashi Iwai16ded522005-06-10 19:58:24 +02002282/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002283 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002285static struct alc_config_preset alc880_presets[] = {
2286 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287 .mixers = { alc880_three_stack_mixer },
2288 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002289 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002291 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2292 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002293 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002294 .input_mux = &alc880_capture_source,
2295 },
2296 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 .mixers = { alc880_three_stack_mixer },
2298 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 .dac_nids = alc880_dac_nids,
2301 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2303 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002304 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002305 .input_mux = &alc880_capture_source,
2306 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002307 [ALC880_TCL_S700] = {
2308 .mixers = { alc880_tcl_s700_mixer },
2309 .init_verbs = { alc880_volume_init_verbs,
2310 alc880_pin_tcl_S700_init_verbs,
2311 alc880_gpio2_init_verbs },
2312 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2313 .dac_nids = alc880_dac_nids,
2314 .hp_nid = 0x03,
2315 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2316 .channel_mode = alc880_2_jack_modes,
2317 .input_mux = &alc880_capture_source,
2318 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002319 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2321 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002322 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2323 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002324 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2325 .channel_mode = alc880_fivestack_modes,
2326 .input_mux = &alc880_capture_source,
2327 },
2328 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2330 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002331 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2332 .dac_nids = alc880_dac_nids,
2333 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002334 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2335 .channel_mode = alc880_fivestack_modes,
2336 .input_mux = &alc880_capture_source,
2337 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002338 [ALC880_6ST] = {
2339 .mixers = { alc880_six_stack_mixer },
2340 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2341 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2342 .dac_nids = alc880_6st_dac_nids,
2343 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2344 .channel_mode = alc880_sixstack_modes,
2345 .input_mux = &alc880_6stack_capture_source,
2346 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002348 .mixers = { alc880_six_stack_mixer },
2349 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002350 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2351 .dac_nids = alc880_6st_dac_nids,
2352 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002353 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2354 .channel_mode = alc880_sixstack_modes,
2355 .input_mux = &alc880_6stack_capture_source,
2356 },
2357 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002359 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2360 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002361 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2362 .dac_nids = alc880_w810_dac_nids,
2363 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002364 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2365 .channel_mode = alc880_w810_modes,
2366 .input_mux = &alc880_capture_source,
2367 },
2368 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002369 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002370 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002371 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2372 .dac_nids = alc880_z71v_dac_nids,
2373 .dig_out_nid = ALC880_DIGOUT_NID,
2374 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002375 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2376 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002377 .input_mux = &alc880_capture_source,
2378 },
2379 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002380 .mixers = { alc880_f1734_mixer },
2381 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2382 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2383 .dac_nids = alc880_f1734_dac_nids,
2384 .hp_nid = 0x02,
2385 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2386 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002387 .input_mux = &alc880_capture_source,
2388 },
2389 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390 .mixers = { alc880_asus_mixer },
2391 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2392 alc880_gpio1_init_verbs },
2393 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2394 .dac_nids = alc880_asus_dac_nids,
2395 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2396 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002397 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002398 .input_mux = &alc880_capture_source,
2399 },
2400 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002401 .mixers = { alc880_asus_mixer },
2402 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2403 alc880_gpio1_init_verbs },
2404 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2405 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002406 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2408 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002409 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002410 .input_mux = &alc880_capture_source,
2411 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002412 [ALC880_ASUS_DIG2] = {
2413 .mixers = { alc880_asus_mixer },
2414 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2415 alc880_gpio2_init_verbs }, /* use GPIO2 */
2416 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2417 .dac_nids = alc880_asus_dac_nids,
2418 .dig_out_nid = ALC880_DIGOUT_NID,
2419 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2420 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002421 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002422 .input_mux = &alc880_capture_source,
2423 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002424 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002425 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2426 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2427 alc880_gpio1_init_verbs },
2428 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2429 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002430 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002431 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2432 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002433 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002434 .input_mux = &alc880_capture_source,
2435 },
2436 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002437 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2439 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2440 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002441 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2443 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002444 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 .input_mux = &alc880_capture_source,
2446 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002447 [ALC880_CLEVO] = {
2448 .mixers = { alc880_three_stack_mixer },
2449 .init_verbs = { alc880_volume_init_verbs,
2450 alc880_pin_clevo_init_verbs },
2451 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2452 .dac_nids = alc880_dac_nids,
2453 .hp_nid = 0x03,
2454 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2455 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002456 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002457 .input_mux = &alc880_capture_source,
2458 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002459 [ALC880_LG] = {
2460 .mixers = { alc880_lg_mixer },
2461 .init_verbs = { alc880_volume_init_verbs,
2462 alc880_lg_init_verbs },
2463 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2464 .dac_nids = alc880_lg_dac_nids,
2465 .dig_out_nid = ALC880_DIGOUT_NID,
2466 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2467 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002468 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002469 .input_mux = &alc880_lg_capture_source,
2470 .unsol_event = alc880_lg_unsol_event,
2471 .init_hook = alc880_lg_automute,
2472 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002473 [ALC880_LG_LW] = {
2474 .mixers = { alc880_lg_lw_mixer },
2475 .init_verbs = { alc880_volume_init_verbs,
2476 alc880_lg_lw_init_verbs },
2477 .num_dacs = 1,
2478 .dac_nids = alc880_dac_nids,
2479 .dig_out_nid = ALC880_DIGOUT_NID,
2480 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2481 .channel_mode = alc880_2_jack_modes,
2482 .input_mux = &alc880_lg_lw_capture_source,
2483 .unsol_event = alc880_lg_lw_unsol_event,
2484 .init_hook = alc880_lg_lw_automute,
2485 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002486#ifdef CONFIG_SND_DEBUG
2487 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002488 .mixers = { alc880_test_mixer },
2489 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002490 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2491 .dac_nids = alc880_test_dac_nids,
2492 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002493 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2494 .channel_mode = alc880_test_modes,
2495 .input_mux = &alc880_test_capture_source,
2496 },
2497#endif
2498};
2499
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500/*
2501 * Automatic parse of I/O pins from the BIOS configuration
2502 */
2503
2504#define NUM_CONTROL_ALLOC 32
2505#define NUM_VERB_ALLOC 32
2506
2507enum {
2508 ALC_CTL_WIDGET_VOL,
2509 ALC_CTL_WIDGET_MUTE,
2510 ALC_CTL_BIND_MUTE,
2511};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002512static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2514 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002515 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002516};
2517
2518/* add dynamic controls */
2519static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2520{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002521 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522
2523 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2524 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2525
2526 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2527 if (! knew)
2528 return -ENOMEM;
2529 if (spec->kctl_alloc) {
2530 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2531 kfree(spec->kctl_alloc);
2532 }
2533 spec->kctl_alloc = knew;
2534 spec->num_kctl_alloc = num;
2535 }
2536
2537 knew = &spec->kctl_alloc[spec->num_kctl_used];
2538 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002539 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540 if (! knew->name)
2541 return -ENOMEM;
2542 knew->private_value = val;
2543 spec->num_kctl_used++;
2544 return 0;
2545}
2546
2547#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2548#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2549#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2550#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2551#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2552#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2553#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2554#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2555#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2556#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2557#define ALC880_PIN_CD_NID 0x1c
2558
2559/* fill in the dac_nids table from the parsed pin configuration */
2560static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2561{
2562 hda_nid_t nid;
2563 int assigned[4];
2564 int i, j;
2565
2566 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002567 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568
2569 /* check the pins hardwired to audio widget */
2570 for (i = 0; i < cfg->line_outs; i++) {
2571 nid = cfg->line_out_pins[i];
2572 if (alc880_is_fixed_pin(nid)) {
2573 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002574 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002575 assigned[idx] = 1;
2576 }
2577 }
2578 /* left pins can be connect to any audio widget */
2579 for (i = 0; i < cfg->line_outs; i++) {
2580 nid = cfg->line_out_pins[i];
2581 if (alc880_is_fixed_pin(nid))
2582 continue;
2583 /* search for an empty channel */
2584 for (j = 0; j < cfg->line_outs; j++) {
2585 if (! assigned[j]) {
2586 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2587 assigned[j] = 1;
2588 break;
2589 }
2590 }
2591 }
2592 spec->multiout.num_dacs = cfg->line_outs;
2593 return 0;
2594}
2595
2596/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002597static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2598 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599{
2600 char name[32];
2601 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2602 hda_nid_t nid;
2603 int i, err;
2604
2605 for (i = 0; i < cfg->line_outs; i++) {
2606 if (! spec->multiout.dac_nids[i])
2607 continue;
2608 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2609 if (i == 2) {
2610 /* Center/LFE */
2611 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2612 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2613 return err;
2614 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2615 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2616 return err;
2617 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2618 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2619 return err;
2620 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2621 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2622 return err;
2623 } else {
2624 sprintf(name, "%s Playback Volume", chname[i]);
2625 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2626 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2627 return err;
2628 sprintf(name, "%s Playback Switch", chname[i]);
2629 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2630 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2631 return err;
2632 }
2633 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 return 0;
2635}
2636
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002637/* add playback controls for speaker and HP outputs */
2638static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2639 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640{
2641 hda_nid_t nid;
2642 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002643 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644
2645 if (! pin)
2646 return 0;
2647
2648 if (alc880_is_fixed_pin(pin)) {
2649 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002650 /* specify the DAC as the extra output */
2651 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002652 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002653 else
2654 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655 /* control HP volume/switch on the output mixer amp */
2656 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002657 sprintf(name, "%s Playback Volume", pfx);
2658 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2660 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002661 sprintf(name, "%s Playback Switch", pfx);
2662 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2664 return err;
2665 } else if (alc880_is_multi_pin(pin)) {
2666 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002668 sprintf(name, "%s Playback Switch", pfx);
2669 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2671 return err;
2672 }
2673 return 0;
2674}
2675
2676/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002677static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2678 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002679{
2680 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002681 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682
2683 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002685 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686 return err;
2687 sprintf(name, "%s Playback Switch", ctlname);
2688 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002689 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002690 return err;
2691 return 0;
2692}
2693
2694/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002695static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2696 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002699 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700
2701 for (i = 0; i < AUTO_PIN_LAST; i++) {
2702 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002703 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002704 err = new_analog_input(spec, cfg->input_pins[i],
2705 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002706 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002707 if (err < 0)
2708 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002709 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2711 imux->num_items++;
2712 }
2713 }
2714 return 0;
2715}
2716
Kailang Yangdf694da2005-12-05 19:42:22 +01002717static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2718 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002719 int dac_idx)
2720{
2721 /* set as output */
2722 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2723 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2724 /* need the manual connection? */
2725 if (alc880_is_multi_pin(nid)) {
2726 struct alc_spec *spec = codec->spec;
2727 int idx = alc880_multi_pin_idx(nid);
2728 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2729 AC_VERB_SET_CONNECT_SEL,
2730 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2731 }
2732}
2733
2734static void alc880_auto_init_multi_out(struct hda_codec *codec)
2735{
2736 struct alc_spec *spec = codec->spec;
2737 int i;
2738
2739 for (i = 0; i < spec->autocfg.line_outs; i++) {
2740 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2741 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2742 }
2743}
2744
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002745static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746{
2747 struct alc_spec *spec = codec->spec;
2748 hda_nid_t pin;
2749
Takashi Iwai82bc9552006-03-21 11:24:42 +01002750 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002751 if (pin) /* connect to front */
2752 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 pin = spec->autocfg.hp_pin;
2754 if (pin) /* connect to front */
2755 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2756}
2757
2758static void alc880_auto_init_analog_input(struct hda_codec *codec)
2759{
2760 struct alc_spec *spec = codec->spec;
2761 int i;
2762
2763 for (i = 0; i < AUTO_PIN_LAST; i++) {
2764 hda_nid_t nid = spec->autocfg.input_pins[i];
2765 if (alc880_is_input_pin(nid)) {
2766 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2767 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2768 if (nid != ALC880_PIN_CD_NID)
2769 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2770 AMP_OUT_MUTE);
2771 }
2772 }
2773}
2774
2775/* parse the BIOS configuration and set up the alc_spec */
2776/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2777static int alc880_parse_auto_config(struct hda_codec *codec)
2778{
2779 struct alc_spec *spec = codec->spec;
2780 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002781 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002782
Kailang Yangdf694da2005-12-05 19:42:22 +01002783 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2784 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002785 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002786 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002787 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002788
2789 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2790 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002791 (err = alc880_auto_create_extra_out(spec,
2792 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002793 "Speaker")) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002794 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002795 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2797 return err;
2798
2799 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2800
2801 if (spec->autocfg.dig_out_pin)
2802 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2803 if (spec->autocfg.dig_in_pin)
2804 spec->dig_in_nid = ALC880_DIGIN_NID;
2805
2806 if (spec->kctl_alloc)
2807 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2808
2809 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2810
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002811 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 spec->input_mux = &spec->private_imux;
2813
2814 return 1;
2815}
2816
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002817/* additional initialization for auto-configuration model */
2818static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002819{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002821 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002823}
2824
2825/*
2826 * OK, here we have finally the patch for ALC880
2827 */
2828
Linus Torvalds1da177e2005-04-16 15:20:36 -07002829static int patch_alc880(struct hda_codec *codec)
2830{
2831 struct alc_spec *spec;
2832 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002833 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002834
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002835 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002836 if (spec == NULL)
2837 return -ENOMEM;
2838
2839 codec->spec = spec;
2840
2841 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002842 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002843 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2844 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002846 }
2847
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002848 if (board_config == ALC880_AUTO) {
2849 /* automatic parse from the BIOS config */
2850 err = alc880_parse_auto_config(codec);
2851 if (err < 0) {
2852 alc_free(codec);
2853 return err;
2854 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002855 printk(KERN_INFO
2856 "hda_codec: Cannot set up configuration "
2857 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002858 board_config = ALC880_3ST;
2859 }
2860 }
2861
Kailang Yangdf694da2005-12-05 19:42:22 +01002862 if (board_config != ALC880_AUTO)
2863 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864
2865 spec->stream_name_analog = "ALC880 Analog";
2866 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2867 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2868
2869 spec->stream_name_digital = "ALC880 Digital";
2870 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2871 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2872
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002873 if (! spec->adc_nids && spec->input_mux) {
2874 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002875 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2877 if (wcap != AC_WID_AUD_IN) {
2878 spec->adc_nids = alc880_adc_nids_alt;
2879 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2880 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2881 spec->num_mixers++;
2882 } else {
2883 spec->adc_nids = alc880_adc_nids;
2884 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2885 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2886 spec->num_mixers++;
2887 }
2888 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889
2890 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002892 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893
2894 return 0;
2895}
2896
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002897
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898/*
2899 * ALC260 support
2900 */
2901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902static hda_nid_t alc260_dac_nids[1] = {
2903 /* front */
2904 0x02,
2905};
2906
2907static hda_nid_t alc260_adc_nids[1] = {
2908 /* ADC0 */
2909 0x04,
2910};
2911
Kailang Yangdf694da2005-12-05 19:42:22 +01002912static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913 /* ADC1 */
2914 0x05,
2915};
2916
Kailang Yangdf694da2005-12-05 19:42:22 +01002917static hda_nid_t alc260_hp_adc_nids[2] = {
2918 /* ADC1, 0 */
2919 0x05, 0x04
2920};
2921
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002922/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2923 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2924 */
2925static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002926 /* ADC0, ADC1 */
2927 0x04, 0x05
2928};
2929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930#define ALC260_DIGOUT_NID 0x03
2931#define ALC260_DIGIN_NID 0x06
2932
2933static struct hda_input_mux alc260_capture_source = {
2934 .num_items = 4,
2935 .items = {
2936 { "Mic", 0x0 },
2937 { "Front Mic", 0x1 },
2938 { "Line", 0x2 },
2939 { "CD", 0x4 },
2940 },
2941};
2942
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002943/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002944 * headphone jack and the internal CD lines since these are the only pins at
2945 * which audio can appear. For flexibility, also allow the option of
2946 * recording the mixer output on the second ADC (ADC0 doesn't have a
2947 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002948 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002949static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2950 {
2951 .num_items = 3,
2952 .items = {
2953 { "Mic/Line", 0x0 },
2954 { "CD", 0x4 },
2955 { "Headphone", 0x2 },
2956 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002957 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002958 {
2959 .num_items = 4,
2960 .items = {
2961 { "Mic/Line", 0x0 },
2962 { "CD", 0x4 },
2963 { "Headphone", 0x2 },
2964 { "Mixer", 0x5 },
2965 },
2966 },
2967
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002968};
2969
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002970/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2971 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002972 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002973static struct hda_input_mux alc260_acer_capture_sources[2] = {
2974 {
2975 .num_items = 4,
2976 .items = {
2977 { "Mic", 0x0 },
2978 { "Line", 0x2 },
2979 { "CD", 0x4 },
2980 { "Headphone", 0x5 },
2981 },
2982 },
2983 {
2984 .num_items = 5,
2985 .items = {
2986 { "Mic", 0x0 },
2987 { "Line", 0x2 },
2988 { "CD", 0x4 },
2989 { "Headphone", 0x6 },
2990 { "Mixer", 0x5 },
2991 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002992 },
2993};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994/*
2995 * This is just place-holder, so there's something for alc_build_pcms to look
2996 * at when it calculates the maximum number of channels. ALC260 has no mixer
2997 * element which allows changing the channel mode, so the verb list is
2998 * never used.
2999 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003000static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003001 { 2, NULL },
3002};
3003
Kailang Yangdf694da2005-12-05 19:42:22 +01003004
3005/* Mixer combinations
3006 *
3007 * basic: base_output + input + pc_beep + capture
3008 * HP: base_output + input + capture_alt
3009 * HP_3013: hp_3013 + input + capture
3010 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003011 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003012 */
3013
3014static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003015 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003016 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003017 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3018 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3019 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3020 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3021 { } /* end */
3022};
3023
3024static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3028 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3030 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003033 { } /* end */
3034};
3035
Kailang Yangdf694da2005-12-05 19:42:22 +01003036static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3037 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3038 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3039 { } /* end */
3040};
3041
3042static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3043 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3045 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3046 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3047 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3049 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3050 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003051 { } /* end */
3052};
3053
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003054/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3055 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3056 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003057static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003058 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003059 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003060 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003061 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3062 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3063 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3064 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003065 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003066 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3067 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3068 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003069 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003070 { } /* end */
3071};
3072
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003073/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3074 * versions of the ALC260 don't act on requests to enable mic bias from NID
3075 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3076 * datasheet doesn't mention this restriction. At this stage it's not clear
3077 * whether this behaviour is intentional or is a hardware bug in chip
3078 * revisions available in early 2006. Therefore for now allow the
3079 * "Headphone Jack Mode" control to span all choices, but if it turns out
3080 * that the lack of mic bias for this NID is intentional we could change the
3081 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3082 *
3083 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3084 * don't appear to make the mic bias available from the "line" jack, even
3085 * though the NID used for this jack (0x14) can supply it. The theory is
3086 * that perhaps Acer have included blocking capacitors between the ALC260
3087 * and the output jack. If this turns out to be the case for all such
3088 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3089 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3090 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003091static struct snd_kcontrol_new alc260_acer_mixer[] = {
3092 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3093 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003094 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003095 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3096 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3098 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3099 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3100 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3101 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3102 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3103 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3104 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3105 { } /* end */
3106};
3107
Kailang Yangdf694da2005-12-05 19:42:22 +01003108/* capture mixer elements */
3109static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003110 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3111 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003112 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3113 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003114 {
3115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003116 /* The multiple "Capture Source" controls confuse alsamixer
3117 * So call somewhat different..
3118 * FIXME: the controls appear in the "playback" view!
3119 */
3120 /* .name = "Capture Source", */
3121 .name = "Input Source",
3122 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003123 .info = alc_mux_enum_info,
3124 .get = alc_mux_enum_get,
3125 .put = alc_mux_enum_put,
3126 },
3127 { } /* end */
3128};
3129
Kailang Yangdf694da2005-12-05 19:42:22 +01003130static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3131 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3132 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3133 {
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 /* The multiple "Capture Source" controls confuse alsamixer
3136 * So call somewhat different..
3137 * FIXME: the controls appear in the "playback" view!
3138 */
3139 /* .name = "Capture Source", */
3140 .name = "Input Source",
3141 .count = 1,
3142 .info = alc_mux_enum_info,
3143 .get = alc_mux_enum_get,
3144 .put = alc_mux_enum_put,
3145 },
3146 { } /* end */
3147};
3148
3149/*
3150 * initialization verbs
3151 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152static struct hda_verb alc260_init_verbs[] = {
3153 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003155 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003156 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003158 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003159 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003161 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003164 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003165 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003166 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003168 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003169 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003170 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3171 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003172 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173 /* set connection select to line in (default select for this ADC) */
3174 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003175 /* mute capture amp left and right */
3176 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3177 /* set connection select to line in (default select for this ADC) */
3178 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003179 /* set vol=0 Line-Out mixer amp left and right */
3180 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3181 /* unmute pin widget amp left and right (no gain on this amp) */
3182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 /* set vol=0 HP mixer amp left and right */
3184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3185 /* unmute pin widget amp left and right (no gain on this amp) */
3186 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* set vol=0 Mono mixer amp left and right */
3188 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3189 /* unmute pin widget amp left and right (no gain on this amp) */
3190 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 /* unmute LINE-2 out pin */
3192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003193 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003194 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003196 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003198 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003200 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003201 /* mute Front out path */
3202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3204 /* mute Headphone out path */
3205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3207 /* mute Mono out path */
3208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003210 { }
3211};
3212
Takashi Iwai474167d2006-05-17 17:17:43 +02003213#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003214static struct hda_verb alc260_hp_init_verbs[] = {
3215 /* Headphone and output */
3216 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3217 /* mono output */
3218 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3219 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3220 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3221 /* Mic2 (front panel) pin widget for input and vref at 80% */
3222 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3223 /* Line In pin widget for input */
3224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3225 /* Line-2 pin widget for output */
3226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3227 /* CD pin widget for input */
3228 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3229 /* unmute amp left and right */
3230 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3231 /* set connection select to line in (default select for this ADC) */
3232 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3233 /* unmute Line-Out mixer amp left and right (volume = 0) */
3234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3235 /* mute pin widget amp left and right (no gain on this amp) */
3236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3237 /* unmute HP mixer amp left and right (volume = 0) */
3238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3239 /* mute pin widget amp left and right (no gain on this amp) */
3240 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3241 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3242 /* unmute CD */
3243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3244 /* unmute Line In */
3245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3246 /* unmute Mic */
3247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3248 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3249 /* Unmute Front out path */
3250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3252 /* Unmute Headphone out path */
3253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3255 /* Unmute Mono out path */
3256 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3257 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3258 { }
3259};
Takashi Iwai474167d2006-05-17 17:17:43 +02003260#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003261
3262static struct hda_verb alc260_hp_3013_init_verbs[] = {
3263 /* Line out and output */
3264 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3265 /* mono output */
3266 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3267 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3268 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3269 /* Mic2 (front panel) pin widget for input and vref at 80% */
3270 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3271 /* Line In pin widget for input */
3272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3273 /* Headphone pin widget for output */
3274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3275 /* CD pin widget for input */
3276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3277 /* unmute amp left and right */
3278 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3279 /* set connection select to line in (default select for this ADC) */
3280 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3281 /* unmute Line-Out mixer amp left and right (volume = 0) */
3282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3283 /* mute pin widget amp left and right (no gain on this amp) */
3284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3285 /* unmute HP mixer amp left and right (volume = 0) */
3286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3287 /* mute pin widget amp left and right (no gain on this amp) */
3288 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3289 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3290 /* unmute CD */
3291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3292 /* unmute Line In */
3293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3294 /* unmute Mic */
3295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3297 /* Unmute Front out path */
3298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300 /* Unmute Headphone out path */
3301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3303 /* Unmute Mono out path */
3304 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3305 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3306 { }
3307};
3308
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003309/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003310 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3311 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003312 */
3313static struct hda_verb alc260_fujitsu_init_verbs[] = {
3314 /* Disable all GPIOs */
3315 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3316 /* Internal speaker is connected to headphone pin */
3317 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3318 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003320 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3321 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3322 /* Ensure all other unused pins are disabled and muted. */
3323 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003325 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003326 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003327 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003328 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003331
Jonathan Woithef7ace402006-02-28 11:46:14 +01003332 /* Disable digital (SPDIF) pins */
3333 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3334 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003335
Jonathan Woithef7ace402006-02-28 11:46:14 +01003336 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3337 * when acting as an output.
3338 */
3339 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3340
3341 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003342 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3347 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3348 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3349 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3350 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003351
Jonathan Woithef7ace402006-02-28 11:46:14 +01003352 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3353 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3354 /* Unmute Line1 pin widget output buffer since it starts as an output.
3355 * If the pin mode is changed by the user the pin mode control will
3356 * take care of enabling the pin's input/output buffers as needed.
3357 * Therefore there's no need to enable the input buffer at this
3358 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003359 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003361 /* Unmute input buffer of pin widget used for Line-in (no equiv
3362 * mixer ctrl)
3363 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003364 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003365
Jonathan Woithef7ace402006-02-28 11:46:14 +01003366 /* Mute capture amp left and right */
3367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3368 /* Set ADC connection select to match default mixer setting - line
3369 * in (on mic1 pin)
3370 */
3371 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003372
Jonathan Woithef7ace402006-02-28 11:46:14 +01003373 /* Do the same for the second ADC: mute capture input amp and
3374 * set ADC connection to line in (on mic1 pin)
3375 */
3376 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3377 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003378
Jonathan Woithef7ace402006-02-28 11:46:14 +01003379 /* Mute all inputs to mixer widget (even unconnected ones) */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003388
3389 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003390};
3391
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003392/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3393 * similar laptops (adapted from Fujitsu init verbs).
3394 */
3395static struct hda_verb alc260_acer_init_verbs[] = {
3396 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3397 * the headphone jack. Turn this on and rely on the standard mute
3398 * methods whenever the user wants to turn these outputs off.
3399 */
3400 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3401 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3402 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3403 /* Internal speaker/Headphone jack is connected to Line-out pin */
3404 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3405 /* Internal microphone/Mic jack is connected to Mic1 pin */
3406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3407 /* Line In jack is connected to Line1 pin */
3408 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3409 /* Ensure all other unused pins are disabled and muted. */
3410 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3411 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3412 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3413 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3414 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3415 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3418 /* Disable digital (SPDIF) pins */
3419 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3420 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3421
3422 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3423 * bus when acting as outputs.
3424 */
3425 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3426 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3427
3428 /* Start with output sum widgets muted and their output gains at min */
3429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3432 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3435 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3436 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3437 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3438
3439 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3440 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3441 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3442 * inputs. If the pin mode is changed by the user the pin mode control
3443 * will take care of enabling the pin's input/output buffers as needed.
3444 * Therefore there's no need to enable the input buffer at this
3445 * stage.
3446 */
3447 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3449
3450 /* Mute capture amp left and right */
3451 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3452 /* Set ADC connection select to match default mixer setting - mic
3453 * (on mic1 pin)
3454 */
3455 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3456
3457 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003458 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003459 */
3460 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003461 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003462
3463 /* Mute all inputs to mixer widget (even unconnected ones) */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3472
3473 { }
3474};
3475
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003476/* Test configuration for debugging, modelled after the ALC880 test
3477 * configuration.
3478 */
3479#ifdef CONFIG_SND_DEBUG
3480static hda_nid_t alc260_test_dac_nids[1] = {
3481 0x02,
3482};
3483static hda_nid_t alc260_test_adc_nids[2] = {
3484 0x04, 0x05,
3485};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003486/* For testing the ALC260, each input MUX needs its own definition since
3487 * the signal assignments are different. This assumes that the first ADC
3488 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003489 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003490static struct hda_input_mux alc260_test_capture_sources[2] = {
3491 {
3492 .num_items = 7,
3493 .items = {
3494 { "MIC1 pin", 0x0 },
3495 { "MIC2 pin", 0x1 },
3496 { "LINE1 pin", 0x2 },
3497 { "LINE2 pin", 0x3 },
3498 { "CD pin", 0x4 },
3499 { "LINE-OUT pin", 0x5 },
3500 { "HP-OUT pin", 0x6 },
3501 },
3502 },
3503 {
3504 .num_items = 8,
3505 .items = {
3506 { "MIC1 pin", 0x0 },
3507 { "MIC2 pin", 0x1 },
3508 { "LINE1 pin", 0x2 },
3509 { "LINE2 pin", 0x3 },
3510 { "CD pin", 0x4 },
3511 { "Mixer", 0x5 },
3512 { "LINE-OUT pin", 0x6 },
3513 { "HP-OUT pin", 0x7 },
3514 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003515 },
3516};
3517static struct snd_kcontrol_new alc260_test_mixer[] = {
3518 /* Output driver widgets */
3519 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3520 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3521 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3522 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3523 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3525
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003526 /* Modes for retasking pin widgets
3527 * Note: the ALC260 doesn't seem to act on requests to enable mic
3528 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3529 * mention this restriction. At this stage it's not clear whether
3530 * this behaviour is intentional or is a hardware bug in chip
3531 * revisions available at least up until early 2006. Therefore for
3532 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3533 * choices, but if it turns out that the lack of mic bias for these
3534 * NIDs is intentional we could change their modes from
3535 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3536 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003537 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3538 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3539 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3540 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3541 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3542 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3543
3544 /* Loopback mixer controls */
3545 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3546 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3547 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3548 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3549 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3550 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3551 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3552 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3553 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3554 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3555 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3556 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3557 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3558 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3559 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3560 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003561
3562 /* Controls for GPIO pins, assuming they are configured as outputs */
3563 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3564 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3565 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3566 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3567
Jonathan Woithe92621f12006-02-28 11:47:47 +01003568 /* Switches to allow the digital IO pins to be enabled. The datasheet
3569 * is ambigious as to which NID is which; testing on laptops which
3570 * make this output available should provide clarification.
3571 */
3572 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3573 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3574
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003575 { } /* end */
3576};
3577static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003578 /* Enable all GPIOs as outputs with an initial value of 0 */
3579 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3580 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3581 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3582
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003583 /* Enable retasking pins as output, initially without power amp */
3584 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3585 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3588 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3589 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3590
Jonathan Woithe92621f12006-02-28 11:47:47 +01003591 /* Disable digital (SPDIF) pins initially, but users can enable
3592 * them via a mixer switch. In the case of SPDIF-out, this initverb
3593 * payload also sets the generation to 0, output to be in "consumer"
3594 * PCM format, copyright asserted, no pre-emphasis and no validity
3595 * control.
3596 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003597 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3598 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3599
Jonathan Woithef7ace402006-02-28 11:46:14 +01003600 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003601 * OUT1 sum bus when acting as an output.
3602 */
3603 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3604 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3605 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3606 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3607
3608 /* Start with output sum widgets muted and their output gains at min */
3609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3617 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3618
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003619 /* Unmute retasking pin widget output buffers since the default
3620 * state appears to be output. As the pin mode is changed by the
3621 * user the pin mode control will take care of enabling the pin's
3622 * input/output buffers as needed.
3623 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003624 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3628 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3629 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3630 /* Also unmute the mono-out pin widget */
3631 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3632
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003633 /* Mute capture amp left and right */
3634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003635 /* Set ADC connection select to match default mixer setting (mic1
3636 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003637 */
3638 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3639
3640 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003641 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003642 */
3643 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3644 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3645
3646 /* Mute all inputs to mixer widget (even unconnected ones) */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3655
3656 { }
3657};
3658#endif
3659
Linus Torvalds1da177e2005-04-16 15:20:36 -07003660static struct hda_pcm_stream alc260_pcm_analog_playback = {
3661 .substreams = 1,
3662 .channels_min = 2,
3663 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664};
3665
3666static struct hda_pcm_stream alc260_pcm_analog_capture = {
3667 .substreams = 1,
3668 .channels_min = 2,
3669 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003670};
3671
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003672#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3673#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3674
Kailang Yangdf694da2005-12-05 19:42:22 +01003675/*
3676 * for BIOS auto-configuration
3677 */
3678
3679static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3680 const char *pfx)
3681{
3682 hda_nid_t nid_vol;
3683 unsigned long vol_val, sw_val;
3684 char name[32];
3685 int err;
3686
3687 if (nid >= 0x0f && nid < 0x11) {
3688 nid_vol = nid - 0x7;
3689 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3690 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3691 } else if (nid == 0x11) {
3692 nid_vol = nid - 0x7;
3693 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3694 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3695 } else if (nid >= 0x12 && nid <= 0x15) {
3696 nid_vol = 0x08;
3697 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3698 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3699 } else
3700 return 0; /* N/A */
3701
3702 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3703 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3704 return err;
3705 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3706 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3707 return err;
3708 return 1;
3709}
3710
3711/* add playback controls from the parsed DAC table */
3712static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3713 const struct auto_pin_cfg *cfg)
3714{
3715 hda_nid_t nid;
3716 int err;
3717
3718 spec->multiout.num_dacs = 1;
3719 spec->multiout.dac_nids = spec->private_dac_nids;
3720 spec->multiout.dac_nids[0] = 0x02;
3721
3722 nid = cfg->line_out_pins[0];
3723 if (nid) {
3724 err = alc260_add_playback_controls(spec, nid, "Front");
3725 if (err < 0)
3726 return err;
3727 }
3728
Takashi Iwai82bc9552006-03-21 11:24:42 +01003729 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003730 if (nid) {
3731 err = alc260_add_playback_controls(spec, nid, "Speaker");
3732 if (err < 0)
3733 return err;
3734 }
3735
3736 nid = cfg->hp_pin;
3737 if (nid) {
3738 err = alc260_add_playback_controls(spec, nid, "Headphone");
3739 if (err < 0)
3740 return err;
3741 }
3742 return 0;
3743}
3744
3745/* create playback/capture controls for input pins */
3746static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3747 const struct auto_pin_cfg *cfg)
3748{
Kailang Yangdf694da2005-12-05 19:42:22 +01003749 struct hda_input_mux *imux = &spec->private_imux;
3750 int i, err, idx;
3751
3752 for (i = 0; i < AUTO_PIN_LAST; i++) {
3753 if (cfg->input_pins[i] >= 0x12) {
3754 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003755 err = new_analog_input(spec, cfg->input_pins[i],
3756 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003757 if (err < 0)
3758 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003759 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003760 imux->items[imux->num_items].index = idx;
3761 imux->num_items++;
3762 }
3763 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3764 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003765 err = new_analog_input(spec, cfg->input_pins[i],
3766 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003767 if (err < 0)
3768 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003769 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003770 imux->items[imux->num_items].index = idx;
3771 imux->num_items++;
3772 }
3773 }
3774 return 0;
3775}
3776
3777static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3778 hda_nid_t nid, int pin_type,
3779 int sel_idx)
3780{
3781 /* set as output */
3782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3783 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3784 /* need the manual connection? */
3785 if (nid >= 0x12) {
3786 int idx = nid - 0x12;
3787 snd_hda_codec_write(codec, idx + 0x0b, 0,
3788 AC_VERB_SET_CONNECT_SEL, sel_idx);
3789
3790 }
3791}
3792
3793static void alc260_auto_init_multi_out(struct hda_codec *codec)
3794{
3795 struct alc_spec *spec = codec->spec;
3796 hda_nid_t nid;
3797
3798 nid = spec->autocfg.line_out_pins[0];
3799 if (nid)
3800 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3801
Takashi Iwai82bc9552006-03-21 11:24:42 +01003802 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003803 if (nid)
3804 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3805
3806 nid = spec->autocfg.hp_pin;
3807 if (nid)
3808 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3809}
3810
3811#define ALC260_PIN_CD_NID 0x16
3812static void alc260_auto_init_analog_input(struct hda_codec *codec)
3813{
3814 struct alc_spec *spec = codec->spec;
3815 int i;
3816
3817 for (i = 0; i < AUTO_PIN_LAST; i++) {
3818 hda_nid_t nid = spec->autocfg.input_pins[i];
3819 if (nid >= 0x12) {
3820 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3821 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3822 if (nid != ALC260_PIN_CD_NID)
3823 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3824 AMP_OUT_MUTE);
3825 }
3826 }
3827}
3828
3829/*
3830 * generic initialization of ADC, input mixers and output mixers
3831 */
3832static struct hda_verb alc260_volume_init_verbs[] = {
3833 /*
3834 * Unmute ADC0-1 and set the default input to mic-in
3835 */
3836 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3837 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3838 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3839 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3840
3841 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3842 * mixer widget
3843 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3844 * mic (mic 2)
3845 */
3846 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3852
3853 /*
3854 * Set up output mixers (0x08 - 0x0a)
3855 */
3856 /* set vol=0 to output mixers */
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3859 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3860 /* set up input amps for analog loopback */
3861 /* Amp Indices: DAC = 0, mixer = 1 */
3862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3865 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3866 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3867 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3868
3869 { }
3870};
3871
3872static int alc260_parse_auto_config(struct hda_codec *codec)
3873{
3874 struct alc_spec *spec = codec->spec;
3875 unsigned int wcap;
3876 int err;
3877 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3878
3879 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3880 alc260_ignore)) < 0)
3881 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003882 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3883 return err;
3884 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003885 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003886 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003887 return err;
3888
3889 spec->multiout.max_channels = 2;
3890
3891 if (spec->autocfg.dig_out_pin)
3892 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3893 if (spec->kctl_alloc)
3894 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3895
3896 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3897
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003898 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01003899 spec->input_mux = &spec->private_imux;
3900
3901 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003902 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003903 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3904 if (wcap != AC_WID_AUD_IN) {
3905 spec->adc_nids = alc260_adc_nids_alt;
3906 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3907 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003908 } else {
3909 spec->adc_nids = alc260_adc_nids;
3910 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3911 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003912 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003913 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003914
3915 return 1;
3916}
3917
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003918/* additional initialization for auto-configuration model */
3919static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003920{
Kailang Yangdf694da2005-12-05 19:42:22 +01003921 alc260_auto_init_multi_out(codec);
3922 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003923}
3924
3925/*
3926 * ALC260 configurations
3927 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003928static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003929 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003930 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3931 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02003932 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3933 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02003934 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3935 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003936 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3937 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003938 { .modelname = "hp", .config = ALC260_HP },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003939 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
Takashi Iwai25b6c432006-08-08 13:01:14 +02003940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02003942 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003943 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3944 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3945 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3946 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3947 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3948 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003949 { .modelname = "acer", .config = ALC260_ACER },
3950 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003951#ifdef CONFIG_SND_DEBUG
3952 { .modelname = "test", .config = ALC260_TEST },
3953#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003954 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003955 {}
3956};
3957
Kailang Yangdf694da2005-12-05 19:42:22 +01003958static struct alc_config_preset alc260_presets[] = {
3959 [ALC260_BASIC] = {
3960 .mixers = { alc260_base_output_mixer,
3961 alc260_input_mixer,
3962 alc260_pc_beep_mixer,
3963 alc260_capture_mixer },
3964 .init_verbs = { alc260_init_verbs },
3965 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3966 .dac_nids = alc260_dac_nids,
3967 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3968 .adc_nids = alc260_adc_nids,
3969 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3970 .channel_mode = alc260_modes,
3971 .input_mux = &alc260_capture_source,
3972 },
3973 [ALC260_HP] = {
3974 .mixers = { alc260_base_output_mixer,
3975 alc260_input_mixer,
3976 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02003977 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01003978 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3979 .dac_nids = alc260_dac_nids,
3980 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3981 .adc_nids = alc260_hp_adc_nids,
3982 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3983 .channel_mode = alc260_modes,
3984 .input_mux = &alc260_capture_source,
3985 },
3986 [ALC260_HP_3013] = {
3987 .mixers = { alc260_hp_3013_mixer,
3988 alc260_input_mixer,
3989 alc260_capture_alt_mixer },
3990 .init_verbs = { alc260_hp_3013_init_verbs },
3991 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3992 .dac_nids = alc260_dac_nids,
3993 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3994 .adc_nids = alc260_hp_adc_nids,
3995 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3996 .channel_mode = alc260_modes,
3997 .input_mux = &alc260_capture_source,
3998 },
3999 [ALC260_FUJITSU_S702X] = {
4000 .mixers = { alc260_fujitsu_mixer,
4001 alc260_capture_mixer },
4002 .init_verbs = { alc260_fujitsu_init_verbs },
4003 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4004 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004005 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4006 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4008 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004009 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4010 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004012 [ALC260_ACER] = {
4013 .mixers = { alc260_acer_mixer,
4014 alc260_capture_mixer },
4015 .init_verbs = { alc260_acer_init_verbs },
4016 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4017 .dac_nids = alc260_dac_nids,
4018 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4019 .adc_nids = alc260_dual_adc_nids,
4020 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4021 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004022 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4023 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004024 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004025#ifdef CONFIG_SND_DEBUG
4026 [ALC260_TEST] = {
4027 .mixers = { alc260_test_mixer,
4028 alc260_capture_mixer },
4029 .init_verbs = { alc260_test_init_verbs },
4030 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4031 .dac_nids = alc260_test_dac_nids,
4032 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4033 .adc_nids = alc260_test_adc_nids,
4034 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4035 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004036 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4037 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004038 },
4039#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004040};
4041
Linus Torvalds1da177e2005-04-16 15:20:36 -07004042static int patch_alc260(struct hda_codec *codec)
4043{
4044 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004045 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004046
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 if (spec == NULL)
4049 return -ENOMEM;
4050
4051 codec->spec = spec;
4052
Takashi Iwai16ded522005-06-10 19:58:24 +02004053 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4054 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004055 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4056 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004057 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004058 }
4059
Kailang Yangdf694da2005-12-05 19:42:22 +01004060 if (board_config == ALC260_AUTO) {
4061 /* automatic parse from the BIOS config */
4062 err = alc260_parse_auto_config(codec);
4063 if (err < 0) {
4064 alc_free(codec);
4065 return err;
4066 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004067 printk(KERN_INFO
4068 "hda_codec: Cannot set up configuration "
4069 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004070 board_config = ALC260_BASIC;
4071 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004072 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004073
Kailang Yangdf694da2005-12-05 19:42:22 +01004074 if (board_config != ALC260_AUTO)
4075 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004076
4077 spec->stream_name_analog = "ALC260 Analog";
4078 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4079 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4080
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004081 spec->stream_name_digital = "ALC260 Digital";
4082 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4083 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4084
Linus Torvalds1da177e2005-04-16 15:20:36 -07004085 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004086 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004087 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004088
4089 return 0;
4090}
4091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092
Linus Torvalds1da177e2005-04-16 15:20:36 -07004093/*
4094 * ALC882 support
4095 *
4096 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4097 * configuration. Each pin widget can choose any input DACs and a mixer.
4098 * Each ADC is connected from a mixer of all inputs. This makes possible
4099 * 6-channel independent captures.
4100 *
4101 * In addition, an independent DAC for the multi-playback (not used in this
4102 * driver yet).
4103 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004104#define ALC882_DIGOUT_NID 0x06
4105#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004106
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004107static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004108 { 8, NULL }
4109};
4110
4111static hda_nid_t alc882_dac_nids[4] = {
4112 /* front, rear, clfe, rear_surr */
4113 0x02, 0x03, 0x04, 0x05
4114};
4115
Kailang Yangdf694da2005-12-05 19:42:22 +01004116/* identical with ALC880 */
4117#define alc882_adc_nids alc880_adc_nids
4118#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004119
4120/* input MUX */
4121/* FIXME: should be a matrix-type input source selection */
4122
4123static struct hda_input_mux alc882_capture_source = {
4124 .num_items = 4,
4125 .items = {
4126 { "Mic", 0x0 },
4127 { "Front Mic", 0x1 },
4128 { "Line", 0x2 },
4129 { "CD", 0x4 },
4130 },
4131};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004132#define alc882_mux_enum_info alc_mux_enum_info
4133#define alc882_mux_enum_get alc_mux_enum_get
4134
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004135static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136{
4137 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4138 struct alc_spec *spec = codec->spec;
4139 const struct hda_input_mux *imux = spec->input_mux;
4140 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4141 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4142 hda_nid_t nid = capture_mixers[adc_idx];
4143 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4144 unsigned int i, idx;
4145
4146 idx = ucontrol->value.enumerated.item[0];
4147 if (idx >= imux->num_items)
4148 idx = imux->num_items - 1;
4149 if (*cur_val == idx && ! codec->in_resume)
4150 return 0;
4151 for (i = 0; i < imux->num_items; i++) {
4152 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4153 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4154 v | (imux->items[i].index << 8));
4155 }
4156 *cur_val = idx;
4157 return 1;
4158}
4159
Kailang Yangdf694da2005-12-05 19:42:22 +01004160/*
4161 * 6ch mode
4162 */
4163static struct hda_verb alc882_sixstack_ch6_init[] = {
4164 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4165 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4166 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4167 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4168 { } /* end */
4169};
4170
4171/*
4172 * 8ch mode
4173 */
4174static struct hda_verb alc882_sixstack_ch8_init[] = {
4175 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4176 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4177 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4178 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4179 { } /* end */
4180};
4181
4182static struct hda_channel_mode alc882_sixstack_modes[2] = {
4183 { 6, alc882_sixstack_ch6_init },
4184 { 8, alc882_sixstack_ch8_init },
4185};
4186
Linus Torvalds1da177e2005-04-16 15:20:36 -07004187/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4188 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4189 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004190static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004194 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4208 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4209 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4210 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4211 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004212 { } /* end */
4213};
4214
Kailang Yangdf694da2005-12-05 19:42:22 +01004215static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4216 {
4217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4218 .name = "Channel Mode",
4219 .info = alc_ch_mode_info,
4220 .get = alc_ch_mode_get,
4221 .put = alc_ch_mode_put,
4222 },
4223 { } /* end */
4224};
4225
Linus Torvalds1da177e2005-04-16 15:20:36 -07004226static struct hda_verb alc882_init_verbs[] = {
4227 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004231 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004235 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004239 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4242 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004244 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004251 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004253 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004255 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004257 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004258 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004259 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4263 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4266 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4269 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4272 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004273 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004275
4276 /* FIXME: use matrix-type input source selection */
4277 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4278 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004283 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004288 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4293 /* ADC1: mute amp left and right */
4294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004295 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004296 /* ADC2: mute amp left and right */
4297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004298 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004299 /* ADC3: mute amp left and right */
4300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004301 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004302
4303 { }
4304};
4305
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004306static struct hda_verb alc882_eapd_verbs[] = {
4307 /* change to EAPD mode */
4308 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4309 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4310 { }
4311};
4312
Kailang Yangdf694da2005-12-05 19:42:22 +01004313/*
4314 * generic initialization of ADC, input mixers and output mixers
4315 */
4316static struct hda_verb alc882_auto_init_verbs[] = {
4317 /*
4318 * Unmute ADC0-2 and set the default input to mic-in
4319 */
4320 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4322 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4324 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4326
4327 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4328 * mixer widget
4329 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4330 * mic (mic 2)
4331 */
4332 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4338
4339 /*
4340 * Set up output mixers (0x0c - 0x0f)
4341 */
4342 /* set vol=0 to output mixers */
4343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4347 /* set up input amps for analog loopback */
4348 /* Amp Indices: DAC = 0, mixer = 1 */
4349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4352 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4354 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4355 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4357 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4358 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4359
4360 /* FIXME: use matrix-type input source selection */
4361 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4362 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4367 /* Input mixer2 */
4368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4372 /* Input mixer3 */
4373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4377
4378 { }
4379};
4380
4381/* capture mixer elements */
4382static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4383 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4384 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4385 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4386 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4387 {
4388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4389 /* The multiple "Capture Source" controls confuse alsamixer
4390 * So call somewhat different..
4391 * FIXME: the controls appear in the "playback" view!
4392 */
4393 /* .name = "Capture Source", */
4394 .name = "Input Source",
4395 .count = 2,
4396 .info = alc882_mux_enum_info,
4397 .get = alc882_mux_enum_get,
4398 .put = alc882_mux_enum_put,
4399 },
4400 { } /* end */
4401};
4402
4403static struct snd_kcontrol_new alc882_capture_mixer[] = {
4404 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4405 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4406 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4407 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4408 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4409 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4410 {
4411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4412 /* The multiple "Capture Source" controls confuse alsamixer
4413 * So call somewhat different..
4414 * FIXME: the controls appear in the "playback" view!
4415 */
4416 /* .name = "Capture Source", */
4417 .name = "Input Source",
4418 .count = 3,
4419 .info = alc882_mux_enum_info,
4420 .get = alc882_mux_enum_get,
4421 .put = alc882_mux_enum_put,
4422 },
4423 { } /* end */
4424};
4425
4426/* pcm configuration: identiacal with ALC880 */
4427#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4428#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4429#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4430#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4431
4432/*
4433 * configuration and preset
4434 */
4435static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004436 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4437 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004438 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4439 .config = ALC882_6ST_DIG }, /* MSI */
4440 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4441 .config = ALC882_6ST_DIG }, /* Foxconn */
4442 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4443 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004444 { .modelname = "arima", .config = ALC882_ARIMA },
4445 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4446 .config = ALC882_ARIMA }, /* Arima W820Di1 */
Takashi Iwai1494a922006-01-31 10:58:46 +01004447 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 {}
4449};
4450
4451static struct alc_config_preset alc882_presets[] = {
4452 [ALC882_3ST_DIG] = {
4453 .mixers = { alc882_base_mixer },
4454 .init_verbs = { alc882_init_verbs },
4455 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4456 .dac_nids = alc882_dac_nids,
4457 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004458 .dig_in_nid = ALC882_DIGIN_NID,
4459 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4460 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004461 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004462 .input_mux = &alc882_capture_source,
4463 },
4464 [ALC882_6ST_DIG] = {
4465 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4466 .init_verbs = { alc882_init_verbs },
4467 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4468 .dac_nids = alc882_dac_nids,
4469 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 .dig_in_nid = ALC882_DIGIN_NID,
4471 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4472 .channel_mode = alc882_sixstack_modes,
4473 .input_mux = &alc882_capture_source,
4474 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004475 [ALC882_ARIMA] = {
4476 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4477 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4478 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4479 .dac_nids = alc882_dac_nids,
4480 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4481 .channel_mode = alc882_sixstack_modes,
4482 .input_mux = &alc882_capture_source,
4483 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004484};
4485
4486
4487/*
4488 * BIOS auto configuration
4489 */
4490static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4491 hda_nid_t nid, int pin_type,
4492 int dac_idx)
4493{
4494 /* set as output */
4495 struct alc_spec *spec = codec->spec;
4496 int idx;
4497
4498 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4499 idx = 4;
4500 else
4501 idx = spec->multiout.dac_nids[dac_idx] - 2;
4502
4503 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4504 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4505 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4506
4507}
4508
4509static void alc882_auto_init_multi_out(struct hda_codec *codec)
4510{
4511 struct alc_spec *spec = codec->spec;
4512 int i;
4513
4514 for (i = 0; i <= HDA_SIDE; i++) {
4515 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4516 if (nid)
4517 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4518 }
4519}
4520
4521static void alc882_auto_init_hp_out(struct hda_codec *codec)
4522{
4523 struct alc_spec *spec = codec->spec;
4524 hda_nid_t pin;
4525
4526 pin = spec->autocfg.hp_pin;
4527 if (pin) /* connect to front */
4528 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4529}
4530
4531#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4532#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4533
4534static void alc882_auto_init_analog_input(struct hda_codec *codec)
4535{
4536 struct alc_spec *spec = codec->spec;
4537 int i;
4538
4539 for (i = 0; i < AUTO_PIN_LAST; i++) {
4540 hda_nid_t nid = spec->autocfg.input_pins[i];
4541 if (alc882_is_input_pin(nid)) {
4542 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4543 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4544 if (nid != ALC882_PIN_CD_NID)
4545 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4546 AMP_OUT_MUTE);
4547 }
4548 }
4549}
4550
4551/* almost identical with ALC880 parser... */
4552static int alc882_parse_auto_config(struct hda_codec *codec)
4553{
4554 struct alc_spec *spec = codec->spec;
4555 int err = alc880_parse_auto_config(codec);
4556
4557 if (err < 0)
4558 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004559 else if (err > 0)
4560 /* hack - override the init verbs */
4561 spec->init_verbs[0] = alc882_auto_init_verbs;
4562 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004563}
4564
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004565/* additional initialization for auto-configuration model */
4566static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004567{
Kailang Yangdf694da2005-12-05 19:42:22 +01004568 alc882_auto_init_multi_out(codec);
4569 alc882_auto_init_hp_out(codec);
4570 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004571}
4572
Linus Torvalds1da177e2005-04-16 15:20:36 -07004573static int patch_alc882(struct hda_codec *codec)
4574{
4575 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004576 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004577
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004578 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004579 if (spec == NULL)
4580 return -ENOMEM;
4581
Linus Torvalds1da177e2005-04-16 15:20:36 -07004582 codec->spec = spec;
4583
Kailang Yangdf694da2005-12-05 19:42:22 +01004584 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004585
Kailang Yangdf694da2005-12-05 19:42:22 +01004586 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004587 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4588 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004589 board_config = ALC882_AUTO;
4590 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004591
Kailang Yangdf694da2005-12-05 19:42:22 +01004592 if (board_config == ALC882_AUTO) {
4593 /* automatic parse from the BIOS config */
4594 err = alc882_parse_auto_config(codec);
4595 if (err < 0) {
4596 alc_free(codec);
4597 return err;
4598 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004599 printk(KERN_INFO
4600 "hda_codec: Cannot set up configuration "
4601 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004602 board_config = ALC882_3ST_DIG;
4603 }
4604 }
4605
4606 if (board_config != ALC882_AUTO)
4607 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004608
4609 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004610 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4611 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004612
4613 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4615 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004616
Kailang Yangdf694da2005-12-05 19:42:22 +01004617 if (! spec->adc_nids && spec->input_mux) {
4618 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004619 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004620 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4621 if (wcap != AC_WID_AUD_IN) {
4622 spec->adc_nids = alc882_adc_nids_alt;
4623 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4624 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4625 spec->num_mixers++;
4626 } else {
4627 spec->adc_nids = alc882_adc_nids;
4628 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4629 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4630 spec->num_mixers++;
4631 }
4632 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004633
4634 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004635 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004636 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004637
4638 return 0;
4639}
4640
4641/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004642 * ALC883 support
4643 *
4644 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4645 * configuration. Each pin widget can choose any input DACs and a mixer.
4646 * Each ADC is connected from a mixer of all inputs. This makes possible
4647 * 6-channel independent captures.
4648 *
4649 * In addition, an independent DAC for the multi-playback (not used in this
4650 * driver yet).
4651 */
4652#define ALC883_DIGOUT_NID 0x06
4653#define ALC883_DIGIN_NID 0x0a
4654
4655static hda_nid_t alc883_dac_nids[4] = {
4656 /* front, rear, clfe, rear_surr */
4657 0x02, 0x04, 0x03, 0x05
4658};
4659
4660static hda_nid_t alc883_adc_nids[2] = {
4661 /* ADC1-2 */
4662 0x08, 0x09,
4663};
4664/* input MUX */
4665/* FIXME: should be a matrix-type input source selection */
4666
4667static struct hda_input_mux alc883_capture_source = {
4668 .num_items = 4,
4669 .items = {
4670 { "Mic", 0x0 },
4671 { "Front Mic", 0x1 },
4672 { "Line", 0x2 },
4673 { "CD", 0x4 },
4674 },
4675};
4676#define alc883_mux_enum_info alc_mux_enum_info
4677#define alc883_mux_enum_get alc_mux_enum_get
4678
4679static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4680 struct snd_ctl_elem_value *ucontrol)
4681{
4682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4683 struct alc_spec *spec = codec->spec;
4684 const struct hda_input_mux *imux = spec->input_mux;
4685 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4686 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4687 hda_nid_t nid = capture_mixers[adc_idx];
4688 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4689 unsigned int i, idx;
4690
4691 idx = ucontrol->value.enumerated.item[0];
4692 if (idx >= imux->num_items)
4693 idx = imux->num_items - 1;
4694 if (*cur_val == idx && ! codec->in_resume)
4695 return 0;
4696 for (i = 0; i < imux->num_items; i++) {
4697 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4698 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4699 v | (imux->items[i].index << 8));
4700 }
4701 *cur_val = idx;
4702 return 1;
4703}
4704/*
4705 * 2ch mode
4706 */
4707static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4708 { 2, NULL }
4709};
4710
4711/*
4712 * 2ch mode
4713 */
4714static struct hda_verb alc883_3ST_ch2_init[] = {
4715 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4716 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4719 { } /* end */
4720};
4721
4722/*
4723 * 6ch mode
4724 */
4725static struct hda_verb alc883_3ST_ch6_init[] = {
4726 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4727 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4728 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4729 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4730 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4731 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4732 { } /* end */
4733};
4734
4735static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4736 { 2, alc883_3ST_ch2_init },
4737 { 6, alc883_3ST_ch6_init },
4738};
4739
4740/*
4741 * 6ch mode
4742 */
4743static struct hda_verb alc883_sixstack_ch6_init[] = {
4744 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4746 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4747 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4748 { } /* end */
4749};
4750
4751/*
4752 * 8ch mode
4753 */
4754static struct hda_verb alc883_sixstack_ch8_init[] = {
4755 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4756 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4757 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4758 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4759 { } /* end */
4760};
4761
4762static struct hda_channel_mode alc883_sixstack_modes[2] = {
4763 { 6, alc883_sixstack_ch6_init },
4764 { 8, alc883_sixstack_ch8_init },
4765};
4766
4767/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4768 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4769 */
4770
4771static struct snd_kcontrol_new alc883_base_mixer[] = {
4772 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4774 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4775 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4776 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4778 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4779 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4780 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4781 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4791 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4792 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4793 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4794 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4795 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4796 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4797 {
4798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4799 /* .name = "Capture Source", */
4800 .name = "Input Source",
4801 .count = 2,
4802 .info = alc883_mux_enum_info,
4803 .get = alc883_mux_enum_get,
4804 .put = alc883_mux_enum_put,
4805 },
4806 { } /* end */
4807};
4808
4809static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4821 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4822 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4823 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4824 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4825 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4826 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4827 {
4828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4829 /* .name = "Capture Source", */
4830 .name = "Input Source",
4831 .count = 2,
4832 .info = alc883_mux_enum_info,
4833 .get = alc883_mux_enum_get,
4834 .put = alc883_mux_enum_put,
4835 },
4836 { } /* end */
4837};
4838
4839static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4840 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4842 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4843 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4844 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4845 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4846 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4847 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4848 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4849 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4850 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4856 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4857 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4858 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4859 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4860 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4861 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4862 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4863 {
4864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4865 /* .name = "Capture Source", */
4866 .name = "Input Source",
4867 .count = 2,
4868 .info = alc883_mux_enum_info,
4869 .get = alc883_mux_enum_get,
4870 .put = alc883_mux_enum_put,
4871 },
4872 { } /* end */
4873};
4874
4875static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4876 {
4877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4878 .name = "Channel Mode",
4879 .info = alc_ch_mode_info,
4880 .get = alc_ch_mode_get,
4881 .put = alc_ch_mode_put,
4882 },
4883 { } /* end */
4884};
4885
4886static struct hda_verb alc883_init_verbs[] = {
4887 /* ADC1: mute amp left and right */
4888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4889 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4890 /* ADC2: mute amp left and right */
4891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4893 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 /* Rear mixer */
4898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4901 /* CLFE mixer */
4902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4905 /* Side mixer */
4906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4909
4910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4915
4916 /* Front Pin: output 0 (0x0c) */
4917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4920 /* Rear Pin: output 1 (0x0d) */
4921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4922 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4924 /* CLFE Pin: output 2 (0x0e) */
4925 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4926 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4927 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4928 /* Side Pin: output 3 (0x0f) */
4929 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4931 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4932 /* Mic (rear) pin: input vref at 80% */
4933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4935 /* Front Mic pin: input vref at 80% */
4936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4937 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4938 /* Line In pin: input */
4939 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4941 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4944 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4945 /* CD pin widget for input */
4946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4947
4948 /* FIXME: use matrix-type input source selection */
4949 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4950 /* Input mixer2 */
4951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4955 /* Input mixer3 */
4956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4960 { }
4961};
4962
4963/*
4964 * generic initialization of ADC, input mixers and output mixers
4965 */
4966static struct hda_verb alc883_auto_init_verbs[] = {
4967 /*
4968 * Unmute ADC0-2 and set the default input to mic-in
4969 */
4970 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4972 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4974
4975 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4976 * mixer widget
4977 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4978 * mic (mic 2)
4979 */
4980 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4986
4987 /*
4988 * Set up output mixers (0x0c - 0x0f)
4989 */
4990 /* set vol=0 to output mixers */
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4992 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4995 /* set up input amps for analog loopback */
4996 /* Amp Indices: DAC = 0, mixer = 1 */
4997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5005 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5006 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5007
5008 /* FIXME: use matrix-type input source selection */
5009 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5010 /* Input mixer1 */
5011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5014 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5016 /* Input mixer2 */
5017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5020 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5021 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5022
5023 { }
5024};
5025
5026/* capture mixer elements */
5027static struct snd_kcontrol_new alc883_capture_mixer[] = {
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 /* The multiple "Capture Source" controls confuse alsamixer
5035 * So call somewhat different..
5036 * FIXME: the controls appear in the "playback" view!
5037 */
5038 /* .name = "Capture Source", */
5039 .name = "Input Source",
5040 .count = 2,
5041 .info = alc882_mux_enum_info,
5042 .get = alc882_mux_enum_get,
5043 .put = alc882_mux_enum_put,
5044 },
5045 { } /* end */
5046};
5047
5048/* pcm configuration: identiacal with ALC880 */
5049#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5050#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5051#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5052#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5053
5054/*
5055 * configuration and preset
5056 */
5057static struct hda_board_config alc883_cfg_tbl[] = {
5058 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005059 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5060 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5061 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5062 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5063 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5064 .config = ALC883_3ST_6ch },
Tobin Davis2aaeee82006-08-21 19:01:12 +02005065 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5066 .config = ALC883_3ST_6ch }, /* D102GGC */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005067 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005068 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5069 .config = ALC883_6ST_DIG }, /* MSI */
5070 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5071 .config = ALC883_6ST_DIG }, /* Foxconn */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005072 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02005073 { .modelname = "acer", .config = ALC883_ACER },
5074 { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
5075 .config = ALC883_ACER },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005076 { .modelname = "auto", .config = ALC883_AUTO },
5077 {}
5078};
5079
5080static struct alc_config_preset alc883_presets[] = {
5081 [ALC883_3ST_2ch_DIG] = {
5082 .mixers = { alc883_3ST_2ch_mixer },
5083 .init_verbs = { alc883_init_verbs },
5084 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5085 .dac_nids = alc883_dac_nids,
5086 .dig_out_nid = ALC883_DIGOUT_NID,
5087 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5088 .adc_nids = alc883_adc_nids,
5089 .dig_in_nid = ALC883_DIGIN_NID,
5090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5091 .channel_mode = alc883_3ST_2ch_modes,
5092 .input_mux = &alc883_capture_source,
5093 },
5094 [ALC883_3ST_6ch_DIG] = {
5095 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5096 .init_verbs = { alc883_init_verbs },
5097 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5098 .dac_nids = alc883_dac_nids,
5099 .dig_out_nid = ALC883_DIGOUT_NID,
5100 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5101 .adc_nids = alc883_adc_nids,
5102 .dig_in_nid = ALC883_DIGIN_NID,
5103 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5104 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005105 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005106 .input_mux = &alc883_capture_source,
5107 },
5108 [ALC883_3ST_6ch] = {
5109 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5110 .init_verbs = { alc883_init_verbs },
5111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5112 .dac_nids = alc883_dac_nids,
5113 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5114 .adc_nids = alc883_adc_nids,
5115 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5116 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005117 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005118 .input_mux = &alc883_capture_source,
5119 },
5120 [ALC883_6ST_DIG] = {
5121 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5122 .init_verbs = { alc883_init_verbs },
5123 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5124 .dac_nids = alc883_dac_nids,
5125 .dig_out_nid = ALC883_DIGOUT_NID,
5126 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5127 .adc_nids = alc883_adc_nids,
5128 .dig_in_nid = ALC883_DIGIN_NID,
5129 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5130 .channel_mode = alc883_sixstack_modes,
5131 .input_mux = &alc883_capture_source,
5132 },
5133 [ALC888_DEMO_BOARD] = {
5134 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5135 .init_verbs = { alc883_init_verbs },
5136 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5137 .dac_nids = alc883_dac_nids,
5138 .dig_out_nid = ALC883_DIGOUT_NID,
5139 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5140 .adc_nids = alc883_adc_nids,
5141 .dig_in_nid = ALC883_DIGIN_NID,
5142 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5143 .channel_mode = alc883_sixstack_modes,
5144 .input_mux = &alc883_capture_source,
5145 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02005146 [ALC883_ACER] = {
5147 .mixers = { alc883_base_mixer,
5148 alc883_chmode_mixer },
5149 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5150 * and the headphone jack. Turn this on and rely on the
5151 * standard mute methods whenever the user wants to turn
5152 * these outputs off.
5153 */
5154 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5155 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5156 .dac_nids = alc883_dac_nids,
5157 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5158 .adc_nids = alc883_adc_nids,
5159 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5160 .channel_mode = alc883_3ST_2ch_modes,
5161 .input_mux = &alc883_capture_source,
5162 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005163};
5164
5165
5166/*
5167 * BIOS auto configuration
5168 */
5169static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5170 hda_nid_t nid, int pin_type,
5171 int dac_idx)
5172{
5173 /* set as output */
5174 struct alc_spec *spec = codec->spec;
5175 int idx;
5176
5177 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5178 idx = 4;
5179 else
5180 idx = spec->multiout.dac_nids[dac_idx] - 2;
5181
5182 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5183 pin_type);
5184 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5185 AMP_OUT_UNMUTE);
5186 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5187
5188}
5189
5190static void alc883_auto_init_multi_out(struct hda_codec *codec)
5191{
5192 struct alc_spec *spec = codec->spec;
5193 int i;
5194
5195 for (i = 0; i <= HDA_SIDE; i++) {
5196 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5197 if (nid)
5198 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5199 }
5200}
5201
5202static void alc883_auto_init_hp_out(struct hda_codec *codec)
5203{
5204 struct alc_spec *spec = codec->spec;
5205 hda_nid_t pin;
5206
5207 pin = spec->autocfg.hp_pin;
5208 if (pin) /* connect to front */
5209 /* use dac 0 */
5210 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5211}
5212
5213#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5214#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5215
5216static void alc883_auto_init_analog_input(struct hda_codec *codec)
5217{
5218 struct alc_spec *spec = codec->spec;
5219 int i;
5220
5221 for (i = 0; i < AUTO_PIN_LAST; i++) {
5222 hda_nid_t nid = spec->autocfg.input_pins[i];
5223 if (alc883_is_input_pin(nid)) {
5224 snd_hda_codec_write(codec, nid, 0,
5225 AC_VERB_SET_PIN_WIDGET_CONTROL,
5226 (i <= AUTO_PIN_FRONT_MIC ?
5227 PIN_VREF80 : PIN_IN));
5228 if (nid != ALC883_PIN_CD_NID)
5229 snd_hda_codec_write(codec, nid, 0,
5230 AC_VERB_SET_AMP_GAIN_MUTE,
5231 AMP_OUT_MUTE);
5232 }
5233 }
5234}
5235
5236/* almost identical with ALC880 parser... */
5237static int alc883_parse_auto_config(struct hda_codec *codec)
5238{
5239 struct alc_spec *spec = codec->spec;
5240 int err = alc880_parse_auto_config(codec);
5241
5242 if (err < 0)
5243 return err;
5244 else if (err > 0)
5245 /* hack - override the init verbs */
5246 spec->init_verbs[0] = alc883_auto_init_verbs;
5247 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5248 spec->num_mixers++;
5249 return err;
5250}
5251
5252/* additional initialization for auto-configuration model */
5253static void alc883_auto_init(struct hda_codec *codec)
5254{
5255 alc883_auto_init_multi_out(codec);
5256 alc883_auto_init_hp_out(codec);
5257 alc883_auto_init_analog_input(codec);
5258}
5259
5260static int patch_alc883(struct hda_codec *codec)
5261{
5262 struct alc_spec *spec;
5263 int err, board_config;
5264
5265 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5266 if (spec == NULL)
5267 return -ENOMEM;
5268
5269 codec->spec = spec;
5270
5271 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5272 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5273 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5274 "trying auto-probe from BIOS...\n");
5275 board_config = ALC883_AUTO;
5276 }
5277
5278 if (board_config == ALC883_AUTO) {
5279 /* automatic parse from the BIOS config */
5280 err = alc883_parse_auto_config(codec);
5281 if (err < 0) {
5282 alc_free(codec);
5283 return err;
5284 } else if (! err) {
5285 printk(KERN_INFO
5286 "hda_codec: Cannot set up configuration "
5287 "from BIOS. Using base mode...\n");
5288 board_config = ALC883_3ST_2ch_DIG;
5289 }
5290 }
5291
5292 if (board_config != ALC883_AUTO)
5293 setup_preset(spec, &alc883_presets[board_config]);
5294
5295 spec->stream_name_analog = "ALC883 Analog";
5296 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5297 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5298
5299 spec->stream_name_digital = "ALC883 Digital";
5300 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5301 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5302
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005303 if (! spec->adc_nids && spec->input_mux) {
5304 spec->adc_nids = alc883_adc_nids;
5305 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5306 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005307
5308 codec->patch_ops = alc_patch_ops;
5309 if (board_config == ALC883_AUTO)
5310 spec->init_hook = alc883_auto_init;
5311
5312 return 0;
5313}
5314
5315/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005316 * ALC262 support
5317 */
5318
5319#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5320#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5321
5322#define alc262_dac_nids alc260_dac_nids
5323#define alc262_adc_nids alc882_adc_nids
5324#define alc262_adc_nids_alt alc882_adc_nids_alt
5325
5326#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005327#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005328
5329static struct snd_kcontrol_new alc262_base_mixer[] = {
5330 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5331 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5332 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5333 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5340 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5341 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5342 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5344 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5345 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005346 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005347};
5348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005349static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5351 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5353 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5354 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5355
5356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5358 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5359 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5360 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5361 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5364 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5365 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5366 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5367 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5368 { } /* end */
5369};
5370
Kailang Yangdf694da2005-12-05 19:42:22 +01005371#define alc262_capture_mixer alc882_capture_mixer
5372#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5373
5374/*
5375 * generic initialization of ADC, input mixers and output mixers
5376 */
5377static struct hda_verb alc262_init_verbs[] = {
5378 /*
5379 * Unmute ADC0-2 and set the default input to mic-in
5380 */
5381 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5383 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5385 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5387
5388 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5389 * mixer widget
5390 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5391 * mic (mic 2)
5392 */
5393 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5399
5400 /*
5401 * Set up output mixers (0x0c - 0x0e)
5402 */
5403 /* set vol=0 to output mixers */
5404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5407 /* set up input amps for analog loopback */
5408 /* Amp Indices: DAC = 0, mixer = 1 */
5409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5415
5416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5421 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5422
5423 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5426 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5427 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5428
5429 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5431
5432 /* FIXME: use matrix-type input source selection */
5433 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5434 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5439 /* Input mixer2 */
5440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5444 /* Input mixer3 */
5445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5449
5450 { }
5451};
5452
Takashi Iwai834be882006-03-01 14:16:17 +01005453/*
5454 * fujitsu model
5455 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5456 */
5457
5458#define ALC_HP_EVENT 0x37
5459
5460static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5463 {}
5464};
5465
5466static struct hda_input_mux alc262_fujitsu_capture_source = {
5467 .num_items = 2,
5468 .items = {
5469 { "Mic", 0x0 },
5470 { "CD", 0x4 },
5471 },
5472};
5473
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005474static struct hda_input_mux alc262_HP_capture_source = {
5475 .num_items = 5,
5476 .items = {
5477 { "Mic", 0x0 },
5478 { "Front Mic", 0x3 },
5479 { "Line", 0x2 },
5480 { "CD", 0x4 },
5481 { "AUX IN", 0x6 },
5482 },
5483};
5484
Takashi Iwai834be882006-03-01 14:16:17 +01005485/* mute/unmute internal speaker according to the hp jack and mute state */
5486static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5487{
5488 struct alc_spec *spec = codec->spec;
5489 unsigned int mute;
5490
5491 if (force || ! spec->sense_updated) {
5492 unsigned int present;
5493 /* need to execute and sync at first */
5494 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5495 present = snd_hda_codec_read(codec, 0x14, 0,
5496 AC_VERB_GET_PIN_SENSE, 0);
5497 spec->jack_present = (present & 0x80000000) != 0;
5498 spec->sense_updated = 1;
5499 }
5500 if (spec->jack_present) {
5501 /* mute internal speaker */
5502 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5503 0x80, 0x80);
5504 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5505 0x80, 0x80);
5506 } else {
5507 /* unmute internal speaker if necessary */
5508 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5509 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5510 0x80, mute & 0x80);
5511 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5512 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5513 0x80, mute & 0x80);
5514 }
5515}
5516
5517/* unsolicited event for HP jack sensing */
5518static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5519 unsigned int res)
5520{
5521 if ((res >> 26) != ALC_HP_EVENT)
5522 return;
5523 alc262_fujitsu_automute(codec, 1);
5524}
5525
5526/* bind volumes of both NID 0x0c and 0x0d */
5527static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5528 struct snd_ctl_elem_value *ucontrol)
5529{
5530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5531 long *valp = ucontrol->value.integer.value;
5532 int change;
5533
5534 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5535 0x7f, valp[0] & 0x7f);
5536 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5537 0x7f, valp[1] & 0x7f);
5538 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5539 0x7f, valp[0] & 0x7f);
5540 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5541 0x7f, valp[1] & 0x7f);
5542 return change;
5543}
5544
5545/* bind hp and internal speaker mute (with plug check) */
5546static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5547 struct snd_ctl_elem_value *ucontrol)
5548{
5549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5550 long *valp = ucontrol->value.integer.value;
5551 int change;
5552
5553 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5554 0x80, valp[0] ? 0 : 0x80);
5555 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5556 0x80, valp[1] ? 0 : 0x80);
5557 if (change || codec->in_resume)
5558 alc262_fujitsu_automute(codec, codec->in_resume);
5559 return change;
5560}
5561
5562static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5563 {
5564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5565 .name = "Master Playback Volume",
5566 .info = snd_hda_mixer_amp_volume_info,
5567 .get = snd_hda_mixer_amp_volume_get,
5568 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02005569 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01005570 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5571 },
5572 {
5573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5574 .name = "Master Playback Switch",
5575 .info = snd_hda_mixer_amp_switch_info,
5576 .get = snd_hda_mixer_amp_switch_get,
5577 .put = alc262_fujitsu_master_sw_put,
5578 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5579 },
5580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5585 { } /* end */
5586};
5587
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005588/* additional init verbs for Benq laptops */
5589static struct hda_verb alc262_EAPD_verbs[] = {
5590 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5591 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5592 {}
5593};
5594
Kailang Yangdf694da2005-12-05 19:42:22 +01005595/* add playback controls from the parsed DAC table */
5596static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5597{
5598 hda_nid_t nid;
5599 int err;
5600
5601 spec->multiout.num_dacs = 1; /* only use one dac */
5602 spec->multiout.dac_nids = spec->private_dac_nids;
5603 spec->multiout.dac_nids[0] = 2;
5604
5605 nid = cfg->line_out_pins[0];
5606 if (nid) {
5607 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5608 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5609 return err;
5610 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5611 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5612 return err;
5613 }
5614
Takashi Iwai82bc9552006-03-21 11:24:42 +01005615 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005616 if (nid) {
5617 if (nid == 0x16) {
5618 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5619 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5620 return err;
5621 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5622 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5623 return err;
5624 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005625 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5626 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5627 return err;
5628 }
5629 }
5630 nid = cfg->hp_pin;
5631 if (nid) {
5632 /* spec->multiout.hp_nid = 2; */
5633 if (nid == 0x16) {
5634 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5635 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5636 return err;
5637 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5638 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5639 return err;
5640 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005641 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5642 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5643 return err;
5644 }
5645 }
5646 return 0;
5647}
5648
5649/* identical with ALC880 */
5650#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5651
5652/*
5653 * generic initialization of ADC, input mixers and output mixers
5654 */
5655static struct hda_verb alc262_volume_init_verbs[] = {
5656 /*
5657 * Unmute ADC0-2 and set the default input to mic-in
5658 */
5659 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5661 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5664 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5665
5666 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5667 * mixer widget
5668 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5669 * mic (mic 2)
5670 */
5671 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5677
5678 /*
5679 * Set up output mixers (0x0c - 0x0f)
5680 */
5681 /* set vol=0 to output mixers */
5682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5685
5686 /* set up input amps for analog loopback */
5687 /* Amp Indices: DAC = 0, mixer = 1 */
5688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5692 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5693 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5694
5695 /* FIXME: use matrix-type input source selection */
5696 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5697 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5702 /* Input mixer2 */
5703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5707 /* Input mixer3 */
5708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5712
5713 { }
5714};
5715
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005716static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5717 /*
5718 * Unmute ADC0-2 and set the default input to mic-in
5719 */
5720 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5722 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5723 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5724 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5726
5727 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5728 * mixer widget
5729 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5730 * mic (mic 2)
5731 */
5732 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5740
5741 /*
5742 * Set up output mixers (0x0c - 0x0e)
5743 */
5744 /* set vol=0 to output mixers */
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5748
5749 /* set up input amps for analog loopback */
5750 /* Amp Indices: DAC = 0, mixer = 1 */
5751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5757
5758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5760 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5761
5762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5764
5765 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5767
5768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5773
5774 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5778 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5779 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5780
5781
5782 /* FIXME: use matrix-type input source selection */
5783 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5784 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5789 /* Input mixer2 */
5790 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5792 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5794 /* Input mixer3 */
5795 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5796 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5797 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5798 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5799
5800 { }
5801};
5802
Kailang Yangdf694da2005-12-05 19:42:22 +01005803/* pcm configuration: identiacal with ALC880 */
5804#define alc262_pcm_analog_playback alc880_pcm_analog_playback
5805#define alc262_pcm_analog_capture alc880_pcm_analog_capture
5806#define alc262_pcm_digital_playback alc880_pcm_digital_playback
5807#define alc262_pcm_digital_capture alc880_pcm_digital_capture
5808
5809/*
5810 * BIOS auto configuration
5811 */
5812static int alc262_parse_auto_config(struct hda_codec *codec)
5813{
5814 struct alc_spec *spec = codec->spec;
5815 int err;
5816 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5817
5818 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5819 alc262_ignore)) < 0)
5820 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005821 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005822 return 0; /* can't find valid BIOS pin config */
5823 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5824 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5825 return err;
5826
5827 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5828
5829 if (spec->autocfg.dig_out_pin)
5830 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5831 if (spec->autocfg.dig_in_pin)
5832 spec->dig_in_nid = ALC262_DIGIN_NID;
5833
5834 if (spec->kctl_alloc)
5835 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5836
5837 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005838 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005839 spec->input_mux = &spec->private_imux;
5840
5841 return 1;
5842}
5843
5844#define alc262_auto_init_multi_out alc882_auto_init_multi_out
5845#define alc262_auto_init_hp_out alc882_auto_init_hp_out
5846#define alc262_auto_init_analog_input alc882_auto_init_analog_input
5847
5848
5849/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005850static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005851{
Kailang Yangdf694da2005-12-05 19:42:22 +01005852 alc262_auto_init_multi_out(codec);
5853 alc262_auto_init_hp_out(codec);
5854 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005855}
5856
5857/*
5858 * configuration and preset
5859 */
5860static struct hda_board_config alc262_cfg_tbl[] = {
5861 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01005862 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005863 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5864 .config = ALC262_FUJITSU },
Takashi Iwai6d177ba2006-07-25 14:51:15 +02005865 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005866 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5867 .config = ALC262_HP_BPC }, /* xw4400 */
5868 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5869 .config = ALC262_HP_BPC }, /* xw6400 */
5870 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5871 .config = ALC262_HP_BPC }, /* xw8400 */
5872 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5873 .config = ALC262_HP_BPC }, /* xw9400 */
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005874 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5875 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5876 .config = ALC262_BENQ_ED8 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005877 { .modelname = "auto", .config = ALC262_AUTO },
5878 {}
5879};
5880
5881static struct alc_config_preset alc262_presets[] = {
5882 [ALC262_BASIC] = {
5883 .mixers = { alc262_base_mixer },
5884 .init_verbs = { alc262_init_verbs },
5885 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5886 .dac_nids = alc262_dac_nids,
5887 .hp_nid = 0x03,
5888 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5889 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005890 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01005891 },
Takashi Iwai834be882006-03-01 14:16:17 +01005892 [ALC262_FUJITSU] = {
5893 .mixers = { alc262_fujitsu_mixer },
5894 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5895 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5896 .dac_nids = alc262_dac_nids,
5897 .hp_nid = 0x03,
5898 .dig_out_nid = ALC262_DIGOUT_NID,
5899 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5900 .channel_mode = alc262_modes,
5901 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005902 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01005903 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005904 [ALC262_HP_BPC] = {
5905 .mixers = { alc262_HP_BPC_mixer },
5906 .init_verbs = { alc262_HP_BPC_init_verbs },
5907 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5908 .dac_nids = alc262_dac_nids,
5909 .hp_nid = 0x03,
5910 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5911 .channel_mode = alc262_modes,
5912 .input_mux = &alc262_HP_capture_source,
5913 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005914 [ALC262_BENQ_ED8] = {
5915 .mixers = { alc262_base_mixer },
5916 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5917 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5918 .dac_nids = alc262_dac_nids,
5919 .hp_nid = 0x03,
5920 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5921 .channel_mode = alc262_modes,
5922 .input_mux = &alc262_capture_source,
5923 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005924};
5925
5926static int patch_alc262(struct hda_codec *codec)
5927{
5928 struct alc_spec *spec;
5929 int board_config;
5930 int err;
5931
5932 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5933 if (spec == NULL)
5934 return -ENOMEM;
5935
5936 codec->spec = spec;
5937#if 0
5938 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5939 {
5940 int tmp;
5941 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5942 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5943 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5944 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5945 }
5946#endif
5947
5948 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005949
Kailang Yangdf694da2005-12-05 19:42:22 +01005950 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005951 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5952 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005953 board_config = ALC262_AUTO;
5954 }
5955
5956 if (board_config == ALC262_AUTO) {
5957 /* automatic parse from the BIOS config */
5958 err = alc262_parse_auto_config(codec);
5959 if (err < 0) {
5960 alc_free(codec);
5961 return err;
5962 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005963 printk(KERN_INFO
5964 "hda_codec: Cannot set up configuration "
5965 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 board_config = ALC262_BASIC;
5967 }
5968 }
5969
5970 if (board_config != ALC262_AUTO)
5971 setup_preset(spec, &alc262_presets[board_config]);
5972
5973 spec->stream_name_analog = "ALC262 Analog";
5974 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5975 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5976
5977 spec->stream_name_digital = "ALC262 Digital";
5978 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5979 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5980
5981 if (! spec->adc_nids && spec->input_mux) {
5982 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005983 unsigned int wcap = get_wcaps(codec, 0x07);
5984
Kailang Yangdf694da2005-12-05 19:42:22 +01005985 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5986 if (wcap != AC_WID_AUD_IN) {
5987 spec->adc_nids = alc262_adc_nids_alt;
5988 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5989 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5990 spec->num_mixers++;
5991 } else {
5992 spec->adc_nids = alc262_adc_nids;
5993 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5994 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5995 spec->num_mixers++;
5996 }
5997 }
5998
5999 codec->patch_ops = alc_patch_ops;
6000 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006001 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006002
Kailang Yangdf694da2005-12-05 19:42:22 +01006003 return 0;
6004}
6005
Kailang Yangdf694da2005-12-05 19:42:22 +01006006/*
6007 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6008 */
6009
6010/*
6011 * set the path ways for 2 channel output
6012 * need to set the codec line out and mic 1 pin widgets to inputs
6013 */
6014static struct hda_verb alc861_threestack_ch2_init[] = {
6015 /* set pin widget 1Ah (line in) for input */
6016 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6017 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6018 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6019
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006020 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6021#if 0
6022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6023 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6024#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006025 { } /* end */
6026};
6027/*
6028 * 6ch mode
6029 * need to set the codec line out and mic 1 pin widgets to outputs
6030 */
6031static struct hda_verb alc861_threestack_ch6_init[] = {
6032 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6033 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6034 /* set pin widget 18h (mic1) for output (CLFE)*/
6035 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6036
6037 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006038 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006039
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6041#if 0
6042 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6043 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6044#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 { } /* end */
6046};
6047
6048static struct hda_channel_mode alc861_threestack_modes[2] = {
6049 { 2, alc861_threestack_ch2_init },
6050 { 6, alc861_threestack_ch6_init },
6051};
Takashi Iwai22309c32006-08-09 16:57:28 +02006052/* Set mic1 as input and unmute the mixer */
6053static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6054 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6055 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6056 { } /* end */
6057};
6058/* Set mic1 as output and mute mixer */
6059static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6060 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6061 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6062 { } /* end */
6063};
6064
6065static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6066 { 2, alc861_uniwill_m31_ch2_init },
6067 { 4, alc861_uniwill_m31_ch4_init },
6068};
Kailang Yangdf694da2005-12-05 19:42:22 +01006069
6070/* patch-ALC861 */
6071
6072static struct snd_kcontrol_new alc861_base_mixer[] = {
6073 /* output mixer control */
6074 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6075 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6076 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6077 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6078 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6079
6080 /*Input mixer control */
6081 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6082 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6083 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6084 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6085 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6086 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6088 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6089 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6091
6092 /* Capture mixer control */
6093 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6094 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6095 {
6096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6097 .name = "Capture Source",
6098 .count = 1,
6099 .info = alc_mux_enum_info,
6100 .get = alc_mux_enum_get,
6101 .put = alc_mux_enum_put,
6102 },
6103 { } /* end */
6104};
6105
6106static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6107 /* output mixer control */
6108 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6109 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6110 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6111 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6112 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6113
6114 /* Input mixer control */
6115 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6116 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6117 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6118 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6119 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6120 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6122 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6125
6126 /* Capture mixer control */
6127 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6128 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6129 {
6130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6131 .name = "Capture Source",
6132 .count = 1,
6133 .info = alc_mux_enum_info,
6134 .get = alc_mux_enum_get,
6135 .put = alc_mux_enum_put,
6136 },
6137 {
6138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6139 .name = "Channel Mode",
6140 .info = alc_ch_mode_info,
6141 .get = alc_ch_mode_get,
6142 .put = alc_ch_mode_put,
6143 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6144 },
6145 { } /* end */
6146};
Takashi Iwai22309c32006-08-09 16:57:28 +02006147static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6148 /* output mixer control */
6149 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6150 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6151 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6152 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6153 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6154
6155 /* Input mixer control */
6156 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6157 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6158 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6159 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6160 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6161 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6163 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6166
6167 /* Capture mixer control */
6168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6170 {
6171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6172 .name = "Capture Source",
6173 .count = 1,
6174 .info = alc_mux_enum_info,
6175 .get = alc_mux_enum_get,
6176 .put = alc_mux_enum_put,
6177 },
6178 {
6179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6180 .name = "Channel Mode",
6181 .info = alc_ch_mode_info,
6182 .get = alc_ch_mode_get,
6183 .put = alc_ch_mode_put,
6184 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6185 },
6186 { } /* end */
6187};
Kailang Yangdf694da2005-12-05 19:42:22 +01006188
6189/*
6190 * generic initialization of ADC, input mixers and output mixers
6191 */
6192static struct hda_verb alc861_base_init_verbs[] = {
6193 /*
6194 * Unmute ADC0 and set the default input to mic-in
6195 */
6196 /* port-A for surround (rear panel) */
6197 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6198 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6199 /* port-B for mic-in (rear panel) with vref */
6200 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6201 /* port-C for line-in (rear panel) */
6202 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6203 /* port-D for Front */
6204 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6205 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6206 /* port-E for HP out (front panel) */
6207 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6208 /* route front PCM to HP */
6209 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6210 /* port-F for mic-in (front panel) with vref */
6211 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6212 /* port-G for CLFE (rear panel) */
6213 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6214 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6215 /* port-H for side (rear panel) */
6216 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6217 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6218 /* CD-in */
6219 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6220 /* route front mic to ADC1*/
6221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6223
6224 /* Unmute DAC0~3 & spdif out*/
6225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6227 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6228 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6230
6231 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6232 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6233 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6234 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6235 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6236
6237 /* Unmute Stereo Mixer 15 */
6238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6242
6243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6246 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6247 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6253
6254 { }
6255};
6256
6257static struct hda_verb alc861_threestack_init_verbs[] = {
6258 /*
6259 * Unmute ADC0 and set the default input to mic-in
6260 */
6261 /* port-A for surround (rear panel) */
6262 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6263 /* port-B for mic-in (rear panel) with vref */
6264 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6265 /* port-C for line-in (rear panel) */
6266 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6267 /* port-D for Front */
6268 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6269 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6270 /* port-E for HP out (front panel) */
6271 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6272 /* route front PCM to HP */
6273 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6274 /* port-F for mic-in (front panel) with vref */
6275 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6276 /* port-G for CLFE (rear panel) */
6277 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6278 /* port-H for side (rear panel) */
6279 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6280 /* CD-in */
6281 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6282 /* route front mic to ADC1*/
6283 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6285 /* Unmute DAC0~3 & spdif out*/
6286 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6287 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6288 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6289 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6291
6292 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6293 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6294 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6295 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6296 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6297
6298 /* Unmute Stereo Mixer 15 */
6299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6303
6304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6310 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6314 { }
6315};
Takashi Iwai22309c32006-08-09 16:57:28 +02006316
6317static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6318 /*
6319 * Unmute ADC0 and set the default input to mic-in
6320 */
6321 /* port-A for surround (rear panel) */
6322 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6323 /* port-B for mic-in (rear panel) with vref */
6324 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6325 /* port-C for line-in (rear panel) */
6326 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6327 /* port-D for Front */
6328 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6329 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6330 /* port-E for HP out (front panel) */
6331 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6332 /* route front PCM to HP */
6333 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6334 /* port-F for mic-in (front panel) with vref */
6335 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6336 /* port-G for CLFE (rear panel) */
6337 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6338 /* port-H for side (rear panel) */
6339 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6340 /* CD-in */
6341 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6342 /* route front mic to ADC1*/
6343 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6345 /* Unmute DAC0~3 & spdif out*/
6346 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6347 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6348 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6349 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6351
6352 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6353 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6354 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6355 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6356 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6357
6358 /* Unmute Stereo Mixer 15 */
6359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6363
6364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6366 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6367 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6374 { }
6375};
6376
Kailang Yangdf694da2005-12-05 19:42:22 +01006377/*
6378 * generic initialization of ADC, input mixers and output mixers
6379 */
6380static struct hda_verb alc861_auto_init_verbs[] = {
6381 /*
6382 * Unmute ADC0 and set the default input to mic-in
6383 */
6384// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6386
6387 /* Unmute DAC0~3 & spdif out*/
6388 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6390 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6391 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6393
6394 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6395 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6396 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6397 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6398 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6399
6400 /* Unmute Stereo Mixer 15 */
6401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6405
6406 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6408 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6409 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6414
6415 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6418 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6419 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6421 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6422 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6423
6424 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6425
6426 { }
6427};
6428
6429/* pcm configuration: identiacal with ALC880 */
6430#define alc861_pcm_analog_playback alc880_pcm_analog_playback
6431#define alc861_pcm_analog_capture alc880_pcm_analog_capture
6432#define alc861_pcm_digital_playback alc880_pcm_digital_playback
6433#define alc861_pcm_digital_capture alc880_pcm_digital_capture
6434
6435
6436#define ALC861_DIGOUT_NID 0x07
6437
6438static struct hda_channel_mode alc861_8ch_modes[1] = {
6439 { 8, NULL }
6440};
6441
6442static hda_nid_t alc861_dac_nids[4] = {
6443 /* front, surround, clfe, side */
6444 0x03, 0x06, 0x05, 0x04
6445};
6446
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006447static hda_nid_t alc660_dac_nids[3] = {
6448 /* front, clfe, surround */
6449 0x03, 0x05, 0x06
6450};
6451
Kailang Yangdf694da2005-12-05 19:42:22 +01006452static hda_nid_t alc861_adc_nids[1] = {
6453 /* ADC0-2 */
6454 0x08,
6455};
6456
6457static struct hda_input_mux alc861_capture_source = {
6458 .num_items = 5,
6459 .items = {
6460 { "Mic", 0x0 },
6461 { "Front Mic", 0x3 },
6462 { "Line", 0x1 },
6463 { "CD", 0x4 },
6464 { "Mixer", 0x5 },
6465 },
6466};
6467
6468/* fill in the dac_nids table from the parsed pin configuration */
6469static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6470{
6471 int i;
6472 hda_nid_t nid;
6473
6474 spec->multiout.dac_nids = spec->private_dac_nids;
6475 for (i = 0; i < cfg->line_outs; i++) {
6476 nid = cfg->line_out_pins[i];
6477 if (nid) {
6478 if (i >= ARRAY_SIZE(alc861_dac_nids))
6479 continue;
6480 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6481 }
6482 }
6483 spec->multiout.num_dacs = cfg->line_outs;
6484 return 0;
6485}
6486
6487/* add playback controls from the parsed DAC table */
6488static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6489 const struct auto_pin_cfg *cfg)
6490{
6491 char name[32];
6492 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6493 hda_nid_t nid;
6494 int i, idx, err;
6495
6496 for (i = 0; i < cfg->line_outs; i++) {
6497 nid = spec->multiout.dac_nids[i];
6498 if (! nid)
6499 continue;
6500 if (nid == 0x05) {
6501 /* Center/LFE */
6502 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6503 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6504 return err;
6505 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6506 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6507 return err;
6508 } else {
6509 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6510 if (nid == alc861_dac_nids[idx])
6511 break;
6512 sprintf(name, "%s Playback Switch", chname[idx]);
6513 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6514 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6515 return err;
6516 }
6517 }
6518 return 0;
6519}
6520
6521static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6522{
6523 int err;
6524 hda_nid_t nid;
6525
6526 if (! pin)
6527 return 0;
6528
6529 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6530 nid = 0x03;
6531 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6532 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6533 return err;
6534 spec->multiout.hp_nid = nid;
6535 }
6536 return 0;
6537}
6538
6539/* create playback/capture controls for input pins */
6540static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6541{
Kailang Yangdf694da2005-12-05 19:42:22 +01006542 struct hda_input_mux *imux = &spec->private_imux;
6543 int i, err, idx, idx1;
6544
6545 for (i = 0; i < AUTO_PIN_LAST; i++) {
6546 switch(cfg->input_pins[i]) {
6547 case 0x0c:
6548 idx1 = 1;
6549 idx = 2; // Line In
6550 break;
6551 case 0x0f:
6552 idx1 = 2;
6553 idx = 2; // Line In
6554 break;
6555 case 0x0d:
6556 idx1 = 0;
6557 idx = 1; // Mic In
6558 break;
6559 case 0x10:
6560 idx1 = 3;
6561 idx = 1; // Mic In
6562 break;
6563 case 0x11:
6564 idx1 = 4;
6565 idx = 0; // CD
6566 break;
6567 default:
6568 continue;
6569 }
6570
Takashi Iwai4a471b72005-12-07 13:56:29 +01006571 err = new_analog_input(spec, cfg->input_pins[i],
6572 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 if (err < 0)
6574 return err;
6575
Takashi Iwai4a471b72005-12-07 13:56:29 +01006576 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006577 imux->items[imux->num_items].index = idx1;
6578 imux->num_items++;
6579 }
6580 return 0;
6581}
6582
6583static struct snd_kcontrol_new alc861_capture_mixer[] = {
6584 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6585 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6586
6587 {
6588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6589 /* The multiple "Capture Source" controls confuse alsamixer
6590 * So call somewhat different..
6591 *FIXME: the controls appear in the "playback" view!
6592 */
6593 /* .name = "Capture Source", */
6594 .name = "Input Source",
6595 .count = 1,
6596 .info = alc_mux_enum_info,
6597 .get = alc_mux_enum_get,
6598 .put = alc_mux_enum_put,
6599 },
6600 { } /* end */
6601};
6602
6603static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6604 int pin_type, int dac_idx)
6605{
6606 /* set as output */
6607
6608 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6609 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6610
6611}
6612
6613static void alc861_auto_init_multi_out(struct hda_codec *codec)
6614{
6615 struct alc_spec *spec = codec->spec;
6616 int i;
6617
6618 for (i = 0; i < spec->autocfg.line_outs; i++) {
6619 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6620 if (nid)
6621 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6622 }
6623}
6624
6625static void alc861_auto_init_hp_out(struct hda_codec *codec)
6626{
6627 struct alc_spec *spec = codec->spec;
6628 hda_nid_t pin;
6629
6630 pin = spec->autocfg.hp_pin;
6631 if (pin) /* connect to front */
6632 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6633}
6634
6635static void alc861_auto_init_analog_input(struct hda_codec *codec)
6636{
6637 struct alc_spec *spec = codec->spec;
6638 int i;
6639
6640 for (i = 0; i < AUTO_PIN_LAST; i++) {
6641 hda_nid_t nid = spec->autocfg.input_pins[i];
6642 if ((nid>=0x0c) && (nid <=0x11)) {
6643 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6644 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6645 }
6646 }
6647}
6648
6649/* parse the BIOS configuration and set up the alc_spec */
6650/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6651static int alc861_parse_auto_config(struct hda_codec *codec)
6652{
6653 struct alc_spec *spec = codec->spec;
6654 int err;
6655 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6656
6657 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6658 alc861_ignore)) < 0)
6659 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006660 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006661 return 0; /* can't find valid BIOS pin config */
6662
6663 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6664 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6665 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6666 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6667 return err;
6668
6669 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6670
6671 if (spec->autocfg.dig_out_pin)
6672 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6673
6674 if (spec->kctl_alloc)
6675 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6676
6677 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6678
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006679 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006680 spec->input_mux = &spec->private_imux;
6681
6682 spec->adc_nids = alc861_adc_nids;
6683 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6684 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6685 spec->num_mixers++;
6686
6687 return 1;
6688}
6689
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006690/* additional initialization for auto-configuration model */
6691static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006692{
Kailang Yangdf694da2005-12-05 19:42:22 +01006693 alc861_auto_init_multi_out(codec);
6694 alc861_auto_init_hp_out(codec);
6695 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006696}
6697
6698
6699/*
6700 * configuration and preset
6701 */
6702static struct hda_board_config alc861_cfg_tbl[] = {
6703 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006704 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6705 .config = ALC861_3ST },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006706 { .modelname = "3stack-660", .config = ALC660_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006707 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6708 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01006709 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6710 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
Takashi Iwai22309c32006-08-09 16:57:28 +02006711 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
6712 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
6713 .config = ALC861_UNIWILL_M31 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006714 { .modelname = "auto", .config = ALC861_AUTO },
6715 {}
6716};
6717
6718static struct alc_config_preset alc861_presets[] = {
6719 [ALC861_3ST] = {
6720 .mixers = { alc861_3ST_mixer },
6721 .init_verbs = { alc861_threestack_init_verbs },
6722 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6723 .dac_nids = alc861_dac_nids,
6724 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6725 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006726 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006727 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6728 .adc_nids = alc861_adc_nids,
6729 .input_mux = &alc861_capture_source,
6730 },
6731 [ALC861_3ST_DIG] = {
6732 .mixers = { alc861_base_mixer },
6733 .init_verbs = { alc861_threestack_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6735 .dac_nids = alc861_dac_nids,
6736 .dig_out_nid = ALC861_DIGOUT_NID,
6737 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6738 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006739 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006740 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6741 .adc_nids = alc861_adc_nids,
6742 .input_mux = &alc861_capture_source,
6743 },
6744 [ALC861_6ST_DIG] = {
6745 .mixers = { alc861_base_mixer },
6746 .init_verbs = { alc861_base_init_verbs },
6747 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6748 .dac_nids = alc861_dac_nids,
6749 .dig_out_nid = ALC861_DIGOUT_NID,
6750 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6751 .channel_mode = alc861_8ch_modes,
6752 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6753 .adc_nids = alc861_adc_nids,
6754 .input_mux = &alc861_capture_source,
6755 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006756 [ALC660_3ST] = {
6757 .mixers = { alc861_3ST_mixer },
6758 .init_verbs = { alc861_threestack_init_verbs },
6759 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6760 .dac_nids = alc660_dac_nids,
6761 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6762 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006763 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006764 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6765 .adc_nids = alc861_adc_nids,
6766 .input_mux = &alc861_capture_source,
6767 },
Takashi Iwai22309c32006-08-09 16:57:28 +02006768 [ALC861_UNIWILL_M31] = {
6769 .mixers = { alc861_uniwill_m31_mixer },
6770 .init_verbs = { alc861_uniwill_m31_init_verbs },
6771 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6772 .dac_nids = alc861_dac_nids,
6773 .dig_out_nid = ALC861_DIGOUT_NID,
6774 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
6775 .channel_mode = alc861_uniwill_m31_modes,
6776 .need_dac_fix = 1,
6777 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6778 .adc_nids = alc861_adc_nids,
6779 .input_mux = &alc861_capture_source,
6780 },
6781
Kailang Yangdf694da2005-12-05 19:42:22 +01006782};
6783
6784
6785static int patch_alc861(struct hda_codec *codec)
6786{
6787 struct alc_spec *spec;
6788 int board_config;
6789 int err;
6790
6791 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6792 if (spec == NULL)
6793 return -ENOMEM;
6794
6795 codec->spec = spec;
6796
6797 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006798
Kailang Yangdf694da2005-12-05 19:42:22 +01006799 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006800 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6801 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006802 board_config = ALC861_AUTO;
6803 }
6804
6805 if (board_config == ALC861_AUTO) {
6806 /* automatic parse from the BIOS config */
6807 err = alc861_parse_auto_config(codec);
6808 if (err < 0) {
6809 alc_free(codec);
6810 return err;
6811 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006812 printk(KERN_INFO
6813 "hda_codec: Cannot set up configuration "
6814 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006815 board_config = ALC861_3ST_DIG;
6816 }
6817 }
6818
6819 if (board_config != ALC861_AUTO)
6820 setup_preset(spec, &alc861_presets[board_config]);
6821
6822 spec->stream_name_analog = "ALC861 Analog";
6823 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6824 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6825
6826 spec->stream_name_digital = "ALC861 Digital";
6827 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6828 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6829
6830 codec->patch_ops = alc_patch_ops;
6831 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006832 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01006833
6834 return 0;
6835}
6836
6837/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006838 * patch entries
6839 */
6840struct hda_codec_preset snd_hda_preset_realtek[] = {
6841 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006842 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006843 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6844 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006845 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006846 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006847 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6848 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6849 .patch = patch_alc861 },
6850 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6851 .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006852 {} /* terminator */
6853};