blob: a29862509032f0f3aa93d033935a362108f2a5e3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010076#ifdef CONFIG_SND_DEBUG
77 ALC260_TEST,
78#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010079 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020080 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081};
82
Kailang Yangdf694da2005-12-05 19:42:22 +010083/* ALC262 models */
84enum {
85 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020086 ALC262_HIPPO,
87 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010088 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020089 ALC262_HP_BPC,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020090 ALC262_BENQ_ED8,
Kailang Yangdf694da2005-12-05 19:42:22 +010091 ALC262_AUTO,
92 ALC262_MODEL_LAST /* last tag */
93};
94
95/* ALC861 models */
96enum {
97 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020098 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +010099 ALC861_3ST_DIG,
100 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200101 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200102 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200103 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100104 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100105 ALC861_AUTO,
106 ALC861_MODEL_LAST,
107};
108
109/* ALC882 models */
110enum {
111 ALC882_3ST_DIG,
112 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200113 ALC882_ARIMA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100114 ALC882_AUTO,
Tobin Davis9102cd12006-12-15 10:02:12 +0100115 ALC885_MACPRO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100116 ALC882_MODEL_LAST,
117};
118
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200119/* ALC883 models */
120enum {
121 ALC883_3ST_2ch_DIG,
122 ALC883_3ST_6ch_DIG,
123 ALC883_3ST_6ch,
124 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200125 ALC883_TARGA_DIG,
126 ALC883_TARGA_2ch_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200127 ALC888_DEMO_BOARD,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200128 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200129 ALC883_MEDION,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100130 ALC883_LAPTOP_EAPD,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200131 ALC883_AUTO,
132 ALC883_MODEL_LAST,
133};
134
Kailang Yangdf694da2005-12-05 19:42:22 +0100135/* for GPIO Poll */
136#define GPIO_MASK 0x03
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138struct alc_spec {
139 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100140 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 unsigned int num_mixers;
142
Kailang Yangdf694da2005-12-05 19:42:22 +0100143 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200144 * don't forget NULL
145 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200146 */
147 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Takashi Iwai16ded522005-06-10 19:58:24 +0200149 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 struct hda_pcm_stream *stream_analog_playback;
151 struct hda_pcm_stream *stream_analog_capture;
152
Takashi Iwai16ded522005-06-10 19:58:24 +0200153 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 struct hda_pcm_stream *stream_digital_playback;
155 struct hda_pcm_stream *stream_digital_capture;
156
157 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200158 struct hda_multi_out multiout; /* playback set-up
159 * max_channels, dacs must be set
160 * dig_out_nid and hp_nid are optional
161 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 /* capture */
164 unsigned int num_adc_nids;
165 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200166 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200169 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 const struct hda_input_mux *input_mux;
171 unsigned int cur_mux[3];
172
173 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100174 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200176 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100179 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200180
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200181 /* dynamic controls, init_verbs and input_mux */
182 struct auto_pin_cfg autocfg;
183 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100184 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200185 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100186 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100187
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100188 /* hooks */
189 void (*init_hook)(struct hda_codec *codec);
190 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
191
Takashi Iwai834be882006-03-01 14:16:17 +0100192 /* for pin sensing */
193 unsigned int sense_updated: 1;
194 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100195};
196
197/*
198 * configuration template - to be copied to the spec instance
199 */
200struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200201 struct snd_kcontrol_new *mixers[5]; /* should be identical size
202 * with spec
203 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100204 const struct hda_verb *init_verbs[5];
205 unsigned int num_dacs;
206 hda_nid_t *dac_nids;
207 hda_nid_t dig_out_nid; /* optional */
208 hda_nid_t hp_nid; /* optional */
209 unsigned int num_adc_nids;
210 hda_nid_t *adc_nids;
211 hda_nid_t dig_in_nid;
212 unsigned int num_channel_mode;
213 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200214 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200215 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100216 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100217 void (*unsol_event)(struct hda_codec *, unsigned int);
218 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219};
220
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222/*
223 * input MUX handling
224 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200225static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227{
228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
229 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200230 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
231 if (mux_idx >= spec->num_mux_defs)
232 mux_idx = 0;
233 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234}
235
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200236static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
237 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
239 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
240 struct alc_spec *spec = codec->spec;
241 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
242
243 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
244 return 0;
245}
246
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
248 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249{
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
251 struct alc_spec *spec = codec->spec;
252 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200253 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
254 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200255 spec->adc_nids[adc_idx],
256 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257}
258
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200259
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260/*
261 * channel mode setting
262 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200263static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
264 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265{
266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
267 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100268 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
269 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270}
271
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200272static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274{
275 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
276 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100277 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200278 spec->num_channel_mode,
279 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280}
281
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
283 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284{
285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
286 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200287 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
288 spec->num_channel_mode,
289 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200290 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200291 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
292 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293}
294
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100296 * Control the mode of pin widget settings via the mixer. "pc" is used
297 * instead of "%" to avoid consequences of accidently treating the % as
298 * being part of a format specifier. Maximum allowed length of a value is
299 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100300 *
301 * Note: some retasking pin complexes seem to ignore requests for input
302 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
303 * are requested. Therefore order this list so that this behaviour will not
304 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200305 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
306 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200307 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100308static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100309 "Mic 50pc bias", "Mic 80pc bias",
310 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100311};
312static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100313 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100314};
315/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200316 * in the pin being assumed to be exclusively an input or an output pin. In
317 * addition, "input" pins may or may not process the mic bias option
318 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
319 * accept requests for bias as of chip versions up to March 2006) and/or
320 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100321 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200322#define ALC_PIN_DIR_IN 0x00
323#define ALC_PIN_DIR_OUT 0x01
324#define ALC_PIN_DIR_INOUT 0x02
325#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
326#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100327
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200328/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100329 * For each direction the minimum and maximum values are given.
330 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200331static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100332 { 0, 2 }, /* ALC_PIN_DIR_IN */
333 { 3, 4 }, /* ALC_PIN_DIR_OUT */
334 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200335 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
336 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100337};
338#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
339#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
340#define alc_pin_mode_n_items(_dir) \
341 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
342
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200345{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100346 unsigned int item_num = uinfo->value.enumerated.item;
347 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
348
349 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200350 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100351 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
352
353 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
354 item_num = alc_pin_mode_min(dir);
355 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200356 return 0;
357}
358
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
360 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200361{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100362 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
364 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200366 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200367 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
368 AC_VERB_GET_PIN_WIDGET_CONTROL,
369 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200370
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100371 /* Find enumerated value for current pinctl setting */
372 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200375 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100376 return 0;
377}
378
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200379static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100381{
382 signed int change;
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 hda_nid_t nid = kcontrol->private_value & 0xffff;
385 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
386 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
388 AC_VERB_GET_PIN_WIDGET_CONTROL,
389 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392 val = alc_pin_mode_min(dir);
393
394 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100395 if (change) {
396 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200397 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200398 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100399
400 /* Also enable the retasking pin's input/output as required
401 * for the requested pin mode. Enum values of 2 or less are
402 * input modes.
403 *
404 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200405 * reduces noise slightly (particularly on input) so we'll
406 * do it. However, having both input and output buffers
407 * enabled simultaneously doesn't seem to be problematic if
408 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100409 */
410 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200411 snd_hda_codec_write(codec, nid, 0,
412 AC_VERB_SET_AMP_GAIN_MUTE,
413 AMP_OUT_MUTE);
414 snd_hda_codec_write(codec, nid, 0,
415 AC_VERB_SET_AMP_GAIN_MUTE,
416 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100417 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418 snd_hda_codec_write(codec, nid, 0,
419 AC_VERB_SET_AMP_GAIN_MUTE,
420 AMP_IN_MUTE(0));
421 snd_hda_codec_write(codec, nid, 0,
422 AC_VERB_SET_AMP_GAIN_MUTE,
423 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100424 }
425 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200426 return change;
427}
428
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200430 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431 .info = alc_pin_mode_info, \
432 .get = alc_pin_mode_get, \
433 .put = alc_pin_mode_put, \
434 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100435
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100436/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
437 * together using a mask with more than one bit set. This control is
438 * currently used only by the ALC260 test model. At this stage they are not
439 * needed for any "production" models.
440 */
441#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100444{
445 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
446 uinfo->count = 1;
447 uinfo->value.integer.min = 0;
448 uinfo->value.integer.max = 1;
449 return 0;
450}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200451static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
452 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100453{
454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
455 hda_nid_t nid = kcontrol->private_value & 0xffff;
456 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
457 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458 unsigned int val = snd_hda_codec_read(codec, nid, 0,
459 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100460
461 *valp = (val & mask) != 0;
462 return 0;
463}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100466{
467 signed int change;
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
471 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_GPIO_DATA,
474 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100475
476 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
478 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100479 gpio_data &= ~mask;
480 else
481 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200482 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100483
484 return change;
485}
486#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
487 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
488 .info = alc_gpio_data_info, \
489 .get = alc_gpio_data_get, \
490 .put = alc_gpio_data_put, \
491 .private_value = nid | (mask<<16) }
492#endif /* CONFIG_SND_DEBUG */
493
Jonathan Woithe92621f12006-02-28 11:47:47 +0100494/* A switch control to allow the enabling of the digital IO pins on the
495 * ALC260. This is incredibly simplistic; the intention of this control is
496 * to provide something in the test model allowing digital outputs to be
497 * identified if present. If models are found which can utilise these
498 * outputs a more complete mixer control can be devised for those models if
499 * necessary.
500 */
501#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200502static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100504{
505 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
506 uinfo->count = 1;
507 uinfo->value.integer.min = 0;
508 uinfo->value.integer.max = 1;
509 return 0;
510}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200511static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100513{
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 hda_nid_t nid = kcontrol->private_value & 0xffff;
516 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
517 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200518 unsigned int val = snd_hda_codec_read(codec, nid, 0,
519 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100520
521 *valp = (val & mask) != 0;
522 return 0;
523}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100526{
527 signed int change;
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 hda_nid_t nid = kcontrol->private_value & 0xffff;
530 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
531 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
533 AC_VERB_GET_DIGI_CONVERT,
534 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100535
536 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200537 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100538 if (val==0)
539 ctrl_data &= ~mask;
540 else
541 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
543 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100544
545 return change;
546}
547#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
548 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
549 .info = alc_spdif_ctrl_info, \
550 .get = alc_spdif_ctrl_get, \
551 .put = alc_spdif_ctrl_put, \
552 .private_value = nid | (mask<<16) }
553#endif /* CONFIG_SND_DEBUG */
554
Kailang Yangdf694da2005-12-05 19:42:22 +0100555/*
556 * set up from the preset table
557 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558static void setup_preset(struct alc_spec *spec,
559 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100560{
561 int i;
562
563 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
564 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
566 i++)
567 spec->init_verbs[spec->num_init_verbs++] =
568 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100569
570 spec->channel_mode = preset->channel_mode;
571 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200572 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100573
574 spec->multiout.max_channels = spec->channel_mode[0].channels;
575
576 spec->multiout.num_dacs = preset->num_dacs;
577 spec->multiout.dac_nids = preset->dac_nids;
578 spec->multiout.dig_out_nid = preset->dig_out_nid;
579 spec->multiout.hp_nid = preset->hp_nid;
580
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200581 spec->num_mux_defs = preset->num_mux_defs;
582 if (! spec->num_mux_defs)
583 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100584 spec->input_mux = preset->input_mux;
585
586 spec->num_adc_nids = preset->num_adc_nids;
587 spec->adc_nids = preset->adc_nids;
588 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100589
590 spec->unsol_event = preset->unsol_event;
591 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100592}
593
Takashi Iwai41e41f12005-06-08 14:48:49 +0200594/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200595 * ALC880 3-stack model
596 *
597 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
599 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 */
601
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200602static hda_nid_t alc880_dac_nids[4] = {
603 /* front, rear, clfe, rear_surr */
604 0x02, 0x05, 0x04, 0x03
605};
606
607static hda_nid_t alc880_adc_nids[3] = {
608 /* ADC0-2 */
609 0x07, 0x08, 0x09,
610};
611
612/* The datasheet says the node 0x07 is connected from inputs,
613 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100614 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200616static hda_nid_t alc880_adc_nids_alt[2] = {
617 /* ADC1-2 */
618 0x08, 0x09,
619};
620
621#define ALC880_DIGOUT_NID 0x06
622#define ALC880_DIGIN_NID 0x0a
623
624static struct hda_input_mux alc880_capture_source = {
625 .num_items = 4,
626 .items = {
627 { "Mic", 0x0 },
628 { "Front Mic", 0x3 },
629 { "Line", 0x2 },
630 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200632};
633
634/* channel source setting (2/6 channel selection for 3-stack) */
635/* 2ch mode */
636static struct hda_verb alc880_threestack_ch2_init[] = {
637 /* set line-in to input, mute it */
638 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
639 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
640 /* set mic-in to input vref 80%, mute it */
641 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
642 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 { } /* end */
644};
645
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200646/* 6ch mode */
647static struct hda_verb alc880_threestack_ch6_init[] = {
648 /* set line-in to output, unmute it */
649 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
650 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
651 /* set mic-in to output, unmute it */
652 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
653 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
654 { } /* end */
655};
656
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100657static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200658 { 2, alc880_threestack_ch2_init },
659 { 6, alc880_threestack_ch6_init },
660};
661
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100662static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100664 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200665 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100666 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200667 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
668 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100669 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
670 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
672 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
673 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
674 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
676 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
677 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
679 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
680 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200682 {
683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
684 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100685 .info = alc_ch_mode_info,
686 .get = alc_ch_mode_get,
687 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200688 },
689 { } /* end */
690};
691
692/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100693static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200694 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
695 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
696 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
697 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
698 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
699 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
700 {
701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
702 /* The multiple "Capture Source" controls confuse alsamixer
703 * So call somewhat different..
704 * FIXME: the controls appear in the "playback" view!
705 */
706 /* .name = "Capture Source", */
707 .name = "Input Source",
708 .count = 3,
709 .info = alc_mux_enum_info,
710 .get = alc_mux_enum_get,
711 .put = alc_mux_enum_put,
712 },
713 { } /* end */
714};
715
716/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100717static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200718 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
719 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
720 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
721 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 {
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 /* The multiple "Capture Source" controls confuse alsamixer
725 * So call somewhat different..
726 * FIXME: the controls appear in the "playback" view!
727 */
728 /* .name = "Capture Source", */
729 .name = "Input Source",
730 .count = 2,
731 .info = alc_mux_enum_info,
732 .get = alc_mux_enum_get,
733 .put = alc_mux_enum_put,
734 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 { } /* end */
736};
737
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200738
739
740/*
741 * ALC880 5-stack model
742 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200743 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
744 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200745 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
746 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
747 */
748
749/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100750static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100752 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 { } /* end */
754};
755
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200756/* channel source setting (6/8 channel selection for 5-stack) */
757/* 6ch mode */
758static struct hda_verb alc880_fivestack_ch6_init[] = {
759 /* set line-in to input, mute it */
760 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
761 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200762 { } /* end */
763};
764
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200765/* 8ch mode */
766static struct hda_verb alc880_fivestack_ch8_init[] = {
767 /* set line-in to output, unmute it */
768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
770 { } /* end */
771};
772
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100773static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200774 { 6, alc880_fivestack_ch6_init },
775 { 8, alc880_fivestack_ch8_init },
776};
777
778
779/*
780 * ALC880 6-stack model
781 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200782 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
783 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200784 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
785 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
786 */
787
788static hda_nid_t alc880_6st_dac_nids[4] = {
789 /* front, rear, clfe, rear_surr */
790 0x02, 0x03, 0x04, 0x05
791};
792
793static struct hda_input_mux alc880_6stack_capture_source = {
794 .num_items = 4,
795 .items = {
796 { "Mic", 0x0 },
797 { "Front Mic", 0x1 },
798 { "Line", 0x2 },
799 { "CD", 0x4 },
800 },
801};
802
803/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100804static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200805 { 8, NULL },
806};
807
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100808static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200811 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100812 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200817 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100818 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
827 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
828 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200829 {
830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
831 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100832 .info = alc_ch_mode_info,
833 .get = alc_ch_mode_get,
834 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200835 },
836 { } /* end */
837};
838
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200839
840/*
841 * ALC880 W810 model
842 *
843 * W810 has rear IO for:
844 * Front (DAC 02)
845 * Surround (DAC 03)
846 * Center/LFE (DAC 04)
847 * Digital out (06)
848 *
849 * The system also has a pair of internal speakers, and a headphone jack.
850 * These are both connected to Line2 on the codec, hence to DAC 02.
851 *
852 * There is a variable resistor to control the speaker or headphone
853 * volume. This is a hardware-only device without a software API.
854 *
855 * Plugging headphones in will disable the internal speakers. This is
856 * implemented in hardware, not via the driver using jack sense. In
857 * a similar fashion, plugging into the rear socket marked "front" will
858 * disable both the speakers and headphones.
859 *
860 * For input, there's a microphone jack, and an "audio in" jack.
861 * These may not do anything useful with this driver yet, because I
862 * haven't setup any initialization verbs for these yet...
863 */
864
865static hda_nid_t alc880_w810_dac_nids[3] = {
866 /* front, rear/surround, clfe */
867 0x02, 0x03, 0x04
868};
869
870/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100871static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200872 { 6, NULL }
873};
874
875/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100876static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100878 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100880 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100883 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
886 { } /* end */
887};
888
889
890/*
891 * Z710V model
892 *
893 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200894 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
895 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200896 */
897
898static hda_nid_t alc880_z71v_dac_nids[1] = {
899 0x02
900};
901#define ALC880_Z71V_HP_DAC 0x03
902
903/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100904static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200905 { 2, NULL }
906};
907
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100908static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100910 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100912 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
917 { } /* end */
918};
919
920
921/* FIXME! */
922/*
923 * ALC880 F1734 model
924 *
925 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
926 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
927 */
928
929static hda_nid_t alc880_f1734_dac_nids[1] = {
930 0x03
931};
932#define ALC880_F1734_HP_DAC 0x02
933
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100934static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200935 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100936 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200937 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100938 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200943 { } /* end */
944};
945
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200946
947/* FIXME! */
948/*
949 * ALC880 ASUS model
950 *
951 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
952 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
953 * Mic = 0x18, Line = 0x1a
954 */
955
956#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
957#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
958
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100959static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100963 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200974 {
975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
976 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100977 .info = alc_ch_mode_info,
978 .get = alc_ch_mode_get,
979 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200980 },
981 { } /* end */
982};
983
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200984/* FIXME! */
985/*
986 * ALC880 ASUS W1V model
987 *
988 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
989 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
990 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
991 */
992
993/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100994static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200995 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
996 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200997 { } /* end */
998};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200999
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001000/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001001static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001002 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1003 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1004 { } /* end */
1005};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001006
Kailang Yangdf694da2005-12-05 19:42:22 +01001007/* TCL S700 */
1008static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1010 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1013 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1016 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1017 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1018 {
1019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1020 /* The multiple "Capture Source" controls confuse alsamixer
1021 * So call somewhat different..
1022 * FIXME: the controls appear in the "playback" view!
1023 */
1024 /* .name = "Capture Source", */
1025 .name = "Input Source",
1026 .count = 1,
1027 .info = alc_mux_enum_info,
1028 .get = alc_mux_enum_get,
1029 .put = alc_mux_enum_put,
1030 },
1031 { } /* end */
1032};
1033
Kailang Yangccc656c2006-10-17 12:32:26 +02001034/* Uniwill */
1035static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1036 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1037 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1038 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1050 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1052 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1053 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1054 {
1055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1056 .name = "Channel Mode",
1057 .info = alc_ch_mode_info,
1058 .get = alc_ch_mode_get,
1059 .put = alc_ch_mode_put,
1060 },
1061 { } /* end */
1062};
1063
1064static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1065 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1066 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1067 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1068 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1071 { } /* end */
1072};
1073
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001075 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 */
1077static int alc_build_controls(struct hda_codec *codec)
1078{
1079 struct alc_spec *spec = codec->spec;
1080 int err;
1081 int i;
1082
1083 for (i = 0; i < spec->num_mixers; i++) {
1084 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1085 if (err < 0)
1086 return err;
1087 }
1088
1089 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001090 err = snd_hda_create_spdif_out_ctls(codec,
1091 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 if (err < 0)
1093 return err;
1094 }
1095 if (spec->dig_in_nid) {
1096 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1097 if (err < 0)
1098 return err;
1099 }
1100 return 0;
1101}
1102
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001103
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104/*
1105 * initialize the codec volumes, etc
1106 */
1107
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001108/*
1109 * generic initialization of ADC, input mixers and output mixers
1110 */
1111static struct hda_verb alc880_volume_init_verbs[] = {
1112 /*
1113 * Unmute ADC0-2 and set the default input to mic-in
1114 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001115 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001117 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1123 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001124 * Note: PASD motherboards uses the Line In 2 as the input for front
1125 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134 /*
1135 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137 /* set vol=0 to output mixers */
1138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1141 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1142 /* set up input amps for analog loopback */
1143 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
1153 { }
1154};
1155
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156/*
1157 * 3-stack pin configuration:
1158 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1159 */
1160static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1161 /*
1162 * preset connection lists of input pins
1163 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1164 */
1165 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1166 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1167 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1168
1169 /*
1170 * Set pin mode and muting
1171 */
1172 /* set front pin widgets 0x14 for output */
1173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1174 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1175 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1176 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1177 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1178 /* Mic2 (as headphone out) for HP output */
1179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1180 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1181 /* Line In pin widget for input */
1182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1184 /* Line2 (as front mic) pin widget for input and vref at 80% */
1185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1186 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1187 /* CD pin widget for input */
1188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1189
1190 { }
1191};
1192
1193/*
1194 * 5-stack pin configuration:
1195 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1196 * line-in/side = 0x1a, f-mic = 0x1b
1197 */
1198static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1199 /*
1200 * preset connection lists of input pins
1201 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1202 */
1203 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1204 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1205
1206 /*
1207 * Set pin mode and muting
1208 */
1209 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1212 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1213 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214 /* unmute pins for output (no gain on this amp) */
1215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1219
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001221 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1223 /* Mic2 (as headphone out) for HP output */
1224 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226 /* Line In pin widget for input */
1227 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1228 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1229 /* Line2 (as front mic) pin widget for input and vref at 80% */
1230 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1231 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1232 /* CD pin widget for input */
1233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234
1235 { }
1236};
1237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238/*
1239 * W810 pin configuration:
1240 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1241 */
1242static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 /* hphone/speaker input selector: front DAC */
1244 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1247 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1250 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1252
1253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256 { }
1257};
1258
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259/*
1260 * Z71V pin configuration:
1261 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1262 */
1263static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001268
Takashi Iwai16ded522005-06-10 19:58:24 +02001269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001273
1274 { }
1275};
1276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001277/*
1278 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001279 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1280 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281 */
1282static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1283 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1284
Takashi Iwai16ded522005-06-10 19:58:24 +02001285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001291 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293
Takashi Iwai16ded522005-06-10 19:58:24 +02001294 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001296 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001298 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001300 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001301 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304 { }
1305};
Takashi Iwai16ded522005-06-10 19:58:24 +02001306
Kailang Yangccc656c2006-10-17 12:32:26 +02001307/*
1308 * Uniwill pin configuration:
1309 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1310 * line = 0x1a
1311 */
1312static struct hda_verb alc880_uniwill_init_verbs[] = {
1313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1314
1315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1322 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1329
1330 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1334 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1336 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1337 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1338 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1339
1340 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1341 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1342
1343 { }
1344};
1345
1346/*
1347* Uniwill P53
1348* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1349 */
1350static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1351 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1352
1353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1365
1366 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1367 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1372
1373 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1374 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1375
1376 { }
1377};
1378
1379/* toggle speaker-output according to the hp-jack state */
1380static void alc880_uniwill_automute(struct hda_codec *codec)
1381{
1382 unsigned int present;
1383
1384 present = snd_hda_codec_read(codec, 0x14, 0,
1385 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1386 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1387 0x80, present ? 0x80 : 0);
1388 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1389 0x80, present ? 0x80 : 0);
1390 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1391 0x80, present ? 0x80 : 0);
1392 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1393 0x80, present ? 0x80 : 0);
1394
1395 present = snd_hda_codec_read(codec, 0x18, 0,
1396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1397 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1398 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1399}
1400
1401static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1402 unsigned int res)
1403{
1404 /* Looks like the unsol event is incompatible with the standard
1405 * definition. 4bit tag is placed at 28 bit!
1406 */
1407 if ((res >> 28) == ALC880_HP_EVENT ||
1408 (res >> 28) == ALC880_MIC_EVENT)
1409 alc880_uniwill_automute(codec);
1410}
1411
1412static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1413{
1414 unsigned int present;
1415
1416 present = snd_hda_codec_read(codec, 0x14, 0,
1417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1418
1419 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1420 0x80, present ? 0x80 : 0);
1421 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1422 0x80, present ? 0x80 : 0);
1423}
1424
1425static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1426{
1427 unsigned int present;
1428
1429 present = snd_hda_codec_read(codec, 0x21, 0,
1430 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1431
1432 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1433 0x7f, present);
1434 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1435 0x7f, present);
1436
1437 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1438 0x7f, present);
1439 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1440 0x7f, present);
1441
1442}
1443static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1444 unsigned int res)
1445{
1446 /* Looks like the unsol event is incompatible with the standard
1447 * definition. 4bit tag is placed at 28 bit!
1448 */
1449 if ((res >> 28) == ALC880_HP_EVENT)
1450 alc880_uniwill_p53_hp_automute(codec);
1451 if ((res >> 28) == ALC880_DCVOL_EVENT)
1452 alc880_uniwill_p53_dcvol_automute(codec);
1453}
1454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455/* FIXME! */
1456/*
1457 * F1734 pin configuration:
1458 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1459 */
1460static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1461 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1462 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1463 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1464 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1465
1466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470
1471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001480
1481 { }
1482};
1483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001484/* FIXME! */
1485/*
1486 * ASUS pin configuration:
1487 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1488 */
1489static struct hda_verb alc880_pin_asus_init_verbs[] = {
1490 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1491 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1492 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1494
1495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503
1504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1513
1514 { }
1515};
1516
1517/* Enable GPIO mask and set output */
1518static struct hda_verb alc880_gpio1_init_verbs[] = {
1519 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1520 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1521 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001522
1523 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001524};
1525
1526/* Enable GPIO mask and set output */
1527static struct hda_verb alc880_gpio2_init_verbs[] = {
1528 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1529 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1530 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001531
1532 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001533};
1534
Kailang Yangdf694da2005-12-05 19:42:22 +01001535/* Clevo m520g init */
1536static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1537 /* headphone output */
1538 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1539 /* line-out */
1540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1542 /* Line-in */
1543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1545 /* CD */
1546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1547 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 /* Mic1 (rear panel) */
1549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1551 /* Mic2 (front panel) */
1552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1553 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1554 /* headphone */
1555 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1556 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1557 /* change to EAPD mode */
1558 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1559 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1560
1561 { }
1562};
1563
1564static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001565 /* change to EAPD mode */
1566 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1567 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1568
Kailang Yangdf694da2005-12-05 19:42:22 +01001569 /* Headphone output */
1570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1571 /* Front output*/
1572 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1573 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1574
1575 /* Line In pin widget for input */
1576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577 /* CD pin widget for input */
1578 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1579 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1580 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1581
1582 /* change to EAPD mode */
1583 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1584 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1585
1586 { }
1587};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001588
1589/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001590 * LG m1 express dual
1591 *
1592 * Pin assignment:
1593 * Rear Line-In/Out (blue): 0x14
1594 * Build-in Mic-In: 0x15
1595 * Speaker-out: 0x17
1596 * HP-Out (green): 0x1b
1597 * Mic-In/Out (red): 0x19
1598 * SPDIF-Out: 0x1e
1599 */
1600
1601/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1602static hda_nid_t alc880_lg_dac_nids[3] = {
1603 0x05, 0x02, 0x03
1604};
1605
1606/* seems analog CD is not working */
1607static struct hda_input_mux alc880_lg_capture_source = {
1608 .num_items = 3,
1609 .items = {
1610 { "Mic", 0x1 },
1611 { "Line", 0x5 },
1612 { "Internal Mic", 0x6 },
1613 },
1614};
1615
1616/* 2,4,6 channel modes */
1617static struct hda_verb alc880_lg_ch2_init[] = {
1618 /* set line-in and mic-in to input */
1619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1620 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1621 { }
1622};
1623
1624static struct hda_verb alc880_lg_ch4_init[] = {
1625 /* set line-in to out and mic-in to input */
1626 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1627 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1628 { }
1629};
1630
1631static struct hda_verb alc880_lg_ch6_init[] = {
1632 /* set line-in and mic-in to output */
1633 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1634 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1635 { }
1636};
1637
1638static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1639 { 2, alc880_lg_ch2_init },
1640 { 4, alc880_lg_ch4_init },
1641 { 6, alc880_lg_ch6_init },
1642};
1643
1644static struct snd_kcontrol_new alc880_lg_mixer[] = {
1645 /* FIXME: it's not really "master" but front channels */
1646 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1647 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1648 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1649 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1650 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1652 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1653 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1658 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1659 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1660 {
1661 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1662 .name = "Channel Mode",
1663 .info = alc_ch_mode_info,
1664 .get = alc_ch_mode_get,
1665 .put = alc_ch_mode_put,
1666 },
1667 { } /* end */
1668};
1669
1670static struct hda_verb alc880_lg_init_verbs[] = {
1671 /* set capture source to mic-in */
1672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1675 /* mute all amp mixer inputs */
1676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1679 /* line-in to input */
1680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1682 /* built-in mic */
1683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 /* speaker-out */
1686 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 /* mic-in to input */
1689 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1690 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1691 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 /* HP-out */
1693 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1694 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696 /* jack sense */
1697 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1698 { }
1699};
1700
1701/* toggle speaker-output according to the hp-jack state */
1702static void alc880_lg_automute(struct hda_codec *codec)
1703{
1704 unsigned int present;
1705
1706 present = snd_hda_codec_read(codec, 0x1b, 0,
1707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1708 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1709 0x80, present ? 0x80 : 0);
1710 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1711 0x80, present ? 0x80 : 0);
1712}
1713
1714static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1715{
1716 /* Looks like the unsol event is incompatible with the standard
1717 * definition. 4bit tag is placed at 28 bit!
1718 */
1719 if ((res >> 28) == 0x01)
1720 alc880_lg_automute(codec);
1721}
1722
1723/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001724 * LG LW20
1725 *
1726 * Pin assignment:
1727 * Speaker-out: 0x14
1728 * Mic-In: 0x18
1729 * Built-in Mic-In: 0x19 (?)
1730 * HP-Out: 0x1b
1731 * SPDIF-Out: 0x1e
1732 */
1733
1734/* seems analog CD is not working */
1735static struct hda_input_mux alc880_lg_lw_capture_source = {
1736 .num_items = 2,
1737 .items = {
1738 { "Mic", 0x0 },
1739 { "Internal Mic", 0x1 },
1740 },
1741};
1742
1743static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1744 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1745 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1748 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1749 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1750 { } /* end */
1751};
1752
1753static struct hda_verb alc880_lg_lw_init_verbs[] = {
1754 /* set capture source to mic-in */
1755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1759 /* speaker-out */
1760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1762 /* HP-out */
1763 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1764 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1765 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1766 /* mic-in to input */
1767 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1769 /* built-in mic */
1770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1771 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1772 /* jack sense */
1773 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1774 { }
1775};
1776
1777/* toggle speaker-output according to the hp-jack state */
1778static void alc880_lg_lw_automute(struct hda_codec *codec)
1779{
1780 unsigned int present;
1781
1782 present = snd_hda_codec_read(codec, 0x1b, 0,
1783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1784 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1785 0x80, present ? 0x80 : 0);
1786 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1787 0x80, present ? 0x80 : 0);
1788}
1789
1790static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1791{
1792 /* Looks like the unsol event is incompatible with the standard
1793 * definition. 4bit tag is placed at 28 bit!
1794 */
1795 if ((res >> 28) == 0x01)
1796 alc880_lg_lw_automute(codec);
1797}
1798
1799/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001800 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001802
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803static int alc_init(struct hda_codec *codec)
1804{
1805 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 unsigned int i;
1807
1808 for (i = 0; i < spec->num_init_verbs; i++)
1809 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001810
1811 if (spec->init_hook)
1812 spec->init_hook(codec);
1813
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 return 0;
1815}
1816
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001817static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1818{
1819 struct alc_spec *spec = codec->spec;
1820
1821 if (spec->unsol_event)
1822 spec->unsol_event(codec, res);
1823}
1824
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825#ifdef CONFIG_PM
1826/*
1827 * resume
1828 */
1829static int alc_resume(struct hda_codec *codec)
1830{
1831 struct alc_spec *spec = codec->spec;
1832 int i;
1833
1834 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 if (spec->multiout.dig_out_nid)
1838 snd_hda_resume_spdif_out(codec);
1839 if (spec->dig_in_nid)
1840 snd_hda_resume_spdif_in(codec);
1841
1842 return 0;
1843}
1844#endif
1845
1846/*
1847 * Analog playback callbacks
1848 */
1849static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1850 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001851 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852{
1853 struct alc_spec *spec = codec->spec;
1854 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1855}
1856
1857static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1858 struct hda_codec *codec,
1859 unsigned int stream_tag,
1860 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001861 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862{
1863 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001864 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1865 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866}
1867
1868static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1869 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001870 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871{
1872 struct alc_spec *spec = codec->spec;
1873 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1874}
1875
1876/*
1877 * Digital out
1878 */
1879static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1880 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001881 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882{
1883 struct alc_spec *spec = codec->spec;
1884 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1885}
1886
1887static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1888 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001889 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890{
1891 struct alc_spec *spec = codec->spec;
1892 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1893}
1894
1895/*
1896 * Analog capture
1897 */
1898static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1899 struct hda_codec *codec,
1900 unsigned int stream_tag,
1901 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001902 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903{
1904 struct alc_spec *spec = codec->spec;
1905
1906 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1907 stream_tag, 0, format);
1908 return 0;
1909}
1910
1911static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1912 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001913 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914{
1915 struct alc_spec *spec = codec->spec;
1916
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001917 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1918 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 return 0;
1920}
1921
1922
1923/*
1924 */
1925static struct hda_pcm_stream alc880_pcm_analog_playback = {
1926 .substreams = 1,
1927 .channels_min = 2,
1928 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001929 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 .ops = {
1931 .open = alc880_playback_pcm_open,
1932 .prepare = alc880_playback_pcm_prepare,
1933 .cleanup = alc880_playback_pcm_cleanup
1934 },
1935};
1936
1937static struct hda_pcm_stream alc880_pcm_analog_capture = {
1938 .substreams = 2,
1939 .channels_min = 2,
1940 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001941 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 .ops = {
1943 .prepare = alc880_capture_pcm_prepare,
1944 .cleanup = alc880_capture_pcm_cleanup
1945 },
1946};
1947
1948static struct hda_pcm_stream alc880_pcm_digital_playback = {
1949 .substreams = 1,
1950 .channels_min = 2,
1951 .channels_max = 2,
1952 /* NID is set in alc_build_pcms */
1953 .ops = {
1954 .open = alc880_dig_playback_pcm_open,
1955 .close = alc880_dig_playback_pcm_close
1956 },
1957};
1958
1959static struct hda_pcm_stream alc880_pcm_digital_capture = {
1960 .substreams = 1,
1961 .channels_min = 2,
1962 .channels_max = 2,
1963 /* NID is set in alc_build_pcms */
1964};
1965
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001966/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1967static struct hda_pcm_stream alc_pcm_null_playback = {
1968 .substreams = 0,
1969 .channels_min = 0,
1970 .channels_max = 0,
1971};
1972
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973static int alc_build_pcms(struct hda_codec *codec)
1974{
1975 struct alc_spec *spec = codec->spec;
1976 struct hda_pcm *info = spec->pcm_rec;
1977 int i;
1978
1979 codec->num_pcms = 1;
1980 codec->pcm_info = info;
1981
1982 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001983 if (spec->stream_analog_playback) {
1984 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1985 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1986 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1987 }
1988 if (spec->stream_analog_capture) {
1989 snd_assert(spec->adc_nids, return -EINVAL);
1990 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1991 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1992 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993
Takashi Iwai4a471b72005-12-07 13:56:29 +01001994 if (spec->channel_mode) {
1995 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1996 for (i = 0; i < spec->num_channel_mode; i++) {
1997 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1998 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1999 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 }
2001 }
2002
Takashi Iwaie08a0072006-09-07 17:52:14 +02002003 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002005 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002006 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002008 if (spec->multiout.dig_out_nid &&
2009 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2011 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2012 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002013 if (spec->dig_in_nid &&
2014 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2016 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2017 }
2018 }
2019
Takashi Iwaie08a0072006-09-07 17:52:14 +02002020 /* If the use of more than one ADC is requested for the current
2021 * model, configure a second analog capture-only PCM.
2022 */
2023 /* Additional Analaog capture for index #2 */
2024 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2025 spec->adc_nids) {
2026 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002027 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002028 info->name = spec->stream_name_analog;
2029 /* No playback stream for second PCM */
2030 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2031 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2032 if (spec->stream_analog_capture) {
2033 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2034 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2035 }
2036 }
2037
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 return 0;
2039}
2040
2041static void alc_free(struct hda_codec *codec)
2042{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043 struct alc_spec *spec = codec->spec;
2044 unsigned int i;
2045
2046 if (! spec)
2047 return;
2048
2049 if (spec->kctl_alloc) {
2050 for (i = 0; i < spec->num_kctl_used; i++)
2051 kfree(spec->kctl_alloc[i].name);
2052 kfree(spec->kctl_alloc);
2053 }
2054 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055}
2056
2057/*
2058 */
2059static struct hda_codec_ops alc_patch_ops = {
2060 .build_controls = alc_build_controls,
2061 .build_pcms = alc_build_pcms,
2062 .init = alc_init,
2063 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002064 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065#ifdef CONFIG_PM
2066 .resume = alc_resume,
2067#endif
2068};
2069
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002070
2071/*
2072 * Test configuration for debugging
2073 *
2074 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2075 * enum controls.
2076 */
2077#ifdef CONFIG_SND_DEBUG
2078static hda_nid_t alc880_test_dac_nids[4] = {
2079 0x02, 0x03, 0x04, 0x05
2080};
2081
2082static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002083 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002084 .items = {
2085 { "In-1", 0x0 },
2086 { "In-2", 0x1 },
2087 { "In-3", 0x2 },
2088 { "In-4", 0x3 },
2089 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002090 { "Front", 0x5 },
2091 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002092 },
2093};
2094
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002095static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002096 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002097 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002098 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002099 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002100};
2101
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002102static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2103 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002104{
2105 static char *texts[] = {
2106 "N/A", "Line Out", "HP Out",
2107 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2108 };
2109 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2110 uinfo->count = 1;
2111 uinfo->value.enumerated.items = 8;
2112 if (uinfo->value.enumerated.item >= 8)
2113 uinfo->value.enumerated.item = 7;
2114 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2115 return 0;
2116}
2117
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002118static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2119 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002120{
2121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2122 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2123 unsigned int pin_ctl, item = 0;
2124
2125 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2126 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2127 if (pin_ctl & AC_PINCTL_OUT_EN) {
2128 if (pin_ctl & AC_PINCTL_HP_EN)
2129 item = 2;
2130 else
2131 item = 1;
2132 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2133 switch (pin_ctl & AC_PINCTL_VREFEN) {
2134 case AC_PINCTL_VREF_HIZ: item = 3; break;
2135 case AC_PINCTL_VREF_50: item = 4; break;
2136 case AC_PINCTL_VREF_GRD: item = 5; break;
2137 case AC_PINCTL_VREF_80: item = 6; break;
2138 case AC_PINCTL_VREF_100: item = 7; break;
2139 }
2140 }
2141 ucontrol->value.enumerated.item[0] = item;
2142 return 0;
2143}
2144
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002145static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2146 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002147{
2148 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2149 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2150 static unsigned int ctls[] = {
2151 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2152 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2153 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2154 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2155 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2156 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2157 };
2158 unsigned int old_ctl, new_ctl;
2159
2160 old_ctl = snd_hda_codec_read(codec, nid, 0,
2161 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2162 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2163 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002164 snd_hda_codec_write(codec, nid, 0,
2165 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002167 (ucontrol->value.enumerated.item[0] >= 3 ?
2168 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002169 return 1;
2170 }
2171 return 0;
2172}
2173
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002174static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2175 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002176{
2177 static char *texts[] = {
2178 "Front", "Surround", "CLFE", "Side"
2179 };
2180 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2181 uinfo->count = 1;
2182 uinfo->value.enumerated.items = 4;
2183 if (uinfo->value.enumerated.item >= 4)
2184 uinfo->value.enumerated.item = 3;
2185 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2186 return 0;
2187}
2188
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002189static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2190 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002191{
2192 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2193 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2194 unsigned int sel;
2195
2196 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2197 ucontrol->value.enumerated.item[0] = sel & 3;
2198 return 0;
2199}
2200
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002201static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2202 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002203{
2204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2205 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2206 unsigned int sel;
2207
2208 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2209 if (ucontrol->value.enumerated.item[0] != sel) {
2210 sel = ucontrol->value.enumerated.item[0] & 3;
2211 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2212 return 1;
2213 }
2214 return 0;
2215}
2216
2217#define PIN_CTL_TEST(xname,nid) { \
2218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2219 .name = xname, \
2220 .info = alc_test_pin_ctl_info, \
2221 .get = alc_test_pin_ctl_get, \
2222 .put = alc_test_pin_ctl_put, \
2223 .private_value = nid \
2224 }
2225
2226#define PIN_SRC_TEST(xname,nid) { \
2227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2228 .name = xname, \
2229 .info = alc_test_pin_src_info, \
2230 .get = alc_test_pin_src_get, \
2231 .put = alc_test_pin_src_put, \
2232 .private_value = nid \
2233 }
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2237 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2238 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2239 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2241 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2242 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2243 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002244 PIN_CTL_TEST("Front Pin Mode", 0x14),
2245 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2246 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2247 PIN_CTL_TEST("Side Pin Mode", 0x17),
2248 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2249 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2250 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2251 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2252 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2253 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2254 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2255 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2256 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2257 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2258 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2259 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2260 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2261 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2262 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2263 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002266 {
2267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2268 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002269 .info = alc_ch_mode_info,
2270 .get = alc_ch_mode_get,
2271 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002272 },
2273 { } /* end */
2274};
2275
2276static struct hda_verb alc880_test_init_verbs[] = {
2277 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002286 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002291 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002296 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002301 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002307 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002312 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002314 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002316 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002319 /* Analog input/passthru */
2320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002325 { }
2326};
2327#endif
2328
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329/*
2330 */
2331
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002332static const char *alc880_models[ALC880_MODEL_LAST] = {
2333 [ALC880_3ST] = "3stack",
2334 [ALC880_TCL_S700] = "tcl",
2335 [ALC880_3ST_DIG] = "3stack-digout",
2336 [ALC880_CLEVO] = "clevo",
2337 [ALC880_5ST] = "5stack",
2338 [ALC880_5ST_DIG] = "5stack-digout",
2339 [ALC880_W810] = "w810",
2340 [ALC880_Z71V] = "z71v",
2341 [ALC880_6ST] = "6stack",
2342 [ALC880_6ST_DIG] = "6stack-digout",
2343 [ALC880_ASUS] = "asus",
2344 [ALC880_ASUS_W1V] = "asus-w1v",
2345 [ALC880_ASUS_DIG] = "asus-dig",
2346 [ALC880_ASUS_DIG2] = "asus-dig2",
2347 [ALC880_UNIWILL_DIG] = "uniwill",
2348 [ALC880_F1734] = "F1734",
2349 [ALC880_LG] = "lg",
2350 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002351#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002352 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002353#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002354 [ALC880_AUTO] = "auto",
2355};
2356
2357static struct snd_pci_quirk alc880_cfg_tbl[] = {
2358 /* Broken BIOS configuration */
2359 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2360 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2361
2362 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2363 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002364 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002365 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2366 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2367 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2368 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2369 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2370 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2371
2372 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2373 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2374
2375 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2376 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2377 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2378 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2379 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2380 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2381 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2382 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2383 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2384 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002385 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002386 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2387 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2388 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2389 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2390
2391 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2392 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2393 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2394 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2395 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2396 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2397 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2398 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2399 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2400 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2401 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2402 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2403 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2404 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2405 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2406 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2407 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2408 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2409
2410 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2411 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2412 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2413 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2414
2415 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2416 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2417 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2418
2419 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2420 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2421 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2422 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2423
2424 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2425 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2426 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2427 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2428 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2429 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2430 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2431 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2432 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2433 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2434 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002435
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 {}
2437};
2438
Takashi Iwai16ded522005-06-10 19:58:24 +02002439/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002440 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002441 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002442static struct alc_config_preset alc880_presets[] = {
2443 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 .mixers = { alc880_three_stack_mixer },
2445 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002446 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002447 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002448 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2449 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002450 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002451 .input_mux = &alc880_capture_source,
2452 },
2453 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454 .mixers = { alc880_three_stack_mixer },
2455 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002456 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002457 .dac_nids = alc880_dac_nids,
2458 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002459 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2460 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002461 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002462 .input_mux = &alc880_capture_source,
2463 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002464 [ALC880_TCL_S700] = {
2465 .mixers = { alc880_tcl_s700_mixer },
2466 .init_verbs = { alc880_volume_init_verbs,
2467 alc880_pin_tcl_S700_init_verbs,
2468 alc880_gpio2_init_verbs },
2469 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2470 .dac_nids = alc880_dac_nids,
2471 .hp_nid = 0x03,
2472 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2473 .channel_mode = alc880_2_jack_modes,
2474 .input_mux = &alc880_capture_source,
2475 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002476 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002477 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2478 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2480 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002481 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2482 .channel_mode = alc880_fivestack_modes,
2483 .input_mux = &alc880_capture_source,
2484 },
2485 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2487 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002488 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2489 .dac_nids = alc880_dac_nids,
2490 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002491 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2492 .channel_mode = alc880_fivestack_modes,
2493 .input_mux = &alc880_capture_source,
2494 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002495 [ALC880_6ST] = {
2496 .mixers = { alc880_six_stack_mixer },
2497 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2498 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2499 .dac_nids = alc880_6st_dac_nids,
2500 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2501 .channel_mode = alc880_sixstack_modes,
2502 .input_mux = &alc880_6stack_capture_source,
2503 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002504 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002505 .mixers = { alc880_six_stack_mixer },
2506 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002507 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2508 .dac_nids = alc880_6st_dac_nids,
2509 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002510 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2511 .channel_mode = alc880_sixstack_modes,
2512 .input_mux = &alc880_6stack_capture_source,
2513 },
2514 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002516 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2517 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002518 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2519 .dac_nids = alc880_w810_dac_nids,
2520 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002521 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2522 .channel_mode = alc880_w810_modes,
2523 .input_mux = &alc880_capture_source,
2524 },
2525 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002527 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002528 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2529 .dac_nids = alc880_z71v_dac_nids,
2530 .dig_out_nid = ALC880_DIGOUT_NID,
2531 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2533 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002534 .input_mux = &alc880_capture_source,
2535 },
2536 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 .mixers = { alc880_f1734_mixer },
2538 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2539 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2540 .dac_nids = alc880_f1734_dac_nids,
2541 .hp_nid = 0x02,
2542 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2543 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002544 .input_mux = &alc880_capture_source,
2545 },
2546 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002547 .mixers = { alc880_asus_mixer },
2548 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2549 alc880_gpio1_init_verbs },
2550 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2551 .dac_nids = alc880_asus_dac_nids,
2552 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2553 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002554 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002555 .input_mux = &alc880_capture_source,
2556 },
2557 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558 .mixers = { alc880_asus_mixer },
2559 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2560 alc880_gpio1_init_verbs },
2561 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2562 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002563 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002564 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2565 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002566 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002567 .input_mux = &alc880_capture_source,
2568 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002569 [ALC880_ASUS_DIG2] = {
2570 .mixers = { alc880_asus_mixer },
2571 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2572 alc880_gpio2_init_verbs }, /* use GPIO2 */
2573 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2574 .dac_nids = alc880_asus_dac_nids,
2575 .dig_out_nid = ALC880_DIGOUT_NID,
2576 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2577 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002578 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002579 .input_mux = &alc880_capture_source,
2580 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002581 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2584 alc880_gpio1_init_verbs },
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002587 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2589 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002590 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002591 .input_mux = &alc880_capture_source,
2592 },
2593 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002594 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002595 .init_verbs = { alc880_volume_init_verbs,
2596 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2598 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002599 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2601 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002602 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002603 .input_mux = &alc880_capture_source,
2604 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002605 [ALC880_UNIWILL] = {
2606 .mixers = { alc880_uniwill_mixer },
2607 .init_verbs = { alc880_volume_init_verbs,
2608 alc880_uniwill_init_verbs },
2609 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2610 .dac_nids = alc880_asus_dac_nids,
2611 .dig_out_nid = ALC880_DIGOUT_NID,
2612 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2613 .channel_mode = alc880_threestack_modes,
2614 .need_dac_fix = 1,
2615 .input_mux = &alc880_capture_source,
2616 .unsol_event = alc880_uniwill_unsol_event,
2617 .init_hook = alc880_uniwill_automute,
2618 },
2619 [ALC880_UNIWILL_P53] = {
2620 .mixers = { alc880_uniwill_p53_mixer },
2621 .init_verbs = { alc880_volume_init_verbs,
2622 alc880_uniwill_p53_init_verbs },
2623 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2624 .dac_nids = alc880_asus_dac_nids,
2625 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2626 .channel_mode = alc880_w810_modes,
2627 .input_mux = &alc880_capture_source,
2628 .unsol_event = alc880_uniwill_p53_unsol_event,
2629 .init_hook = alc880_uniwill_p53_hp_automute,
2630 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002631 [ALC880_CLEVO] = {
2632 .mixers = { alc880_three_stack_mixer },
2633 .init_verbs = { alc880_volume_init_verbs,
2634 alc880_pin_clevo_init_verbs },
2635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2636 .dac_nids = alc880_dac_nids,
2637 .hp_nid = 0x03,
2638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2639 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002640 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002641 .input_mux = &alc880_capture_source,
2642 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002643 [ALC880_LG] = {
2644 .mixers = { alc880_lg_mixer },
2645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_lg_init_verbs },
2647 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2648 .dac_nids = alc880_lg_dac_nids,
2649 .dig_out_nid = ALC880_DIGOUT_NID,
2650 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2651 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002652 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002653 .input_mux = &alc880_lg_capture_source,
2654 .unsol_event = alc880_lg_unsol_event,
2655 .init_hook = alc880_lg_automute,
2656 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002657 [ALC880_LG_LW] = {
2658 .mixers = { alc880_lg_lw_mixer },
2659 .init_verbs = { alc880_volume_init_verbs,
2660 alc880_lg_lw_init_verbs },
2661 .num_dacs = 1,
2662 .dac_nids = alc880_dac_nids,
2663 .dig_out_nid = ALC880_DIGOUT_NID,
2664 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2665 .channel_mode = alc880_2_jack_modes,
2666 .input_mux = &alc880_lg_lw_capture_source,
2667 .unsol_event = alc880_lg_lw_unsol_event,
2668 .init_hook = alc880_lg_lw_automute,
2669 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002670#ifdef CONFIG_SND_DEBUG
2671 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 .mixers = { alc880_test_mixer },
2673 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2675 .dac_nids = alc880_test_dac_nids,
2676 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2678 .channel_mode = alc880_test_modes,
2679 .input_mux = &alc880_test_capture_source,
2680 },
2681#endif
2682};
2683
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684/*
2685 * Automatic parse of I/O pins from the BIOS configuration
2686 */
2687
2688#define NUM_CONTROL_ALLOC 32
2689#define NUM_VERB_ALLOC 32
2690
2691enum {
2692 ALC_CTL_WIDGET_VOL,
2693 ALC_CTL_WIDGET_MUTE,
2694 ALC_CTL_BIND_MUTE,
2695};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002696static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2698 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002699 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700};
2701
2702/* add dynamic controls */
2703static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2704{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002705 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706
2707 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2708 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2709
2710 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2711 if (! knew)
2712 return -ENOMEM;
2713 if (spec->kctl_alloc) {
2714 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2715 kfree(spec->kctl_alloc);
2716 }
2717 spec->kctl_alloc = knew;
2718 spec->num_kctl_alloc = num;
2719 }
2720
2721 knew = &spec->kctl_alloc[spec->num_kctl_used];
2722 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002723 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002724 if (! knew->name)
2725 return -ENOMEM;
2726 knew->private_value = val;
2727 spec->num_kctl_used++;
2728 return 0;
2729}
2730
2731#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2732#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2733#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2734#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2735#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2736#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2737#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2738#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2739#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2740#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2741#define ALC880_PIN_CD_NID 0x1c
2742
2743/* fill in the dac_nids table from the parsed pin configuration */
2744static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2745{
2746 hda_nid_t nid;
2747 int assigned[4];
2748 int i, j;
2749
2750 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002751 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752
2753 /* check the pins hardwired to audio widget */
2754 for (i = 0; i < cfg->line_outs; i++) {
2755 nid = cfg->line_out_pins[i];
2756 if (alc880_is_fixed_pin(nid)) {
2757 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002758 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759 assigned[idx] = 1;
2760 }
2761 }
2762 /* left pins can be connect to any audio widget */
2763 for (i = 0; i < cfg->line_outs; i++) {
2764 nid = cfg->line_out_pins[i];
2765 if (alc880_is_fixed_pin(nid))
2766 continue;
2767 /* search for an empty channel */
2768 for (j = 0; j < cfg->line_outs; j++) {
2769 if (! assigned[j]) {
2770 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2771 assigned[j] = 1;
2772 break;
2773 }
2774 }
2775 }
2776 spec->multiout.num_dacs = cfg->line_outs;
2777 return 0;
2778}
2779
2780/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002781static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2782 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783{
2784 char name[32];
2785 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2786 hda_nid_t nid;
2787 int i, err;
2788
2789 for (i = 0; i < cfg->line_outs; i++) {
2790 if (! spec->multiout.dac_nids[i])
2791 continue;
2792 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2793 if (i == 2) {
2794 /* Center/LFE */
2795 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2796 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2797 return err;
2798 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2799 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2800 return err;
2801 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2802 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2803 return err;
2804 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2805 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2806 return err;
2807 } else {
2808 sprintf(name, "%s Playback Volume", chname[i]);
2809 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2810 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2811 return err;
2812 sprintf(name, "%s Playback Switch", chname[i]);
2813 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2814 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2815 return err;
2816 }
2817 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 return 0;
2819}
2820
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002821/* add playback controls for speaker and HP outputs */
2822static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2823 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824{
2825 hda_nid_t nid;
2826 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002827 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828
2829 if (! pin)
2830 return 0;
2831
2832 if (alc880_is_fixed_pin(pin)) {
2833 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002834 /* specify the DAC as the extra output */
2835 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002837 else
2838 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 /* control HP volume/switch on the output mixer amp */
2840 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002841 sprintf(name, "%s Playback Volume", pfx);
2842 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002843 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2844 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002845 sprintf(name, "%s Playback Switch", pfx);
2846 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002847 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2848 return err;
2849 } else if (alc880_is_multi_pin(pin)) {
2850 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002851 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002852 sprintf(name, "%s Playback Switch", pfx);
2853 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002854 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2855 return err;
2856 }
2857 return 0;
2858}
2859
2860/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002861static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2862 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863{
2864 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002865 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866
2867 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002869 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 return err;
2871 sprintf(name, "%s Playback Switch", ctlname);
2872 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002873 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002874 return err;
2875 return 0;
2876}
2877
2878/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002879static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2880 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002881{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002883 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884
2885 for (i = 0; i < AUTO_PIN_LAST; i++) {
2886 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002887 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002888 err = new_analog_input(spec, cfg->input_pins[i],
2889 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002890 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891 if (err < 0)
2892 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002893 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2895 imux->num_items++;
2896 }
2897 }
2898 return 0;
2899}
2900
Kailang Yangdf694da2005-12-05 19:42:22 +01002901static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2902 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903 int dac_idx)
2904{
2905 /* set as output */
2906 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2907 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2908 /* need the manual connection? */
2909 if (alc880_is_multi_pin(nid)) {
2910 struct alc_spec *spec = codec->spec;
2911 int idx = alc880_multi_pin_idx(nid);
2912 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2913 AC_VERB_SET_CONNECT_SEL,
2914 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2915 }
2916}
2917
2918static void alc880_auto_init_multi_out(struct hda_codec *codec)
2919{
2920 struct alc_spec *spec = codec->spec;
2921 int i;
2922
2923 for (i = 0; i < spec->autocfg.line_outs; i++) {
2924 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2925 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2926 }
2927}
2928
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002929static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930{
2931 struct alc_spec *spec = codec->spec;
2932 hda_nid_t pin;
2933
Takashi Iwai82bc9552006-03-21 11:24:42 +01002934 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002935 if (pin) /* connect to front */
2936 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002937 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002938 if (pin) /* connect to front */
2939 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2940}
2941
2942static void alc880_auto_init_analog_input(struct hda_codec *codec)
2943{
2944 struct alc_spec *spec = codec->spec;
2945 int i;
2946
2947 for (i = 0; i < AUTO_PIN_LAST; i++) {
2948 hda_nid_t nid = spec->autocfg.input_pins[i];
2949 if (alc880_is_input_pin(nid)) {
2950 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2951 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2952 if (nid != ALC880_PIN_CD_NID)
2953 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2954 AMP_OUT_MUTE);
2955 }
2956 }
2957}
2958
2959/* parse the BIOS configuration and set up the alc_spec */
2960/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2961static int alc880_parse_auto_config(struct hda_codec *codec)
2962{
2963 struct alc_spec *spec = codec->spec;
2964 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002965 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966
Kailang Yangdf694da2005-12-05 19:42:22 +01002967 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2968 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002970 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002971 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002972
2973 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2974 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002975 (err = alc880_auto_create_extra_out(spec,
2976 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002977 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002978 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002979 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002980 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2981 return err;
2982
2983 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2984
2985 if (spec->autocfg.dig_out_pin)
2986 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2987 if (spec->autocfg.dig_in_pin)
2988 spec->dig_in_nid = ALC880_DIGIN_NID;
2989
2990 if (spec->kctl_alloc)
2991 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2992
2993 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2994
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002995 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 spec->input_mux = &spec->private_imux;
2997
2998 return 1;
2999}
3000
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003001/* additional initialization for auto-configuration model */
3002static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003005 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003006 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007}
3008
3009/*
3010 * OK, here we have finally the patch for ALC880
3011 */
3012
Linus Torvalds1da177e2005-04-16 15:20:36 -07003013static int patch_alc880(struct hda_codec *codec)
3014{
3015 struct alc_spec *spec;
3016 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003017 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003019 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 if (spec == NULL)
3021 return -ENOMEM;
3022
3023 codec->spec = spec;
3024
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003025 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3026 alc880_models,
3027 alc880_cfg_tbl);
3028 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003029 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3030 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003032 }
3033
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 if (board_config == ALC880_AUTO) {
3035 /* automatic parse from the BIOS config */
3036 err = alc880_parse_auto_config(codec);
3037 if (err < 0) {
3038 alc_free(codec);
3039 return err;
3040 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003041 printk(KERN_INFO
3042 "hda_codec: Cannot set up configuration "
3043 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003044 board_config = ALC880_3ST;
3045 }
3046 }
3047
Kailang Yangdf694da2005-12-05 19:42:22 +01003048 if (board_config != ALC880_AUTO)
3049 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050
3051 spec->stream_name_analog = "ALC880 Analog";
3052 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3053 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3054
3055 spec->stream_name_digital = "ALC880 Digital";
3056 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3057 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 if (! spec->adc_nids && spec->input_mux) {
3060 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003061 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003062 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3063 if (wcap != AC_WID_AUD_IN) {
3064 spec->adc_nids = alc880_adc_nids_alt;
3065 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3066 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3067 spec->num_mixers++;
3068 } else {
3069 spec->adc_nids = alc880_adc_nids;
3070 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3071 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3072 spec->num_mixers++;
3073 }
3074 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075
3076 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003078 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003079
3080 return 0;
3081}
3082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003083
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084/*
3085 * ALC260 support
3086 */
3087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088static hda_nid_t alc260_dac_nids[1] = {
3089 /* front */
3090 0x02,
3091};
3092
3093static hda_nid_t alc260_adc_nids[1] = {
3094 /* ADC0 */
3095 0x04,
3096};
3097
Kailang Yangdf694da2005-12-05 19:42:22 +01003098static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099 /* ADC1 */
3100 0x05,
3101};
3102
Kailang Yangdf694da2005-12-05 19:42:22 +01003103static hda_nid_t alc260_hp_adc_nids[2] = {
3104 /* ADC1, 0 */
3105 0x05, 0x04
3106};
3107
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003108/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3109 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3110 */
3111static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003112 /* ADC0, ADC1 */
3113 0x04, 0x05
3114};
3115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116#define ALC260_DIGOUT_NID 0x03
3117#define ALC260_DIGIN_NID 0x06
3118
3119static struct hda_input_mux alc260_capture_source = {
3120 .num_items = 4,
3121 .items = {
3122 { "Mic", 0x0 },
3123 { "Front Mic", 0x1 },
3124 { "Line", 0x2 },
3125 { "CD", 0x4 },
3126 },
3127};
3128
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003129/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003130 * headphone jack and the internal CD lines since these are the only pins at
3131 * which audio can appear. For flexibility, also allow the option of
3132 * recording the mixer output on the second ADC (ADC0 doesn't have a
3133 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003134 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003135static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3136 {
3137 .num_items = 3,
3138 .items = {
3139 { "Mic/Line", 0x0 },
3140 { "CD", 0x4 },
3141 { "Headphone", 0x2 },
3142 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003143 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003144 {
3145 .num_items = 4,
3146 .items = {
3147 { "Mic/Line", 0x0 },
3148 { "CD", 0x4 },
3149 { "Headphone", 0x2 },
3150 { "Mixer", 0x5 },
3151 },
3152 },
3153
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003154};
3155
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003156/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3157 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003158 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003159static struct hda_input_mux alc260_acer_capture_sources[2] = {
3160 {
3161 .num_items = 4,
3162 .items = {
3163 { "Mic", 0x0 },
3164 { "Line", 0x2 },
3165 { "CD", 0x4 },
3166 { "Headphone", 0x5 },
3167 },
3168 },
3169 {
3170 .num_items = 5,
3171 .items = {
3172 { "Mic", 0x0 },
3173 { "Line", 0x2 },
3174 { "CD", 0x4 },
3175 { "Headphone", 0x6 },
3176 { "Mixer", 0x5 },
3177 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003178 },
3179};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003180/*
3181 * This is just place-holder, so there's something for alc_build_pcms to look
3182 * at when it calculates the maximum number of channels. ALC260 has no mixer
3183 * element which allows changing the channel mode, so the verb list is
3184 * never used.
3185 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003186static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003187 { 2, NULL },
3188};
3189
Kailang Yangdf694da2005-12-05 19:42:22 +01003190
3191/* Mixer combinations
3192 *
3193 * basic: base_output + input + pc_beep + capture
3194 * HP: base_output + input + capture_alt
3195 * HP_3013: hp_3013 + input + capture
3196 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003197 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003198 */
3199
3200static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003201 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003202 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003203 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3204 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3205 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3206 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3207 { } /* end */
3208};
3209
3210static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003211 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3212 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3213 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3214 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3216 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3218 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219 { } /* end */
3220};
3221
Kailang Yangdf694da2005-12-05 19:42:22 +01003222static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3223 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3224 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3225 { } /* end */
3226};
3227
3228static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3229 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3230 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3231 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3232 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3233 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3234 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3235 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3236 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003237 { } /* end */
3238};
3239
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003240/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3241 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3242 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003243static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003244 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003245 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003246 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003247 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3248 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3249 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3250 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003251 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003252 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3253 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3254 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003255 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003256 { } /* end */
3257};
3258
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003259/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3260 * versions of the ALC260 don't act on requests to enable mic bias from NID
3261 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3262 * datasheet doesn't mention this restriction. At this stage it's not clear
3263 * whether this behaviour is intentional or is a hardware bug in chip
3264 * revisions available in early 2006. Therefore for now allow the
3265 * "Headphone Jack Mode" control to span all choices, but if it turns out
3266 * that the lack of mic bias for this NID is intentional we could change the
3267 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3268 *
3269 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3270 * don't appear to make the mic bias available from the "line" jack, even
3271 * though the NID used for this jack (0x14) can supply it. The theory is
3272 * that perhaps Acer have included blocking capacitors between the ALC260
3273 * and the output jack. If this turns out to be the case for all such
3274 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3275 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003276 *
3277 * The C20x Tablet series have a mono internal speaker which is controlled
3278 * via the chip's Mono sum widget and pin complex, so include the necessary
3279 * controls for such models. On models without a "mono speaker" the control
3280 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003281 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003282static struct snd_kcontrol_new alc260_acer_mixer[] = {
3283 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3284 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003285 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003286 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3287 HDA_OUTPUT),
3288 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3289 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003290 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3291 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3293 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3294 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3295 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3296 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3297 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3298 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3299 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3300 { } /* end */
3301};
3302
Kailang Yangdf694da2005-12-05 19:42:22 +01003303/* capture mixer elements */
3304static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003305 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3306 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003307 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3308 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003309 {
3310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003311 /* The multiple "Capture Source" controls confuse alsamixer
3312 * So call somewhat different..
3313 * FIXME: the controls appear in the "playback" view!
3314 */
3315 /* .name = "Capture Source", */
3316 .name = "Input Source",
3317 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003318 .info = alc_mux_enum_info,
3319 .get = alc_mux_enum_get,
3320 .put = alc_mux_enum_put,
3321 },
3322 { } /* end */
3323};
3324
Kailang Yangdf694da2005-12-05 19:42:22 +01003325static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3326 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3327 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3328 {
3329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3330 /* The multiple "Capture Source" controls confuse alsamixer
3331 * So call somewhat different..
3332 * FIXME: the controls appear in the "playback" view!
3333 */
3334 /* .name = "Capture Source", */
3335 .name = "Input Source",
3336 .count = 1,
3337 .info = alc_mux_enum_info,
3338 .get = alc_mux_enum_get,
3339 .put = alc_mux_enum_put,
3340 },
3341 { } /* end */
3342};
3343
3344/*
3345 * initialization verbs
3346 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003347static struct hda_verb alc260_init_verbs[] = {
3348 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003351 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003354 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003355 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003357 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003358 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003359 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003361 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003363 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003365 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3366 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003368 /* set connection select to line in (default select for this ADC) */
3369 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003370 /* mute capture amp left and right */
3371 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3372 /* set connection select to line in (default select for this ADC) */
3373 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003374 /* set vol=0 Line-Out mixer amp left and right */
3375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3376 /* unmute pin widget amp left and right (no gain on this amp) */
3377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3378 /* set vol=0 HP mixer amp left and right */
3379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3380 /* unmute pin widget amp left and right (no gain on this amp) */
3381 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* set vol=0 Mono mixer amp left and right */
3383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3384 /* unmute pin widget amp left and right (no gain on this amp) */
3385 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3386 /* unmute LINE-2 out pin */
3387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003388 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003389 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003391 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003393 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003395 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003396 /* mute Front out path */
3397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3398 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3399 /* mute Headphone out path */
3400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3402 /* mute Mono out path */
3403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3404 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405 { }
3406};
3407
Takashi Iwai474167d2006-05-17 17:17:43 +02003408#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003409static struct hda_verb alc260_hp_init_verbs[] = {
3410 /* Headphone and output */
3411 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3412 /* mono output */
3413 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3414 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3415 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3416 /* Mic2 (front panel) pin widget for input and vref at 80% */
3417 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3418 /* Line In pin widget for input */
3419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3420 /* Line-2 pin widget for output */
3421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3422 /* CD pin widget for input */
3423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3424 /* unmute amp left and right */
3425 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3426 /* set connection select to line in (default select for this ADC) */
3427 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3428 /* unmute Line-Out mixer amp left and right (volume = 0) */
3429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3430 /* mute pin widget amp left and right (no gain on this amp) */
3431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3432 /* unmute HP mixer amp left and right (volume = 0) */
3433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3434 /* mute pin widget amp left and right (no gain on this amp) */
3435 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3436 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3437 /* unmute CD */
3438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3439 /* unmute Line In */
3440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3441 /* unmute Mic */
3442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3443 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3444 /* Unmute Front out path */
3445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3447 /* Unmute Headphone out path */
3448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3450 /* Unmute Mono out path */
3451 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3453 { }
3454};
Takashi Iwai474167d2006-05-17 17:17:43 +02003455#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003456
3457static struct hda_verb alc260_hp_3013_init_verbs[] = {
3458 /* Line out and output */
3459 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3460 /* mono output */
3461 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3462 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3464 /* Mic2 (front panel) pin widget for input and vref at 80% */
3465 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3466 /* Line In pin widget for input */
3467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3468 /* Headphone pin widget for output */
3469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3470 /* CD pin widget for input */
3471 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3472 /* unmute amp left and right */
3473 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3474 /* set connection select to line in (default select for this ADC) */
3475 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3476 /* unmute Line-Out mixer amp left and right (volume = 0) */
3477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3478 /* mute pin widget amp left and right (no gain on this amp) */
3479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3480 /* unmute HP mixer amp left and right (volume = 0) */
3481 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3482 /* mute pin widget amp left and right (no gain on this amp) */
3483 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3484 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3485 /* unmute CD */
3486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3487 /* unmute Line In */
3488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3489 /* unmute Mic */
3490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3491 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3492 /* Unmute Front out path */
3493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3495 /* Unmute Headphone out path */
3496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3498 /* Unmute Mono out path */
3499 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3500 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3501 { }
3502};
3503
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003504/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003505 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3506 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003507 */
3508static struct hda_verb alc260_fujitsu_init_verbs[] = {
3509 /* Disable all GPIOs */
3510 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3511 /* Internal speaker is connected to headphone pin */
3512 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3513 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003515 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3516 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3517 /* Ensure all other unused pins are disabled and muted. */
3518 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003520 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003521 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003522 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003523 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003526
Jonathan Woithef7ace402006-02-28 11:46:14 +01003527 /* Disable digital (SPDIF) pins */
3528 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3529 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003530
Jonathan Woithef7ace402006-02-28 11:46:14 +01003531 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3532 * when acting as an output.
3533 */
3534 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3535
3536 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3544 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3545 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003546
Jonathan Woithef7ace402006-02-28 11:46:14 +01003547 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3548 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549 /* Unmute Line1 pin widget output buffer since it starts as an output.
3550 * If the pin mode is changed by the user the pin mode control will
3551 * take care of enabling the pin's input/output buffers as needed.
3552 * Therefore there's no need to enable the input buffer at this
3553 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003554 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003556 /* Unmute input buffer of pin widget used for Line-in (no equiv
3557 * mixer ctrl)
3558 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003559 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003560
Jonathan Woithef7ace402006-02-28 11:46:14 +01003561 /* Mute capture amp left and right */
3562 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3563 /* Set ADC connection select to match default mixer setting - line
3564 * in (on mic1 pin)
3565 */
3566 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003567
Jonathan Woithef7ace402006-02-28 11:46:14 +01003568 /* Do the same for the second ADC: mute capture input amp and
3569 * set ADC connection to line in (on mic1 pin)
3570 */
3571 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3572 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003573
Jonathan Woithef7ace402006-02-28 11:46:14 +01003574 /* Mute all inputs to mixer widget (even unconnected ones) */
3575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003583
3584 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003585};
3586
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003587/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3588 * similar laptops (adapted from Fujitsu init verbs).
3589 */
3590static struct hda_verb alc260_acer_init_verbs[] = {
3591 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3592 * the headphone jack. Turn this on and rely on the standard mute
3593 * methods whenever the user wants to turn these outputs off.
3594 */
3595 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3596 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3597 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3598 /* Internal speaker/Headphone jack is connected to Line-out pin */
3599 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3600 /* Internal microphone/Mic jack is connected to Mic1 pin */
3601 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3602 /* Line In jack is connected to Line1 pin */
3603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003604 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3605 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003606 /* Ensure all other unused pins are disabled and muted. */
3607 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3608 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003609 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3610 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3612 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3613 /* Disable digital (SPDIF) pins */
3614 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3615 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3616
3617 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3618 * bus when acting as outputs.
3619 */
3620 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3621 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3622
3623 /* Start with output sum widgets muted and their output gains at min */
3624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3626 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3630 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3631 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3632 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3633
3634 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003636 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3637 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003638 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3639 * inputs. If the pin mode is changed by the user the pin mode control
3640 * will take care of enabling the pin's input/output buffers as needed.
3641 * Therefore there's no need to enable the input buffer at this
3642 * stage.
3643 */
3644 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3646
3647 /* Mute capture amp left and right */
3648 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3649 /* Set ADC connection select to match default mixer setting - mic
3650 * (on mic1 pin)
3651 */
3652 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3653
3654 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003655 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003656 */
3657 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003658 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003659
3660 /* Mute all inputs to mixer widget (even unconnected ones) */
3661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3669
3670 { }
3671};
3672
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003673/* Test configuration for debugging, modelled after the ALC880 test
3674 * configuration.
3675 */
3676#ifdef CONFIG_SND_DEBUG
3677static hda_nid_t alc260_test_dac_nids[1] = {
3678 0x02,
3679};
3680static hda_nid_t alc260_test_adc_nids[2] = {
3681 0x04, 0x05,
3682};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003683/* For testing the ALC260, each input MUX needs its own definition since
3684 * the signal assignments are different. This assumes that the first ADC
3685 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003686 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003687static struct hda_input_mux alc260_test_capture_sources[2] = {
3688 {
3689 .num_items = 7,
3690 .items = {
3691 { "MIC1 pin", 0x0 },
3692 { "MIC2 pin", 0x1 },
3693 { "LINE1 pin", 0x2 },
3694 { "LINE2 pin", 0x3 },
3695 { "CD pin", 0x4 },
3696 { "LINE-OUT pin", 0x5 },
3697 { "HP-OUT pin", 0x6 },
3698 },
3699 },
3700 {
3701 .num_items = 8,
3702 .items = {
3703 { "MIC1 pin", 0x0 },
3704 { "MIC2 pin", 0x1 },
3705 { "LINE1 pin", 0x2 },
3706 { "LINE2 pin", 0x3 },
3707 { "CD pin", 0x4 },
3708 { "Mixer", 0x5 },
3709 { "LINE-OUT pin", 0x6 },
3710 { "HP-OUT pin", 0x7 },
3711 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003712 },
3713};
3714static struct snd_kcontrol_new alc260_test_mixer[] = {
3715 /* Output driver widgets */
3716 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3717 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3718 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3719 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3720 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3721 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3722
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003723 /* Modes for retasking pin widgets
3724 * Note: the ALC260 doesn't seem to act on requests to enable mic
3725 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3726 * mention this restriction. At this stage it's not clear whether
3727 * this behaviour is intentional or is a hardware bug in chip
3728 * revisions available at least up until early 2006. Therefore for
3729 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3730 * choices, but if it turns out that the lack of mic bias for these
3731 * NIDs is intentional we could change their modes from
3732 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3733 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003734 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3735 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3736 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3737 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3738 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3739 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3740
3741 /* Loopback mixer controls */
3742 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3743 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3744 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3745 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3746 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3747 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3748 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3749 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3750 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3751 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3752 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3753 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3754 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3755 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3756 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3757 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003758
3759 /* Controls for GPIO pins, assuming they are configured as outputs */
3760 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3761 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3762 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3763 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3764
Jonathan Woithe92621f12006-02-28 11:47:47 +01003765 /* Switches to allow the digital IO pins to be enabled. The datasheet
3766 * is ambigious as to which NID is which; testing on laptops which
3767 * make this output available should provide clarification.
3768 */
3769 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3770 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3771
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003772 { } /* end */
3773};
3774static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003775 /* Enable all GPIOs as outputs with an initial value of 0 */
3776 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3777 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3778 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3779
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003780 /* Enable retasking pins as output, initially without power amp */
3781 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3782 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3785 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3786 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3787
Jonathan Woithe92621f12006-02-28 11:47:47 +01003788 /* Disable digital (SPDIF) pins initially, but users can enable
3789 * them via a mixer switch. In the case of SPDIF-out, this initverb
3790 * payload also sets the generation to 0, output to be in "consumer"
3791 * PCM format, copyright asserted, no pre-emphasis and no validity
3792 * control.
3793 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003794 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3795 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3796
Jonathan Woithef7ace402006-02-28 11:46:14 +01003797 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003798 * OUT1 sum bus when acting as an output.
3799 */
3800 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3801 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3802 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3803 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3804
3805 /* Start with output sum widgets muted and their output gains at min */
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3812 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3813 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3815
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003816 /* Unmute retasking pin widget output buffers since the default
3817 * state appears to be output. As the pin mode is changed by the
3818 * user the pin mode control will take care of enabling the pin's
3819 * input/output buffers as needed.
3820 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003821 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3825 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3826 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3827 /* Also unmute the mono-out pin widget */
3828 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3829
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003830 /* Mute capture amp left and right */
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003832 /* Set ADC connection select to match default mixer setting (mic1
3833 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003834 */
3835 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3836
3837 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003838 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01003839 */
3840 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3841 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3842
3843 /* Mute all inputs to mixer widget (even unconnected ones) */
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3852
3853 { }
3854};
3855#endif
3856
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857static struct hda_pcm_stream alc260_pcm_analog_playback = {
3858 .substreams = 1,
3859 .channels_min = 2,
3860 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861};
3862
3863static struct hda_pcm_stream alc260_pcm_analog_capture = {
3864 .substreams = 1,
3865 .channels_min = 2,
3866 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867};
3868
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003869#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3870#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3871
Kailang Yangdf694da2005-12-05 19:42:22 +01003872/*
3873 * for BIOS auto-configuration
3874 */
3875
3876static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3877 const char *pfx)
3878{
3879 hda_nid_t nid_vol;
3880 unsigned long vol_val, sw_val;
3881 char name[32];
3882 int err;
3883
3884 if (nid >= 0x0f && nid < 0x11) {
3885 nid_vol = nid - 0x7;
3886 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3887 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3888 } else if (nid == 0x11) {
3889 nid_vol = nid - 0x7;
3890 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3891 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3892 } else if (nid >= 0x12 && nid <= 0x15) {
3893 nid_vol = 0x08;
3894 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3895 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3896 } else
3897 return 0; /* N/A */
3898
3899 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3900 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3901 return err;
3902 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3903 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3904 return err;
3905 return 1;
3906}
3907
3908/* add playback controls from the parsed DAC table */
3909static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3910 const struct auto_pin_cfg *cfg)
3911{
3912 hda_nid_t nid;
3913 int err;
3914
3915 spec->multiout.num_dacs = 1;
3916 spec->multiout.dac_nids = spec->private_dac_nids;
3917 spec->multiout.dac_nids[0] = 0x02;
3918
3919 nid = cfg->line_out_pins[0];
3920 if (nid) {
3921 err = alc260_add_playback_controls(spec, nid, "Front");
3922 if (err < 0)
3923 return err;
3924 }
3925
Takashi Iwai82bc9552006-03-21 11:24:42 +01003926 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003927 if (nid) {
3928 err = alc260_add_playback_controls(spec, nid, "Speaker");
3929 if (err < 0)
3930 return err;
3931 }
3932
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003933 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003934 if (nid) {
3935 err = alc260_add_playback_controls(spec, nid, "Headphone");
3936 if (err < 0)
3937 return err;
3938 }
3939 return 0;
3940}
3941
3942/* create playback/capture controls for input pins */
3943static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3944 const struct auto_pin_cfg *cfg)
3945{
Kailang Yangdf694da2005-12-05 19:42:22 +01003946 struct hda_input_mux *imux = &spec->private_imux;
3947 int i, err, idx;
3948
3949 for (i = 0; i < AUTO_PIN_LAST; i++) {
3950 if (cfg->input_pins[i] >= 0x12) {
3951 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003952 err = new_analog_input(spec, cfg->input_pins[i],
3953 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003954 if (err < 0)
3955 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003956 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003957 imux->items[imux->num_items].index = idx;
3958 imux->num_items++;
3959 }
3960 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3961 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003962 err = new_analog_input(spec, cfg->input_pins[i],
3963 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003964 if (err < 0)
3965 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003966 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003967 imux->items[imux->num_items].index = idx;
3968 imux->num_items++;
3969 }
3970 }
3971 return 0;
3972}
3973
3974static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3975 hda_nid_t nid, int pin_type,
3976 int sel_idx)
3977{
3978 /* set as output */
3979 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3980 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3981 /* need the manual connection? */
3982 if (nid >= 0x12) {
3983 int idx = nid - 0x12;
3984 snd_hda_codec_write(codec, idx + 0x0b, 0,
3985 AC_VERB_SET_CONNECT_SEL, sel_idx);
3986
3987 }
3988}
3989
3990static void alc260_auto_init_multi_out(struct hda_codec *codec)
3991{
3992 struct alc_spec *spec = codec->spec;
3993 hda_nid_t nid;
3994
3995 nid = spec->autocfg.line_out_pins[0];
3996 if (nid)
3997 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3998
Takashi Iwai82bc9552006-03-21 11:24:42 +01003999 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004000 if (nid)
4001 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4002
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004003 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004004 if (nid)
4005 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4006}
4007
4008#define ALC260_PIN_CD_NID 0x16
4009static void alc260_auto_init_analog_input(struct hda_codec *codec)
4010{
4011 struct alc_spec *spec = codec->spec;
4012 int i;
4013
4014 for (i = 0; i < AUTO_PIN_LAST; i++) {
4015 hda_nid_t nid = spec->autocfg.input_pins[i];
4016 if (nid >= 0x12) {
4017 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4018 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4019 if (nid != ALC260_PIN_CD_NID)
4020 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4021 AMP_OUT_MUTE);
4022 }
4023 }
4024}
4025
4026/*
4027 * generic initialization of ADC, input mixers and output mixers
4028 */
4029static struct hda_verb alc260_volume_init_verbs[] = {
4030 /*
4031 * Unmute ADC0-1 and set the default input to mic-in
4032 */
4033 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4034 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4035 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4037
4038 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4039 * mixer widget
4040 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4041 * mic (mic 2)
4042 */
4043 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4049
4050 /*
4051 * Set up output mixers (0x08 - 0x0a)
4052 */
4053 /* set vol=0 to output mixers */
4054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4055 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4056 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4057 /* set up input amps for analog loopback */
4058 /* Amp Indices: DAC = 0, mixer = 1 */
4059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4063 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4065
4066 { }
4067};
4068
4069static int alc260_parse_auto_config(struct hda_codec *codec)
4070{
4071 struct alc_spec *spec = codec->spec;
4072 unsigned int wcap;
4073 int err;
4074 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4075
4076 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4077 alc260_ignore)) < 0)
4078 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004079 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4080 return err;
4081 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004082 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004083 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004084 return err;
4085
4086 spec->multiout.max_channels = 2;
4087
4088 if (spec->autocfg.dig_out_pin)
4089 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4090 if (spec->kctl_alloc)
4091 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4092
4093 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4094
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004095 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004096 spec->input_mux = &spec->private_imux;
4097
4098 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004099 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004100 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4101 if (wcap != AC_WID_AUD_IN) {
4102 spec->adc_nids = alc260_adc_nids_alt;
4103 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4104 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004105 } else {
4106 spec->adc_nids = alc260_adc_nids;
4107 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4108 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004109 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004110 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004111
4112 return 1;
4113}
4114
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004115/* additional initialization for auto-configuration model */
4116static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004117{
Kailang Yangdf694da2005-12-05 19:42:22 +01004118 alc260_auto_init_multi_out(codec);
4119 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004120}
4121
4122/*
4123 * ALC260 configurations
4124 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004125static const char *alc260_models[ALC260_MODEL_LAST] = {
4126 [ALC260_BASIC] = "basic",
4127 [ALC260_HP] = "hp",
4128 [ALC260_HP_3013] = "hp-3013",
4129 [ALC260_FUJITSU_S702X] = "fujitsu",
4130 [ALC260_ACER] = "acer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004131#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004132 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004133#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 [ALC260_AUTO] = "auto",
4135};
4136
4137static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004138 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004139 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4140 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4141 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4142 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4143 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4144 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4145 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4146 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4147 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4148 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4149 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4150 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4151 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Takashi Iwai16ded522005-06-10 19:58:24 +02004152 {}
4153};
4154
Kailang Yangdf694da2005-12-05 19:42:22 +01004155static struct alc_config_preset alc260_presets[] = {
4156 [ALC260_BASIC] = {
4157 .mixers = { alc260_base_output_mixer,
4158 alc260_input_mixer,
4159 alc260_pc_beep_mixer,
4160 alc260_capture_mixer },
4161 .init_verbs = { alc260_init_verbs },
4162 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4163 .dac_nids = alc260_dac_nids,
4164 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4165 .adc_nids = alc260_adc_nids,
4166 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4167 .channel_mode = alc260_modes,
4168 .input_mux = &alc260_capture_source,
4169 },
4170 [ALC260_HP] = {
4171 .mixers = { alc260_base_output_mixer,
4172 alc260_input_mixer,
4173 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004174 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004175 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4176 .dac_nids = alc260_dac_nids,
4177 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4178 .adc_nids = alc260_hp_adc_nids,
4179 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4180 .channel_mode = alc260_modes,
4181 .input_mux = &alc260_capture_source,
4182 },
4183 [ALC260_HP_3013] = {
4184 .mixers = { alc260_hp_3013_mixer,
4185 alc260_input_mixer,
4186 alc260_capture_alt_mixer },
4187 .init_verbs = { alc260_hp_3013_init_verbs },
4188 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4189 .dac_nids = alc260_dac_nids,
4190 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4191 .adc_nids = alc260_hp_adc_nids,
4192 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4193 .channel_mode = alc260_modes,
4194 .input_mux = &alc260_capture_source,
4195 },
4196 [ALC260_FUJITSU_S702X] = {
4197 .mixers = { alc260_fujitsu_mixer,
4198 alc260_capture_mixer },
4199 .init_verbs = { alc260_fujitsu_init_verbs },
4200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4201 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004202 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4203 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4205 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004206 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4207 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004208 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004209 [ALC260_ACER] = {
4210 .mixers = { alc260_acer_mixer,
4211 alc260_capture_mixer },
4212 .init_verbs = { alc260_acer_init_verbs },
4213 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4214 .dac_nids = alc260_dac_nids,
4215 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4216 .adc_nids = alc260_dual_adc_nids,
4217 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4218 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004219 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4220 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004221 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004222#ifdef CONFIG_SND_DEBUG
4223 [ALC260_TEST] = {
4224 .mixers = { alc260_test_mixer,
4225 alc260_capture_mixer },
4226 .init_verbs = { alc260_test_init_verbs },
4227 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4228 .dac_nids = alc260_test_dac_nids,
4229 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4230 .adc_nids = alc260_test_adc_nids,
4231 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4232 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004233 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4234 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004235 },
4236#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004237};
4238
Linus Torvalds1da177e2005-04-16 15:20:36 -07004239static int patch_alc260(struct hda_codec *codec)
4240{
4241 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004242 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004244 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004245 if (spec == NULL)
4246 return -ENOMEM;
4247
4248 codec->spec = spec;
4249
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004250 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4251 alc260_models,
4252 alc260_cfg_tbl);
4253 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004254 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4255 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004256 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004257 }
4258
Kailang Yangdf694da2005-12-05 19:42:22 +01004259 if (board_config == ALC260_AUTO) {
4260 /* automatic parse from the BIOS config */
4261 err = alc260_parse_auto_config(codec);
4262 if (err < 0) {
4263 alc_free(codec);
4264 return err;
4265 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004266 printk(KERN_INFO
4267 "hda_codec: Cannot set up configuration "
4268 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004269 board_config = ALC260_BASIC;
4270 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004271 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004272
Kailang Yangdf694da2005-12-05 19:42:22 +01004273 if (board_config != ALC260_AUTO)
4274 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004275
4276 spec->stream_name_analog = "ALC260 Analog";
4277 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4278 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4279
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004280 spec->stream_name_digital = "ALC260 Digital";
4281 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4282 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4283
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004285 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004286 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004287
4288 return 0;
4289}
4290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291
Linus Torvalds1da177e2005-04-16 15:20:36 -07004292/*
4293 * ALC882 support
4294 *
4295 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4296 * configuration. Each pin widget can choose any input DACs and a mixer.
4297 * Each ADC is connected from a mixer of all inputs. This makes possible
4298 * 6-channel independent captures.
4299 *
4300 * In addition, an independent DAC for the multi-playback (not used in this
4301 * driver yet).
4302 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004303#define ALC882_DIGOUT_NID 0x06
4304#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004305
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004306static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307 { 8, NULL }
4308};
4309
4310static hda_nid_t alc882_dac_nids[4] = {
4311 /* front, rear, clfe, rear_surr */
4312 0x02, 0x03, 0x04, 0x05
4313};
4314
Kailang Yangdf694da2005-12-05 19:42:22 +01004315/* identical with ALC880 */
4316#define alc882_adc_nids alc880_adc_nids
4317#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004318
4319/* input MUX */
4320/* FIXME: should be a matrix-type input source selection */
4321
4322static struct hda_input_mux alc882_capture_source = {
4323 .num_items = 4,
4324 .items = {
4325 { "Mic", 0x0 },
4326 { "Front Mic", 0x1 },
4327 { "Line", 0x2 },
4328 { "CD", 0x4 },
4329 },
4330};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004331#define alc882_mux_enum_info alc_mux_enum_info
4332#define alc882_mux_enum_get alc_mux_enum_get
4333
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004334static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004335{
4336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4337 struct alc_spec *spec = codec->spec;
4338 const struct hda_input_mux *imux = spec->input_mux;
4339 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4340 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4341 hda_nid_t nid = capture_mixers[adc_idx];
4342 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4343 unsigned int i, idx;
4344
4345 idx = ucontrol->value.enumerated.item[0];
4346 if (idx >= imux->num_items)
4347 idx = imux->num_items - 1;
4348 if (*cur_val == idx && ! codec->in_resume)
4349 return 0;
4350 for (i = 0; i < imux->num_items; i++) {
4351 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4352 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4353 v | (imux->items[i].index << 8));
4354 }
4355 *cur_val = idx;
4356 return 1;
4357}
4358
Kailang Yangdf694da2005-12-05 19:42:22 +01004359/*
4360 * 6ch mode
4361 */
4362static struct hda_verb alc882_sixstack_ch6_init[] = {
4363 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4364 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4365 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4366 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4367 { } /* end */
4368};
4369
4370/*
4371 * 8ch mode
4372 */
4373static struct hda_verb alc882_sixstack_ch8_init[] = {
4374 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4376 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4377 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4378 { } /* end */
4379};
4380
4381static struct hda_channel_mode alc882_sixstack_modes[2] = {
4382 { 6, alc882_sixstack_ch6_init },
4383 { 8, alc882_sixstack_ch8_init },
4384};
4385
Linus Torvalds1da177e2005-04-16 15:20:36 -07004386/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4387 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4388 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004389static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004390 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004391 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004392 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004393 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004396 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4397 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004398 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004399 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004400 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4401 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4402 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004406 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004407 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4408 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004409 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004410 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4411 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4412 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004413 { } /* end */
4414};
4415
Kailang Yangdf694da2005-12-05 19:42:22 +01004416static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4417 {
4418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4419 .name = "Channel Mode",
4420 .info = alc_ch_mode_info,
4421 .get = alc_ch_mode_get,
4422 .put = alc_ch_mode_put,
4423 },
4424 { } /* end */
4425};
4426
Linus Torvalds1da177e2005-04-16 15:20:36 -07004427static struct hda_verb alc882_init_verbs[] = {
4428 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004432 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004437 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004440 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4442 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4443 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004448 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004454 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004456 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004458 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004459 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004460 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004462 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4464 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004465 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4467 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4470 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4472 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4473 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004474 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004476
4477 /* FIXME: use matrix-type input source selection */
4478 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4479 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004484 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004489 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4494 /* ADC1: mute amp left and right */
4495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004496 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004497 /* ADC2: mute amp left and right */
4498 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004499 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004500 /* ADC3: mute amp left and right */
4501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004502 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004503
4504 { }
4505};
4506
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004507static struct hda_verb alc882_eapd_verbs[] = {
4508 /* change to EAPD mode */
4509 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004510 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004511 { }
4512};
4513
Tobin Davis9102cd12006-12-15 10:02:12 +01004514/* Mac Pro test */
4515static struct snd_kcontrol_new alc882_macpro_mixer[] = {
4516 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4517 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4518 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
4519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
4520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
4521 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
4522 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
4523 { } /* end */
4524};
4525
4526static struct hda_verb alc882_macpro_init_verbs[] = {
4527 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4531 /* Front Pin: output 0 (0x0c) */
4532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4534 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
4535 /* Front Mic pin: input vref at 80% */
4536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4537 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4538 /* Speaker: output */
4539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4541 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
4542 /* Headphone output (output 0 - 0x0c) */
4543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4545 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
4546
4547 /* FIXME: use matrix-type input source selection */
4548 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4549 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4554 /* Input mixer2 */
4555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4559 /* Input mixer3 */
4560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4564 /* ADC1: mute amp left and right */
4565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4567 /* ADC2: mute amp left and right */
4568 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4569 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4570 /* ADC3: mute amp left and right */
4571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4572 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4573
4574 { }
4575};
4576static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4577{
4578 unsigned int gpiostate, gpiomask, gpiodir;
4579
4580 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4581 AC_VERB_GET_GPIO_DATA, 0);
4582
4583 if (!muted)
4584 gpiostate |= (1 << pin);
4585 else
4586 gpiostate &= ~(1 << pin);
4587
4588 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4589 AC_VERB_GET_GPIO_MASK, 0);
4590 gpiomask |= (1 << pin);
4591
4592 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4593 AC_VERB_GET_GPIO_DIRECTION, 0);
4594 gpiodir |= (1 << pin);
4595
4596
4597 snd_hda_codec_write(codec, codec->afg, 0,
4598 AC_VERB_SET_GPIO_MASK, gpiomask);
4599 snd_hda_codec_write(codec, codec->afg, 0,
4600 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4601
4602 msleep(1);
4603
4604 snd_hda_codec_write(codec, codec->afg, 0,
4605 AC_VERB_SET_GPIO_DATA, gpiostate);
4606}
4607
Kailang Yangdf694da2005-12-05 19:42:22 +01004608/*
4609 * generic initialization of ADC, input mixers and output mixers
4610 */
4611static struct hda_verb alc882_auto_init_verbs[] = {
4612 /*
4613 * Unmute ADC0-2 and set the default input to mic-in
4614 */
4615 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4617 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4618 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4619 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4620 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4621
4622 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4623 * mixer widget
4624 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4625 * mic (mic 2)
4626 */
4627 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4633
4634 /*
4635 * Set up output mixers (0x0c - 0x0f)
4636 */
4637 /* set vol=0 to output mixers */
4638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4642 /* set up input amps for analog loopback */
4643 /* Amp Indices: DAC = 0, mixer = 1 */
4644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4651 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4652 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4653 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4654
4655 /* FIXME: use matrix-type input source selection */
4656 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4657 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4662 /* Input mixer2 */
4663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4667 /* Input mixer3 */
4668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4672
4673 { }
4674};
4675
4676/* capture mixer elements */
4677static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4678 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4679 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4680 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4681 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4682 {
4683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4684 /* The multiple "Capture Source" controls confuse alsamixer
4685 * So call somewhat different..
4686 * FIXME: the controls appear in the "playback" view!
4687 */
4688 /* .name = "Capture Source", */
4689 .name = "Input Source",
4690 .count = 2,
4691 .info = alc882_mux_enum_info,
4692 .get = alc882_mux_enum_get,
4693 .put = alc882_mux_enum_put,
4694 },
4695 { } /* end */
4696};
4697
4698static struct snd_kcontrol_new alc882_capture_mixer[] = {
4699 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4700 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4701 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4702 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4703 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4704 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4705 {
4706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4707 /* The multiple "Capture Source" controls confuse alsamixer
4708 * So call somewhat different..
4709 * FIXME: the controls appear in the "playback" view!
4710 */
4711 /* .name = "Capture Source", */
4712 .name = "Input Source",
4713 .count = 3,
4714 .info = alc882_mux_enum_info,
4715 .get = alc882_mux_enum_get,
4716 .put = alc882_mux_enum_put,
4717 },
4718 { } /* end */
4719};
4720
4721/* pcm configuration: identiacal with ALC880 */
4722#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4723#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4724#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4725#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4726
4727/*
4728 * configuration and preset
4729 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004730static const char *alc882_models[ALC882_MODEL_LAST] = {
4731 [ALC882_3ST_DIG] = "3stack-dig",
4732 [ALC882_6ST_DIG] = "6stack-dig",
4733 [ALC882_ARIMA] = "arima",
Tobin Davis9102cd12006-12-15 10:02:12 +01004734 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004735 [ALC882_AUTO] = "auto",
4736};
4737
4738static struct snd_pci_quirk alc882_cfg_tbl[] = {
4739 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4740 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4741 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4742 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Tobin Davis7b9470d2006-12-28 13:56:48 +01004743 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangdf694da2005-12-05 19:42:22 +01004744 {}
4745};
4746
4747static struct alc_config_preset alc882_presets[] = {
4748 [ALC882_3ST_DIG] = {
4749 .mixers = { alc882_base_mixer },
4750 .init_verbs = { alc882_init_verbs },
4751 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4752 .dac_nids = alc882_dac_nids,
4753 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004754 .dig_in_nid = ALC882_DIGIN_NID,
4755 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4756 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004757 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004758 .input_mux = &alc882_capture_source,
4759 },
4760 [ALC882_6ST_DIG] = {
4761 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4762 .init_verbs = { alc882_init_verbs },
4763 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4764 .dac_nids = alc882_dac_nids,
4765 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01004766 .dig_in_nid = ALC882_DIGIN_NID,
4767 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4768 .channel_mode = alc882_sixstack_modes,
4769 .input_mux = &alc882_capture_source,
4770 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004771 [ALC882_ARIMA] = {
4772 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4773 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4774 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4775 .dac_nids = alc882_dac_nids,
4776 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4777 .channel_mode = alc882_sixstack_modes,
4778 .input_mux = &alc882_capture_source,
4779 },
Tobin Davis9102cd12006-12-15 10:02:12 +01004780 [ALC885_MACPRO] = {
4781 .mixers = { alc882_macpro_mixer },
4782 .init_verbs = { alc882_macpro_init_verbs },
4783 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4784 .dac_nids = alc882_dac_nids,
4785 .dig_out_nid = ALC882_DIGOUT_NID,
4786 .dig_in_nid = ALC882_DIGIN_NID,
4787 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4788 .channel_mode = alc882_ch_modes,
4789 .input_mux = &alc882_capture_source,
4790 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004791};
4792
4793
4794/*
4795 * BIOS auto configuration
4796 */
4797static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4798 hda_nid_t nid, int pin_type,
4799 int dac_idx)
4800{
4801 /* set as output */
4802 struct alc_spec *spec = codec->spec;
4803 int idx;
4804
4805 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4806 idx = 4;
4807 else
4808 idx = spec->multiout.dac_nids[dac_idx] - 2;
4809
4810 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4811 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4812 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4813
4814}
4815
4816static void alc882_auto_init_multi_out(struct hda_codec *codec)
4817{
4818 struct alc_spec *spec = codec->spec;
4819 int i;
4820
4821 for (i = 0; i <= HDA_SIDE; i++) {
4822 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4823 if (nid)
4824 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4825 }
4826}
4827
4828static void alc882_auto_init_hp_out(struct hda_codec *codec)
4829{
4830 struct alc_spec *spec = codec->spec;
4831 hda_nid_t pin;
4832
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004833 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004834 if (pin) /* connect to front */
4835 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4836}
4837
4838#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4839#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4840
4841static void alc882_auto_init_analog_input(struct hda_codec *codec)
4842{
4843 struct alc_spec *spec = codec->spec;
4844 int i;
4845
4846 for (i = 0; i < AUTO_PIN_LAST; i++) {
4847 hda_nid_t nid = spec->autocfg.input_pins[i];
4848 if (alc882_is_input_pin(nid)) {
4849 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4850 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4851 if (nid != ALC882_PIN_CD_NID)
4852 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4853 AMP_OUT_MUTE);
4854 }
4855 }
4856}
4857
4858/* almost identical with ALC880 parser... */
4859static int alc882_parse_auto_config(struct hda_codec *codec)
4860{
4861 struct alc_spec *spec = codec->spec;
4862 int err = alc880_parse_auto_config(codec);
4863
4864 if (err < 0)
4865 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004866 else if (err > 0)
4867 /* hack - override the init verbs */
4868 spec->init_verbs[0] = alc882_auto_init_verbs;
4869 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004870}
4871
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004872/* additional initialization for auto-configuration model */
4873static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004874{
Kailang Yangdf694da2005-12-05 19:42:22 +01004875 alc882_auto_init_multi_out(codec);
4876 alc882_auto_init_hp_out(codec);
4877 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004878}
4879
Linus Torvalds1da177e2005-04-16 15:20:36 -07004880static int patch_alc882(struct hda_codec *codec)
4881{
4882 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004883 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004884
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004885 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004886 if (spec == NULL)
4887 return -ENOMEM;
4888
Linus Torvalds1da177e2005-04-16 15:20:36 -07004889 codec->spec = spec;
4890
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004891 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
4892 alc882_models,
4893 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004894
Kailang Yangdf694da2005-12-05 19:42:22 +01004895 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004896 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4897 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004898 board_config = ALC882_AUTO;
4899 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004900
Kailang Yangdf694da2005-12-05 19:42:22 +01004901 if (board_config == ALC882_AUTO) {
4902 /* automatic parse from the BIOS config */
4903 err = alc882_parse_auto_config(codec);
4904 if (err < 0) {
4905 alc_free(codec);
4906 return err;
4907 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004908 printk(KERN_INFO
4909 "hda_codec: Cannot set up configuration "
4910 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004911 board_config = ALC882_3ST_DIG;
4912 }
4913 }
4914
4915 if (board_config != ALC882_AUTO)
4916 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004917
Tobin Davis9102cd12006-12-15 10:02:12 +01004918 if (board_config == ALC885_MACPRO) {
4919 alc882_gpio_mute(codec, 0, 0);
4920 alc882_gpio_mute(codec, 1, 0);
4921 }
4922
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004924 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4925 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926
4927 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004928 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4929 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930
Kailang Yangdf694da2005-12-05 19:42:22 +01004931 if (! spec->adc_nids && spec->input_mux) {
4932 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004933 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4935 if (wcap != AC_WID_AUD_IN) {
4936 spec->adc_nids = alc882_adc_nids_alt;
4937 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4938 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4939 spec->num_mixers++;
4940 } else {
4941 spec->adc_nids = alc882_adc_nids;
4942 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4943 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4944 spec->num_mixers++;
4945 }
4946 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004947
4948 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004949 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004950 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004951
4952 return 0;
4953}
4954
4955/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004956 * ALC883 support
4957 *
4958 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4959 * configuration. Each pin widget can choose any input DACs and a mixer.
4960 * Each ADC is connected from a mixer of all inputs. This makes possible
4961 * 6-channel independent captures.
4962 *
4963 * In addition, an independent DAC for the multi-playback (not used in this
4964 * driver yet).
4965 */
4966#define ALC883_DIGOUT_NID 0x06
4967#define ALC883_DIGIN_NID 0x0a
4968
4969static hda_nid_t alc883_dac_nids[4] = {
4970 /* front, rear, clfe, rear_surr */
4971 0x02, 0x04, 0x03, 0x05
4972};
4973
4974static hda_nid_t alc883_adc_nids[2] = {
4975 /* ADC1-2 */
4976 0x08, 0x09,
4977};
4978/* input MUX */
4979/* FIXME: should be a matrix-type input source selection */
4980
4981static struct hda_input_mux alc883_capture_source = {
4982 .num_items = 4,
4983 .items = {
4984 { "Mic", 0x0 },
4985 { "Front Mic", 0x1 },
4986 { "Line", 0x2 },
4987 { "CD", 0x4 },
4988 },
4989};
4990#define alc883_mux_enum_info alc_mux_enum_info
4991#define alc883_mux_enum_get alc_mux_enum_get
4992
4993static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4994 struct snd_ctl_elem_value *ucontrol)
4995{
4996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4997 struct alc_spec *spec = codec->spec;
4998 const struct hda_input_mux *imux = spec->input_mux;
4999 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5000 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5001 hda_nid_t nid = capture_mixers[adc_idx];
5002 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5003 unsigned int i, idx;
5004
5005 idx = ucontrol->value.enumerated.item[0];
5006 if (idx >= imux->num_items)
5007 idx = imux->num_items - 1;
5008 if (*cur_val == idx && ! codec->in_resume)
5009 return 0;
5010 for (i = 0; i < imux->num_items; i++) {
5011 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5012 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5013 v | (imux->items[i].index << 8));
5014 }
5015 *cur_val = idx;
5016 return 1;
5017}
5018/*
5019 * 2ch mode
5020 */
5021static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5022 { 2, NULL }
5023};
5024
5025/*
5026 * 2ch mode
5027 */
5028static struct hda_verb alc883_3ST_ch2_init[] = {
5029 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5030 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5031 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5032 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5033 { } /* end */
5034};
5035
5036/*
5037 * 6ch mode
5038 */
5039static struct hda_verb alc883_3ST_ch6_init[] = {
5040 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5041 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5042 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5043 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5044 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5045 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5046 { } /* end */
5047};
5048
5049static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5050 { 2, alc883_3ST_ch2_init },
5051 { 6, alc883_3ST_ch6_init },
5052};
5053
5054/*
5055 * 6ch mode
5056 */
5057static struct hda_verb alc883_sixstack_ch6_init[] = {
5058 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5059 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5060 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5062 { } /* end */
5063};
5064
5065/*
5066 * 8ch mode
5067 */
5068static struct hda_verb alc883_sixstack_ch8_init[] = {
5069 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5070 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5071 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5072 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5073 { } /* end */
5074};
5075
5076static struct hda_channel_mode alc883_sixstack_modes[2] = {
5077 { 6, alc883_sixstack_ch6_init },
5078 { 8, alc883_sixstack_ch8_init },
5079};
5080
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005081static struct hda_verb alc883_medion_eapd_verbs[] = {
5082 /* eanable EAPD on medion laptop */
5083 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5084 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5085 { }
5086};
5087
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005088/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5089 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5090 */
5091
5092static struct snd_kcontrol_new alc883_base_mixer[] = {
5093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5094 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5095 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5096 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5097 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5098 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5099 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5100 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5101 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5102 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005112 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5114 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5115 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5116 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5117 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5118 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5119 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5120 {
5121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5122 /* .name = "Capture Source", */
5123 .name = "Input Source",
5124 .count = 2,
5125 .info = alc883_mux_enum_info,
5126 .get = alc883_mux_enum_get,
5127 .put = alc883_mux_enum_put,
5128 },
5129 { } /* end */
5130};
5131
5132static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5133 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5134 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005144 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5146 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5147 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5152 {
5153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5154 /* .name = "Capture Source", */
5155 .name = "Input Source",
5156 .count = 2,
5157 .info = alc883_mux_enum_info,
5158 .get = alc883_mux_enum_get,
5159 .put = alc883_mux_enum_put,
5160 },
5161 { } /* end */
5162};
5163
5164static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5168 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5175 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005179 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005182 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5184 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5185 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5186 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5187 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5188 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5189 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5190 {
5191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5192 /* .name = "Capture Source", */
5193 .name = "Input Source",
5194 .count = 2,
5195 .info = alc883_mux_enum_info,
5196 .get = alc883_mux_enum_get,
5197 .put = alc883_mux_enum_put,
5198 },
5199 { } /* end */
5200};
5201
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005202static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005203 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5204 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5205 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5206 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5207 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5208 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5209 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5210 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5211 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5222 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5223 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5224 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5225 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5226
5227 {
5228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5229 /* .name = "Capture Source", */
5230 .name = "Input Source",
5231 .count = 1,
5232 .info = alc883_mux_enum_info,
5233 .get = alc883_mux_enum_get,
5234 .put = alc883_mux_enum_put,
5235 },
5236 { } /* end */
5237};
5238
Kailang Yangccc656c2006-10-17 12:32:26 +02005239static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5242 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5244 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5258 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5259 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5260 {
5261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5262 /* .name = "Capture Source", */
5263 .name = "Input Source",
5264 .count = 2,
5265 .info = alc883_mux_enum_info,
5266 .get = alc883_mux_enum_get,
5267 .put = alc883_mux_enum_put,
5268 },
5269 { } /* end */
5270};
5271
5272static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5275 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005279 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5281 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5282 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5283 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5284 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5285 {
5286 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5287 /* .name = "Capture Source", */
5288 .name = "Input Source",
5289 .count = 2,
5290 .info = alc883_mux_enum_info,
5291 .get = alc883_mux_enum_get,
5292 .put = alc883_mux_enum_put,
5293 },
5294 { } /* end */
5295};
5296
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005297static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5298 {
5299 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5300 .name = "Channel Mode",
5301 .info = alc_ch_mode_info,
5302 .get = alc_ch_mode_get,
5303 .put = alc_ch_mode_put,
5304 },
5305 { } /* end */
5306};
5307
5308static struct hda_verb alc883_init_verbs[] = {
5309 /* ADC1: mute amp left and right */
5310 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5311 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5312 /* ADC2: mute amp left and right */
5313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5314 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5319 /* Rear mixer */
5320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5323 /* CLFE mixer */
5324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5327 /* Side mixer */
5328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5331
5332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5337
5338 /* Front Pin: output 0 (0x0c) */
5339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5341 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5342 /* Rear Pin: output 1 (0x0d) */
5343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5345 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5346 /* CLFE Pin: output 2 (0x0e) */
5347 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5348 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5349 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5350 /* Side Pin: output 3 (0x0f) */
5351 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5352 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5353 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5354 /* Mic (rear) pin: input vref at 80% */
5355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5357 /* Front Mic pin: input vref at 80% */
5358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5360 /* Line In pin: input */
5361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5363 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5366 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5367 /* CD pin widget for input */
5368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5369
5370 /* FIXME: use matrix-type input source selection */
5371 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5372 /* Input mixer2 */
5373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5377 /* Input mixer3 */
5378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5382 { }
5383};
5384
Kailang Yangccc656c2006-10-17 12:32:26 +02005385static struct hda_verb alc883_tagra_verbs[] = {
5386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5388
5389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5390 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5391
5392 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5394 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5395
5396 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5397 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5398 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5399 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5400
5401 { } /* end */
5402};
5403
5404/* toggle speaker-output according to the hp-jack state */
5405static void alc883_tagra_automute(struct hda_codec *codec)
5406{
5407 unsigned int present;
5408
5409 present = snd_hda_codec_read(codec, 0x14, 0,
5410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5411 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5412 0x80, present ? 0x80 : 0);
5413 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5414 0x80, present ? 0x80 : 0);
5415 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5416}
5417
5418static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5419{
5420 if ((res >> 26) == ALC880_HP_EVENT)
5421 alc883_tagra_automute(codec);
5422}
5423
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005424/*
5425 * generic initialization of ADC, input mixers and output mixers
5426 */
5427static struct hda_verb alc883_auto_init_verbs[] = {
5428 /*
5429 * Unmute ADC0-2 and set the default input to mic-in
5430 */
5431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5433 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5435
5436 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5437 * mixer widget
5438 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5439 * mic (mic 2)
5440 */
5441 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5447
5448 /*
5449 * Set up output mixers (0x0c - 0x0f)
5450 */
5451 /* set vol=0 to output mixers */
5452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5454 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5455 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5456 /* set up input amps for analog loopback */
5457 /* Amp Indices: DAC = 0, mixer = 1 */
5458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5466 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5467 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5468
5469 /* FIXME: use matrix-type input source selection */
5470 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5471 /* Input mixer1 */
5472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5475 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5477 /* Input mixer2 */
5478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5481 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5483
5484 { }
5485};
5486
5487/* capture mixer elements */
5488static struct snd_kcontrol_new alc883_capture_mixer[] = {
5489 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5490 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5491 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5492 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5493 {
5494 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5495 /* The multiple "Capture Source" controls confuse alsamixer
5496 * So call somewhat different..
5497 * FIXME: the controls appear in the "playback" view!
5498 */
5499 /* .name = "Capture Source", */
5500 .name = "Input Source",
5501 .count = 2,
5502 .info = alc882_mux_enum_info,
5503 .get = alc882_mux_enum_get,
5504 .put = alc882_mux_enum_put,
5505 },
5506 { } /* end */
5507};
5508
5509/* pcm configuration: identiacal with ALC880 */
5510#define alc883_pcm_analog_playback alc880_pcm_analog_playback
5511#define alc883_pcm_analog_capture alc880_pcm_analog_capture
5512#define alc883_pcm_digital_playback alc880_pcm_digital_playback
5513#define alc883_pcm_digital_capture alc880_pcm_digital_capture
5514
5515/*
5516 * configuration and preset
5517 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005518static const char *alc883_models[ALC883_MODEL_LAST] = {
5519 [ALC883_3ST_2ch_DIG] = "3stack-dig",
5520 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
5521 [ALC883_3ST_6ch] = "3stack-6ch",
5522 [ALC883_6ST_DIG] = "6stack-dig",
5523 [ALC883_TARGA_DIG] = "targa-dig",
5524 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5525 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5526 [ALC883_ACER] = "acer",
5527 [ALC883_MEDION] = "medion",
5528 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
5529 [ALC883_AUTO] = "auto",
5530};
5531
5532static struct snd_pci_quirk alc883_cfg_tbl[] = {
5533 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
5534 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5535 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5536 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
5537 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5538 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01005539 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005540 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
5541 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5542 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5543 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
5544 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
5545 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
5546 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
5547 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
5548 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5549 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5550 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
5551 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5552 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5553 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005554 {}
5555};
5556
5557static struct alc_config_preset alc883_presets[] = {
5558 [ALC883_3ST_2ch_DIG] = {
5559 .mixers = { alc883_3ST_2ch_mixer },
5560 .init_verbs = { alc883_init_verbs },
5561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5562 .dac_nids = alc883_dac_nids,
5563 .dig_out_nid = ALC883_DIGOUT_NID,
5564 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5565 .adc_nids = alc883_adc_nids,
5566 .dig_in_nid = ALC883_DIGIN_NID,
5567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5568 .channel_mode = alc883_3ST_2ch_modes,
5569 .input_mux = &alc883_capture_source,
5570 },
5571 [ALC883_3ST_6ch_DIG] = {
5572 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5573 .init_verbs = { alc883_init_verbs },
5574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5575 .dac_nids = alc883_dac_nids,
5576 .dig_out_nid = ALC883_DIGOUT_NID,
5577 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5578 .adc_nids = alc883_adc_nids,
5579 .dig_in_nid = ALC883_DIGIN_NID,
5580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5581 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005582 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005583 .input_mux = &alc883_capture_source,
5584 },
5585 [ALC883_3ST_6ch] = {
5586 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5587 .init_verbs = { alc883_init_verbs },
5588 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5589 .dac_nids = alc883_dac_nids,
5590 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5591 .adc_nids = alc883_adc_nids,
5592 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5593 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005594 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005595 .input_mux = &alc883_capture_source,
5596 },
5597 [ALC883_6ST_DIG] = {
5598 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5599 .init_verbs = { alc883_init_verbs },
5600 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5601 .dac_nids = alc883_dac_nids,
5602 .dig_out_nid = ALC883_DIGOUT_NID,
5603 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5604 .adc_nids = alc883_adc_nids,
5605 .dig_in_nid = ALC883_DIGIN_NID,
5606 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5607 .channel_mode = alc883_sixstack_modes,
5608 .input_mux = &alc883_capture_source,
5609 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005610 [ALC883_TARGA_DIG] = {
5611 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5612 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5614 .dac_nids = alc883_dac_nids,
5615 .dig_out_nid = ALC883_DIGOUT_NID,
5616 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5617 .adc_nids = alc883_adc_nids,
5618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5619 .channel_mode = alc883_3ST_6ch_modes,
5620 .need_dac_fix = 1,
5621 .input_mux = &alc883_capture_source,
5622 .unsol_event = alc883_tagra_unsol_event,
5623 .init_hook = alc883_tagra_automute,
5624 },
5625 [ALC883_TARGA_2ch_DIG] = {
5626 .mixers = { alc883_tagra_2ch_mixer},
5627 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5629 .dac_nids = alc883_dac_nids,
5630 .dig_out_nid = ALC883_DIGOUT_NID,
5631 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5632 .adc_nids = alc883_adc_nids,
5633 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5634 .channel_mode = alc883_3ST_2ch_modes,
5635 .input_mux = &alc883_capture_source,
5636 .unsol_event = alc883_tagra_unsol_event,
5637 .init_hook = alc883_tagra_automute,
5638 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005639 [ALC888_DEMO_BOARD] = {
5640 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5641 .init_verbs = { alc883_init_verbs },
5642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5643 .dac_nids = alc883_dac_nids,
5644 .dig_out_nid = ALC883_DIGOUT_NID,
5645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5646 .adc_nids = alc883_adc_nids,
5647 .dig_in_nid = ALC883_DIGIN_NID,
5648 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5649 .channel_mode = alc883_sixstack_modes,
5650 .input_mux = &alc883_capture_source,
5651 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02005652 [ALC883_ACER] = {
5653 .mixers = { alc883_base_mixer,
5654 alc883_chmode_mixer },
5655 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5656 * and the headphone jack. Turn this on and rely on the
5657 * standard mute methods whenever the user wants to turn
5658 * these outputs off.
5659 */
5660 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5662 .dac_nids = alc883_dac_nids,
5663 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5664 .adc_nids = alc883_adc_nids,
5665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5666 .channel_mode = alc883_3ST_2ch_modes,
5667 .input_mux = &alc883_capture_source,
5668 },
Tobin Davisc07584c2006-10-13 12:32:16 +02005669 [ALC883_MEDION] = {
5670 .mixers = { alc883_fivestack_mixer,
5671 alc883_chmode_mixer },
5672 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005673 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02005674 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5675 .dac_nids = alc883_dac_nids,
5676 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5677 .adc_nids = alc883_adc_nids,
5678 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5679 .channel_mode = alc883_sixstack_modes,
5680 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005681 },
5682 [ALC883_LAPTOP_EAPD] = {
5683 .mixers = { alc883_base_mixer,
5684 alc883_chmode_mixer },
5685 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
5686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5687 .dac_nids = alc883_dac_nids,
5688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5689 .adc_nids = alc883_adc_nids,
5690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5691 .channel_mode = alc883_3ST_2ch_modes,
5692 .input_mux = &alc883_capture_source,
5693 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005694};
5695
5696
5697/*
5698 * BIOS auto configuration
5699 */
5700static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5701 hda_nid_t nid, int pin_type,
5702 int dac_idx)
5703{
5704 /* set as output */
5705 struct alc_spec *spec = codec->spec;
5706 int idx;
5707
5708 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5709 idx = 4;
5710 else
5711 idx = spec->multiout.dac_nids[dac_idx] - 2;
5712
5713 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5714 pin_type);
5715 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5716 AMP_OUT_UNMUTE);
5717 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5718
5719}
5720
5721static void alc883_auto_init_multi_out(struct hda_codec *codec)
5722{
5723 struct alc_spec *spec = codec->spec;
5724 int i;
5725
5726 for (i = 0; i <= HDA_SIDE; i++) {
5727 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5728 if (nid)
5729 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5730 }
5731}
5732
5733static void alc883_auto_init_hp_out(struct hda_codec *codec)
5734{
5735 struct alc_spec *spec = codec->spec;
5736 hda_nid_t pin;
5737
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005738 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005739 if (pin) /* connect to front */
5740 /* use dac 0 */
5741 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5742}
5743
5744#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5745#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5746
5747static void alc883_auto_init_analog_input(struct hda_codec *codec)
5748{
5749 struct alc_spec *spec = codec->spec;
5750 int i;
5751
5752 for (i = 0; i < AUTO_PIN_LAST; i++) {
5753 hda_nid_t nid = spec->autocfg.input_pins[i];
5754 if (alc883_is_input_pin(nid)) {
5755 snd_hda_codec_write(codec, nid, 0,
5756 AC_VERB_SET_PIN_WIDGET_CONTROL,
5757 (i <= AUTO_PIN_FRONT_MIC ?
5758 PIN_VREF80 : PIN_IN));
5759 if (nid != ALC883_PIN_CD_NID)
5760 snd_hda_codec_write(codec, nid, 0,
5761 AC_VERB_SET_AMP_GAIN_MUTE,
5762 AMP_OUT_MUTE);
5763 }
5764 }
5765}
5766
5767/* almost identical with ALC880 parser... */
5768static int alc883_parse_auto_config(struct hda_codec *codec)
5769{
5770 struct alc_spec *spec = codec->spec;
5771 int err = alc880_parse_auto_config(codec);
5772
5773 if (err < 0)
5774 return err;
5775 else if (err > 0)
5776 /* hack - override the init verbs */
5777 spec->init_verbs[0] = alc883_auto_init_verbs;
5778 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5779 spec->num_mixers++;
5780 return err;
5781}
5782
5783/* additional initialization for auto-configuration model */
5784static void alc883_auto_init(struct hda_codec *codec)
5785{
5786 alc883_auto_init_multi_out(codec);
5787 alc883_auto_init_hp_out(codec);
5788 alc883_auto_init_analog_input(codec);
5789}
5790
5791static int patch_alc883(struct hda_codec *codec)
5792{
5793 struct alc_spec *spec;
5794 int err, board_config;
5795
5796 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5797 if (spec == NULL)
5798 return -ENOMEM;
5799
5800 codec->spec = spec;
5801
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005802 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
5803 alc883_models,
5804 alc883_cfg_tbl);
5805 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005806 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5807 "trying auto-probe from BIOS...\n");
5808 board_config = ALC883_AUTO;
5809 }
5810
5811 if (board_config == ALC883_AUTO) {
5812 /* automatic parse from the BIOS config */
5813 err = alc883_parse_auto_config(codec);
5814 if (err < 0) {
5815 alc_free(codec);
5816 return err;
5817 } else if (! err) {
5818 printk(KERN_INFO
5819 "hda_codec: Cannot set up configuration "
5820 "from BIOS. Using base mode...\n");
5821 board_config = ALC883_3ST_2ch_DIG;
5822 }
5823 }
5824
5825 if (board_config != ALC883_AUTO)
5826 setup_preset(spec, &alc883_presets[board_config]);
5827
5828 spec->stream_name_analog = "ALC883 Analog";
5829 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5830 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5831
5832 spec->stream_name_digital = "ALC883 Digital";
5833 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5834 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5835
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005836 if (! spec->adc_nids && spec->input_mux) {
5837 spec->adc_nids = alc883_adc_nids;
5838 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5839 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005840
5841 codec->patch_ops = alc_patch_ops;
5842 if (board_config == ALC883_AUTO)
5843 spec->init_hook = alc883_auto_init;
5844
5845 return 0;
5846}
5847
5848/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005849 * ALC262 support
5850 */
5851
5852#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5853#define ALC262_DIGIN_NID ALC880_DIGIN_NID
5854
5855#define alc262_dac_nids alc260_dac_nids
5856#define alc262_adc_nids alc882_adc_nids
5857#define alc262_adc_nids_alt alc882_adc_nids_alt
5858
5859#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005860#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01005861
5862static struct snd_kcontrol_new alc262_base_mixer[] = {
5863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5873 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5874 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5878 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005879 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01005880};
5881
Kailang Yangccc656c2006-10-17 12:32:26 +02005882static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5884 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5891 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5892 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5893 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5894 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5895 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5897 { } /* end */
5898};
5899
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005900static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5902 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5904 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5905 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5906
5907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5915 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5916 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5917 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5918 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5919 { } /* end */
5920};
5921
Kailang Yangdf694da2005-12-05 19:42:22 +01005922#define alc262_capture_mixer alc882_capture_mixer
5923#define alc262_capture_alt_mixer alc882_capture_alt_mixer
5924
5925/*
5926 * generic initialization of ADC, input mixers and output mixers
5927 */
5928static struct hda_verb alc262_init_verbs[] = {
5929 /*
5930 * Unmute ADC0-2 and set the default input to mic-in
5931 */
5932 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5936 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5938
5939 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5940 * mixer widget
5941 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5942 * mic (mic 2)
5943 */
5944 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5950
5951 /*
5952 * Set up output mixers (0x0c - 0x0e)
5953 */
5954 /* set vol=0 to output mixers */
5955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5958 /* set up input amps for analog loopback */
5959 /* Amp Indices: DAC = 0, mixer = 1 */
5960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5966
5967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5973
5974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5979
5980 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5982
5983 /* FIXME: use matrix-type input source selection */
5984 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5985 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5990 /* Input mixer2 */
5991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5995 /* Input mixer3 */
5996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6000
6001 { }
6002};
6003
Kailang Yangccc656c2006-10-17 12:32:26 +02006004static struct hda_verb alc262_hippo_unsol_verbs[] = {
6005 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6007 {}
6008};
6009
6010static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6011 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6012 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6013 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6014
6015 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6017 {}
6018};
6019
6020/* mute/unmute internal speaker according to the hp jack and mute state */
6021static void alc262_hippo_automute(struct hda_codec *codec, int force)
6022{
6023 struct alc_spec *spec = codec->spec;
6024 unsigned int mute;
6025
6026 if (force || ! spec->sense_updated) {
6027 unsigned int present;
6028 /* need to execute and sync at first */
6029 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6030 present = snd_hda_codec_read(codec, 0x15, 0,
6031 AC_VERB_GET_PIN_SENSE, 0);
6032 spec->jack_present = (present & 0x80000000) != 0;
6033 spec->sense_updated = 1;
6034 }
6035 if (spec->jack_present) {
6036 /* mute internal speaker */
6037 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6038 0x80, 0x80);
6039 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6040 0x80, 0x80);
6041 } else {
6042 /* unmute internal speaker if necessary */
6043 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
6044 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6045 0x80, mute & 0x80);
6046 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
6047 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6048 0x80, mute & 0x80);
6049 }
6050}
6051
6052/* unsolicited event for HP jack sensing */
6053static void alc262_hippo_unsol_event(struct hda_codec *codec,
6054 unsigned int res)
6055{
6056 if ((res >> 26) != ALC880_HP_EVENT)
6057 return;
6058 alc262_hippo_automute(codec, 1);
6059}
6060
6061static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6062{
6063 struct alc_spec *spec = codec->spec;
6064 unsigned int mute;
6065
6066 if (force || ! spec->sense_updated) {
6067 unsigned int present;
6068 /* need to execute and sync at first */
6069 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
6070 present = snd_hda_codec_read(codec, 0x1b, 0,
6071 AC_VERB_GET_PIN_SENSE, 0);
6072 spec->jack_present = (present & 0x80000000) != 0;
6073 spec->sense_updated = 1;
6074 }
6075 if (spec->jack_present) {
6076 /* mute internal speaker */
6077 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6078 0x80, 0x80);
6079 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6080 0x80, 0x80);
6081 } else {
6082 /* unmute internal speaker if necessary */
6083 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
6084 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6085 0x80, mute & 0x80);
6086 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
6087 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6088 0x80, mute & 0x80);
6089 }
6090}
6091
6092/* unsolicited event for HP jack sensing */
6093static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6094 unsigned int res)
6095{
6096 if ((res >> 26) != ALC880_HP_EVENT)
6097 return;
6098 alc262_hippo1_automute(codec, 1);
6099}
6100
Takashi Iwai834be882006-03-01 14:16:17 +01006101/*
6102 * fujitsu model
6103 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6104 */
6105
6106#define ALC_HP_EVENT 0x37
6107
6108static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6109 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6111 {}
6112};
6113
6114static struct hda_input_mux alc262_fujitsu_capture_source = {
6115 .num_items = 2,
6116 .items = {
6117 { "Mic", 0x0 },
6118 { "CD", 0x4 },
6119 },
6120};
6121
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006122static struct hda_input_mux alc262_HP_capture_source = {
6123 .num_items = 5,
6124 .items = {
6125 { "Mic", 0x0 },
6126 { "Front Mic", 0x3 },
6127 { "Line", 0x2 },
6128 { "CD", 0x4 },
6129 { "AUX IN", 0x6 },
6130 },
6131};
6132
Takashi Iwai834be882006-03-01 14:16:17 +01006133/* mute/unmute internal speaker according to the hp jack and mute state */
6134static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6135{
6136 struct alc_spec *spec = codec->spec;
6137 unsigned int mute;
6138
6139 if (force || ! spec->sense_updated) {
6140 unsigned int present;
6141 /* need to execute and sync at first */
6142 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6143 present = snd_hda_codec_read(codec, 0x14, 0,
6144 AC_VERB_GET_PIN_SENSE, 0);
6145 spec->jack_present = (present & 0x80000000) != 0;
6146 spec->sense_updated = 1;
6147 }
6148 if (spec->jack_present) {
6149 /* mute internal speaker */
6150 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6151 0x80, 0x80);
6152 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6153 0x80, 0x80);
6154 } else {
6155 /* unmute internal speaker if necessary */
6156 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6157 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6158 0x80, mute & 0x80);
6159 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6160 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6161 0x80, mute & 0x80);
6162 }
6163}
6164
6165/* unsolicited event for HP jack sensing */
6166static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6167 unsigned int res)
6168{
6169 if ((res >> 26) != ALC_HP_EVENT)
6170 return;
6171 alc262_fujitsu_automute(codec, 1);
6172}
6173
6174/* bind volumes of both NID 0x0c and 0x0d */
6175static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6176 struct snd_ctl_elem_value *ucontrol)
6177{
6178 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6179 long *valp = ucontrol->value.integer.value;
6180 int change;
6181
6182 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6183 0x7f, valp[0] & 0x7f);
6184 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6185 0x7f, valp[1] & 0x7f);
6186 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6187 0x7f, valp[0] & 0x7f);
6188 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6189 0x7f, valp[1] & 0x7f);
6190 return change;
6191}
6192
6193/* bind hp and internal speaker mute (with plug check) */
6194static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6195 struct snd_ctl_elem_value *ucontrol)
6196{
6197 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6198 long *valp = ucontrol->value.integer.value;
6199 int change;
6200
6201 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6202 0x80, valp[0] ? 0 : 0x80);
6203 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6204 0x80, valp[1] ? 0 : 0x80);
6205 if (change || codec->in_resume)
6206 alc262_fujitsu_automute(codec, codec->in_resume);
6207 return change;
6208}
6209
6210static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6211 {
6212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6213 .name = "Master Playback Volume",
6214 .info = snd_hda_mixer_amp_volume_info,
6215 .get = snd_hda_mixer_amp_volume_get,
6216 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02006217 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01006218 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6219 },
6220 {
6221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6222 .name = "Master Playback Switch",
6223 .info = snd_hda_mixer_amp_switch_info,
6224 .get = snd_hda_mixer_amp_switch_get,
6225 .put = alc262_fujitsu_master_sw_put,
6226 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6227 },
6228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6233 { } /* end */
6234};
6235
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006236/* additional init verbs for Benq laptops */
6237static struct hda_verb alc262_EAPD_verbs[] = {
6238 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6239 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6240 {}
6241};
6242
Kailang Yangdf694da2005-12-05 19:42:22 +01006243/* add playback controls from the parsed DAC table */
6244static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6245{
6246 hda_nid_t nid;
6247 int err;
6248
6249 spec->multiout.num_dacs = 1; /* only use one dac */
6250 spec->multiout.dac_nids = spec->private_dac_nids;
6251 spec->multiout.dac_nids[0] = 2;
6252
6253 nid = cfg->line_out_pins[0];
6254 if (nid) {
6255 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6256 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6257 return err;
6258 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6259 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6260 return err;
6261 }
6262
Takashi Iwai82bc9552006-03-21 11:24:42 +01006263 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006264 if (nid) {
6265 if (nid == 0x16) {
6266 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6267 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6268 return err;
6269 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6270 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6271 return err;
6272 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006273 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6274 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6275 return err;
6276 }
6277 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006278 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 if (nid) {
6280 /* spec->multiout.hp_nid = 2; */
6281 if (nid == 0x16) {
6282 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6283 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6284 return err;
6285 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6286 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6287 return err;
6288 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01006289 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6290 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6291 return err;
6292 }
6293 }
6294 return 0;
6295}
6296
6297/* identical with ALC880 */
6298#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6299
6300/*
6301 * generic initialization of ADC, input mixers and output mixers
6302 */
6303static struct hda_verb alc262_volume_init_verbs[] = {
6304 /*
6305 * Unmute ADC0-2 and set the default input to mic-in
6306 */
6307 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6310 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6312 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6313
6314 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6315 * mixer widget
6316 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6317 * mic (mic 2)
6318 */
6319 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6325
6326 /*
6327 * Set up output mixers (0x0c - 0x0f)
6328 */
6329 /* set vol=0 to output mixers */
6330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6333
6334 /* set up input amps for analog loopback */
6335 /* Amp Indices: DAC = 0, mixer = 1 */
6336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6340 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6342
6343 /* FIXME: use matrix-type input source selection */
6344 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6345 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6350 /* Input mixer2 */
6351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6355 /* Input mixer3 */
6356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6360
6361 { }
6362};
6363
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006364static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6365 /*
6366 * Unmute ADC0-2 and set the default input to mic-in
6367 */
6368 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6370 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6372 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374
6375 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6376 * mixer widget
6377 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6378 * mic (mic 2)
6379 */
6380 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6388
6389 /*
6390 * Set up output mixers (0x0c - 0x0e)
6391 */
6392 /* set vol=0 to output mixers */
6393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6396
6397 /* set up input amps for analog loopback */
6398 /* Amp Indices: DAC = 0, mixer = 1 */
6399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6405
6406 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6408 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6409
6410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6412
6413 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6415
6416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6417 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6418 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6419 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6420 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6421
6422 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6424 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6426 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6427 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6428
6429
6430 /* FIXME: use matrix-type input source selection */
6431 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6432 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6437 /* Input mixer2 */
6438 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6439 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6442 /* Input mixer3 */
6443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6447
6448 { }
6449};
6450
Kailang Yangdf694da2005-12-05 19:42:22 +01006451/* pcm configuration: identiacal with ALC880 */
6452#define alc262_pcm_analog_playback alc880_pcm_analog_playback
6453#define alc262_pcm_analog_capture alc880_pcm_analog_capture
6454#define alc262_pcm_digital_playback alc880_pcm_digital_playback
6455#define alc262_pcm_digital_capture alc880_pcm_digital_capture
6456
6457/*
6458 * BIOS auto configuration
6459 */
6460static int alc262_parse_auto_config(struct hda_codec *codec)
6461{
6462 struct alc_spec *spec = codec->spec;
6463 int err;
6464 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6465
6466 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6467 alc262_ignore)) < 0)
6468 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01006469 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006470 return 0; /* can't find valid BIOS pin config */
6471 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6472 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6473 return err;
6474
6475 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6476
6477 if (spec->autocfg.dig_out_pin)
6478 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6479 if (spec->autocfg.dig_in_pin)
6480 spec->dig_in_nid = ALC262_DIGIN_NID;
6481
6482 if (spec->kctl_alloc)
6483 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6484
6485 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006486 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 spec->input_mux = &spec->private_imux;
6488
6489 return 1;
6490}
6491
6492#define alc262_auto_init_multi_out alc882_auto_init_multi_out
6493#define alc262_auto_init_hp_out alc882_auto_init_hp_out
6494#define alc262_auto_init_analog_input alc882_auto_init_analog_input
6495
6496
6497/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006498static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006499{
Kailang Yangdf694da2005-12-05 19:42:22 +01006500 alc262_auto_init_multi_out(codec);
6501 alc262_auto_init_hp_out(codec);
6502 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006503}
6504
6505/*
6506 * configuration and preset
6507 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006508static const char *alc262_models[ALC262_MODEL_LAST] = {
6509 [ALC262_BASIC] = "basic",
6510 [ALC262_HIPPO] = "hippo",
6511 [ALC262_HIPPO_1] = "hippo_1",
6512 [ALC262_FUJITSU] = "fujitsu",
6513 [ALC262_HP_BPC] = "hp-bpc",
6514 [ALC262_BENQ_ED8] = "benq",
6515 [ALC262_AUTO] = "auto",
6516};
6517
6518static struct snd_pci_quirk alc262_cfg_tbl[] = {
6519 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6520 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6521 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
6522 SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
6523 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
6524 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
6525 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
6526 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
6527 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
6528 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yangdf694da2005-12-05 19:42:22 +01006529 {}
6530};
6531
6532static struct alc_config_preset alc262_presets[] = {
6533 [ALC262_BASIC] = {
6534 .mixers = { alc262_base_mixer },
6535 .init_verbs = { alc262_init_verbs },
6536 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6537 .dac_nids = alc262_dac_nids,
6538 .hp_nid = 0x03,
6539 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6540 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006541 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01006542 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006543 [ALC262_HIPPO] = {
6544 .mixers = { alc262_base_mixer },
6545 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6546 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6547 .dac_nids = alc262_dac_nids,
6548 .hp_nid = 0x03,
6549 .dig_out_nid = ALC262_DIGOUT_NID,
6550 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6551 .channel_mode = alc262_modes,
6552 .input_mux = &alc262_capture_source,
6553 .unsol_event = alc262_hippo_unsol_event,
6554 },
6555 [ALC262_HIPPO_1] = {
6556 .mixers = { alc262_hippo1_mixer },
6557 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6558 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6559 .dac_nids = alc262_dac_nids,
6560 .hp_nid = 0x02,
6561 .dig_out_nid = ALC262_DIGOUT_NID,
6562 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6563 .channel_mode = alc262_modes,
6564 .input_mux = &alc262_capture_source,
6565 .unsol_event = alc262_hippo1_unsol_event,
6566 },
Takashi Iwai834be882006-03-01 14:16:17 +01006567 [ALC262_FUJITSU] = {
6568 .mixers = { alc262_fujitsu_mixer },
6569 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6570 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6571 .dac_nids = alc262_dac_nids,
6572 .hp_nid = 0x03,
6573 .dig_out_nid = ALC262_DIGOUT_NID,
6574 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6575 .channel_mode = alc262_modes,
6576 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006577 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01006578 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006579 [ALC262_HP_BPC] = {
6580 .mixers = { alc262_HP_BPC_mixer },
6581 .init_verbs = { alc262_HP_BPC_init_verbs },
6582 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6583 .dac_nids = alc262_dac_nids,
6584 .hp_nid = 0x03,
6585 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6586 .channel_mode = alc262_modes,
6587 .input_mux = &alc262_HP_capture_source,
6588 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02006589 [ALC262_BENQ_ED8] = {
6590 .mixers = { alc262_base_mixer },
6591 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6592 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6593 .dac_nids = alc262_dac_nids,
6594 .hp_nid = 0x03,
6595 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6596 .channel_mode = alc262_modes,
6597 .input_mux = &alc262_capture_source,
6598 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006599};
6600
6601static int patch_alc262(struct hda_codec *codec)
6602{
6603 struct alc_spec *spec;
6604 int board_config;
6605 int err;
6606
Robert P. J. Daydc041e02006-12-19 14:44:15 +01006607 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01006608 if (spec == NULL)
6609 return -ENOMEM;
6610
6611 codec->spec = spec;
6612#if 0
6613 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6614 {
6615 int tmp;
6616 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6617 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6618 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6619 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6620 }
6621#endif
6622
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006623 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
6624 alc262_models,
6625 alc262_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006626
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006627 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006628 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6629 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006630 board_config = ALC262_AUTO;
6631 }
6632
6633 if (board_config == ALC262_AUTO) {
6634 /* automatic parse from the BIOS config */
6635 err = alc262_parse_auto_config(codec);
6636 if (err < 0) {
6637 alc_free(codec);
6638 return err;
6639 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006640 printk(KERN_INFO
6641 "hda_codec: Cannot set up configuration "
6642 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006643 board_config = ALC262_BASIC;
6644 }
6645 }
6646
6647 if (board_config != ALC262_AUTO)
6648 setup_preset(spec, &alc262_presets[board_config]);
6649
6650 spec->stream_name_analog = "ALC262 Analog";
6651 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6652 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6653
6654 spec->stream_name_digital = "ALC262 Digital";
6655 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6656 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6657
6658 if (! spec->adc_nids && spec->input_mux) {
6659 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006660 unsigned int wcap = get_wcaps(codec, 0x07);
6661
Kailang Yangdf694da2005-12-05 19:42:22 +01006662 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6663 if (wcap != AC_WID_AUD_IN) {
6664 spec->adc_nids = alc262_adc_nids_alt;
6665 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6666 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6667 spec->num_mixers++;
6668 } else {
6669 spec->adc_nids = alc262_adc_nids;
6670 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6671 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6672 spec->num_mixers++;
6673 }
6674 }
6675
6676 codec->patch_ops = alc_patch_ops;
6677 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006678 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01006679
Kailang Yangdf694da2005-12-05 19:42:22 +01006680 return 0;
6681}
6682
Kailang Yangdf694da2005-12-05 19:42:22 +01006683/*
6684 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6685 */
6686
6687/*
6688 * set the path ways for 2 channel output
6689 * need to set the codec line out and mic 1 pin widgets to inputs
6690 */
6691static struct hda_verb alc861_threestack_ch2_init[] = {
6692 /* set pin widget 1Ah (line in) for input */
6693 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6694 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6695 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6696
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006697 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6698#if 0
6699 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6700 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6701#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006702 { } /* end */
6703};
6704/*
6705 * 6ch mode
6706 * need to set the codec line out and mic 1 pin widgets to outputs
6707 */
6708static struct hda_verb alc861_threestack_ch6_init[] = {
6709 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6710 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6711 /* set pin widget 18h (mic1) for output (CLFE)*/
6712 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6713
6714 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006715 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6718#if 0
6719 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6720 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6721#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006722 { } /* end */
6723};
6724
6725static struct hda_channel_mode alc861_threestack_modes[2] = {
6726 { 2, alc861_threestack_ch2_init },
6727 { 6, alc861_threestack_ch6_init },
6728};
Takashi Iwai22309c32006-08-09 16:57:28 +02006729/* Set mic1 as input and unmute the mixer */
6730static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6731 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6732 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6733 { } /* end */
6734};
6735/* Set mic1 as output and mute mixer */
6736static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6737 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6738 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6739 { } /* end */
6740};
6741
6742static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6743 { 2, alc861_uniwill_m31_ch2_init },
6744 { 4, alc861_uniwill_m31_ch4_init },
6745};
Kailang Yangdf694da2005-12-05 19:42:22 +01006746
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006747/* Set mic1 and line-in as input and unmute the mixer */
6748static struct hda_verb alc861_asus_ch2_init[] = {
6749 /* set pin widget 1Ah (line in) for input */
6750 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6751 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6752 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6753
6754 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6755#if 0
6756 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6757 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6758#endif
6759 { } /* end */
6760};
6761/* Set mic1 nad line-in as output and mute mixer */
6762static struct hda_verb alc861_asus_ch6_init[] = {
6763 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6764 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6765 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6766 /* set pin widget 18h (mic1) for output (CLFE)*/
6767 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6768 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6769 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6770 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6771
6772 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6773#if 0
6774 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6775 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6776#endif
6777 { } /* end */
6778};
6779
6780static struct hda_channel_mode alc861_asus_modes[2] = {
6781 { 2, alc861_asus_ch2_init },
6782 { 6, alc861_asus_ch6_init },
6783};
6784
Kailang Yangdf694da2005-12-05 19:42:22 +01006785/* patch-ALC861 */
6786
6787static struct snd_kcontrol_new alc861_base_mixer[] = {
6788 /* output mixer control */
6789 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6790 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6793 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6794
6795 /*Input mixer control */
6796 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6797 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6798 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6799 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6800 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6801 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6803 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6804 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6806
6807 /* Capture mixer control */
6808 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6809 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6810 {
6811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6812 .name = "Capture Source",
6813 .count = 1,
6814 .info = alc_mux_enum_info,
6815 .get = alc_mux_enum_get,
6816 .put = alc_mux_enum_put,
6817 },
6818 { } /* end */
6819};
6820
6821static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6822 /* output mixer control */
6823 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6824 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6825 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6826 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6827 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6828
6829 /* Input mixer control */
6830 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6831 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6832 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6833 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6834 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6835 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6837 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6840
6841 /* Capture mixer control */
6842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6844 {
6845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6846 .name = "Capture Source",
6847 .count = 1,
6848 .info = alc_mux_enum_info,
6849 .get = alc_mux_enum_get,
6850 .put = alc_mux_enum_put,
6851 },
6852 {
6853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6854 .name = "Channel Mode",
6855 .info = alc_ch_mode_info,
6856 .get = alc_ch_mode_get,
6857 .put = alc_ch_mode_put,
6858 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6859 },
6860 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006861};
6862
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006863static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02006864 /* output mixer control */
6865 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6867 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6868
6869 /*Capture mixer control */
6870 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6871 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6872 {
6873 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6874 .name = "Capture Source",
6875 .count = 1,
6876 .info = alc_mux_enum_info,
6877 .get = alc_mux_enum_get,
6878 .put = alc_mux_enum_put,
6879 },
6880
6881 { } /* end */
6882};
6883
Takashi Iwai22309c32006-08-09 16:57:28 +02006884static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6885 /* output mixer control */
6886 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6887 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6888 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6889 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6890 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6891
6892 /* Input mixer control */
6893 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6894 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6895 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6896 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6897 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6898 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6900 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6903
6904 /* Capture mixer control */
6905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6907 {
6908 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6909 .name = "Capture Source",
6910 .count = 1,
6911 .info = alc_mux_enum_info,
6912 .get = alc_mux_enum_get,
6913 .put = alc_mux_enum_put,
6914 },
6915 {
6916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6917 .name = "Channel Mode",
6918 .info = alc_ch_mode_info,
6919 .get = alc_ch_mode_get,
6920 .put = alc_ch_mode_put,
6921 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6922 },
6923 { } /* end */
6924};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006925
6926static struct snd_kcontrol_new alc861_asus_mixer[] = {
6927 /* output mixer control */
6928 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6929 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6930 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6932 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6933
6934 /* Input mixer control */
6935 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6936 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6937 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6938 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6942 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6943 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
6945
6946 /* Capture mixer control */
6947 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6948 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6949 {
6950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6951 .name = "Capture Source",
6952 .count = 1,
6953 .info = alc_mux_enum_info,
6954 .get = alc_mux_enum_get,
6955 .put = alc_mux_enum_put,
6956 },
6957 {
6958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6959 .name = "Channel Mode",
6960 .info = alc_ch_mode_info,
6961 .get = alc_ch_mode_get,
6962 .put = alc_ch_mode_put,
6963 .private_value = ARRAY_SIZE(alc861_asus_modes),
6964 },
6965 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006966};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02006967
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006968/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006969static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01006970 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6971 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6972 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
6973 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
6974 { }
6975};
6976
Kailang Yangdf694da2005-12-05 19:42:22 +01006977/*
6978 * generic initialization of ADC, input mixers and output mixers
6979 */
6980static struct hda_verb alc861_base_init_verbs[] = {
6981 /*
6982 * Unmute ADC0 and set the default input to mic-in
6983 */
6984 /* port-A for surround (rear panel) */
6985 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6986 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6987 /* port-B for mic-in (rear panel) with vref */
6988 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6989 /* port-C for line-in (rear panel) */
6990 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6991 /* port-D for Front */
6992 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6993 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6994 /* port-E for HP out (front panel) */
6995 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6996 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01006997 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006998 /* port-F for mic-in (front panel) with vref */
6999 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7000 /* port-G for CLFE (rear panel) */
7001 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7002 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7003 /* port-H for side (rear panel) */
7004 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7005 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
7006 /* CD-in */
7007 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7008 /* route front mic to ADC1*/
7009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7011
7012 /* Unmute DAC0~3 & spdif out*/
7013 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7014 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7015 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7016 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7018
7019 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7020 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7024
7025 /* Unmute Stereo Mixer 15 */
7026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7029 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7030
7031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7033 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7041
7042 { }
7043};
7044
7045static struct hda_verb alc861_threestack_init_verbs[] = {
7046 /*
7047 * Unmute ADC0 and set the default input to mic-in
7048 */
7049 /* port-A for surround (rear panel) */
7050 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7051 /* port-B for mic-in (rear panel) with vref */
7052 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7053 /* port-C for line-in (rear panel) */
7054 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7055 /* port-D for Front */
7056 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7057 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7058 /* port-E for HP out (front panel) */
7059 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7060 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007061 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007062 /* port-F for mic-in (front panel) with vref */
7063 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7064 /* port-G for CLFE (rear panel) */
7065 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7066 /* port-H for side (rear panel) */
7067 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7068 /* CD-in */
7069 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7070 /* route front mic to ADC1*/
7071 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7073 /* Unmute DAC0~3 & spdif out*/
7074 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7075 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7076 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7077 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7078 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7079
7080 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7081 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7084 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7085
7086 /* Unmute Stereo Mixer 15 */
7087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7091
7092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7094 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7095 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7096 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7097 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7099 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7102 { }
7103};
Takashi Iwai22309c32006-08-09 16:57:28 +02007104
7105static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7106 /*
7107 * Unmute ADC0 and set the default input to mic-in
7108 */
7109 /* port-A for surround (rear panel) */
7110 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7111 /* port-B for mic-in (rear panel) with vref */
7112 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7113 /* port-C for line-in (rear panel) */
7114 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7115 /* port-D for Front */
7116 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7117 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7118 /* port-E for HP out (front panel) */
7119 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
7120 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007121 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007122 /* port-F for mic-in (front panel) with vref */
7123 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7124 /* port-G for CLFE (rear panel) */
7125 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7126 /* port-H for side (rear panel) */
7127 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7128 /* CD-in */
7129 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7130 /* route front mic to ADC1*/
7131 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7133 /* Unmute DAC0~3 & spdif out*/
7134 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7136 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7137 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7139
7140 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7141 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7142 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7143 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7144 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7145
7146 /* Unmute Stereo Mixer 15 */
7147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7149 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7151
7152 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7153 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7154 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7155 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7157 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7160 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7162 { }
7163};
7164
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007165static struct hda_verb alc861_asus_init_verbs[] = {
7166 /*
7167 * Unmute ADC0 and set the default input to mic-in
7168 */
7169 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7170 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7171 /* route front PCM to HP */
7172 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7173 /* port-B for mic-in (rear panel) with vref */
7174 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7175 /* port-C for line-in (rear panel) */
7176 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7177 /* port-D for Front */
7178 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7179 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7180 /* port-E for HP out (front panel) */
7181 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7182 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01007183 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007184 /* port-F for mic-in (front panel) with vref */
7185 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7186 /* port-G for CLFE (rear panel) */
7187 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7188 /* port-H for side (rear panel) */
7189 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7190 /* CD-in */
7191 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7192 /* route front mic to ADC1*/
7193 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7194 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 /* Unmute DAC0~3 & spdif out*/
7196 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7197 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7198 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7199 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7201 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7202 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7203 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7204 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7205 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7206
7207 /* Unmute Stereo Mixer 15 */
7208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7212
7213 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7217 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7218 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7221 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7222 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7223 { }
7224};
7225
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01007226/* additional init verbs for ASUS laptops */
7227static struct hda_verb alc861_asus_laptop_init_verbs[] = {
7228 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
7229 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
7230 { }
7231};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007232
Kailang Yangdf694da2005-12-05 19:42:22 +01007233/*
7234 * generic initialization of ADC, input mixers and output mixers
7235 */
7236static struct hda_verb alc861_auto_init_verbs[] = {
7237 /*
7238 * Unmute ADC0 and set the default input to mic-in
7239 */
7240// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7242
7243 /* Unmute DAC0~3 & spdif out*/
7244 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7245 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7246 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7247 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7249
7250 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7251 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7252 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7253 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7254 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7255
7256 /* Unmute Stereo Mixer 15 */
7257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7261
7262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7265 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7270
7271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7276 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7279
7280 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7281
7282 { }
7283};
7284
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007285static struct hda_verb alc861_toshiba_init_verbs[] = {
7286 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7287
7288 { }
7289};
7290
7291/* toggle speaker-output according to the hp-jack state */
7292static void alc861_toshiba_automute(struct hda_codec *codec)
7293{
7294 unsigned int present;
7295
7296 present = snd_hda_codec_read(codec, 0x0f, 0,
7297 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7298 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7299 0x80, present ? 0x80 : 0);
7300 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7301 0x80, present ? 0x80 : 0);
7302 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7303 0x80, present ? 0 : 0x80);
7304 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7305 0x80, present ? 0 : 0x80);
7306}
7307
7308static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7309 unsigned int res)
7310{
7311 /* Looks like the unsol event is incompatible with the standard
7312 * definition. 6bit tag is placed at 26 bit!
7313 */
7314 if ((res >> 26) == ALC880_HP_EVENT)
7315 alc861_toshiba_automute(codec);
7316}
7317
Kailang Yangdf694da2005-12-05 19:42:22 +01007318/* pcm configuration: identiacal with ALC880 */
7319#define alc861_pcm_analog_playback alc880_pcm_analog_playback
7320#define alc861_pcm_analog_capture alc880_pcm_analog_capture
7321#define alc861_pcm_digital_playback alc880_pcm_digital_playback
7322#define alc861_pcm_digital_capture alc880_pcm_digital_capture
7323
7324
7325#define ALC861_DIGOUT_NID 0x07
7326
7327static struct hda_channel_mode alc861_8ch_modes[1] = {
7328 { 8, NULL }
7329};
7330
7331static hda_nid_t alc861_dac_nids[4] = {
7332 /* front, surround, clfe, side */
7333 0x03, 0x06, 0x05, 0x04
7334};
7335
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007336static hda_nid_t alc660_dac_nids[3] = {
7337 /* front, clfe, surround */
7338 0x03, 0x05, 0x06
7339};
7340
Kailang Yangdf694da2005-12-05 19:42:22 +01007341static hda_nid_t alc861_adc_nids[1] = {
7342 /* ADC0-2 */
7343 0x08,
7344};
7345
7346static struct hda_input_mux alc861_capture_source = {
7347 .num_items = 5,
7348 .items = {
7349 { "Mic", 0x0 },
7350 { "Front Mic", 0x3 },
7351 { "Line", 0x1 },
7352 { "CD", 0x4 },
7353 { "Mixer", 0x5 },
7354 },
7355};
7356
7357/* fill in the dac_nids table from the parsed pin configuration */
7358static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7359{
7360 int i;
7361 hda_nid_t nid;
7362
7363 spec->multiout.dac_nids = spec->private_dac_nids;
7364 for (i = 0; i < cfg->line_outs; i++) {
7365 nid = cfg->line_out_pins[i];
7366 if (nid) {
7367 if (i >= ARRAY_SIZE(alc861_dac_nids))
7368 continue;
7369 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7370 }
7371 }
7372 spec->multiout.num_dacs = cfg->line_outs;
7373 return 0;
7374}
7375
7376/* add playback controls from the parsed DAC table */
7377static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7378 const struct auto_pin_cfg *cfg)
7379{
7380 char name[32];
7381 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7382 hda_nid_t nid;
7383 int i, idx, err;
7384
7385 for (i = 0; i < cfg->line_outs; i++) {
7386 nid = spec->multiout.dac_nids[i];
7387 if (! nid)
7388 continue;
7389 if (nid == 0x05) {
7390 /* Center/LFE */
7391 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7392 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7393 return err;
7394 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7395 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7396 return err;
7397 } else {
7398 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7399 if (nid == alc861_dac_nids[idx])
7400 break;
7401 sprintf(name, "%s Playback Switch", chname[idx]);
7402 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7403 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7404 return err;
7405 }
7406 }
7407 return 0;
7408}
7409
7410static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7411{
7412 int err;
7413 hda_nid_t nid;
7414
7415 if (! pin)
7416 return 0;
7417
7418 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7419 nid = 0x03;
7420 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7421 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7422 return err;
7423 spec->multiout.hp_nid = nid;
7424 }
7425 return 0;
7426}
7427
7428/* create playback/capture controls for input pins */
7429static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7430{
Kailang Yangdf694da2005-12-05 19:42:22 +01007431 struct hda_input_mux *imux = &spec->private_imux;
7432 int i, err, idx, idx1;
7433
7434 for (i = 0; i < AUTO_PIN_LAST; i++) {
7435 switch(cfg->input_pins[i]) {
7436 case 0x0c:
7437 idx1 = 1;
7438 idx = 2; // Line In
7439 break;
7440 case 0x0f:
7441 idx1 = 2;
7442 idx = 2; // Line In
7443 break;
7444 case 0x0d:
7445 idx1 = 0;
7446 idx = 1; // Mic In
7447 break;
7448 case 0x10:
7449 idx1 = 3;
7450 idx = 1; // Mic In
7451 break;
7452 case 0x11:
7453 idx1 = 4;
7454 idx = 0; // CD
7455 break;
7456 default:
7457 continue;
7458 }
7459
Takashi Iwai4a471b72005-12-07 13:56:29 +01007460 err = new_analog_input(spec, cfg->input_pins[i],
7461 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01007462 if (err < 0)
7463 return err;
7464
Takashi Iwai4a471b72005-12-07 13:56:29 +01007465 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01007466 imux->items[imux->num_items].index = idx1;
7467 imux->num_items++;
7468 }
7469 return 0;
7470}
7471
7472static struct snd_kcontrol_new alc861_capture_mixer[] = {
7473 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7474 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7475
7476 {
7477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7478 /* The multiple "Capture Source" controls confuse alsamixer
7479 * So call somewhat different..
7480 *FIXME: the controls appear in the "playback" view!
7481 */
7482 /* .name = "Capture Source", */
7483 .name = "Input Source",
7484 .count = 1,
7485 .info = alc_mux_enum_info,
7486 .get = alc_mux_enum_get,
7487 .put = alc_mux_enum_put,
7488 },
7489 { } /* end */
7490};
7491
7492static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7493 int pin_type, int dac_idx)
7494{
7495 /* set as output */
7496
7497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7498 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7499
7500}
7501
7502static void alc861_auto_init_multi_out(struct hda_codec *codec)
7503{
7504 struct alc_spec *spec = codec->spec;
7505 int i;
7506
7507 for (i = 0; i < spec->autocfg.line_outs; i++) {
7508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7509 if (nid)
7510 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7511 }
7512}
7513
7514static void alc861_auto_init_hp_out(struct hda_codec *codec)
7515{
7516 struct alc_spec *spec = codec->spec;
7517 hda_nid_t pin;
7518
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007519 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007520 if (pin) /* connect to front */
7521 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7522}
7523
7524static void alc861_auto_init_analog_input(struct hda_codec *codec)
7525{
7526 struct alc_spec *spec = codec->spec;
7527 int i;
7528
7529 for (i = 0; i < AUTO_PIN_LAST; i++) {
7530 hda_nid_t nid = spec->autocfg.input_pins[i];
7531 if ((nid>=0x0c) && (nid <=0x11)) {
7532 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7533 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7534 }
7535 }
7536}
7537
7538/* parse the BIOS configuration and set up the alc_spec */
7539/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7540static int alc861_parse_auto_config(struct hda_codec *codec)
7541{
7542 struct alc_spec *spec = codec->spec;
7543 int err;
7544 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7545
7546 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7547 alc861_ignore)) < 0)
7548 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01007549 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007550 return 0; /* can't find valid BIOS pin config */
7551
7552 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7553 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007554 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
Kailang Yangdf694da2005-12-05 19:42:22 +01007555 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7556 return err;
7557
7558 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7559
7560 if (spec->autocfg.dig_out_pin)
7561 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7562
7563 if (spec->kctl_alloc)
7564 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7565
7566 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7567
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007568 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007569 spec->input_mux = &spec->private_imux;
7570
7571 spec->adc_nids = alc861_adc_nids;
7572 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7573 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7574 spec->num_mixers++;
7575
7576 return 1;
7577}
7578
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007579/* additional initialization for auto-configuration model */
7580static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007581{
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 alc861_auto_init_multi_out(codec);
7583 alc861_auto_init_hp_out(codec);
7584 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007585}
7586
7587
7588/*
7589 * configuration and preset
7590 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007591static const char *alc861_models[ALC861_MODEL_LAST] = {
7592 [ALC861_3ST] = "3stack",
7593 [ALC660_3ST] = "3stack-660",
7594 [ALC861_3ST_DIG] = "3stack-dig",
7595 [ALC861_6ST_DIG] = "6stack-dig",
7596 [ALC861_UNIWILL_M31] = "uniwill-m31",
7597 [ALC861_TOSHIBA] = "toshiba",
7598 [ALC861_ASUS] = "asus",
7599 [ALC861_ASUS_LAPTOP] = "asus-laptop",
7600 [ALC861_AUTO] = "auto",
7601};
7602
7603static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01007604 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007605 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7606 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7607 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7608 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
Tobin Davisad5e7732007-01-08 10:57:32 +01007609 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007610 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
7611 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
7612 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01007613 {}
7614};
7615
7616static struct alc_config_preset alc861_presets[] = {
7617 [ALC861_3ST] = {
7618 .mixers = { alc861_3ST_mixer },
7619 .init_verbs = { alc861_threestack_init_verbs },
7620 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7621 .dac_nids = alc861_dac_nids,
7622 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7623 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007624 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007625 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7626 .adc_nids = alc861_adc_nids,
7627 .input_mux = &alc861_capture_source,
7628 },
7629 [ALC861_3ST_DIG] = {
7630 .mixers = { alc861_base_mixer },
7631 .init_verbs = { alc861_threestack_init_verbs },
7632 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7633 .dac_nids = alc861_dac_nids,
7634 .dig_out_nid = ALC861_DIGOUT_NID,
7635 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7636 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007637 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007638 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7639 .adc_nids = alc861_adc_nids,
7640 .input_mux = &alc861_capture_source,
7641 },
7642 [ALC861_6ST_DIG] = {
7643 .mixers = { alc861_base_mixer },
7644 .init_verbs = { alc861_base_init_verbs },
7645 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7646 .dac_nids = alc861_dac_nids,
7647 .dig_out_nid = ALC861_DIGOUT_NID,
7648 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7649 .channel_mode = alc861_8ch_modes,
7650 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7651 .adc_nids = alc861_adc_nids,
7652 .input_mux = &alc861_capture_source,
7653 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007654 [ALC660_3ST] = {
7655 .mixers = { alc861_3ST_mixer },
7656 .init_verbs = { alc861_threestack_init_verbs },
7657 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7658 .dac_nids = alc660_dac_nids,
7659 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7660 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007661 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007662 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7663 .adc_nids = alc861_adc_nids,
7664 .input_mux = &alc861_capture_source,
7665 },
Takashi Iwai22309c32006-08-09 16:57:28 +02007666 [ALC861_UNIWILL_M31] = {
7667 .mixers = { alc861_uniwill_m31_mixer },
7668 .init_verbs = { alc861_uniwill_m31_init_verbs },
7669 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7670 .dac_nids = alc861_dac_nids,
7671 .dig_out_nid = ALC861_DIGOUT_NID,
7672 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7673 .channel_mode = alc861_uniwill_m31_modes,
7674 .need_dac_fix = 1,
7675 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7676 .adc_nids = alc861_adc_nids,
7677 .input_mux = &alc861_capture_source,
7678 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007679 [ALC861_TOSHIBA] = {
7680 .mixers = { alc861_toshiba_mixer },
7681 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7682 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7683 .dac_nids = alc861_dac_nids,
7684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7685 .channel_mode = alc883_3ST_2ch_modes,
7686 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7687 .adc_nids = alc861_adc_nids,
7688 .input_mux = &alc861_capture_source,
7689 .unsol_event = alc861_toshiba_unsol_event,
7690 .init_hook = alc861_toshiba_automute,
7691 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007692 [ALC861_ASUS] = {
7693 .mixers = { alc861_asus_mixer },
7694 .init_verbs = { alc861_asus_init_verbs },
7695 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7696 .dac_nids = alc861_dac_nids,
7697 .dig_out_nid = ALC861_DIGOUT_NID,
7698 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
7699 .channel_mode = alc861_asus_modes,
7700 .need_dac_fix = 1,
7701 .hp_nid = 0x06,
7702 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7703 .adc_nids = alc861_adc_nids,
7704 .input_mux = &alc861_capture_source,
7705 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01007706 [ALC861_ASUS_LAPTOP] = {
7707 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
7708 .init_verbs = { alc861_asus_init_verbs,
7709 alc861_asus_laptop_init_verbs },
7710 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7711 .dac_nids = alc861_dac_nids,
7712 .dig_out_nid = ALC861_DIGOUT_NID,
7713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7714 .channel_mode = alc883_3ST_2ch_modes,
7715 .need_dac_fix = 1,
7716 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7717 .adc_nids = alc861_adc_nids,
7718 .input_mux = &alc861_capture_source,
7719 },
7720};
Kailang Yangdf694da2005-12-05 19:42:22 +01007721
7722
7723static int patch_alc861(struct hda_codec *codec)
7724{
7725 struct alc_spec *spec;
7726 int board_config;
7727 int err;
7728
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007730 if (spec == NULL)
7731 return -ENOMEM;
7732
7733 codec->spec = spec;
7734
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007735 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7736 alc861_models,
7737 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007738
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007739 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007740 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7741 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007742 board_config = ALC861_AUTO;
7743 }
7744
7745 if (board_config == ALC861_AUTO) {
7746 /* automatic parse from the BIOS config */
7747 err = alc861_parse_auto_config(codec);
7748 if (err < 0) {
7749 alc_free(codec);
7750 return err;
7751 } else if (! err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007752 printk(KERN_INFO
7753 "hda_codec: Cannot set up configuration "
7754 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007755 board_config = ALC861_3ST_DIG;
7756 }
7757 }
7758
7759 if (board_config != ALC861_AUTO)
7760 setup_preset(spec, &alc861_presets[board_config]);
7761
7762 spec->stream_name_analog = "ALC861 Analog";
7763 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7764 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7765
7766 spec->stream_name_digital = "ALC861 Digital";
7767 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7768 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7769
7770 codec->patch_ops = alc_patch_ops;
7771 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007772 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01007773
7774 return 0;
7775}
7776
7777/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07007778 * patch entries
7779 */
7780struct hda_codec_preset snd_hda_preset_realtek[] = {
7781 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007782 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007783 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
7784 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007785 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007786 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007787 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
7788 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
7789 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007790 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007791 .patch = patch_alc861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007792 { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07007793 {} /* terminator */
7794};