blob: 1420db43423a6ea805d14c8daa838eeba250be01 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
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 Woithe7cf51e482006-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 Avdoninbab282b92006-08-22 13:31:58 +0200114 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200115 ALC883_MEDION,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200116 ALC883_AUTO,
117 ALC883_MODEL_LAST,
118};
119
Kailang Yangdf694da2005-12-05 19:42:22 +0100120/* for GPIO Poll */
121#define GPIO_MASK 0x03
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123struct alc_spec {
124 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100125 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 unsigned int num_mixers;
127
Kailang Yangdf694da2005-12-05 19:42:22 +0100128 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200129 * don't forget NULL
130 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200131 */
132 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Takashi Iwai16ded522005-06-10 19:58:24 +0200134 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 struct hda_pcm_stream *stream_analog_playback;
136 struct hda_pcm_stream *stream_analog_capture;
137
Takashi Iwai16ded522005-06-10 19:58:24 +0200138 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 struct hda_pcm_stream *stream_digital_playback;
140 struct hda_pcm_stream *stream_digital_capture;
141
142 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200143 struct hda_multi_out multiout; /* playback set-up
144 * max_channels, dacs must be set
145 * dig_out_nid and hp_nid are optional
146 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148 /* capture */
149 unsigned int num_adc_nids;
150 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200151 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200154 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 const struct hda_input_mux *input_mux;
156 unsigned int cur_mux[3];
157
158 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100159 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200161 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100164 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200165
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200166 /* dynamic controls, init_verbs and input_mux */
167 struct auto_pin_cfg autocfg;
168 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100169 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200170 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100171 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100172
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100173 /* hooks */
174 void (*init_hook)(struct hda_codec *codec);
175 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
176
Takashi Iwai834be882006-03-01 14:16:17 +0100177 /* for pin sensing */
178 unsigned int sense_updated: 1;
179 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100180};
181
182/*
183 * configuration template - to be copied to the spec instance
184 */
185struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200186 struct snd_kcontrol_new *mixers[5]; /* should be identical size
187 * with spec
188 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100189 const struct hda_verb *init_verbs[5];
190 unsigned int num_dacs;
191 hda_nid_t *dac_nids;
192 hda_nid_t dig_out_nid; /* optional */
193 hda_nid_t hp_nid; /* optional */
194 unsigned int num_adc_nids;
195 hda_nid_t *adc_nids;
196 hda_nid_t dig_in_nid;
197 unsigned int num_channel_mode;
198 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200199 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200200 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100201 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100202 void (*unsol_event)(struct hda_codec *, unsigned int);
203 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204};
205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207/*
208 * input MUX handling
209 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200210static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
211 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212{
213 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
214 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200215 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
216 if (mux_idx >= spec->num_mux_defs)
217 mux_idx = 0;
218 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
220
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200221static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
222 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223{
224 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
225 struct alc_spec *spec = codec->spec;
226 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
227
228 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
229 return 0;
230}
231
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200232static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
233 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
235 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
236 struct alc_spec *spec = codec->spec;
237 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200238 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
239 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200240 spec->adc_nids[adc_idx],
241 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242}
243
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200244
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245/*
246 * channel mode setting
247 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200248static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250{
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100253 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
254 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255}
256
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200257static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
258 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259{
260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
261 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100262 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200263 spec->num_channel_mode,
264 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265}
266
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200267static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
268 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269{
270 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
271 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200272 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
273 spec->num_channel_mode,
274 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200275 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200276 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
277 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278}
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100281 * Control the mode of pin widget settings via the mixer. "pc" is used
282 * instead of "%" to avoid consequences of accidently treating the % as
283 * being part of a format specifier. Maximum allowed length of a value is
284 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100285 *
286 * Note: some retasking pin complexes seem to ignore requests for input
287 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
288 * are requested. Therefore order this list so that this behaviour will not
289 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200290 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
291 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200292 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100293static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100294 "Mic 50pc bias", "Mic 80pc bias",
295 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100296};
297static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100298 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100299};
300/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200301 * in the pin being assumed to be exclusively an input or an output pin. In
302 * addition, "input" pins may or may not process the mic bias option
303 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
304 * accept requests for bias as of chip versions up to March 2006) and/or
305 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100306 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200307#define ALC_PIN_DIR_IN 0x00
308#define ALC_PIN_DIR_OUT 0x01
309#define ALC_PIN_DIR_INOUT 0x02
310#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
311#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100312
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100314 * For each direction the minimum and maximum values are given.
315 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200316static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100317 { 0, 2 }, /* ALC_PIN_DIR_IN */
318 { 3, 4 }, /* ALC_PIN_DIR_OUT */
319 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200320 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
321 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100322};
323#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
324#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
325#define alc_pin_mode_n_items(_dir) \
326 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
327
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200328static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
329 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200330{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 unsigned int item_num = uinfo->value.enumerated.item;
332 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
333
334 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200335 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100336 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
337
338 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
339 item_num = alc_pin_mode_min(dir);
340 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200341 return 0;
342}
343
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200344static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200346{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100347 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
349 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100350 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200351 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
353 AC_VERB_GET_PIN_WIDGET_CONTROL,
354 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200355
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356 /* Find enumerated value for current pinctl setting */
357 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200358 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100359 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200360 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 return 0;
362}
363
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200364static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
365 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100366{
367 signed int change;
368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
369 hda_nid_t nid = kcontrol->private_value & 0xffff;
370 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
371 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200372 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
373 AC_VERB_GET_PIN_WIDGET_CONTROL,
374 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200376 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100377 val = alc_pin_mode_min(dir);
378
379 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100380 if (change) {
381 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200382 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200383 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100384
385 /* Also enable the retasking pin's input/output as required
386 * for the requested pin mode. Enum values of 2 or less are
387 * input modes.
388 *
389 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200390 * reduces noise slightly (particularly on input) so we'll
391 * do it. However, having both input and output buffers
392 * enabled simultaneously doesn't seem to be problematic if
393 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100394 */
395 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
398 AMP_OUT_MUTE);
399 snd_hda_codec_write(codec, nid, 0,
400 AC_VERB_SET_AMP_GAIN_MUTE,
401 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100402 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403 snd_hda_codec_write(codec, nid, 0,
404 AC_VERB_SET_AMP_GAIN_MUTE,
405 AMP_IN_MUTE(0));
406 snd_hda_codec_write(codec, nid, 0,
407 AC_VERB_SET_AMP_GAIN_MUTE,
408 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100409 }
410 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200411 return change;
412}
413
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100414#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200415 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 .info = alc_pin_mode_info, \
417 .get = alc_pin_mode_get, \
418 .put = alc_pin_mode_put, \
419 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100420
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100421/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
422 * together using a mask with more than one bit set. This control is
423 * currently used only by the ALC260 test model. At this stage they are not
424 * needed for any "production" models.
425 */
426#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100429{
430 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
431 uinfo->count = 1;
432 uinfo->value.integer.min = 0;
433 uinfo->value.integer.max = 1;
434 return 0;
435}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200436static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
437 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100438{
439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
440 hda_nid_t nid = kcontrol->private_value & 0xffff;
441 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
442 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443 unsigned int val = snd_hda_codec_read(codec, nid, 0,
444 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100445
446 *valp = (val & mask) != 0;
447 return 0;
448}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100451{
452 signed int change;
453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
454 hda_nid_t nid = kcontrol->private_value & 0xffff;
455 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
456 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
458 AC_VERB_GET_GPIO_DATA,
459 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100460
461 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
463 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100464 gpio_data &= ~mask;
465 else
466 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100468
469 return change;
470}
471#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
472 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
473 .info = alc_gpio_data_info, \
474 .get = alc_gpio_data_get, \
475 .put = alc_gpio_data_put, \
476 .private_value = nid | (mask<<16) }
477#endif /* CONFIG_SND_DEBUG */
478
Jonathan Woithe92621f12006-02-28 11:47:47 +0100479/* A switch control to allow the enabling of the digital IO pins on the
480 * ALC260. This is incredibly simplistic; the intention of this control is
481 * to provide something in the test model allowing digital outputs to be
482 * identified if present. If models are found which can utilise these
483 * outputs a more complete mixer control can be devised for those models if
484 * necessary.
485 */
486#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100489{
490 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
491 uinfo->count = 1;
492 uinfo->value.integer.min = 0;
493 uinfo->value.integer.max = 1;
494 return 0;
495}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200496static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100498{
499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
500 hda_nid_t nid = kcontrol->private_value & 0xffff;
501 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
502 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200503 unsigned int val = snd_hda_codec_read(codec, nid, 0,
504 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100505
506 *valp = (val & mask) != 0;
507 return 0;
508}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200509static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100511{
512 signed int change;
513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
514 hda_nid_t nid = kcontrol->private_value & 0xffff;
515 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
516 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
518 AC_VERB_GET_DIGI_CONVERT,
519 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100520
521 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100523 if (val==0)
524 ctrl_data &= ~mask;
525 else
526 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
528 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100529
530 return change;
531}
532#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
533 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
534 .info = alc_spdif_ctrl_info, \
535 .get = alc_spdif_ctrl_get, \
536 .put = alc_spdif_ctrl_put, \
537 .private_value = nid | (mask<<16) }
538#endif /* CONFIG_SND_DEBUG */
539
Kailang Yangdf694da2005-12-05 19:42:22 +0100540/*
541 * set up from the preset table
542 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static void setup_preset(struct alc_spec *spec,
544 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100545{
546 int i;
547
548 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
549 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
551 i++)
552 spec->init_verbs[spec->num_init_verbs++] =
553 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100554
555 spec->channel_mode = preset->channel_mode;
556 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200557 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100558
559 spec->multiout.max_channels = spec->channel_mode[0].channels;
560
561 spec->multiout.num_dacs = preset->num_dacs;
562 spec->multiout.dac_nids = preset->dac_nids;
563 spec->multiout.dig_out_nid = preset->dig_out_nid;
564 spec->multiout.hp_nid = preset->hp_nid;
565
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200566 spec->num_mux_defs = preset->num_mux_defs;
567 if (! spec->num_mux_defs)
568 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100569 spec->input_mux = preset->input_mux;
570
571 spec->num_adc_nids = preset->num_adc_nids;
572 spec->adc_nids = preset->adc_nids;
573 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100574
575 spec->unsol_event = preset->unsol_event;
576 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100577}
578
Takashi Iwai41e41f12005-06-08 14:48:49 +0200579/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200580 * ALC880 3-stack model
581 *
582 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
584 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 */
586
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200587static hda_nid_t alc880_dac_nids[4] = {
588 /* front, rear, clfe, rear_surr */
589 0x02, 0x05, 0x04, 0x03
590};
591
592static hda_nid_t alc880_adc_nids[3] = {
593 /* ADC0-2 */
594 0x07, 0x08, 0x09,
595};
596
597/* The datasheet says the node 0x07 is connected from inputs,
598 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100599 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200601static hda_nid_t alc880_adc_nids_alt[2] = {
602 /* ADC1-2 */
603 0x08, 0x09,
604};
605
606#define ALC880_DIGOUT_NID 0x06
607#define ALC880_DIGIN_NID 0x0a
608
609static struct hda_input_mux alc880_capture_source = {
610 .num_items = 4,
611 .items = {
612 { "Mic", 0x0 },
613 { "Front Mic", 0x3 },
614 { "Line", 0x2 },
615 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200617};
618
619/* channel source setting (2/6 channel selection for 3-stack) */
620/* 2ch mode */
621static struct hda_verb alc880_threestack_ch2_init[] = {
622 /* set line-in to input, mute it */
623 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
624 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
625 /* set mic-in to input vref 80%, mute it */
626 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
627 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 { } /* end */
629};
630
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200631/* 6ch mode */
632static struct hda_verb alc880_threestack_ch6_init[] = {
633 /* set line-in to output, unmute it */
634 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
635 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
636 /* set mic-in to output, unmute it */
637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
639 { } /* end */
640};
641
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100642static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200643 { 2, alc880_threestack_ch2_init },
644 { 6, alc880_threestack_ch6_init },
645};
646
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100647static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100651 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100654 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
655 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
662 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
664 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
665 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200667 {
668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
669 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100670 .info = alc_ch_mode_info,
671 .get = alc_ch_mode_get,
672 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200673 },
674 { } /* end */
675};
676
677/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100678static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200679 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
680 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
681 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
682 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
683 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
684 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
685 {
686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
687 /* The multiple "Capture Source" controls confuse alsamixer
688 * So call somewhat different..
689 * FIXME: the controls appear in the "playback" view!
690 */
691 /* .name = "Capture Source", */
692 .name = "Input Source",
693 .count = 3,
694 .info = alc_mux_enum_info,
695 .get = alc_mux_enum_get,
696 .put = alc_mux_enum_put,
697 },
698 { } /* end */
699};
700
701/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100702static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200703 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
704 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
705 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
706 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 {
708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
709 /* The multiple "Capture Source" controls confuse alsamixer
710 * So call somewhat different..
711 * FIXME: the controls appear in the "playback" view!
712 */
713 /* .name = "Capture Source", */
714 .name = "Input Source",
715 .count = 2,
716 .info = alc_mux_enum_info,
717 .get = alc_mux_enum_get,
718 .put = alc_mux_enum_put,
719 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 { } /* end */
721};
722
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200723
724
725/*
726 * ALC880 5-stack model
727 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200728 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
729 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200730 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
731 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
732 */
733
734/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100735static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200736 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100737 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 { } /* end */
739};
740
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200741/* channel source setting (6/8 channel selection for 5-stack) */
742/* 6ch mode */
743static struct hda_verb alc880_fivestack_ch6_init[] = {
744 /* set line-in to input, mute it */
745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200747 { } /* end */
748};
749
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200750/* 8ch mode */
751static struct hda_verb alc880_fivestack_ch8_init[] = {
752 /* set line-in to output, unmute it */
753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
755 { } /* end */
756};
757
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100758static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200759 { 6, alc880_fivestack_ch6_init },
760 { 8, alc880_fivestack_ch8_init },
761};
762
763
764/*
765 * ALC880 6-stack model
766 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200767 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
768 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200769 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
770 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
771 */
772
773static hda_nid_t alc880_6st_dac_nids[4] = {
774 /* front, rear, clfe, rear_surr */
775 0x02, 0x03, 0x04, 0x05
776};
777
778static struct hda_input_mux alc880_6stack_capture_source = {
779 .num_items = 4,
780 .items = {
781 { "Mic", 0x0 },
782 { "Front Mic", 0x1 },
783 { "Line", 0x2 },
784 { "CD", 0x4 },
785 },
786};
787
788/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100789static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200790 { 8, NULL },
791};
792
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100793static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100795 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100797 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200802 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100803 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
812 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
813 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200814 {
815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
816 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100817 .info = alc_ch_mode_info,
818 .get = alc_ch_mode_get,
819 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200820 },
821 { } /* end */
822};
823
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200824
825/*
826 * ALC880 W810 model
827 *
828 * W810 has rear IO for:
829 * Front (DAC 02)
830 * Surround (DAC 03)
831 * Center/LFE (DAC 04)
832 * Digital out (06)
833 *
834 * The system also has a pair of internal speakers, and a headphone jack.
835 * These are both connected to Line2 on the codec, hence to DAC 02.
836 *
837 * There is a variable resistor to control the speaker or headphone
838 * volume. This is a hardware-only device without a software API.
839 *
840 * Plugging headphones in will disable the internal speakers. This is
841 * implemented in hardware, not via the driver using jack sense. In
842 * a similar fashion, plugging into the rear socket marked "front" will
843 * disable both the speakers and headphones.
844 *
845 * For input, there's a microphone jack, and an "audio in" jack.
846 * These may not do anything useful with this driver yet, because I
847 * haven't setup any initialization verbs for these yet...
848 */
849
850static hda_nid_t alc880_w810_dac_nids[3] = {
851 /* front, rear/surround, clfe */
852 0x02, 0x03, 0x04
853};
854
855/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100856static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200857 { 6, NULL }
858};
859
860/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100861static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100863 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200864 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100865 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200866 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
867 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100868 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
869 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200870 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
871 { } /* end */
872};
873
874
875/*
876 * Z710V model
877 *
878 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200879 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
880 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200881 */
882
883static hda_nid_t alc880_z71v_dac_nids[1] = {
884 0x02
885};
886#define ALC880_Z71V_HP_DAC 0x03
887
888/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100889static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200890 { 2, NULL }
891};
892
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100893static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100895 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100897 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
902 { } /* end */
903};
904
905
906/* FIXME! */
907/*
908 * ALC880 F1734 model
909 *
910 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
911 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
912 */
913
914static hda_nid_t alc880_f1734_dac_nids[1] = {
915 0x03
916};
917#define ALC880_F1734_HP_DAC 0x02
918
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100919static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200920 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100921 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200922 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100923 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200928 { } /* end */
929};
930
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200931
932/* FIXME! */
933/*
934 * ALC880 ASUS model
935 *
936 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
937 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
938 * Mic = 0x18, Line = 0x1a
939 */
940
941#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
942#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
943
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100944static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100946 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200947 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100948 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200949 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
950 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100951 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
952 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200953 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
954 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200959 {
960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
961 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100962 .info = alc_ch_mode_info,
963 .get = alc_ch_mode_get,
964 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200965 },
966 { } /* end */
967};
968
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200969/* FIXME! */
970/*
971 * ALC880 ASUS W1V model
972 *
973 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
974 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
975 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
976 */
977
978/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100979static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200980 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
981 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200982 { } /* end */
983};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200984
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200985/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100986static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200987 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
988 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
989 { } /* end */
990};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200991
Kailang Yangdf694da2005-12-05 19:42:22 +0100992/* TCL S700 */
993static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
994 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
995 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
997 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
998 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1001 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1003 {
1004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1005 /* The multiple "Capture Source" controls confuse alsamixer
1006 * So call somewhat different..
1007 * FIXME: the controls appear in the "playback" view!
1008 */
1009 /* .name = "Capture Source", */
1010 .name = "Input Source",
1011 .count = 1,
1012 .info = alc_mux_enum_info,
1013 .get = alc_mux_enum_get,
1014 .put = alc_mux_enum_put,
1015 },
1016 { } /* end */
1017};
1018
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001020 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 */
1022static int alc_build_controls(struct hda_codec *codec)
1023{
1024 struct alc_spec *spec = codec->spec;
1025 int err;
1026 int i;
1027
1028 for (i = 0; i < spec->num_mixers; i++) {
1029 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1030 if (err < 0)
1031 return err;
1032 }
1033
1034 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001035 err = snd_hda_create_spdif_out_ctls(codec,
1036 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 if (err < 0)
1038 return err;
1039 }
1040 if (spec->dig_in_nid) {
1041 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1042 if (err < 0)
1043 return err;
1044 }
1045 return 0;
1046}
1047
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001048
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049/*
1050 * initialize the codec volumes, etc
1051 */
1052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001053/*
1054 * generic initialization of ADC, input mixers and output mixers
1055 */
1056static struct hda_verb alc880_volume_init_verbs[] = {
1057 /*
1058 * Unmute ADC0-2 and set the default input to mic-in
1059 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001060 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001062 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001064 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001065 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1068 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001069 * Note: PASD motherboards uses the Line In 2 as the input for front
1070 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001079 /*
1080 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001082 /* set vol=0 to output mixers */
1083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1087 /* set up input amps for analog loopback */
1088 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097
1098 { }
1099};
1100
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001101/*
1102 * 3-stack pin configuration:
1103 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1104 */
1105static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1106 /*
1107 * preset connection lists of input pins
1108 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1109 */
1110 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1111 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1112 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1113
1114 /*
1115 * Set pin mode and muting
1116 */
1117 /* set front pin widgets 0x14 for output */
1118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1120 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1123 /* Mic2 (as headphone out) for HP output */
1124 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1125 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1126 /* Line In pin widget for input */
1127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1129 /* Line2 (as front mic) pin widget for input and vref at 80% */
1130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1131 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1132 /* CD pin widget for input */
1133 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1134
1135 { }
1136};
1137
1138/*
1139 * 5-stack pin configuration:
1140 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1141 * line-in/side = 0x1a, f-mic = 0x1b
1142 */
1143static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1144 /*
1145 * preset connection lists of input pins
1146 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1147 */
1148 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1149 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1150
1151 /*
1152 * Set pin mode and muting
1153 */
1154 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1157 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1158 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001159 /* unmute pins for output (no gain on this amp) */
1160 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1164
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001166 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001167 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1168 /* Mic2 (as headphone out) for HP output */
1169 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001170 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001171 /* Line In pin widget for input */
1172 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 /* Line2 (as front mic) pin widget for input and vref at 80% */
1175 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1176 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1177 /* CD pin widget for input */
1178 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179
1180 { }
1181};
1182
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001183/*
1184 * W810 pin configuration:
1185 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1186 */
1187static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 /* hphone/speaker input selector: front DAC */
1189 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1197
1198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 { }
1202};
1203
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001204/*
1205 * Z71V pin configuration:
1206 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1207 */
1208static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001213
Takashi Iwai16ded522005-06-10 19:58:24 +02001214 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001215 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001216 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001217 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001218
1219 { }
1220};
1221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001222/*
1223 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001224 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1225 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226 */
1227static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1228 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1229
Takashi Iwai16ded522005-06-10 19:58:24 +02001230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001231 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001233 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001234 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001235 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001236 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001237 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1238
Takashi Iwai16ded522005-06-10 19:58:24 +02001239 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001240 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001241 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001242 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001245 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001246 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1248
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249 { }
1250};
Takashi Iwai16ded522005-06-10 19:58:24 +02001251
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001252/* FIXME! */
1253/*
1254 * F1734 pin configuration:
1255 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1256 */
1257static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1258 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1259 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1260 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1261 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1262
1263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1267
1268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1276 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001277
1278 { }
1279};
1280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281/* FIXME! */
1282/*
1283 * ASUS pin configuration:
1284 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1285 */
1286static struct hda_verb alc880_pin_asus_init_verbs[] = {
1287 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1288 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1289 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1290 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1291
1292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1300
1301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1310
1311 { }
1312};
1313
1314/* Enable GPIO mask and set output */
1315static struct hda_verb alc880_gpio1_init_verbs[] = {
1316 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1317 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1318 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001319
1320 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001321};
1322
1323/* Enable GPIO mask and set output */
1324static struct hda_verb alc880_gpio2_init_verbs[] = {
1325 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1326 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1327 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001328
1329 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330};
1331
Kailang Yangdf694da2005-12-05 19:42:22 +01001332/* Clevo m520g init */
1333static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1334 /* headphone output */
1335 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1336 /* line-out */
1337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1339 /* Line-in */
1340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1342 /* CD */
1343 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1344 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Mic1 (rear panel) */
1346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 /* Mic2 (front panel) */
1349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 /* headphone */
1352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 /* change to EAPD mode */
1355 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1356 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1357
1358 { }
1359};
1360
1361static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001362 /* change to EAPD mode */
1363 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1364 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1365
Kailang Yangdf694da2005-12-05 19:42:22 +01001366 /* Headphone output */
1367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1368 /* Front output*/
1369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1371
1372 /* Line In pin widget for input */
1373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 /* CD pin widget for input */
1375 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1376 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1377 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1378
1379 /* change to EAPD mode */
1380 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1381 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1382
1383 { }
1384};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001385
1386/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001387 * LG m1 express dual
1388 *
1389 * Pin assignment:
1390 * Rear Line-In/Out (blue): 0x14
1391 * Build-in Mic-In: 0x15
1392 * Speaker-out: 0x17
1393 * HP-Out (green): 0x1b
1394 * Mic-In/Out (red): 0x19
1395 * SPDIF-Out: 0x1e
1396 */
1397
1398/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1399static hda_nid_t alc880_lg_dac_nids[3] = {
1400 0x05, 0x02, 0x03
1401};
1402
1403/* seems analog CD is not working */
1404static struct hda_input_mux alc880_lg_capture_source = {
1405 .num_items = 3,
1406 .items = {
1407 { "Mic", 0x1 },
1408 { "Line", 0x5 },
1409 { "Internal Mic", 0x6 },
1410 },
1411};
1412
1413/* 2,4,6 channel modes */
1414static struct hda_verb alc880_lg_ch2_init[] = {
1415 /* set line-in and mic-in to input */
1416 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1417 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1418 { }
1419};
1420
1421static struct hda_verb alc880_lg_ch4_init[] = {
1422 /* set line-in to out and mic-in to input */
1423 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1424 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1425 { }
1426};
1427
1428static struct hda_verb alc880_lg_ch6_init[] = {
1429 /* set line-in and mic-in to output */
1430 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1431 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1432 { }
1433};
1434
1435static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1436 { 2, alc880_lg_ch2_init },
1437 { 4, alc880_lg_ch4_init },
1438 { 6, alc880_lg_ch6_init },
1439};
1440
1441static struct snd_kcontrol_new alc880_lg_mixer[] = {
1442 /* FIXME: it's not really "master" but front channels */
1443 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1455 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1456 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1457 {
1458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1459 .name = "Channel Mode",
1460 .info = alc_ch_mode_info,
1461 .get = alc_ch_mode_get,
1462 .put = alc_ch_mode_put,
1463 },
1464 { } /* end */
1465};
1466
1467static struct hda_verb alc880_lg_init_verbs[] = {
1468 /* set capture source to mic-in */
1469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1472 /* mute all amp mixer inputs */
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1476 /* line-in to input */
1477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 /* built-in mic */
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 /* speaker-out */
1483 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 /* mic-in to input */
1486 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 /* HP-out */
1490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 /* jack sense */
1494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1495 { }
1496};
1497
1498/* toggle speaker-output according to the hp-jack state */
1499static void alc880_lg_automute(struct hda_codec *codec)
1500{
1501 unsigned int present;
1502
1503 present = snd_hda_codec_read(codec, 0x1b, 0,
1504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1505 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1506 0x80, present ? 0x80 : 0);
1507 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1508 0x80, present ? 0x80 : 0);
1509}
1510
1511static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1512{
1513 /* Looks like the unsol event is incompatible with the standard
1514 * definition. 4bit tag is placed at 28 bit!
1515 */
1516 if ((res >> 28) == 0x01)
1517 alc880_lg_automute(codec);
1518}
1519
1520/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001521 * LG LW20
1522 *
1523 * Pin assignment:
1524 * Speaker-out: 0x14
1525 * Mic-In: 0x18
1526 * Built-in Mic-In: 0x19 (?)
1527 * HP-Out: 0x1b
1528 * SPDIF-Out: 0x1e
1529 */
1530
1531/* seems analog CD is not working */
1532static struct hda_input_mux alc880_lg_lw_capture_source = {
1533 .num_items = 2,
1534 .items = {
1535 { "Mic", 0x0 },
1536 { "Internal Mic", 0x1 },
1537 },
1538};
1539
1540static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1541 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1542 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1545 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1546 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1547 { } /* end */
1548};
1549
1550static struct hda_verb alc880_lg_lw_init_verbs[] = {
1551 /* set capture source to mic-in */
1552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1556 /* speaker-out */
1557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1559 /* HP-out */
1560 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1562 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1563 /* mic-in to input */
1564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1566 /* built-in mic */
1567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1569 /* jack sense */
1570 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1571 { }
1572};
1573
1574/* toggle speaker-output according to the hp-jack state */
1575static void alc880_lg_lw_automute(struct hda_codec *codec)
1576{
1577 unsigned int present;
1578
1579 present = snd_hda_codec_read(codec, 0x1b, 0,
1580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1581 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1582 0x80, present ? 0x80 : 0);
1583 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1584 0x80, present ? 0x80 : 0);
1585}
1586
1587static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1588{
1589 /* Looks like the unsol event is incompatible with the standard
1590 * definition. 4bit tag is placed at 28 bit!
1591 */
1592 if ((res >> 28) == 0x01)
1593 alc880_lg_lw_automute(codec);
1594}
1595
1596/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001597 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001598 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001599
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600static int alc_init(struct hda_codec *codec)
1601{
1602 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001603 unsigned int i;
1604
1605 for (i = 0; i < spec->num_init_verbs; i++)
1606 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001607
1608 if (spec->init_hook)
1609 spec->init_hook(codec);
1610
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 return 0;
1612}
1613
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001614static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1615{
1616 struct alc_spec *spec = codec->spec;
1617
1618 if (spec->unsol_event)
1619 spec->unsol_event(codec, res);
1620}
1621
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622#ifdef CONFIG_PM
1623/*
1624 * resume
1625 */
1626static int alc_resume(struct hda_codec *codec)
1627{
1628 struct alc_spec *spec = codec->spec;
1629 int i;
1630
1631 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001632 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 if (spec->multiout.dig_out_nid)
1635 snd_hda_resume_spdif_out(codec);
1636 if (spec->dig_in_nid)
1637 snd_hda_resume_spdif_in(codec);
1638
1639 return 0;
1640}
1641#endif
1642
1643/*
1644 * Analog playback callbacks
1645 */
1646static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1647 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001648 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649{
1650 struct alc_spec *spec = codec->spec;
1651 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1652}
1653
1654static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1655 struct hda_codec *codec,
1656 unsigned int stream_tag,
1657 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001658 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659{
1660 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001661 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1662 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663}
1664
1665static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1666 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001667 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668{
1669 struct alc_spec *spec = codec->spec;
1670 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1671}
1672
1673/*
1674 * Digital out
1675 */
1676static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1677 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001678 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679{
1680 struct alc_spec *spec = codec->spec;
1681 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1682}
1683
1684static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1685 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001686 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687{
1688 struct alc_spec *spec = codec->spec;
1689 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1690}
1691
1692/*
1693 * Analog capture
1694 */
1695static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1696 struct hda_codec *codec,
1697 unsigned int stream_tag,
1698 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001699 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700{
1701 struct alc_spec *spec = codec->spec;
1702
1703 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1704 stream_tag, 0, format);
1705 return 0;
1706}
1707
1708static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1709 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001710 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711{
1712 struct alc_spec *spec = codec->spec;
1713
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001714 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1715 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 return 0;
1717}
1718
1719
1720/*
1721 */
1722static struct hda_pcm_stream alc880_pcm_analog_playback = {
1723 .substreams = 1,
1724 .channels_min = 2,
1725 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 .ops = {
1728 .open = alc880_playback_pcm_open,
1729 .prepare = alc880_playback_pcm_prepare,
1730 .cleanup = alc880_playback_pcm_cleanup
1731 },
1732};
1733
1734static struct hda_pcm_stream alc880_pcm_analog_capture = {
1735 .substreams = 2,
1736 .channels_min = 2,
1737 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001738 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 .ops = {
1740 .prepare = alc880_capture_pcm_prepare,
1741 .cleanup = alc880_capture_pcm_cleanup
1742 },
1743};
1744
1745static struct hda_pcm_stream alc880_pcm_digital_playback = {
1746 .substreams = 1,
1747 .channels_min = 2,
1748 .channels_max = 2,
1749 /* NID is set in alc_build_pcms */
1750 .ops = {
1751 .open = alc880_dig_playback_pcm_open,
1752 .close = alc880_dig_playback_pcm_close
1753 },
1754};
1755
1756static struct hda_pcm_stream alc880_pcm_digital_capture = {
1757 .substreams = 1,
1758 .channels_min = 2,
1759 .channels_max = 2,
1760 /* NID is set in alc_build_pcms */
1761};
1762
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001763/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1764static struct hda_pcm_stream alc_pcm_null_playback = {
1765 .substreams = 0,
1766 .channels_min = 0,
1767 .channels_max = 0,
1768};
1769
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770static int alc_build_pcms(struct hda_codec *codec)
1771{
1772 struct alc_spec *spec = codec->spec;
1773 struct hda_pcm *info = spec->pcm_rec;
1774 int i;
1775
1776 codec->num_pcms = 1;
1777 codec->pcm_info = info;
1778
1779 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001780 if (spec->stream_analog_playback) {
1781 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1782 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1783 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1784 }
1785 if (spec->stream_analog_capture) {
1786 snd_assert(spec->adc_nids, return -EINVAL);
1787 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1788 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1789 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001790
Takashi Iwai4a471b72005-12-07 13:56:29 +01001791 if (spec->channel_mode) {
1792 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1793 for (i = 0; i < spec->num_channel_mode; i++) {
1794 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1795 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1796 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797 }
1798 }
1799
Takashi Iwaie08a0072006-09-07 17:52:14 +02001800 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02001802 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02001803 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001805 if (spec->multiout.dig_out_nid &&
1806 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1808 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1809 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001810 if (spec->dig_in_nid &&
1811 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1813 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1814 }
1815 }
1816
Takashi Iwaie08a0072006-09-07 17:52:14 +02001817 /* If the use of more than one ADC is requested for the current
1818 * model, configure a second analog capture-only PCM.
1819 */
1820 /* Additional Analaog capture for index #2 */
1821 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
1822 spec->adc_nids) {
1823 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02001824 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02001825 info->name = spec->stream_name_analog;
1826 /* No playback stream for second PCM */
1827 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1828 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1829 if (spec->stream_analog_capture) {
1830 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1831 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1832 }
1833 }
1834
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 return 0;
1836}
1837
1838static void alc_free(struct hda_codec *codec)
1839{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 struct alc_spec *spec = codec->spec;
1841 unsigned int i;
1842
1843 if (! spec)
1844 return;
1845
1846 if (spec->kctl_alloc) {
1847 for (i = 0; i < spec->num_kctl_used; i++)
1848 kfree(spec->kctl_alloc[i].name);
1849 kfree(spec->kctl_alloc);
1850 }
1851 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852}
1853
1854/*
1855 */
1856static struct hda_codec_ops alc_patch_ops = {
1857 .build_controls = alc_build_controls,
1858 .build_pcms = alc_build_pcms,
1859 .init = alc_init,
1860 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001861 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862#ifdef CONFIG_PM
1863 .resume = alc_resume,
1864#endif
1865};
1866
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001867
1868/*
1869 * Test configuration for debugging
1870 *
1871 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1872 * enum controls.
1873 */
1874#ifdef CONFIG_SND_DEBUG
1875static hda_nid_t alc880_test_dac_nids[4] = {
1876 0x02, 0x03, 0x04, 0x05
1877};
1878
1879static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001880 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001881 .items = {
1882 { "In-1", 0x0 },
1883 { "In-2", 0x1 },
1884 { "In-3", 0x2 },
1885 { "In-4", 0x3 },
1886 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001887 { "Front", 0x5 },
1888 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001889 },
1890};
1891
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001892static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001893 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001894 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001895 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001896 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001897};
1898
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001899static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1900 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001901{
1902 static char *texts[] = {
1903 "N/A", "Line Out", "HP Out",
1904 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1905 };
1906 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1907 uinfo->count = 1;
1908 uinfo->value.enumerated.items = 8;
1909 if (uinfo->value.enumerated.item >= 8)
1910 uinfo->value.enumerated.item = 7;
1911 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1912 return 0;
1913}
1914
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001915static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1916 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001917{
1918 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1919 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1920 unsigned int pin_ctl, item = 0;
1921
1922 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1923 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1924 if (pin_ctl & AC_PINCTL_OUT_EN) {
1925 if (pin_ctl & AC_PINCTL_HP_EN)
1926 item = 2;
1927 else
1928 item = 1;
1929 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1930 switch (pin_ctl & AC_PINCTL_VREFEN) {
1931 case AC_PINCTL_VREF_HIZ: item = 3; break;
1932 case AC_PINCTL_VREF_50: item = 4; break;
1933 case AC_PINCTL_VREF_GRD: item = 5; break;
1934 case AC_PINCTL_VREF_80: item = 6; break;
1935 case AC_PINCTL_VREF_100: item = 7; break;
1936 }
1937 }
1938 ucontrol->value.enumerated.item[0] = item;
1939 return 0;
1940}
1941
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001942static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1943 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001944{
1945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1946 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1947 static unsigned int ctls[] = {
1948 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1949 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1950 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1951 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1952 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1953 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1954 };
1955 unsigned int old_ctl, new_ctl;
1956
1957 old_ctl = snd_hda_codec_read(codec, nid, 0,
1958 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1959 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1960 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001961 snd_hda_codec_write(codec, nid, 0,
1962 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001963 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001964 (ucontrol->value.enumerated.item[0] >= 3 ?
1965 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001966 return 1;
1967 }
1968 return 0;
1969}
1970
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001971static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1972 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001973{
1974 static char *texts[] = {
1975 "Front", "Surround", "CLFE", "Side"
1976 };
1977 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1978 uinfo->count = 1;
1979 uinfo->value.enumerated.items = 4;
1980 if (uinfo->value.enumerated.item >= 4)
1981 uinfo->value.enumerated.item = 3;
1982 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1983 return 0;
1984}
1985
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001986static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001988{
1989 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1990 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1991 unsigned int sel;
1992
1993 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1994 ucontrol->value.enumerated.item[0] = sel & 3;
1995 return 0;
1996}
1997
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001998static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1999 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002000{
2001 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2002 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2003 unsigned int sel;
2004
2005 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2006 if (ucontrol->value.enumerated.item[0] != sel) {
2007 sel = ucontrol->value.enumerated.item[0] & 3;
2008 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2009 return 1;
2010 }
2011 return 0;
2012}
2013
2014#define PIN_CTL_TEST(xname,nid) { \
2015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2016 .name = xname, \
2017 .info = alc_test_pin_ctl_info, \
2018 .get = alc_test_pin_ctl_get, \
2019 .put = alc_test_pin_ctl_put, \
2020 .private_value = nid \
2021 }
2022
2023#define PIN_SRC_TEST(xname,nid) { \
2024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2025 .name = xname, \
2026 .info = alc_test_pin_src_info, \
2027 .get = alc_test_pin_src_get, \
2028 .put = alc_test_pin_src_put, \
2029 .private_value = nid \
2030 }
2031
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002032static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2034 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2035 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2036 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002037 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2038 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2039 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2040 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002041 PIN_CTL_TEST("Front Pin Mode", 0x14),
2042 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2043 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2044 PIN_CTL_TEST("Side Pin Mode", 0x17),
2045 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2046 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2047 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2048 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2049 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2050 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2051 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2052 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2053 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2054 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2055 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2056 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2057 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2058 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2059 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2060 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2061 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2062 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002063 {
2064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2065 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002066 .info = alc_ch_mode_info,
2067 .get = alc_ch_mode_get,
2068 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002069 },
2070 { } /* end */
2071};
2072
2073static struct hda_verb alc880_test_init_verbs[] = {
2074 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002083 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2085 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002088 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2092 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002093 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002094 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2095 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2096 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002098 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002101 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2103 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002104 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2106 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2108 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002109 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002112 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002114 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002116 /* Analog input/passthru */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002122 { }
2123};
2124#endif
2125
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126/*
2127 */
2128
2129static struct hda_board_config alc880_cfg_tbl[] = {
2130 /* Back 3 jack, front 2 jack */
2131 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
Tobin Davis2aaeee82006-08-21 19:01:12 +02002153 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002154 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2159 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2160 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2161 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2162 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2163 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2164 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2165 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2166 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002167 /* TCL S700 */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002168 { .modelname = "tcl", .config = ALC880_TCL_S700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002169 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170
2171 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002172 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002173 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002174 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175
2176 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2177 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002178 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02002179 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Takashi Iwai5a053d02006-07-25 14:51:15 +02002180
2181 /* Clevo laptops */
2182 { .modelname = "clevo", .config = ALC880_CLEVO },
2183 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2184 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2185 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2186 .config = ALC880_CLEVO }, /* Clevo m665n */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187
2188 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002189 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2190 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2191 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192
2193 /* Back 5 jack, front 2 jack */
2194 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002195 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2196 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2197 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2198 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002199 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200
2201 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2202 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002203 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2205 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2206 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2207 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2208 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2209 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2210 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002211 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002212 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2213 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002214 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002215 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002216 /* note subvendor = 0 below */
2217 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218
2219 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002220 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002222 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002223 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002224
Takashi Iwaib6482d42005-06-27 15:32:43 +02002225 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002226 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002227 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002228 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002229 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002230
2231 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002232 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2233 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2234 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2235 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002236 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2237 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2238 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2239 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002240 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002241 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002242 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002243
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002249 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
Danny Tholenf5a5ffa2006-08-08 18:59:07 +02002251 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2253 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2254 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2255 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002256 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002258 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
Takashi Iwai84f34302006-03-21 19:12:53 +01002259 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002260 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002261 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002262
2263 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2264 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2265
2266 { .modelname = "F1734", .config = ALC880_F1734 },
2267 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002268 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002270 { .modelname = "lg", .config = ALC880_LG },
2271 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
Takashi Iwai886da862006-05-02 18:17:57 +02002272 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002273
Takashi Iwaid6815182006-03-23 16:06:23 +01002274 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2275 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
Takashi Iwaicd417d42006-09-06 16:03:11 +02002276 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
Takashi Iwaid6815182006-03-23 16:06:23 +01002277
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002278#ifdef CONFIG_SND_DEBUG
2279 { .modelname = "test", .config = ALC880_TEST },
2280#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002281 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002282
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 {}
2284};
2285
Takashi Iwai16ded522005-06-10 19:58:24 +02002286/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002287 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002289static struct alc_config_preset alc880_presets[] = {
2290 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 .mixers = { alc880_three_stack_mixer },
2292 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002293 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002294 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002295 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2296 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002297 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002298 .input_mux = &alc880_capture_source,
2299 },
2300 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 .mixers = { alc880_three_stack_mixer },
2302 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 .dac_nids = alc880_dac_nids,
2305 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002306 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2307 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002308 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002309 .input_mux = &alc880_capture_source,
2310 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002311 [ALC880_TCL_S700] = {
2312 .mixers = { alc880_tcl_s700_mixer },
2313 .init_verbs = { alc880_volume_init_verbs,
2314 alc880_pin_tcl_S700_init_verbs,
2315 alc880_gpio2_init_verbs },
2316 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2317 .dac_nids = alc880_dac_nids,
2318 .hp_nid = 0x03,
2319 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2320 .channel_mode = alc880_2_jack_modes,
2321 .input_mux = &alc880_capture_source,
2322 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002323 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2325 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002326 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2327 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002328 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2329 .channel_mode = alc880_fivestack_modes,
2330 .input_mux = &alc880_capture_source,
2331 },
2332 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002333 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2334 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002335 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2336 .dac_nids = alc880_dac_nids,
2337 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002338 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2339 .channel_mode = alc880_fivestack_modes,
2340 .input_mux = &alc880_capture_source,
2341 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002342 [ALC880_6ST] = {
2343 .mixers = { alc880_six_stack_mixer },
2344 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2345 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2346 .dac_nids = alc880_6st_dac_nids,
2347 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2348 .channel_mode = alc880_sixstack_modes,
2349 .input_mux = &alc880_6stack_capture_source,
2350 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002351 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 .mixers = { alc880_six_stack_mixer },
2353 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002354 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2355 .dac_nids = alc880_6st_dac_nids,
2356 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002357 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2358 .channel_mode = alc880_sixstack_modes,
2359 .input_mux = &alc880_6stack_capture_source,
2360 },
2361 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002362 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002363 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2364 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002365 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2366 .dac_nids = alc880_w810_dac_nids,
2367 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002368 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2369 .channel_mode = alc880_w810_modes,
2370 .input_mux = &alc880_capture_source,
2371 },
2372 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002373 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002374 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002375 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2376 .dac_nids = alc880_z71v_dac_nids,
2377 .dig_out_nid = ALC880_DIGOUT_NID,
2378 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002379 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2380 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002381 .input_mux = &alc880_capture_source,
2382 },
2383 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002384 .mixers = { alc880_f1734_mixer },
2385 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2386 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2387 .dac_nids = alc880_f1734_dac_nids,
2388 .hp_nid = 0x02,
2389 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2390 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002391 .input_mux = &alc880_capture_source,
2392 },
2393 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002394 .mixers = { alc880_asus_mixer },
2395 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2396 alc880_gpio1_init_verbs },
2397 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2398 .dac_nids = alc880_asus_dac_nids,
2399 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2400 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002401 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002402 .input_mux = &alc880_capture_source,
2403 },
2404 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 .mixers = { alc880_asus_mixer },
2406 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2407 alc880_gpio1_init_verbs },
2408 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2409 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002410 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002411 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2412 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002413 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002414 .input_mux = &alc880_capture_source,
2415 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002416 [ALC880_ASUS_DIG2] = {
2417 .mixers = { alc880_asus_mixer },
2418 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2419 alc880_gpio2_init_verbs }, /* use GPIO2 */
2420 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2421 .dac_nids = alc880_asus_dac_nids,
2422 .dig_out_nid = ALC880_DIGOUT_NID,
2423 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2424 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002425 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002426 .input_mux = &alc880_capture_source,
2427 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002428 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002429 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2430 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2431 alc880_gpio1_init_verbs },
2432 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2433 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002434 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002435 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2436 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002437 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002438 .input_mux = &alc880_capture_source,
2439 },
2440 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002441 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2443 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2444 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002446 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2447 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002448 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002449 .input_mux = &alc880_capture_source,
2450 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002451 [ALC880_CLEVO] = {
2452 .mixers = { alc880_three_stack_mixer },
2453 .init_verbs = { alc880_volume_init_verbs,
2454 alc880_pin_clevo_init_verbs },
2455 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2456 .dac_nids = alc880_dac_nids,
2457 .hp_nid = 0x03,
2458 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2459 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002460 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002461 .input_mux = &alc880_capture_source,
2462 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002463 [ALC880_LG] = {
2464 .mixers = { alc880_lg_mixer },
2465 .init_verbs = { alc880_volume_init_verbs,
2466 alc880_lg_init_verbs },
2467 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2468 .dac_nids = alc880_lg_dac_nids,
2469 .dig_out_nid = ALC880_DIGOUT_NID,
2470 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2471 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002472 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002473 .input_mux = &alc880_lg_capture_source,
2474 .unsol_event = alc880_lg_unsol_event,
2475 .init_hook = alc880_lg_automute,
2476 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002477 [ALC880_LG_LW] = {
2478 .mixers = { alc880_lg_lw_mixer },
2479 .init_verbs = { alc880_volume_init_verbs,
2480 alc880_lg_lw_init_verbs },
2481 .num_dacs = 1,
2482 .dac_nids = alc880_dac_nids,
2483 .dig_out_nid = ALC880_DIGOUT_NID,
2484 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2485 .channel_mode = alc880_2_jack_modes,
2486 .input_mux = &alc880_lg_lw_capture_source,
2487 .unsol_event = alc880_lg_lw_unsol_event,
2488 .init_hook = alc880_lg_lw_automute,
2489 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002490#ifdef CONFIG_SND_DEBUG
2491 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 .mixers = { alc880_test_mixer },
2493 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002494 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2495 .dac_nids = alc880_test_dac_nids,
2496 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002497 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2498 .channel_mode = alc880_test_modes,
2499 .input_mux = &alc880_test_capture_source,
2500 },
2501#endif
2502};
2503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504/*
2505 * Automatic parse of I/O pins from the BIOS configuration
2506 */
2507
2508#define NUM_CONTROL_ALLOC 32
2509#define NUM_VERB_ALLOC 32
2510
2511enum {
2512 ALC_CTL_WIDGET_VOL,
2513 ALC_CTL_WIDGET_MUTE,
2514 ALC_CTL_BIND_MUTE,
2515};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002516static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2518 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002519 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002520};
2521
2522/* add dynamic controls */
2523static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2524{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002525 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526
2527 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2528 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2529
2530 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2531 if (! knew)
2532 return -ENOMEM;
2533 if (spec->kctl_alloc) {
2534 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2535 kfree(spec->kctl_alloc);
2536 }
2537 spec->kctl_alloc = knew;
2538 spec->num_kctl_alloc = num;
2539 }
2540
2541 knew = &spec->kctl_alloc[spec->num_kctl_used];
2542 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002543 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 if (! knew->name)
2545 return -ENOMEM;
2546 knew->private_value = val;
2547 spec->num_kctl_used++;
2548 return 0;
2549}
2550
2551#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2552#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2553#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2554#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2555#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2556#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2557#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2558#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2559#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2560#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2561#define ALC880_PIN_CD_NID 0x1c
2562
2563/* fill in the dac_nids table from the parsed pin configuration */
2564static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2565{
2566 hda_nid_t nid;
2567 int assigned[4];
2568 int i, j;
2569
2570 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002571 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002572
2573 /* check the pins hardwired to audio widget */
2574 for (i = 0; i < cfg->line_outs; i++) {
2575 nid = cfg->line_out_pins[i];
2576 if (alc880_is_fixed_pin(nid)) {
2577 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002578 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002579 assigned[idx] = 1;
2580 }
2581 }
2582 /* left pins can be connect to any audio widget */
2583 for (i = 0; i < cfg->line_outs; i++) {
2584 nid = cfg->line_out_pins[i];
2585 if (alc880_is_fixed_pin(nid))
2586 continue;
2587 /* search for an empty channel */
2588 for (j = 0; j < cfg->line_outs; j++) {
2589 if (! assigned[j]) {
2590 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2591 assigned[j] = 1;
2592 break;
2593 }
2594 }
2595 }
2596 spec->multiout.num_dacs = cfg->line_outs;
2597 return 0;
2598}
2599
2600/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002601static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2602 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002603{
2604 char name[32];
2605 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2606 hda_nid_t nid;
2607 int i, err;
2608
2609 for (i = 0; i < cfg->line_outs; i++) {
2610 if (! spec->multiout.dac_nids[i])
2611 continue;
2612 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2613 if (i == 2) {
2614 /* Center/LFE */
2615 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2616 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2617 return err;
2618 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2619 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2620 return err;
2621 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2622 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2623 return err;
2624 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2625 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2626 return err;
2627 } else {
2628 sprintf(name, "%s Playback Volume", chname[i]);
2629 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2630 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2631 return err;
2632 sprintf(name, "%s Playback Switch", chname[i]);
2633 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2634 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2635 return err;
2636 }
2637 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 return 0;
2639}
2640
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002641/* add playback controls for speaker and HP outputs */
2642static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2643 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644{
2645 hda_nid_t nid;
2646 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002647 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648
2649 if (! pin)
2650 return 0;
2651
2652 if (alc880_is_fixed_pin(pin)) {
2653 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002654 /* specify the DAC as the extra output */
2655 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002657 else
2658 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 /* control HP volume/switch on the output mixer amp */
2660 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002661 sprintf(name, "%s Playback Volume", pfx);
2662 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2664 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002665 sprintf(name, "%s Playback Switch", pfx);
2666 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2668 return err;
2669 } else if (alc880_is_multi_pin(pin)) {
2670 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002672 sprintf(name, "%s Playback Switch", pfx);
2673 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2675 return err;
2676 }
2677 return 0;
2678}
2679
2680/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002681static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2682 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683{
2684 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002685 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686
2687 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002688 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 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 sprintf(name, "%s Playback Switch", ctlname);
2692 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002693 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694 return err;
2695 return 0;
2696}
2697
2698/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002699static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2700 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002703 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704
2705 for (i = 0; i < AUTO_PIN_LAST; i++) {
2706 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002707 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002708 err = new_analog_input(spec, cfg->input_pins[i],
2709 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002710 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 if (err < 0)
2712 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002713 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2715 imux->num_items++;
2716 }
2717 }
2718 return 0;
2719}
2720
Kailang Yangdf694da2005-12-05 19:42:22 +01002721static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2722 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 int dac_idx)
2724{
2725 /* set as output */
2726 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2727 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2728 /* need the manual connection? */
2729 if (alc880_is_multi_pin(nid)) {
2730 struct alc_spec *spec = codec->spec;
2731 int idx = alc880_multi_pin_idx(nid);
2732 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2733 AC_VERB_SET_CONNECT_SEL,
2734 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2735 }
2736}
2737
2738static void alc880_auto_init_multi_out(struct hda_codec *codec)
2739{
2740 struct alc_spec *spec = codec->spec;
2741 int i;
2742
2743 for (i = 0; i < spec->autocfg.line_outs; i++) {
2744 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2745 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2746 }
2747}
2748
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002749static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750{
2751 struct alc_spec *spec = codec->spec;
2752 hda_nid_t pin;
2753
Takashi Iwai82bc9552006-03-21 11:24:42 +01002754 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002755 if (pin) /* connect to front */
2756 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002757 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002758 if (pin) /* connect to front */
2759 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2760}
2761
2762static void alc880_auto_init_analog_input(struct hda_codec *codec)
2763{
2764 struct alc_spec *spec = codec->spec;
2765 int i;
2766
2767 for (i = 0; i < AUTO_PIN_LAST; i++) {
2768 hda_nid_t nid = spec->autocfg.input_pins[i];
2769 if (alc880_is_input_pin(nid)) {
2770 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2771 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2772 if (nid != ALC880_PIN_CD_NID)
2773 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2774 AMP_OUT_MUTE);
2775 }
2776 }
2777}
2778
2779/* parse the BIOS configuration and set up the alc_spec */
2780/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2781static int alc880_parse_auto_config(struct hda_codec *codec)
2782{
2783 struct alc_spec *spec = codec->spec;
2784 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002785 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786
Kailang Yangdf694da2005-12-05 19:42:22 +01002787 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2788 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002790 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002792
2793 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2794 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002795 (err = alc880_auto_create_extra_out(spec,
2796 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002797 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002798 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002799 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2801 return err;
2802
2803 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2804
2805 if (spec->autocfg.dig_out_pin)
2806 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2807 if (spec->autocfg.dig_in_pin)
2808 spec->dig_in_nid = ALC880_DIGIN_NID;
2809
2810 if (spec->kctl_alloc)
2811 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2812
2813 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2814
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002815 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816 spec->input_mux = &spec->private_imux;
2817
2818 return 1;
2819}
2820
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002821/* additional initialization for auto-configuration model */
2822static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002823{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002825 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002826 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002827}
2828
2829/*
2830 * OK, here we have finally the patch for ALC880
2831 */
2832
Linus Torvalds1da177e2005-04-16 15:20:36 -07002833static int patch_alc880(struct hda_codec *codec)
2834{
2835 struct alc_spec *spec;
2836 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002837 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002839 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 if (spec == NULL)
2841 return -ENOMEM;
2842
2843 codec->spec = spec;
2844
2845 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002846 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002847 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2848 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 }
2851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852 if (board_config == ALC880_AUTO) {
2853 /* automatic parse from the BIOS config */
2854 err = alc880_parse_auto_config(codec);
2855 if (err < 0) {
2856 alc_free(codec);
2857 return err;
2858 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002859 printk(KERN_INFO
2860 "hda_codec: Cannot set up configuration "
2861 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002862 board_config = ALC880_3ST;
2863 }
2864 }
2865
Kailang Yangdf694da2005-12-05 19:42:22 +01002866 if (board_config != ALC880_AUTO)
2867 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002868
2869 spec->stream_name_analog = "ALC880 Analog";
2870 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2871 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2872
2873 spec->stream_name_digital = "ALC880 Digital";
2874 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2875 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2876
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877 if (! spec->adc_nids && spec->input_mux) {
2878 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002879 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002880 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2881 if (wcap != AC_WID_AUD_IN) {
2882 spec->adc_nids = alc880_adc_nids_alt;
2883 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2884 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2885 spec->num_mixers++;
2886 } else {
2887 spec->adc_nids = alc880_adc_nids;
2888 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2889 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2890 spec->num_mixers++;
2891 }
2892 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893
2894 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002896 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002897
2898 return 0;
2899}
2900
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902/*
2903 * ALC260 support
2904 */
2905
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002906static hda_nid_t alc260_dac_nids[1] = {
2907 /* front */
2908 0x02,
2909};
2910
2911static hda_nid_t alc260_adc_nids[1] = {
2912 /* ADC0 */
2913 0x04,
2914};
2915
Kailang Yangdf694da2005-12-05 19:42:22 +01002916static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002917 /* ADC1 */
2918 0x05,
2919};
2920
Kailang Yangdf694da2005-12-05 19:42:22 +01002921static hda_nid_t alc260_hp_adc_nids[2] = {
2922 /* ADC1, 0 */
2923 0x05, 0x04
2924};
2925
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002926/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2927 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2928 */
2929static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002930 /* ADC0, ADC1 */
2931 0x04, 0x05
2932};
2933
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934#define ALC260_DIGOUT_NID 0x03
2935#define ALC260_DIGIN_NID 0x06
2936
2937static struct hda_input_mux alc260_capture_source = {
2938 .num_items = 4,
2939 .items = {
2940 { "Mic", 0x0 },
2941 { "Front Mic", 0x1 },
2942 { "Line", 0x2 },
2943 { "CD", 0x4 },
2944 },
2945};
2946
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002947/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002948 * headphone jack and the internal CD lines since these are the only pins at
2949 * which audio can appear. For flexibility, also allow the option of
2950 * recording the mixer output on the second ADC (ADC0 doesn't have a
2951 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002952 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002953static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2954 {
2955 .num_items = 3,
2956 .items = {
2957 { "Mic/Line", 0x0 },
2958 { "CD", 0x4 },
2959 { "Headphone", 0x2 },
2960 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002961 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002962 {
2963 .num_items = 4,
2964 .items = {
2965 { "Mic/Line", 0x0 },
2966 { "CD", 0x4 },
2967 { "Headphone", 0x2 },
2968 { "Mixer", 0x5 },
2969 },
2970 },
2971
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002972};
2973
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002974/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2975 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002976 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002977static struct hda_input_mux alc260_acer_capture_sources[2] = {
2978 {
2979 .num_items = 4,
2980 .items = {
2981 { "Mic", 0x0 },
2982 { "Line", 0x2 },
2983 { "CD", 0x4 },
2984 { "Headphone", 0x5 },
2985 },
2986 },
2987 {
2988 .num_items = 5,
2989 .items = {
2990 { "Mic", 0x0 },
2991 { "Line", 0x2 },
2992 { "CD", 0x4 },
2993 { "Headphone", 0x6 },
2994 { "Mixer", 0x5 },
2995 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002996 },
2997};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002998/*
2999 * This is just place-holder, so there's something for alc_build_pcms to look
3000 * at when it calculates the maximum number of channels. ALC260 has no mixer
3001 * element which allows changing the channel mode, so the verb list is
3002 * never used.
3003 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003004static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003005 { 2, NULL },
3006};
3007
Kailang Yangdf694da2005-12-05 19:42:22 +01003008
3009/* Mixer combinations
3010 *
3011 * basic: base_output + input + pc_beep + capture
3012 * HP: base_output + input + capture_alt
3013 * HP_3013: hp_3013 + input + capture
3014 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003015 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003016 */
3017
3018static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003019 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003020 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003021 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3022 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3023 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3024 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3025 { } /* end */
3026};
3027
3028static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3030 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3031 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3032 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3034 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3036 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003037 { } /* end */
3038};
3039
Kailang Yangdf694da2005-12-05 19:42:22 +01003040static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3041 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3042 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3043 { } /* end */
3044};
3045
3046static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3047 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3048 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3049 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3050 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3051 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3053 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3054 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003055 { } /* end */
3056};
3057
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003058/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3059 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3060 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003061static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003063 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003064 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003065 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3066 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3067 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3068 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003069 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003070 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3071 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3072 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003073 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003074 { } /* end */
3075};
3076
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003077/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3078 * versions of the ALC260 don't act on requests to enable mic bias from NID
3079 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3080 * datasheet doesn't mention this restriction. At this stage it's not clear
3081 * whether this behaviour is intentional or is a hardware bug in chip
3082 * revisions available in early 2006. Therefore for now allow the
3083 * "Headphone Jack Mode" control to span all choices, but if it turns out
3084 * that the lack of mic bias for this NID is intentional we could change the
3085 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3086 *
3087 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3088 * don't appear to make the mic bias available from the "line" jack, even
3089 * though the NID used for this jack (0x14) can supply it. The theory is
3090 * that perhaps Acer have included blocking capacitors between the ALC260
3091 * and the output jack. If this turns out to be the case for all such
3092 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3093 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3094 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003095static struct snd_kcontrol_new alc260_acer_mixer[] = {
3096 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3097 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003098 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003099 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3100 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3102 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3103 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3104 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3105 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3106 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3107 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3108 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3109 { } /* end */
3110};
3111
Kailang Yangdf694da2005-12-05 19:42:22 +01003112/* capture mixer elements */
3113static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003114 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3115 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003116 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3117 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003118 {
3119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003120 /* The multiple "Capture Source" controls confuse alsamixer
3121 * So call somewhat different..
3122 * FIXME: the controls appear in the "playback" view!
3123 */
3124 /* .name = "Capture Source", */
3125 .name = "Input Source",
3126 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003127 .info = alc_mux_enum_info,
3128 .get = alc_mux_enum_get,
3129 .put = alc_mux_enum_put,
3130 },
3131 { } /* end */
3132};
3133
Kailang Yangdf694da2005-12-05 19:42:22 +01003134static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3135 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3136 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3137 {
3138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3139 /* The multiple "Capture Source" controls confuse alsamixer
3140 * So call somewhat different..
3141 * FIXME: the controls appear in the "playback" view!
3142 */
3143 /* .name = "Capture Source", */
3144 .name = "Input Source",
3145 .count = 1,
3146 .info = alc_mux_enum_info,
3147 .get = alc_mux_enum_get,
3148 .put = alc_mux_enum_put,
3149 },
3150 { } /* end */
3151};
3152
3153/*
3154 * initialization verbs
3155 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003156static struct hda_verb alc260_init_verbs[] = {
3157 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003159 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003160 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003161 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003162 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003164 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003165 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003168 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003169 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003170 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003172 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003174 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3175 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003176 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177 /* set connection select to line in (default select for this ADC) */
3178 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003179 /* mute capture amp left and right */
3180 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3181 /* set connection select to line in (default select for this ADC) */
3182 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003183 /* set vol=0 Line-Out mixer amp left and right */
3184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3185 /* unmute pin widget amp left and right (no gain on this amp) */
3186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* set vol=0 HP mixer amp left and right */
3188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3189 /* unmute pin widget amp left and right (no gain on this amp) */
3190 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 /* set vol=0 Mono mixer amp left and right */
3192 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3193 /* unmute pin widget amp left and right (no gain on this amp) */
3194 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 /* unmute LINE-2 out pin */
3196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003198 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003200 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003202 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003205 /* mute Front out path */
3206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3208 /* mute Headphone out path */
3209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3211 /* mute Mono out path */
3212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 { }
3215};
3216
Takashi Iwai474167d2006-05-17 17:17:43 +02003217#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003218static struct hda_verb alc260_hp_init_verbs[] = {
3219 /* Headphone and output */
3220 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3221 /* mono output */
3222 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3223 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3224 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3225 /* Mic2 (front panel) pin widget for input and vref at 80% */
3226 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3227 /* Line In pin widget for input */
3228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3229 /* Line-2 pin widget for output */
3230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3231 /* CD pin widget for input */
3232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3233 /* unmute amp left and right */
3234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3235 /* set connection select to line in (default select for this ADC) */
3236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3237 /* unmute Line-Out mixer amp left and right (volume = 0) */
3238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3239 /* mute pin widget amp left and right (no gain on this amp) */
3240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3241 /* unmute HP mixer amp left and right (volume = 0) */
3242 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3243 /* mute pin widget amp left and right (no gain on this amp) */
3244 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3245 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3246 /* unmute CD */
3247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3248 /* unmute Line In */
3249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3250 /* unmute Mic */
3251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3252 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3253 /* Unmute Front out path */
3254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3256 /* Unmute Headphone out path */
3257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3259 /* Unmute Mono out path */
3260 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3261 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3262 { }
3263};
Takashi Iwai474167d2006-05-17 17:17:43 +02003264#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003265
3266static struct hda_verb alc260_hp_3013_init_verbs[] = {
3267 /* Line out and output */
3268 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3269 /* mono output */
3270 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3271 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3272 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3273 /* Mic2 (front panel) pin widget for input and vref at 80% */
3274 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3275 /* Line In pin widget for input */
3276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3277 /* Headphone pin widget for output */
3278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3279 /* CD pin widget for input */
3280 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3281 /* unmute amp left and right */
3282 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3283 /* set connection select to line in (default select for this ADC) */
3284 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3285 /* unmute Line-Out mixer amp left and right (volume = 0) */
3286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3287 /* mute pin widget amp left and right (no gain on this amp) */
3288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3289 /* unmute HP mixer amp left and right (volume = 0) */
3290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3291 /* mute pin widget amp left and right (no gain on this amp) */
3292 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3293 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3294 /* unmute CD */
3295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3296 /* unmute Line In */
3297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3298 /* unmute Mic */
3299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3300 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3301 /* Unmute Front out path */
3302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3304 /* Unmute Headphone out path */
3305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3307 /* Unmute Mono out path */
3308 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3309 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3310 { }
3311};
3312
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003313/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003314 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3315 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003316 */
3317static struct hda_verb alc260_fujitsu_init_verbs[] = {
3318 /* Disable all GPIOs */
3319 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3320 /* Internal speaker is connected to headphone pin */
3321 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3322 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003324 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3325 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3326 /* Ensure all other unused pins are disabled and muted. */
3327 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003329 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003330 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003331 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003332 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003335
Jonathan Woithef7ace402006-02-28 11:46:14 +01003336 /* Disable digital (SPDIF) pins */
3337 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3338 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003339
Jonathan Woithef7ace402006-02-28 11:46:14 +01003340 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3341 * when acting as an output.
3342 */
3343 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3344
3345 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3349 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3352 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3353 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3354 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003355
Jonathan Woithef7ace402006-02-28 11:46:14 +01003356 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3357 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3358 /* Unmute Line1 pin widget output buffer since it starts as an output.
3359 * If the pin mode is changed by the user the pin mode control will
3360 * take care of enabling the pin's input/output buffers as needed.
3361 * Therefore there's no need to enable the input buffer at this
3362 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003363 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003365 /* Unmute input buffer of pin widget used for Line-in (no equiv
3366 * mixer ctrl)
3367 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003368 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003369
Jonathan Woithef7ace402006-02-28 11:46:14 +01003370 /* Mute capture amp left and right */
3371 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3372 /* Set ADC connection select to match default mixer setting - line
3373 * in (on mic1 pin)
3374 */
3375 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003376
Jonathan Woithef7ace402006-02-28 11:46:14 +01003377 /* Do the same for the second ADC: mute capture input amp and
3378 * set ADC connection to line in (on mic1 pin)
3379 */
3380 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3381 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003382
Jonathan Woithef7ace402006-02-28 11:46:14 +01003383 /* Mute all inputs to mixer widget (even unconnected ones) */
3384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003392
3393 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003394};
3395
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003396/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3397 * similar laptops (adapted from Fujitsu init verbs).
3398 */
3399static struct hda_verb alc260_acer_init_verbs[] = {
3400 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3401 * the headphone jack. Turn this on and rely on the standard mute
3402 * methods whenever the user wants to turn these outputs off.
3403 */
3404 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3405 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3406 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3407 /* Internal speaker/Headphone jack is connected to Line-out pin */
3408 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3409 /* Internal microphone/Mic jack is connected to Mic1 pin */
3410 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3411 /* Line In jack is connected to Line1 pin */
3412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3413 /* Ensure all other unused pins are disabled and muted. */
3414 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3415 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3416 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3417 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3418 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3419 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3422 /* Disable digital (SPDIF) pins */
3423 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3424 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3425
3426 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3427 * bus when acting as outputs.
3428 */
3429 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3430 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3431
3432 /* Start with output sum widgets muted and their output gains at min */
3433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3436 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3439 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3440 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3441 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3442
3443 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3444 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3446 * inputs. If the pin mode is changed by the user the pin mode control
3447 * will take care of enabling the pin's input/output buffers as needed.
3448 * Therefore there's no need to enable the input buffer at this
3449 * stage.
3450 */
3451 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3452 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3453
3454 /* Mute capture amp left and right */
3455 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3456 /* Set ADC connection select to match default mixer setting - mic
3457 * (on mic1 pin)
3458 */
3459 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3460
3461 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003462 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003463 */
3464 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003465 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003466
3467 /* Mute all inputs to mixer widget (even unconnected ones) */
3468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3476
3477 { }
3478};
3479
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003480/* Test configuration for debugging, modelled after the ALC880 test
3481 * configuration.
3482 */
3483#ifdef CONFIG_SND_DEBUG
3484static hda_nid_t alc260_test_dac_nids[1] = {
3485 0x02,
3486};
3487static hda_nid_t alc260_test_adc_nids[2] = {
3488 0x04, 0x05,
3489};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003490/* For testing the ALC260, each input MUX needs its own definition since
3491 * the signal assignments are different. This assumes that the first ADC
3492 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003493 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003494static struct hda_input_mux alc260_test_capture_sources[2] = {
3495 {
3496 .num_items = 7,
3497 .items = {
3498 { "MIC1 pin", 0x0 },
3499 { "MIC2 pin", 0x1 },
3500 { "LINE1 pin", 0x2 },
3501 { "LINE2 pin", 0x3 },
3502 { "CD pin", 0x4 },
3503 { "LINE-OUT pin", 0x5 },
3504 { "HP-OUT pin", 0x6 },
3505 },
3506 },
3507 {
3508 .num_items = 8,
3509 .items = {
3510 { "MIC1 pin", 0x0 },
3511 { "MIC2 pin", 0x1 },
3512 { "LINE1 pin", 0x2 },
3513 { "LINE2 pin", 0x3 },
3514 { "CD pin", 0x4 },
3515 { "Mixer", 0x5 },
3516 { "LINE-OUT pin", 0x6 },
3517 { "HP-OUT pin", 0x7 },
3518 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003519 },
3520};
3521static struct snd_kcontrol_new alc260_test_mixer[] = {
3522 /* Output driver widgets */
3523 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3525 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3526 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3527 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3528 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3529
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003530 /* Modes for retasking pin widgets
3531 * Note: the ALC260 doesn't seem to act on requests to enable mic
3532 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3533 * mention this restriction. At this stage it's not clear whether
3534 * this behaviour is intentional or is a hardware bug in chip
3535 * revisions available at least up until early 2006. Therefore for
3536 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3537 * choices, but if it turns out that the lack of mic bias for these
3538 * NIDs is intentional we could change their modes from
3539 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3540 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003541 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3542 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3543 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3544 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3545 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3546 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3547
3548 /* Loopback mixer controls */
3549 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3550 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3551 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3552 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3553 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3554 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3555 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3556 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3557 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3558 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3559 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3560 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3561 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3562 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3563 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3564 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003565
3566 /* Controls for GPIO pins, assuming they are configured as outputs */
3567 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3568 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3569 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3570 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3571
Jonathan Woithe92621f12006-02-28 11:47:47 +01003572 /* Switches to allow the digital IO pins to be enabled. The datasheet
3573 * is ambigious as to which NID is which; testing on laptops which
3574 * make this output available should provide clarification.
3575 */
3576 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3577 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3578
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003579 { } /* end */
3580};
3581static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003582 /* Enable all GPIOs as outputs with an initial value of 0 */
3583 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3584 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3585 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3586
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003587 /* Enable retasking pins as output, initially without power amp */
3588 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3589 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3590 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3592 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3594
Jonathan Woithe92621f12006-02-28 11:47:47 +01003595 /* Disable digital (SPDIF) pins initially, but users can enable
3596 * them via a mixer switch. In the case of SPDIF-out, this initverb
3597 * payload also sets the generation to 0, output to be in "consumer"
3598 * PCM format, copyright asserted, no pre-emphasis and no validity
3599 * control.
3600 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003601 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3602 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3603
Jonathan Woithef7ace402006-02-28 11:46:14 +01003604 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003605 * OUT1 sum bus when acting as an output.
3606 */
3607 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3608 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3609 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3610 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3611
3612 /* Start with output sum widgets muted and their output gains at min */
3613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3620 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3621 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3622
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003623 /* Unmute retasking pin widget output buffers since the default
3624 * state appears to be output. As the pin mode is changed by the
3625 * user the pin mode control will take care of enabling the pin's
3626 * input/output buffers as needed.
3627 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003628 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3631 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3632 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3633 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3634 /* Also unmute the mono-out pin widget */
3635 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3636
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003637 /* Mute capture amp left and right */
3638 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003639 /* Set ADC connection select to match default mixer setting (mic1
3640 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003641 */
3642 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3643
3644 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003645 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003646 */
3647 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3648 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3649
3650 /* Mute all inputs to mixer widget (even unconnected ones) */
3651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3659
3660 { }
3661};
3662#endif
3663
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664static struct hda_pcm_stream alc260_pcm_analog_playback = {
3665 .substreams = 1,
3666 .channels_min = 2,
3667 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003668};
3669
3670static struct hda_pcm_stream alc260_pcm_analog_capture = {
3671 .substreams = 1,
3672 .channels_min = 2,
3673 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674};
3675
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003676#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3677#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3678
Kailang Yangdf694da2005-12-05 19:42:22 +01003679/*
3680 * for BIOS auto-configuration
3681 */
3682
3683static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3684 const char *pfx)
3685{
3686 hda_nid_t nid_vol;
3687 unsigned long vol_val, sw_val;
3688 char name[32];
3689 int err;
3690
3691 if (nid >= 0x0f && nid < 0x11) {
3692 nid_vol = nid - 0x7;
3693 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3694 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3695 } else if (nid == 0x11) {
3696 nid_vol = nid - 0x7;
3697 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3698 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3699 } else if (nid >= 0x12 && nid <= 0x15) {
3700 nid_vol = 0x08;
3701 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3702 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3703 } else
3704 return 0; /* N/A */
3705
3706 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3707 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3708 return err;
3709 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3710 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3711 return err;
3712 return 1;
3713}
3714
3715/* add playback controls from the parsed DAC table */
3716static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3717 const struct auto_pin_cfg *cfg)
3718{
3719 hda_nid_t nid;
3720 int err;
3721
3722 spec->multiout.num_dacs = 1;
3723 spec->multiout.dac_nids = spec->private_dac_nids;
3724 spec->multiout.dac_nids[0] = 0x02;
3725
3726 nid = cfg->line_out_pins[0];
3727 if (nid) {
3728 err = alc260_add_playback_controls(spec, nid, "Front");
3729 if (err < 0)
3730 return err;
3731 }
3732
Takashi Iwai82bc9552006-03-21 11:24:42 +01003733 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003734 if (nid) {
3735 err = alc260_add_playback_controls(spec, nid, "Speaker");
3736 if (err < 0)
3737 return err;
3738 }
3739
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003740 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003741 if (nid) {
3742 err = alc260_add_playback_controls(spec, nid, "Headphone");
3743 if (err < 0)
3744 return err;
3745 }
3746 return 0;
3747}
3748
3749/* create playback/capture controls for input pins */
3750static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3751 const struct auto_pin_cfg *cfg)
3752{
Kailang Yangdf694da2005-12-05 19:42:22 +01003753 struct hda_input_mux *imux = &spec->private_imux;
3754 int i, err, idx;
3755
3756 for (i = 0; i < AUTO_PIN_LAST; i++) {
3757 if (cfg->input_pins[i] >= 0x12) {
3758 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003759 err = new_analog_input(spec, cfg->input_pins[i],
3760 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003761 if (err < 0)
3762 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003763 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003764 imux->items[imux->num_items].index = idx;
3765 imux->num_items++;
3766 }
3767 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3768 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003769 err = new_analog_input(spec, cfg->input_pins[i],
3770 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003771 if (err < 0)
3772 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003773 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003774 imux->items[imux->num_items].index = idx;
3775 imux->num_items++;
3776 }
3777 }
3778 return 0;
3779}
3780
3781static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3782 hda_nid_t nid, int pin_type,
3783 int sel_idx)
3784{
3785 /* set as output */
3786 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3787 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3788 /* need the manual connection? */
3789 if (nid >= 0x12) {
3790 int idx = nid - 0x12;
3791 snd_hda_codec_write(codec, idx + 0x0b, 0,
3792 AC_VERB_SET_CONNECT_SEL, sel_idx);
3793
3794 }
3795}
3796
3797static void alc260_auto_init_multi_out(struct hda_codec *codec)
3798{
3799 struct alc_spec *spec = codec->spec;
3800 hda_nid_t nid;
3801
3802 nid = spec->autocfg.line_out_pins[0];
3803 if (nid)
3804 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3805
Takashi Iwai82bc9552006-03-21 11:24:42 +01003806 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003807 if (nid)
3808 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3809
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003810 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003811 if (nid)
3812 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3813}
3814
3815#define ALC260_PIN_CD_NID 0x16
3816static void alc260_auto_init_analog_input(struct hda_codec *codec)
3817{
3818 struct alc_spec *spec = codec->spec;
3819 int i;
3820
3821 for (i = 0; i < AUTO_PIN_LAST; i++) {
3822 hda_nid_t nid = spec->autocfg.input_pins[i];
3823 if (nid >= 0x12) {
3824 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3825 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3826 if (nid != ALC260_PIN_CD_NID)
3827 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3828 AMP_OUT_MUTE);
3829 }
3830 }
3831}
3832
3833/*
3834 * generic initialization of ADC, input mixers and output mixers
3835 */
3836static struct hda_verb alc260_volume_init_verbs[] = {
3837 /*
3838 * Unmute ADC0-1 and set the default input to mic-in
3839 */
3840 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3841 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3843 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844
3845 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3846 * mixer widget
3847 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3848 * mic (mic 2)
3849 */
3850 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3856
3857 /*
3858 * Set up output mixers (0x08 - 0x0a)
3859 */
3860 /* set vol=0 to output mixers */
3861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3864 /* set up input amps for analog loopback */
3865 /* Amp Indices: DAC = 0, mixer = 1 */
3866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3872
3873 { }
3874};
3875
3876static int alc260_parse_auto_config(struct hda_codec *codec)
3877{
3878 struct alc_spec *spec = codec->spec;
3879 unsigned int wcap;
3880 int err;
3881 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3882
3883 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3884 alc260_ignore)) < 0)
3885 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003886 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3887 return err;
3888 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003889 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003890 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003891 return err;
3892
3893 spec->multiout.max_channels = 2;
3894
3895 if (spec->autocfg.dig_out_pin)
3896 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3897 if (spec->kctl_alloc)
3898 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3899
3900 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3901
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003902 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01003903 spec->input_mux = &spec->private_imux;
3904
3905 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003906 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003907 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3908 if (wcap != AC_WID_AUD_IN) {
3909 spec->adc_nids = alc260_adc_nids_alt;
3910 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3911 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003912 } else {
3913 spec->adc_nids = alc260_adc_nids;
3914 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3915 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003916 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003917 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003918
3919 return 1;
3920}
3921
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003922/* additional initialization for auto-configuration model */
3923static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003924{
Kailang Yangdf694da2005-12-05 19:42:22 +01003925 alc260_auto_init_multi_out(codec);
3926 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003927}
3928
3929/*
3930 * ALC260 configurations
3931 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003932static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003933 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003934 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3935 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwai3206b9c2006-05-10 16:33:11 +02003936 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3937 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02003938 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3939 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003940 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3941 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003942 { .modelname = "hp", .config = ALC260_HP },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003943 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
Takashi Iwai25b6c432006-08-08 13:01:14 +02003944 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003945 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
Takashi Iwai766a6c32006-05-26 14:58:29 +02003946 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003947 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3948 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3949 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3950 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3951 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3952 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003953 { .modelname = "acer", .config = ALC260_ACER },
3954 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003955#ifdef CONFIG_SND_DEBUG
3956 { .modelname = "test", .config = ALC260_TEST },
3957#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003958 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003959 {}
3960};
3961
Kailang Yangdf694da2005-12-05 19:42:22 +01003962static struct alc_config_preset alc260_presets[] = {
3963 [ALC260_BASIC] = {
3964 .mixers = { alc260_base_output_mixer,
3965 alc260_input_mixer,
3966 alc260_pc_beep_mixer,
3967 alc260_capture_mixer },
3968 .init_verbs = { alc260_init_verbs },
3969 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3970 .dac_nids = alc260_dac_nids,
3971 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3972 .adc_nids = alc260_adc_nids,
3973 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3974 .channel_mode = alc260_modes,
3975 .input_mux = &alc260_capture_source,
3976 },
3977 [ALC260_HP] = {
3978 .mixers = { alc260_base_output_mixer,
3979 alc260_input_mixer,
3980 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02003981 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01003982 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3983 .dac_nids = alc260_dac_nids,
3984 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3985 .adc_nids = alc260_hp_adc_nids,
3986 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3987 .channel_mode = alc260_modes,
3988 .input_mux = &alc260_capture_source,
3989 },
3990 [ALC260_HP_3013] = {
3991 .mixers = { alc260_hp_3013_mixer,
3992 alc260_input_mixer,
3993 alc260_capture_alt_mixer },
3994 .init_verbs = { alc260_hp_3013_init_verbs },
3995 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3996 .dac_nids = alc260_dac_nids,
3997 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3998 .adc_nids = alc260_hp_adc_nids,
3999 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4000 .channel_mode = alc260_modes,
4001 .input_mux = &alc260_capture_source,
4002 },
4003 [ALC260_FUJITSU_S702X] = {
4004 .mixers = { alc260_fujitsu_mixer,
4005 alc260_capture_mixer },
4006 .init_verbs = { alc260_fujitsu_init_verbs },
4007 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4008 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004009 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4010 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4012 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004013 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4014 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004015 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004016 [ALC260_ACER] = {
4017 .mixers = { alc260_acer_mixer,
4018 alc260_capture_mixer },
4019 .init_verbs = { alc260_acer_init_verbs },
4020 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4021 .dac_nids = alc260_dac_nids,
4022 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4023 .adc_nids = alc260_dual_adc_nids,
4024 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4025 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004026 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4027 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004028 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004029#ifdef CONFIG_SND_DEBUG
4030 [ALC260_TEST] = {
4031 .mixers = { alc260_test_mixer,
4032 alc260_capture_mixer },
4033 .init_verbs = { alc260_test_init_verbs },
4034 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4035 .dac_nids = alc260_test_dac_nids,
4036 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4037 .adc_nids = alc260_test_adc_nids,
4038 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4039 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004040 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4041 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004042 },
4043#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004044};
4045
Linus Torvalds1da177e2005-04-16 15:20:36 -07004046static int patch_alc260(struct hda_codec *codec)
4047{
4048 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004049 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004050
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004051 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004052 if (spec == NULL)
4053 return -ENOMEM;
4054
4055 codec->spec = spec;
4056
Takashi Iwai16ded522005-06-10 19:58:24 +02004057 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4058 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004059 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4060 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004061 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004062 }
4063
Kailang Yangdf694da2005-12-05 19:42:22 +01004064 if (board_config == ALC260_AUTO) {
4065 /* automatic parse from the BIOS config */
4066 err = alc260_parse_auto_config(codec);
4067 if (err < 0) {
4068 alc_free(codec);
4069 return err;
4070 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004071 printk(KERN_INFO
4072 "hda_codec: Cannot set up configuration "
4073 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004074 board_config = ALC260_BASIC;
4075 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004077
Kailang Yangdf694da2005-12-05 19:42:22 +01004078 if (board_config != ALC260_AUTO)
4079 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004080
4081 spec->stream_name_analog = "ALC260 Analog";
4082 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4083 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4084
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004085 spec->stream_name_digital = "ALC260 Digital";
4086 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4087 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4088
Linus Torvalds1da177e2005-04-16 15:20:36 -07004089 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004090 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004091 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004092
4093 return 0;
4094}
4095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096
Linus Torvalds1da177e2005-04-16 15:20:36 -07004097/*
4098 * ALC882 support
4099 *
4100 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4101 * configuration. Each pin widget can choose any input DACs and a mixer.
4102 * Each ADC is connected from a mixer of all inputs. This makes possible
4103 * 6-channel independent captures.
4104 *
4105 * In addition, an independent DAC for the multi-playback (not used in this
4106 * driver yet).
4107 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004108#define ALC882_DIGOUT_NID 0x06
4109#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004110
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004111static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112 { 8, NULL }
4113};
4114
4115static hda_nid_t alc882_dac_nids[4] = {
4116 /* front, rear, clfe, rear_surr */
4117 0x02, 0x03, 0x04, 0x05
4118};
4119
Kailang Yangdf694da2005-12-05 19:42:22 +01004120/* identical with ALC880 */
4121#define alc882_adc_nids alc880_adc_nids
4122#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004123
4124/* input MUX */
4125/* FIXME: should be a matrix-type input source selection */
4126
4127static struct hda_input_mux alc882_capture_source = {
4128 .num_items = 4,
4129 .items = {
4130 { "Mic", 0x0 },
4131 { "Front Mic", 0x1 },
4132 { "Line", 0x2 },
4133 { "CD", 0x4 },
4134 },
4135};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136#define alc882_mux_enum_info alc_mux_enum_info
4137#define alc882_mux_enum_get alc_mux_enum_get
4138
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004139static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004140{
4141 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4142 struct alc_spec *spec = codec->spec;
4143 const struct hda_input_mux *imux = spec->input_mux;
4144 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4145 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4146 hda_nid_t nid = capture_mixers[adc_idx];
4147 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4148 unsigned int i, idx;
4149
4150 idx = ucontrol->value.enumerated.item[0];
4151 if (idx >= imux->num_items)
4152 idx = imux->num_items - 1;
4153 if (*cur_val == idx && ! codec->in_resume)
4154 return 0;
4155 for (i = 0; i < imux->num_items; i++) {
4156 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4158 v | (imux->items[i].index << 8));
4159 }
4160 *cur_val = idx;
4161 return 1;
4162}
4163
Kailang Yangdf694da2005-12-05 19:42:22 +01004164/*
4165 * 6ch mode
4166 */
4167static struct hda_verb alc882_sixstack_ch6_init[] = {
4168 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4169 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4170 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4171 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { } /* end */
4173};
4174
4175/*
4176 * 8ch mode
4177 */
4178static struct hda_verb alc882_sixstack_ch8_init[] = {
4179 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4180 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4181 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4182 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4183 { } /* end */
4184};
4185
4186static struct hda_channel_mode alc882_sixstack_modes[2] = {
4187 { 6, alc882_sixstack_ch6_init },
4188 { 8, alc882_sixstack_ch8_init },
4189};
4190
Linus Torvalds1da177e2005-04-16 15:20:36 -07004191/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4192 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4193 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004194static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004195 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004196 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004197 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004198 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004199 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4200 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004201 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4202 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004203 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004204 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4209 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4214 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4215 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004216 { } /* end */
4217};
4218
Kailang Yangdf694da2005-12-05 19:42:22 +01004219static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4220 {
4221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4222 .name = "Channel Mode",
4223 .info = alc_ch_mode_info,
4224 .get = alc_ch_mode_get,
4225 .put = alc_ch_mode_put,
4226 },
4227 { } /* end */
4228};
4229
Linus Torvalds1da177e2005-04-16 15:20:36 -07004230static struct hda_verb alc882_init_verbs[] = {
4231 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004235 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004236 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4237 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4238 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004239 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4242 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004244 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4245 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4246 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004251 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004255 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004257 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004258 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004259 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004261 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004262 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004263 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4267 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4270 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4273 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4276 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004277 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004278 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004279
4280 /* FIXME: use matrix-type input source selection */
4281 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4282 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004287 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004292 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4297 /* ADC1: mute amp left and right */
4298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004299 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004300 /* ADC2: mute amp left and right */
4301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004302 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004303 /* ADC3: mute amp left and right */
4304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004305 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004306
4307 { }
4308};
4309
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004310static struct hda_verb alc882_eapd_verbs[] = {
4311 /* change to EAPD mode */
4312 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Tobin Davisc07584c2006-10-13 12:32:16 +02004313 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004314 { }
4315};
4316
Kailang Yangdf694da2005-12-05 19:42:22 +01004317/*
4318 * generic initialization of ADC, input mixers and output mixers
4319 */
4320static struct hda_verb alc882_auto_init_verbs[] = {
4321 /*
4322 * Unmute ADC0-2 and set the default input to mic-in
4323 */
4324 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4326 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4328 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4329 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4330
4331 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4332 * mixer widget
4333 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4334 * mic (mic 2)
4335 */
4336 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4342
4343 /*
4344 * Set up output mixers (0x0c - 0x0f)
4345 */
4346 /* set vol=0 to output mixers */
4347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4351 /* set up input amps for analog loopback */
4352 /* Amp Indices: DAC = 0, mixer = 1 */
4353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4359 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4360 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4361 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4362 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4363
4364 /* FIXME: use matrix-type input source selection */
4365 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4366 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4371 /* Input mixer2 */
4372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4376 /* Input mixer3 */
4377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4381
4382 { }
4383};
4384
4385/* capture mixer elements */
4386static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4387 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4388 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4391 {
4392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4393 /* The multiple "Capture Source" controls confuse alsamixer
4394 * So call somewhat different..
4395 * FIXME: the controls appear in the "playback" view!
4396 */
4397 /* .name = "Capture Source", */
4398 .name = "Input Source",
4399 .count = 2,
4400 .info = alc882_mux_enum_info,
4401 .get = alc882_mux_enum_get,
4402 .put = alc882_mux_enum_put,
4403 },
4404 { } /* end */
4405};
4406
4407static struct snd_kcontrol_new alc882_capture_mixer[] = {
4408 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4409 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4410 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4411 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4412 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4413 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4414 {
4415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4416 /* The multiple "Capture Source" controls confuse alsamixer
4417 * So call somewhat different..
4418 * FIXME: the controls appear in the "playback" view!
4419 */
4420 /* .name = "Capture Source", */
4421 .name = "Input Source",
4422 .count = 3,
4423 .info = alc882_mux_enum_info,
4424 .get = alc882_mux_enum_get,
4425 .put = alc882_mux_enum_put,
4426 },
4427 { } /* end */
4428};
4429
4430/* pcm configuration: identiacal with ALC880 */
4431#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4432#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4433#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4434#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4435
4436/*
4437 * configuration and preset
4438 */
4439static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004440 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4441 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004442 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4443 .config = ALC882_6ST_DIG }, /* MSI */
4444 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4445 .config = ALC882_6ST_DIG }, /* Foxconn */
4446 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4447 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004448 { .modelname = "arima", .config = ALC882_ARIMA },
4449 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4450 .config = ALC882_ARIMA }, /* Arima W820Di1 */
Takashi Iwai1494a922006-01-31 10:58:46 +01004451 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004452 {}
4453};
4454
4455static struct alc_config_preset alc882_presets[] = {
4456 [ALC882_3ST_DIG] = {
4457 .mixers = { alc882_base_mixer },
4458 .init_verbs = { alc882_init_verbs },
4459 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4460 .dac_nids = alc882_dac_nids,
4461 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004462 .dig_in_nid = ALC882_DIGIN_NID,
4463 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4464 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004465 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004466 .input_mux = &alc882_capture_source,
4467 },
4468 [ALC882_6ST_DIG] = {
4469 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4470 .init_verbs = { alc882_init_verbs },
4471 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4472 .dac_nids = alc882_dac_nids,
4473 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004474 .dig_in_nid = ALC882_DIGIN_NID,
4475 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4476 .channel_mode = alc882_sixstack_modes,
4477 .input_mux = &alc882_capture_source,
4478 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004479 [ALC882_ARIMA] = {
4480 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4481 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4482 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4483 .dac_nids = alc882_dac_nids,
4484 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4485 .channel_mode = alc882_sixstack_modes,
4486 .input_mux = &alc882_capture_source,
4487 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004488};
4489
4490
4491/*
4492 * BIOS auto configuration
4493 */
4494static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4495 hda_nid_t nid, int pin_type,
4496 int dac_idx)
4497{
4498 /* set as output */
4499 struct alc_spec *spec = codec->spec;
4500 int idx;
4501
4502 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4503 idx = 4;
4504 else
4505 idx = spec->multiout.dac_nids[dac_idx] - 2;
4506
4507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4508 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4509 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4510
4511}
4512
4513static void alc882_auto_init_multi_out(struct hda_codec *codec)
4514{
4515 struct alc_spec *spec = codec->spec;
4516 int i;
4517
4518 for (i = 0; i <= HDA_SIDE; i++) {
4519 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4520 if (nid)
4521 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4522 }
4523}
4524
4525static void alc882_auto_init_hp_out(struct hda_codec *codec)
4526{
4527 struct alc_spec *spec = codec->spec;
4528 hda_nid_t pin;
4529
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004530 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004531 if (pin) /* connect to front */
4532 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4533}
4534
4535#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4536#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4537
4538static void alc882_auto_init_analog_input(struct hda_codec *codec)
4539{
4540 struct alc_spec *spec = codec->spec;
4541 int i;
4542
4543 for (i = 0; i < AUTO_PIN_LAST; i++) {
4544 hda_nid_t nid = spec->autocfg.input_pins[i];
4545 if (alc882_is_input_pin(nid)) {
4546 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4547 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4548 if (nid != ALC882_PIN_CD_NID)
4549 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4550 AMP_OUT_MUTE);
4551 }
4552 }
4553}
4554
4555/* almost identical with ALC880 parser... */
4556static int alc882_parse_auto_config(struct hda_codec *codec)
4557{
4558 struct alc_spec *spec = codec->spec;
4559 int err = alc880_parse_auto_config(codec);
4560
4561 if (err < 0)
4562 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004563 else if (err > 0)
4564 /* hack - override the init verbs */
4565 spec->init_verbs[0] = alc882_auto_init_verbs;
4566 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004567}
4568
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004569/* additional initialization for auto-configuration model */
4570static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004571{
Kailang Yangdf694da2005-12-05 19:42:22 +01004572 alc882_auto_init_multi_out(codec);
4573 alc882_auto_init_hp_out(codec);
4574 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004575}
4576
Linus Torvalds1da177e2005-04-16 15:20:36 -07004577static int patch_alc882(struct hda_codec *codec)
4578{
4579 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004580 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004581
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004583 if (spec == NULL)
4584 return -ENOMEM;
4585
Linus Torvalds1da177e2005-04-16 15:20:36 -07004586 codec->spec = spec;
4587
Kailang Yangdf694da2005-12-05 19:42:22 +01004588 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004589
Kailang Yangdf694da2005-12-05 19:42:22 +01004590 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004591 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4592 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004593 board_config = ALC882_AUTO;
4594 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595
Kailang Yangdf694da2005-12-05 19:42:22 +01004596 if (board_config == ALC882_AUTO) {
4597 /* automatic parse from the BIOS config */
4598 err = alc882_parse_auto_config(codec);
4599 if (err < 0) {
4600 alc_free(codec);
4601 return err;
4602 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004603 printk(KERN_INFO
4604 "hda_codec: Cannot set up configuration "
4605 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004606 board_config = ALC882_3ST_DIG;
4607 }
4608 }
4609
4610 if (board_config != ALC882_AUTO)
4611 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004612
4613 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4615 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004616
4617 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004618 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4619 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004620
Kailang Yangdf694da2005-12-05 19:42:22 +01004621 if (! spec->adc_nids && spec->input_mux) {
4622 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004623 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004624 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4625 if (wcap != AC_WID_AUD_IN) {
4626 spec->adc_nids = alc882_adc_nids_alt;
4627 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4628 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4629 spec->num_mixers++;
4630 } else {
4631 spec->adc_nids = alc882_adc_nids;
4632 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4633 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4634 spec->num_mixers++;
4635 }
4636 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004637
4638 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004639 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004640 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004641
4642 return 0;
4643}
4644
4645/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004646 * ALC883 support
4647 *
4648 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4649 * configuration. Each pin widget can choose any input DACs and a mixer.
4650 * Each ADC is connected from a mixer of all inputs. This makes possible
4651 * 6-channel independent captures.
4652 *
4653 * In addition, an independent DAC for the multi-playback (not used in this
4654 * driver yet).
4655 */
4656#define ALC883_DIGOUT_NID 0x06
4657#define ALC883_DIGIN_NID 0x0a
4658
4659static hda_nid_t alc883_dac_nids[4] = {
4660 /* front, rear, clfe, rear_surr */
4661 0x02, 0x04, 0x03, 0x05
4662};
4663
4664static hda_nid_t alc883_adc_nids[2] = {
4665 /* ADC1-2 */
4666 0x08, 0x09,
4667};
4668/* input MUX */
4669/* FIXME: should be a matrix-type input source selection */
4670
4671static struct hda_input_mux alc883_capture_source = {
4672 .num_items = 4,
4673 .items = {
4674 { "Mic", 0x0 },
4675 { "Front Mic", 0x1 },
4676 { "Line", 0x2 },
4677 { "CD", 0x4 },
4678 },
4679};
4680#define alc883_mux_enum_info alc_mux_enum_info
4681#define alc883_mux_enum_get alc_mux_enum_get
4682
4683static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4684 struct snd_ctl_elem_value *ucontrol)
4685{
4686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4687 struct alc_spec *spec = codec->spec;
4688 const struct hda_input_mux *imux = spec->input_mux;
4689 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4690 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4691 hda_nid_t nid = capture_mixers[adc_idx];
4692 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4693 unsigned int i, idx;
4694
4695 idx = ucontrol->value.enumerated.item[0];
4696 if (idx >= imux->num_items)
4697 idx = imux->num_items - 1;
4698 if (*cur_val == idx && ! codec->in_resume)
4699 return 0;
4700 for (i = 0; i < imux->num_items; i++) {
4701 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4702 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4703 v | (imux->items[i].index << 8));
4704 }
4705 *cur_val = idx;
4706 return 1;
4707}
4708/*
4709 * 2ch mode
4710 */
4711static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4712 { 2, NULL }
4713};
4714
4715/*
4716 * 2ch mode
4717 */
4718static struct hda_verb alc883_3ST_ch2_init[] = {
4719 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4720 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4721 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4722 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4723 { } /* end */
4724};
4725
4726/*
4727 * 6ch mode
4728 */
4729static struct hda_verb alc883_3ST_ch6_init[] = {
4730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4732 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4735 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4736 { } /* end */
4737};
4738
4739static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4740 { 2, alc883_3ST_ch2_init },
4741 { 6, alc883_3ST_ch6_init },
4742};
4743
4744/*
4745 * 6ch mode
4746 */
4747static struct hda_verb alc883_sixstack_ch6_init[] = {
4748 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4749 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4750 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4751 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { } /* end */
4753};
4754
4755/*
4756 * 8ch mode
4757 */
4758static struct hda_verb alc883_sixstack_ch8_init[] = {
4759 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4760 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4761 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4762 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4763 { } /* end */
4764};
4765
4766static struct hda_channel_mode alc883_sixstack_modes[2] = {
4767 { 6, alc883_sixstack_ch6_init },
4768 { 8, alc883_sixstack_ch8_init },
4769};
4770
4771/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4772 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4773 */
4774
4775static struct snd_kcontrol_new alc883_base_mixer[] = {
4776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4778 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4779 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4780 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4781 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4782 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4783 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4784 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4785 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4787 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4788 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4793 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4794 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4795 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4796 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4798 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4799 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4800 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4801 {
4802 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4803 /* .name = "Capture Source", */
4804 .name = "Input Source",
4805 .count = 2,
4806 .info = alc883_mux_enum_info,
4807 .get = alc883_mux_enum_get,
4808 .put = alc883_mux_enum_put,
4809 },
4810 { } /* end */
4811};
4812
4813static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4814 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4815 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4816 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4825 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4826 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4827 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4828 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4829 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4830 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4831 {
4832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4833 /* .name = "Capture Source", */
4834 .name = "Input Source",
4835 .count = 2,
4836 .info = alc883_mux_enum_info,
4837 .get = alc883_mux_enum_get,
4838 .put = alc883_mux_enum_put,
4839 },
4840 { } /* end */
4841};
4842
4843static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4845 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4846 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4847 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4848 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4849 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4850 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4851 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4852 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4853 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4854 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4856 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4859 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4861 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4862 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4863 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4864 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4865 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4866 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4867 {
4868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4869 /* .name = "Capture Source", */
4870 .name = "Input Source",
4871 .count = 2,
4872 .info = alc883_mux_enum_info,
4873 .get = alc883_mux_enum_get,
4874 .put = alc883_mux_enum_put,
4875 },
4876 { } /* end */
4877};
4878
Tobin Davisc07584c2006-10-13 12:32:16 +02004879static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
4880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4881 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4883 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4886 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
4887 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
4888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4889 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4890 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4891 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4892 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4895 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4897 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4898 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4900 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4901
4902 {
4903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4904 /* .name = "Capture Source", */
4905 .name = "Input Source",
4906 .count = 1,
4907 .info = alc883_mux_enum_info,
4908 .get = alc883_mux_enum_get,
4909 .put = alc883_mux_enum_put,
4910 },
4911 { } /* end */
4912};
4913
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004914static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4915 {
4916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4917 .name = "Channel Mode",
4918 .info = alc_ch_mode_info,
4919 .get = alc_ch_mode_get,
4920 .put = alc_ch_mode_put,
4921 },
4922 { } /* end */
4923};
4924
4925static struct hda_verb alc883_init_verbs[] = {
4926 /* ADC1: mute amp left and right */
4927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4928 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4929 /* ADC2: mute amp left and right */
4930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4931 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4932 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4936 /* Rear mixer */
4937 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4939 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4940 /* CLFE mixer */
4941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4944 /* Side mixer */
4945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4948
4949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4954
4955 /* Front Pin: output 0 (0x0c) */
4956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4958 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4959 /* Rear Pin: output 1 (0x0d) */
4960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4963 /* CLFE Pin: output 2 (0x0e) */
4964 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4966 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4967 /* Side Pin: output 3 (0x0f) */
4968 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4969 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4970 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4971 /* Mic (rear) pin: input vref at 80% */
4972 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4973 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4974 /* Front Mic pin: input vref at 80% */
4975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4976 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4977 /* Line In pin: input */
4978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4980 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4984 /* CD pin widget for input */
4985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4986
4987 /* FIXME: use matrix-type input source selection */
4988 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4989 /* Input mixer2 */
4990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4994 /* Input mixer3 */
4995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4999 { }
5000};
5001
5002/*
5003 * generic initialization of ADC, input mixers and output mixers
5004 */
5005static struct hda_verb alc883_auto_init_verbs[] = {
5006 /*
5007 * Unmute ADC0-2 and set the default input to mic-in
5008 */
5009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5013
5014 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5015 * mixer widget
5016 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5017 * mic (mic 2)
5018 */
5019 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5025
5026 /*
5027 * Set up output mixers (0x0c - 0x0f)
5028 */
5029 /* set vol=0 to output mixers */
5030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5033 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5034 /* set up input amps for analog loopback */
5035 /* Amp Indices: DAC = 0, mixer = 1 */
5036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5041 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5043 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5044 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5045 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5046
5047 /* FIXME: use matrix-type input source selection */
5048 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5049 /* Input mixer1 */
5050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5053 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5055 /* Input mixer2 */
5056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5059 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5061
5062 { }
5063};
5064
5065/* capture mixer elements */
5066static struct snd_kcontrol_new alc883_capture_mixer[] = {
5067 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5068 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5069 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5070 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5071 {
5072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5073 /* The multiple "Capture Source" controls confuse alsamixer
5074 * So call somewhat different..
5075 * FIXME: the controls appear in the "playback" view!
5076 */
5077 /* .name = "Capture Source", */
5078 .name = "Input Source",
5079 .count = 2,
5080 .info = alc882_mux_enum_info,
5081 .get = alc882_mux_enum_get,
5082 .put = alc882_mux_enum_put,
5083 },
5084 { } /* end */
5085};
5086
5087/* pcm configuration: identiacal with ALC880 */
5088#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5089#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5090#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5091#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5092
5093/*
5094 * configuration and preset
5095 */
5096static struct hda_board_config alc883_cfg_tbl[] = {
5097 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005098 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5099 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5100 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5101 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5102 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5103 .config = ALC883_3ST_6ch },
Tobin Davis2aaeee82006-08-21 19:01:12 +02005104 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5105 .config = ALC883_3ST_6ch }, /* D102GGC */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005106 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005107 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5108 .config = ALC883_6ST_DIG }, /* MSI */
Leonard Norrgårde22a9a82007-01-01 19:00:54 +02005109 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
5110 .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005111 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5112 .config = ALC883_6ST_DIG }, /* Foxconn */
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005113 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02005114 { .modelname = "acer", .config = ALC883_ACER },
5115 { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
5116 .config = ALC883_ACER },
Tobin Davis7a997952006-09-26 15:30:10 +02005117 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
5118 .config = ALC883_ACER },
5119 { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
5120 .config = ALC883_ACER },
Tobin Davisc07584c2006-10-13 12:32:16 +02005121 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
Takashi Iwai35f60832006-10-13 12:46:10 +02005122 .modelname = "medion", .config = ALC883_MEDION },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005123 { .modelname = "auto", .config = ALC883_AUTO },
5124 {}
5125};
5126
5127static struct alc_config_preset alc883_presets[] = {
5128 [ALC883_3ST_2ch_DIG] = {
5129 .mixers = { alc883_3ST_2ch_mixer },
5130 .init_verbs = { alc883_init_verbs },
5131 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5132 .dac_nids = alc883_dac_nids,
5133 .dig_out_nid = ALC883_DIGOUT_NID,
5134 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5135 .adc_nids = alc883_adc_nids,
5136 .dig_in_nid = ALC883_DIGIN_NID,
5137 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5138 .channel_mode = alc883_3ST_2ch_modes,
5139 .input_mux = &alc883_capture_source,
5140 },
5141 [ALC883_3ST_6ch_DIG] = {
5142 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5143 .init_verbs = { alc883_init_verbs },
5144 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5145 .dac_nids = alc883_dac_nids,
5146 .dig_out_nid = ALC883_DIGOUT_NID,
5147 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5148 .adc_nids = alc883_adc_nids,
5149 .dig_in_nid = ALC883_DIGIN_NID,
5150 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5151 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005152 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005153 .input_mux = &alc883_capture_source,
5154 },
5155 [ALC883_3ST_6ch] = {
5156 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5157 .init_verbs = { alc883_init_verbs },
5158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5159 .dac_nids = alc883_dac_nids,
5160 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5161 .adc_nids = alc883_adc_nids,
5162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5163 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005164 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005165 .input_mux = &alc883_capture_source,
5166 },
5167 [ALC883_6ST_DIG] = {
5168 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5169 .init_verbs = { alc883_init_verbs },
5170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5171 .dac_nids = alc883_dac_nids,
5172 .dig_out_nid = ALC883_DIGOUT_NID,
5173 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5174 .adc_nids = alc883_adc_nids,
5175 .dig_in_nid = ALC883_DIGIN_NID,
5176 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5177 .channel_mode = alc883_sixstack_modes,
5178 .input_mux = &alc883_capture_source,
5179 },
5180 [ALC888_DEMO_BOARD] = {
5181 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5182 .init_verbs = { alc883_init_verbs },
5183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5184 .dac_nids = alc883_dac_nids,
5185 .dig_out_nid = ALC883_DIGOUT_NID,
5186 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5187 .adc_nids = alc883_adc_nids,
5188 .dig_in_nid = ALC883_DIGIN_NID,
5189 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5190 .channel_mode = alc883_sixstack_modes,
5191 .input_mux = &alc883_capture_source,
5192 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02005193 [ALC883_ACER] = {
5194 .mixers = { alc883_base_mixer,
5195 alc883_chmode_mixer },
5196 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5197 * and the headphone jack. Turn this on and rely on the
5198 * standard mute methods whenever the user wants to turn
5199 * these outputs off.
5200 */
5201 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5203 .dac_nids = alc883_dac_nids,
5204 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5205 .adc_nids = alc883_adc_nids,
5206 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5207 .channel_mode = alc883_3ST_2ch_modes,
5208 .input_mux = &alc883_capture_source,
5209 },
Tobin Davisc07584c2006-10-13 12:32:16 +02005210 [ALC883_MEDION] = {
5211 .mixers = { alc883_fivestack_mixer,
5212 alc883_chmode_mixer },
5213 .init_verbs = { alc883_init_verbs,
5214 alc882_eapd_verbs },
5215 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5216 .dac_nids = alc883_dac_nids,
5217 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5218 .adc_nids = alc883_adc_nids,
5219 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5220 .channel_mode = alc883_sixstack_modes,
5221 .input_mux = &alc883_capture_source,
5222 }
5223
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005224};
5225
5226
5227/*
5228 * BIOS auto configuration
5229 */
5230static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5231 hda_nid_t nid, int pin_type,
5232 int dac_idx)
5233{
5234 /* set as output */
5235 struct alc_spec *spec = codec->spec;
5236 int idx;
5237
5238 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5239 idx = 4;
5240 else
5241 idx = spec->multiout.dac_nids[dac_idx] - 2;
5242
5243 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5244 pin_type);
5245 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5246 AMP_OUT_UNMUTE);
5247 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5248
5249}
5250
5251static void alc883_auto_init_multi_out(struct hda_codec *codec)
5252{
5253 struct alc_spec *spec = codec->spec;
5254 int i;
5255
5256 for (i = 0; i <= HDA_SIDE; i++) {
5257 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5258 if (nid)
5259 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5260 }
5261}
5262
5263static void alc883_auto_init_hp_out(struct hda_codec *codec)
5264{
5265 struct alc_spec *spec = codec->spec;
5266 hda_nid_t pin;
5267
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005268 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005269 if (pin) /* connect to front */
5270 /* use dac 0 */
5271 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5272}
5273
5274#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5275#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5276
5277static void alc883_auto_init_analog_input(struct hda_codec *codec)
5278{
5279 struct alc_spec *spec = codec->spec;
5280 int i;
5281
5282 for (i = 0; i < AUTO_PIN_LAST; i++) {
5283 hda_nid_t nid = spec->autocfg.input_pins[i];
5284 if (alc883_is_input_pin(nid)) {
5285 snd_hda_codec_write(codec, nid, 0,
5286 AC_VERB_SET_PIN_WIDGET_CONTROL,
5287 (i <= AUTO_PIN_FRONT_MIC ?
5288 PIN_VREF80 : PIN_IN));
5289 if (nid != ALC883_PIN_CD_NID)
5290 snd_hda_codec_write(codec, nid, 0,
5291 AC_VERB_SET_AMP_GAIN_MUTE,
5292 AMP_OUT_MUTE);
5293 }
5294 }
5295}
5296
5297/* almost identical with ALC880 parser... */
5298static int alc883_parse_auto_config(struct hda_codec *codec)
5299{
5300 struct alc_spec *spec = codec->spec;
5301 int err = alc880_parse_auto_config(codec);
5302
5303 if (err < 0)
5304 return err;
5305 else if (err > 0)
5306 /* hack - override the init verbs */
5307 spec->init_verbs[0] = alc883_auto_init_verbs;
5308 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5309 spec->num_mixers++;
5310 return err;
5311}
5312
5313/* additional initialization for auto-configuration model */
5314static void alc883_auto_init(struct hda_codec *codec)
5315{
5316 alc883_auto_init_multi_out(codec);
5317 alc883_auto_init_hp_out(codec);
5318 alc883_auto_init_analog_input(codec);
5319}
5320
5321static int patch_alc883(struct hda_codec *codec)
5322{
5323 struct alc_spec *spec;
5324 int err, board_config;
5325
5326 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5327 if (spec == NULL)
5328 return -ENOMEM;
5329
5330 codec->spec = spec;
5331
5332 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5333 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5334 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5335 "trying auto-probe from BIOS...\n");
5336 board_config = ALC883_AUTO;
5337 }
5338
5339 if (board_config == ALC883_AUTO) {
5340 /* automatic parse from the BIOS config */
5341 err = alc883_parse_auto_config(codec);
5342 if (err < 0) {
5343 alc_free(codec);
5344 return err;
5345 } else if (! err) {
5346 printk(KERN_INFO
5347 "hda_codec: Cannot set up configuration "
5348 "from BIOS. Using base mode...\n");
5349 board_config = ALC883_3ST_2ch_DIG;
5350 }
5351 }
5352
5353 if (board_config != ALC883_AUTO)
5354 setup_preset(spec, &alc883_presets[board_config]);
5355
5356 spec->stream_name_analog = "ALC883 Analog";
5357 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5358 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5359
5360 spec->stream_name_digital = "ALC883 Digital";
5361 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5362 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5363
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005364 if (! spec->adc_nids && spec->input_mux) {
5365 spec->adc_nids = alc883_adc_nids;
5366 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5367 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005368
5369 codec->patch_ops = alc_patch_ops;
5370 if (board_config == ALC883_AUTO)
5371 spec->init_hook = alc883_auto_init;
5372
5373 return 0;
5374}
5375
5376/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005377 * ALC262 support
5378 */
5379
5380#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5381#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5382
5383#define alc262_dac_nids alc260_dac_nids
5384#define alc262_adc_nids alc882_adc_nids
5385#define alc262_adc_nids_alt alc882_adc_nids_alt
5386
5387#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005388#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005389
5390static struct snd_kcontrol_new alc262_base_mixer[] = {
5391 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5392 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5393 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5394 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5395 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5396 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5399 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5400 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5401 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5402 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5403 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5405 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5406 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005407 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005408};
5409
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005410static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5411 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5412 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5414 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5415 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5416
5417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5418 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5419 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5420 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5423 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5424 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5425 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5426 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5427 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5428 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5429 { } /* end */
5430};
5431
Kailang Yangdf694da2005-12-05 19:42:22 +01005432#define alc262_capture_mixer alc882_capture_mixer
5433#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5434
5435/*
5436 * generic initialization of ADC, input mixers and output mixers
5437 */
5438static struct hda_verb alc262_init_verbs[] = {
5439 /*
5440 * Unmute ADC0-2 and set the default input to mic-in
5441 */
5442 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5444 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5446 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5448
5449 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5450 * mixer widget
5451 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5452 * mic (mic 2)
5453 */
5454 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5460
5461 /*
5462 * Set up output mixers (0x0c - 0x0e)
5463 */
5464 /* set vol=0 to output mixers */
5465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5468 /* set up input amps for analog loopback */
5469 /* Amp Indices: DAC = 0, mixer = 1 */
5470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5476
5477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5483
5484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5486 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5489
5490 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5491 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5492
5493 /* FIXME: use matrix-type input source selection */
5494 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5495 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5500 /* Input mixer2 */
5501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5505 /* Input mixer3 */
5506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5510
5511 { }
5512};
5513
Takashi Iwai834be882006-03-01 14:16:17 +01005514/*
5515 * fujitsu model
5516 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5517 */
5518
5519#define ALC_HP_EVENT 0x37
5520
5521static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5522 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5524 {}
5525};
5526
5527static struct hda_input_mux alc262_fujitsu_capture_source = {
5528 .num_items = 2,
5529 .items = {
5530 { "Mic", 0x0 },
5531 { "CD", 0x4 },
5532 },
5533};
5534
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005535static struct hda_input_mux alc262_HP_capture_source = {
5536 .num_items = 5,
5537 .items = {
5538 { "Mic", 0x0 },
5539 { "Front Mic", 0x3 },
5540 { "Line", 0x2 },
5541 { "CD", 0x4 },
5542 { "AUX IN", 0x6 },
5543 },
5544};
5545
Takashi Iwai834be882006-03-01 14:16:17 +01005546/* mute/unmute internal speaker according to the hp jack and mute state */
5547static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5548{
5549 struct alc_spec *spec = codec->spec;
5550 unsigned int mute;
5551
5552 if (force || ! spec->sense_updated) {
5553 unsigned int present;
5554 /* need to execute and sync at first */
5555 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5556 present = snd_hda_codec_read(codec, 0x14, 0,
5557 AC_VERB_GET_PIN_SENSE, 0);
5558 spec->jack_present = (present & 0x80000000) != 0;
5559 spec->sense_updated = 1;
5560 }
5561 if (spec->jack_present) {
5562 /* mute internal speaker */
5563 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5564 0x80, 0x80);
5565 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5566 0x80, 0x80);
5567 } else {
5568 /* unmute internal speaker if necessary */
5569 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5570 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5571 0x80, mute & 0x80);
5572 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5573 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5574 0x80, mute & 0x80);
5575 }
5576}
5577
5578/* unsolicited event for HP jack sensing */
5579static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5580 unsigned int res)
5581{
5582 if ((res >> 26) != ALC_HP_EVENT)
5583 return;
5584 alc262_fujitsu_automute(codec, 1);
5585}
5586
5587/* bind volumes of both NID 0x0c and 0x0d */
5588static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5589 struct snd_ctl_elem_value *ucontrol)
5590{
5591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5592 long *valp = ucontrol->value.integer.value;
5593 int change;
5594
5595 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5596 0x7f, valp[0] & 0x7f);
5597 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5598 0x7f, valp[1] & 0x7f);
5599 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5600 0x7f, valp[0] & 0x7f);
5601 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5602 0x7f, valp[1] & 0x7f);
5603 return change;
5604}
5605
5606/* bind hp and internal speaker mute (with plug check) */
5607static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5608 struct snd_ctl_elem_value *ucontrol)
5609{
5610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5611 long *valp = ucontrol->value.integer.value;
5612 int change;
5613
5614 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5615 0x80, valp[0] ? 0 : 0x80);
5616 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5617 0x80, valp[1] ? 0 : 0x80);
5618 if (change || codec->in_resume)
5619 alc262_fujitsu_automute(codec, codec->in_resume);
5620 return change;
5621}
5622
5623static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5624 {
5625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5626 .name = "Master Playback Volume",
5627 .info = snd_hda_mixer_amp_volume_info,
5628 .get = snd_hda_mixer_amp_volume_get,
5629 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02005630 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01005631 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5632 },
5633 {
5634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5635 .name = "Master Playback Switch",
5636 .info = snd_hda_mixer_amp_switch_info,
5637 .get = snd_hda_mixer_amp_switch_get,
5638 .put = alc262_fujitsu_master_sw_put,
5639 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5640 },
5641 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5642 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5646 { } /* end */
5647};
5648
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005649/* additional init verbs for Benq laptops */
5650static struct hda_verb alc262_EAPD_verbs[] = {
5651 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5652 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5653 {}
5654};
5655
Kailang Yangdf694da2005-12-05 19:42:22 +01005656/* add playback controls from the parsed DAC table */
5657static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5658{
5659 hda_nid_t nid;
5660 int err;
5661
5662 spec->multiout.num_dacs = 1; /* only use one dac */
5663 spec->multiout.dac_nids = spec->private_dac_nids;
5664 spec->multiout.dac_nids[0] = 2;
5665
5666 nid = cfg->line_out_pins[0];
5667 if (nid) {
5668 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5669 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5670 return err;
5671 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5672 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5673 return err;
5674 }
5675
Takashi Iwai82bc9552006-03-21 11:24:42 +01005676 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005677 if (nid) {
5678 if (nid == 0x16) {
5679 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5680 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5681 return err;
5682 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5683 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5684 return err;
5685 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005686 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5687 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5688 return err;
5689 }
5690 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005691 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005692 if (nid) {
5693 /* spec->multiout.hp_nid = 2; */
5694 if (nid == 0x16) {
5695 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5696 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5697 return err;
5698 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5699 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5700 return err;
5701 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01005702 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5703 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5704 return err;
5705 }
5706 }
5707 return 0;
5708}
5709
5710/* identical with ALC880 */
5711#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5712
5713/*
5714 * generic initialization of ADC, input mixers and output mixers
5715 */
5716static struct hda_verb alc262_volume_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
5739 /*
5740 * Set up output mixers (0x0c - 0x0f)
5741 */
5742 /* set vol=0 to output mixers */
5743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746
5747 /* set up input amps for analog loopback */
5748 /* Amp Indices: DAC = 0, mixer = 1 */
5749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5755
5756 /* FIXME: use matrix-type input source selection */
5757 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5758 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5763 /* Input mixer2 */
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5768 /* Input mixer3 */
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5773
5774 { }
5775};
5776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005777static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5778 /*
5779 * Unmute ADC0-2 and set the default input to mic-in
5780 */
5781 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5785 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5787
5788 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5789 * mixer widget
5790 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5791 * mic (mic 2)
5792 */
5793 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5801
5802 /*
5803 * Set up output mixers (0x0c - 0x0e)
5804 */
5805 /* set vol=0 to output mixers */
5806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5809
5810 /* set up input amps for analog loopback */
5811 /* Amp Indices: DAC = 0, mixer = 1 */
5812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5818
5819 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5821 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5822
5823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5825
5826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5828
5829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5830 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5832 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5833 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5834
5835 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5839 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5840 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5841
5842
5843 /* FIXME: use matrix-type input source selection */
5844 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5845 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5850 /* Input mixer2 */
5851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5855 /* Input mixer3 */
5856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5860
5861 { }
5862};
5863
Kailang Yangdf694da2005-12-05 19:42:22 +01005864/* pcm configuration: identiacal with ALC880 */
5865#define alc262_pcm_analog_playback alc880_pcm_analog_playback
5866#define alc262_pcm_analog_capture alc880_pcm_analog_capture
5867#define alc262_pcm_digital_playback alc880_pcm_digital_playback
5868#define alc262_pcm_digital_capture alc880_pcm_digital_capture
5869
5870/*
5871 * BIOS auto configuration
5872 */
5873static int alc262_parse_auto_config(struct hda_codec *codec)
5874{
5875 struct alc_spec *spec = codec->spec;
5876 int err;
5877 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5878
5879 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5880 alc262_ignore)) < 0)
5881 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005882 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005883 return 0; /* can't find valid BIOS pin config */
5884 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5885 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5886 return err;
5887
5888 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5889
5890 if (spec->autocfg.dig_out_pin)
5891 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5892 if (spec->autocfg.dig_in_pin)
5893 spec->dig_in_nid = ALC262_DIGIN_NID;
5894
5895 if (spec->kctl_alloc)
5896 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5897
5898 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005899 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005900 spec->input_mux = &spec->private_imux;
5901
5902 return 1;
5903}
5904
5905#define alc262_auto_init_multi_out alc882_auto_init_multi_out
5906#define alc262_auto_init_hp_out alc882_auto_init_hp_out
5907#define alc262_auto_init_analog_input alc882_auto_init_analog_input
5908
5909
5910/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005911static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005912{
Kailang Yangdf694da2005-12-05 19:42:22 +01005913 alc262_auto_init_multi_out(codec);
5914 alc262_auto_init_hp_out(codec);
5915 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005916}
5917
5918/*
5919 * configuration and preset
5920 */
5921static struct hda_board_config alc262_cfg_tbl[] = {
5922 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01005923 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005924 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5925 .config = ALC262_FUJITSU },
Takashi Iwai6d177ba72006-07-25 14:51:15 +02005926 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
John W. Linville282e0c82006-11-06 12:01:53 +01005927 { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005928 .config = ALC262_HP_BPC }, /* xw4400 */
Takashi Iwaiefeccac2006-10-24 14:57:52 +02005929 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
5930 .config = ALC262_HP_BPC }, /* q965 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005931 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5932 .config = ALC262_HP_BPC }, /* xw6400 */
5933 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5934 .config = ALC262_HP_BPC }, /* xw8400 */
5935 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5936 .config = ALC262_HP_BPC }, /* xw9400 */
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005937 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5938 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5939 .config = ALC262_BENQ_ED8 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005940 { .modelname = "auto", .config = ALC262_AUTO },
5941 {}
5942};
5943
5944static struct alc_config_preset alc262_presets[] = {
5945 [ALC262_BASIC] = {
5946 .mixers = { alc262_base_mixer },
5947 .init_verbs = { alc262_init_verbs },
5948 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5949 .dac_nids = alc262_dac_nids,
5950 .hp_nid = 0x03,
5951 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5952 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005953 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 },
Takashi Iwai834be882006-03-01 14:16:17 +01005955 [ALC262_FUJITSU] = {
5956 .mixers = { alc262_fujitsu_mixer },
5957 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5958 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5959 .dac_nids = alc262_dac_nids,
5960 .hp_nid = 0x03,
5961 .dig_out_nid = ALC262_DIGOUT_NID,
5962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5963 .channel_mode = alc262_modes,
5964 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005965 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01005966 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005967 [ALC262_HP_BPC] = {
5968 .mixers = { alc262_HP_BPC_mixer },
5969 .init_verbs = { alc262_HP_BPC_init_verbs },
5970 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5971 .dac_nids = alc262_dac_nids,
5972 .hp_nid = 0x03,
5973 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5974 .channel_mode = alc262_modes,
5975 .input_mux = &alc262_HP_capture_source,
5976 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02005977 [ALC262_BENQ_ED8] = {
5978 .mixers = { alc262_base_mixer },
5979 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5980 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5981 .dac_nids = alc262_dac_nids,
5982 .hp_nid = 0x03,
5983 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5984 .channel_mode = alc262_modes,
5985 .input_mux = &alc262_capture_source,
5986 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005987};
5988
5989static int patch_alc262(struct hda_codec *codec)
5990{
5991 struct alc_spec *spec;
5992 int board_config;
5993 int err;
5994
5995 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5996 if (spec == NULL)
5997 return -ENOMEM;
5998
5999 codec->spec = spec;
6000#if 0
6001 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6002 {
6003 int tmp;
6004 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6005 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6006 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6007 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6008 }
6009#endif
6010
6011 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006012
Kailang Yangdf694da2005-12-05 19:42:22 +01006013 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006014 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6015 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006016 board_config = ALC262_AUTO;
6017 }
6018
6019 if (board_config == ALC262_AUTO) {
6020 /* automatic parse from the BIOS config */
6021 err = alc262_parse_auto_config(codec);
6022 if (err < 0) {
6023 alc_free(codec);
6024 return err;
6025 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006026 printk(KERN_INFO
6027 "hda_codec: Cannot set up configuration "
6028 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006029 board_config = ALC262_BASIC;
6030 }
6031 }
6032
6033 if (board_config != ALC262_AUTO)
6034 setup_preset(spec, &alc262_presets[board_config]);
6035
6036 spec->stream_name_analog = "ALC262 Analog";
6037 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6038 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6039
6040 spec->stream_name_digital = "ALC262 Digital";
6041 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6042 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6043
6044 if (! spec->adc_nids && spec->input_mux) {
6045 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006046 unsigned int wcap = get_wcaps(codec, 0x07);
6047
Kailang Yangdf694da2005-12-05 19:42:22 +01006048 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6049 if (wcap != AC_WID_AUD_IN) {
6050 spec->adc_nids = alc262_adc_nids_alt;
6051 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6052 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6053 spec->num_mixers++;
6054 } else {
6055 spec->adc_nids = alc262_adc_nids;
6056 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6057 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6058 spec->num_mixers++;
6059 }
6060 }
6061
6062 codec->patch_ops = alc_patch_ops;
6063 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006064 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006065
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 return 0;
6067}
6068
Kailang Yangdf694da2005-12-05 19:42:22 +01006069/*
6070 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6071 */
6072
6073/*
6074 * set the path ways for 2 channel output
6075 * need to set the codec line out and mic 1 pin widgets to inputs
6076 */
6077static struct hda_verb alc861_threestack_ch2_init[] = {
6078 /* set pin widget 1Ah (line in) for input */
6079 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6080 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6081 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6082
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006083 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6084#if 0
6085 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6086 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6087#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006088 { } /* end */
6089};
6090/*
6091 * 6ch mode
6092 * need to set the codec line out and mic 1 pin widgets to outputs
6093 */
6094static struct hda_verb alc861_threestack_ch6_init[] = {
6095 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6096 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6097 /* set pin widget 18h (mic1) for output (CLFE)*/
6098 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6099
6100 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006101 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006102
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006103 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6104#if 0
6105 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6106 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6107#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 { } /* end */
6109};
6110
6111static struct hda_channel_mode alc861_threestack_modes[2] = {
6112 { 2, alc861_threestack_ch2_init },
6113 { 6, alc861_threestack_ch6_init },
6114};
Takashi Iwai22309c32006-08-09 16:57:28 +02006115/* Set mic1 as input and unmute the mixer */
6116static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6117 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6118 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6119 { } /* end */
6120};
6121/* Set mic1 as output and mute mixer */
6122static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6123 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6124 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6125 { } /* end */
6126};
6127
6128static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6129 { 2, alc861_uniwill_m31_ch2_init },
6130 { 4, alc861_uniwill_m31_ch4_init },
6131};
Kailang Yangdf694da2005-12-05 19:42:22 +01006132
6133/* patch-ALC861 */
6134
6135static struct snd_kcontrol_new alc861_base_mixer[] = {
6136 /* output mixer control */
6137 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6139 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6140 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6141 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6142
6143 /*Input mixer control */
6144 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6145 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6146 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6149 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6151 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6152 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6154
6155 /* Capture mixer control */
6156 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6157 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6158 {
6159 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6160 .name = "Capture Source",
6161 .count = 1,
6162 .info = alc_mux_enum_info,
6163 .get = alc_mux_enum_get,
6164 .put = alc_mux_enum_put,
6165 },
6166 { } /* end */
6167};
6168
6169static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6170 /* output mixer control */
6171 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6173 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6174 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6175 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6176
6177 /* Input mixer control */
6178 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6179 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6180 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6181 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6182 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6183 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6185 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6186 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6188
6189 /* Capture mixer control */
6190 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6191 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6192 {
6193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6194 .name = "Capture Source",
6195 .count = 1,
6196 .info = alc_mux_enum_info,
6197 .get = alc_mux_enum_get,
6198 .put = alc_mux_enum_put,
6199 },
6200 {
6201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6202 .name = "Channel Mode",
6203 .info = alc_ch_mode_info,
6204 .get = alc_ch_mode_get,
6205 .put = alc_ch_mode_put,
6206 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6207 },
6208 { } /* end */
6209};
Takashi Iwai22309c32006-08-09 16:57:28 +02006210static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6211 /* output mixer control */
6212 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6213 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6214 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6215 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6216 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6217
6218 /* Input mixer control */
6219 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6220 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6221 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6222 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6223 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6224 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6226 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6229
6230 /* Capture mixer control */
6231 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6232 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6233 {
6234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6235 .name = "Capture Source",
6236 .count = 1,
6237 .info = alc_mux_enum_info,
6238 .get = alc_mux_enum_get,
6239 .put = alc_mux_enum_put,
6240 },
6241 {
6242 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6243 .name = "Channel Mode",
6244 .info = alc_ch_mode_info,
6245 .get = alc_ch_mode_get,
6246 .put = alc_ch_mode_put,
6247 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6248 },
6249 { } /* end */
6250};
Kailang Yangdf694da2005-12-05 19:42:22 +01006251
6252/*
6253 * generic initialization of ADC, input mixers and output mixers
6254 */
6255static struct hda_verb alc861_base_init_verbs[] = {
6256 /*
6257 * Unmute ADC0 and set the default input to mic-in
6258 */
6259 /* port-A for surround (rear panel) */
6260 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6261 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6262 /* port-B for mic-in (rear panel) with vref */
6263 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6264 /* port-C for line-in (rear panel) */
6265 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6266 /* port-D for Front */
6267 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6268 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6269 /* port-E for HP out (front panel) */
6270 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6271 /* route front PCM to HP */
6272 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6273 /* port-F for mic-in (front panel) with vref */
6274 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6275 /* port-G for CLFE (rear panel) */
6276 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6277 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6278 /* port-H for side (rear panel) */
6279 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6280 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6281 /* CD-in */
6282 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6283 /* route front mic to ADC1*/
6284 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6286
6287 /* Unmute DAC0~3 & spdif out*/
6288 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6289 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6290 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6291 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6293
6294 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6295 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6296 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6297 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6298 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6299
6300 /* Unmute Stereo Mixer 15 */
6301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6305
6306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6308 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6313 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6316
6317 { }
6318};
6319
6320static struct hda_verb alc861_threestack_init_verbs[] = {
6321 /*
6322 * Unmute ADC0 and set the default input to mic-in
6323 */
6324 /* port-A for surround (rear panel) */
6325 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6326 /* port-B for mic-in (rear panel) with vref */
6327 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6328 /* port-C for line-in (rear panel) */
6329 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6330 /* port-D for Front */
6331 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6332 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6333 /* port-E for HP out (front panel) */
6334 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6335 /* route front PCM to HP */
6336 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6337 /* port-F for mic-in (front panel) with vref */
6338 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6339 /* port-G for CLFE (rear panel) */
6340 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6341 /* port-H for side (rear panel) */
6342 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6343 /* CD-in */
6344 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6345 /* route front mic to ADC1*/
6346 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6348 /* Unmute DAC0~3 & spdif out*/
6349 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6350 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6351 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6352 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6354
6355 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6356 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6358 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6359 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6360
6361 /* Unmute Stereo Mixer 15 */
6362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6366
6367 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6369 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6370 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6371 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6377 { }
6378};
Takashi Iwai22309c32006-08-09 16:57:28 +02006379
6380static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6381 /*
6382 * Unmute ADC0 and set the default input to mic-in
6383 */
6384 /* port-A for surround (rear panel) */
6385 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6386 /* port-B for mic-in (rear panel) with vref */
6387 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6388 /* port-C for line-in (rear panel) */
6389 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6390 /* port-D for Front */
6391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6393 /* port-E for HP out (front panel) */
6394 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6395 /* route front PCM to HP */
6396 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6397 /* port-F for mic-in (front panel) with vref */
6398 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6399 /* port-G for CLFE (rear panel) */
6400 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6401 /* port-H for side (rear panel) */
6402 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6403 /* CD-in */
6404 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6405 /* route front mic to ADC1*/
6406 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6408 /* Unmute DAC0~3 & spdif out*/
6409 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6410 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6412 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6414
6415 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6416 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6417 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6418 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6419 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6420
6421 /* Unmute Stereo Mixer 15 */
6422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6426
6427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6429 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6430 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6436 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6437 { }
6438};
6439
Kailang Yangdf694da2005-12-05 19:42:22 +01006440/*
6441 * generic initialization of ADC, input mixers and output mixers
6442 */
6443static struct hda_verb alc861_auto_init_verbs[] = {
6444 /*
6445 * Unmute ADC0 and set the default input to mic-in
6446 */
6447// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6449
6450 /* Unmute DAC0~3 & spdif out*/
6451 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6452 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6453 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6454 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6456
6457 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6458 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6459 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6460 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6461 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6462
6463 /* Unmute Stereo Mixer 15 */
6464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6468
6469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6477
6478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6482 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6483 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6486
6487 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6488
6489 { }
6490};
6491
6492/* pcm configuration: identiacal with ALC880 */
6493#define alc861_pcm_analog_playback alc880_pcm_analog_playback
6494#define alc861_pcm_analog_capture alc880_pcm_analog_capture
6495#define alc861_pcm_digital_playback alc880_pcm_digital_playback
6496#define alc861_pcm_digital_capture alc880_pcm_digital_capture
6497
6498
6499#define ALC861_DIGOUT_NID 0x07
6500
6501static struct hda_channel_mode alc861_8ch_modes[1] = {
6502 { 8, NULL }
6503};
6504
6505static hda_nid_t alc861_dac_nids[4] = {
6506 /* front, surround, clfe, side */
6507 0x03, 0x06, 0x05, 0x04
6508};
6509
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006510static hda_nid_t alc660_dac_nids[3] = {
6511 /* front, clfe, surround */
6512 0x03, 0x05, 0x06
6513};
6514
Kailang Yangdf694da2005-12-05 19:42:22 +01006515static hda_nid_t alc861_adc_nids[1] = {
6516 /* ADC0-2 */
6517 0x08,
6518};
6519
6520static struct hda_input_mux alc861_capture_source = {
6521 .num_items = 5,
6522 .items = {
6523 { "Mic", 0x0 },
6524 { "Front Mic", 0x3 },
6525 { "Line", 0x1 },
6526 { "CD", 0x4 },
6527 { "Mixer", 0x5 },
6528 },
6529};
6530
6531/* fill in the dac_nids table from the parsed pin configuration */
6532static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6533{
6534 int i;
6535 hda_nid_t nid;
6536
6537 spec->multiout.dac_nids = spec->private_dac_nids;
6538 for (i = 0; i < cfg->line_outs; i++) {
6539 nid = cfg->line_out_pins[i];
6540 if (nid) {
6541 if (i >= ARRAY_SIZE(alc861_dac_nids))
6542 continue;
6543 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6544 }
6545 }
6546 spec->multiout.num_dacs = cfg->line_outs;
6547 return 0;
6548}
6549
6550/* add playback controls from the parsed DAC table */
6551static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6552 const struct auto_pin_cfg *cfg)
6553{
6554 char name[32];
6555 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6556 hda_nid_t nid;
6557 int i, idx, err;
6558
6559 for (i = 0; i < cfg->line_outs; i++) {
6560 nid = spec->multiout.dac_nids[i];
6561 if (! nid)
6562 continue;
6563 if (nid == 0x05) {
6564 /* Center/LFE */
6565 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6566 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6567 return err;
6568 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6569 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6570 return err;
6571 } else {
6572 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6573 if (nid == alc861_dac_nids[idx])
6574 break;
6575 sprintf(name, "%s Playback Switch", chname[idx]);
6576 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6577 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6578 return err;
6579 }
6580 }
6581 return 0;
6582}
6583
6584static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6585{
6586 int err;
6587 hda_nid_t nid;
6588
6589 if (! pin)
6590 return 0;
6591
6592 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6593 nid = 0x03;
6594 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6595 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6596 return err;
6597 spec->multiout.hp_nid = nid;
6598 }
6599 return 0;
6600}
6601
6602/* create playback/capture controls for input pins */
6603static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6604{
Kailang Yangdf694da2005-12-05 19:42:22 +01006605 struct hda_input_mux *imux = &spec->private_imux;
6606 int i, err, idx, idx1;
6607
6608 for (i = 0; i < AUTO_PIN_LAST; i++) {
6609 switch(cfg->input_pins[i]) {
6610 case 0x0c:
6611 idx1 = 1;
6612 idx = 2; // Line In
6613 break;
6614 case 0x0f:
6615 idx1 = 2;
6616 idx = 2; // Line In
6617 break;
6618 case 0x0d:
6619 idx1 = 0;
6620 idx = 1; // Mic In
6621 break;
6622 case 0x10:
6623 idx1 = 3;
6624 idx = 1; // Mic In
6625 break;
6626 case 0x11:
6627 idx1 = 4;
6628 idx = 0; // CD
6629 break;
6630 default:
6631 continue;
6632 }
6633
Takashi Iwai4a471b72005-12-07 13:56:29 +01006634 err = new_analog_input(spec, cfg->input_pins[i],
6635 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01006636 if (err < 0)
6637 return err;
6638
Takashi Iwai4a471b72005-12-07 13:56:29 +01006639 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 imux->items[imux->num_items].index = idx1;
6641 imux->num_items++;
6642 }
6643 return 0;
6644}
6645
6646static struct snd_kcontrol_new alc861_capture_mixer[] = {
6647 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6648 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6649
6650 {
6651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6652 /* The multiple "Capture Source" controls confuse alsamixer
6653 * So call somewhat different..
6654 *FIXME: the controls appear in the "playback" view!
6655 */
6656 /* .name = "Capture Source", */
6657 .name = "Input Source",
6658 .count = 1,
6659 .info = alc_mux_enum_info,
6660 .get = alc_mux_enum_get,
6661 .put = alc_mux_enum_put,
6662 },
6663 { } /* end */
6664};
6665
6666static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6667 int pin_type, int dac_idx)
6668{
6669 /* set as output */
6670
6671 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6672 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6673
6674}
6675
6676static void alc861_auto_init_multi_out(struct hda_codec *codec)
6677{
6678 struct alc_spec *spec = codec->spec;
6679 int i;
6680
6681 for (i = 0; i < spec->autocfg.line_outs; i++) {
6682 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6683 if (nid)
6684 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6685 }
6686}
6687
6688static void alc861_auto_init_hp_out(struct hda_codec *codec)
6689{
6690 struct alc_spec *spec = codec->spec;
6691 hda_nid_t pin;
6692
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006693 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006694 if (pin) /* connect to front */
6695 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6696}
6697
6698static void alc861_auto_init_analog_input(struct hda_codec *codec)
6699{
6700 struct alc_spec *spec = codec->spec;
6701 int i;
6702
6703 for (i = 0; i < AUTO_PIN_LAST; i++) {
6704 hda_nid_t nid = spec->autocfg.input_pins[i];
6705 if ((nid>=0x0c) && (nid <=0x11)) {
6706 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6707 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6708 }
6709 }
6710}
6711
6712/* parse the BIOS configuration and set up the alc_spec */
6713/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6714static int alc861_parse_auto_config(struct hda_codec *codec)
6715{
6716 struct alc_spec *spec = codec->spec;
6717 int err;
6718 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6719
6720 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6721 alc861_ignore)) < 0)
6722 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006723 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 return 0; /* can't find valid BIOS pin config */
6725
6726 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6727 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006728 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
Kailang Yangdf694da2005-12-05 19:42:22 +01006729 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6730 return err;
6731
6732 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6733
6734 if (spec->autocfg.dig_out_pin)
6735 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6736
6737 if (spec->kctl_alloc)
6738 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6739
6740 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6741
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006742 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006743 spec->input_mux = &spec->private_imux;
6744
6745 spec->adc_nids = alc861_adc_nids;
6746 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6747 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6748 spec->num_mixers++;
6749
6750 return 1;
6751}
6752
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006753/* additional initialization for auto-configuration model */
6754static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006755{
Kailang Yangdf694da2005-12-05 19:42:22 +01006756 alc861_auto_init_multi_out(codec);
6757 alc861_auto_init_hp_out(codec);
6758 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006759}
6760
6761
6762/*
6763 * configuration and preset
6764 */
6765static struct hda_board_config alc861_cfg_tbl[] = {
6766 { .modelname = "3stack", .config = ALC861_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006767 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6768 .config = ALC861_3ST },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006769 { .modelname = "3stack-660", .config = ALC660_3ST },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006770 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6771 .config = ALC660_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01006772 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6773 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
Takashi Iwai22309c32006-08-09 16:57:28 +02006774 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
6775 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
6776 .config = ALC861_UNIWILL_M31 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006777 { .modelname = "auto", .config = ALC861_AUTO },
6778 {}
6779};
6780
6781static struct alc_config_preset alc861_presets[] = {
6782 [ALC861_3ST] = {
6783 .mixers = { alc861_3ST_mixer },
6784 .init_verbs = { alc861_threestack_init_verbs },
6785 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6786 .dac_nids = alc861_dac_nids,
6787 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6788 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006789 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006790 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6791 .adc_nids = alc861_adc_nids,
6792 .input_mux = &alc861_capture_source,
6793 },
6794 [ALC861_3ST_DIG] = {
6795 .mixers = { alc861_base_mixer },
6796 .init_verbs = { alc861_threestack_init_verbs },
6797 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6798 .dac_nids = alc861_dac_nids,
6799 .dig_out_nid = ALC861_DIGOUT_NID,
6800 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6801 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006802 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006803 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6804 .adc_nids = alc861_adc_nids,
6805 .input_mux = &alc861_capture_source,
6806 },
6807 [ALC861_6ST_DIG] = {
6808 .mixers = { alc861_base_mixer },
6809 .init_verbs = { alc861_base_init_verbs },
6810 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6811 .dac_nids = alc861_dac_nids,
6812 .dig_out_nid = ALC861_DIGOUT_NID,
6813 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6814 .channel_mode = alc861_8ch_modes,
6815 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6816 .adc_nids = alc861_adc_nids,
6817 .input_mux = &alc861_capture_source,
6818 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006819 [ALC660_3ST] = {
6820 .mixers = { alc861_3ST_mixer },
6821 .init_verbs = { alc861_threestack_init_verbs },
6822 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6823 .dac_nids = alc660_dac_nids,
6824 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6825 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006826 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006827 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6828 .adc_nids = alc861_adc_nids,
6829 .input_mux = &alc861_capture_source,
6830 },
Takashi Iwai22309c32006-08-09 16:57:28 +02006831 [ALC861_UNIWILL_M31] = {
6832 .mixers = { alc861_uniwill_m31_mixer },
6833 .init_verbs = { alc861_uniwill_m31_init_verbs },
6834 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6835 .dac_nids = alc861_dac_nids,
6836 .dig_out_nid = ALC861_DIGOUT_NID,
6837 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
6838 .channel_mode = alc861_uniwill_m31_modes,
6839 .need_dac_fix = 1,
6840 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6841 .adc_nids = alc861_adc_nids,
6842 .input_mux = &alc861_capture_source,
6843 },
6844
Kailang Yangdf694da2005-12-05 19:42:22 +01006845};
6846
6847
6848static int patch_alc861(struct hda_codec *codec)
6849{
6850 struct alc_spec *spec;
6851 int board_config;
6852 int err;
6853
6854 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6855 if (spec == NULL)
6856 return -ENOMEM;
6857
6858 codec->spec = spec;
6859
6860 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006861
Kailang Yangdf694da2005-12-05 19:42:22 +01006862 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006863 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6864 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006865 board_config = ALC861_AUTO;
6866 }
6867
6868 if (board_config == ALC861_AUTO) {
6869 /* automatic parse from the BIOS config */
6870 err = alc861_parse_auto_config(codec);
6871 if (err < 0) {
6872 alc_free(codec);
6873 return err;
6874 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006875 printk(KERN_INFO
6876 "hda_codec: Cannot set up configuration "
6877 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006878 board_config = ALC861_3ST_DIG;
6879 }
6880 }
6881
6882 if (board_config != ALC861_AUTO)
6883 setup_preset(spec, &alc861_presets[board_config]);
6884
6885 spec->stream_name_analog = "ALC861 Analog";
6886 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6887 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6888
6889 spec->stream_name_digital = "ALC861 Digital";
6890 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6891 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6892
6893 codec->patch_ops = alc_patch_ops;
6894 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006895 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01006896
6897 return 0;
6898}
6899
6900/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006901 * patch entries
6902 */
6903struct hda_codec_preset snd_hda_preset_realtek[] = {
6904 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006905 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006906 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6907 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006908 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006910 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6911 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6912 .patch = patch_alc861 },
6913 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6914 .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07006915 {} /* terminator */
6916};