blob: 4bff20f76b0811d3114592d95d5f27929a365aa9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yangdf694da2005-12-05 19:42:22 +010097 ALC262_AUTO,
98 ALC262_MODEL_LAST /* last tag */
99};
100
Kailang Yanga361d842007-06-05 12:30:55 +0200101/* ALC268 models */
102enum {
103 ALC268_3ST,
104 ALC268_AUTO,
105 ALC268_MODEL_LAST /* last tag */
106};
107
Kailang Yangdf694da2005-12-05 19:42:22 +0100108/* ALC861 models */
109enum {
110 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200111 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100112 ALC861_3ST_DIG,
113 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200114 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200115 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200116 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100117 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100118 ALC861_AUTO,
119 ALC861_MODEL_LAST,
120};
121
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100122/* ALC861-VD models */
123enum {
124 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200125 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100126 ALC861VD_3ST,
127 ALC861VD_3ST_DIG,
128 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200129 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200130 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100131 ALC861VD_AUTO,
132 ALC861VD_MODEL_LAST,
133};
134
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200135/* ALC662 models */
136enum {
137 ALC662_3ST_2ch_DIG,
138 ALC662_3ST_6ch_DIG,
139 ALC662_3ST_6ch,
140 ALC662_5ST_DIG,
141 ALC662_LENOVO_101E,
142 ALC662_AUTO,
143 ALC662_MODEL_LAST,
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC882 models */
147enum {
148 ALC882_3ST_DIG,
149 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200150 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200151 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200152 ALC882_TARGA,
153 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100154 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200155 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC882_MODEL_LAST,
157};
158
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200159/* ALC883 models */
160enum {
161 ALC883_3ST_2ch_DIG,
162 ALC883_3ST_6ch_DIG,
163 ALC883_3ST_6ch,
164 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200165 ALC883_TARGA_DIG,
166 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200167 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200168 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100170 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200172 ALC883_LENOVO_NB0763,
173 ALC888_LENOVO_MS7195_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200174 ALC883_AUTO,
175 ALC883_MODEL_LAST,
176};
177
Kailang Yangdf694da2005-12-05 19:42:22 +0100178/* for GPIO Poll */
179#define GPIO_MASK 0x03
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181struct alc_spec {
182 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100183 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 unsigned int num_mixers;
185
Kailang Yangdf694da2005-12-05 19:42:22 +0100186 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200187 * don't forget NULL
188 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200189 */
190 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
Takashi Iwai16ded522005-06-10 19:58:24 +0200192 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 struct hda_pcm_stream *stream_analog_playback;
194 struct hda_pcm_stream *stream_analog_capture;
195
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200196 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 struct hda_pcm_stream *stream_digital_playback;
198 struct hda_pcm_stream *stream_digital_capture;
199
200 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200201 struct hda_multi_out multiout; /* playback set-up
202 * max_channels, dacs must be set
203 * dig_out_nid and hp_nid are optional
204 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 /* capture */
207 unsigned int num_adc_nids;
208 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200209 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200212 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 const struct hda_input_mux *input_mux;
214 unsigned int cur_mux[3];
215
216 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100217 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200219 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100222 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200223
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200224 /* dynamic controls, init_verbs and input_mux */
225 struct auto_pin_cfg autocfg;
226 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100227 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200228 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100229 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100230
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100231 /* hooks */
232 void (*init_hook)(struct hda_codec *codec);
233 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
234
Takashi Iwai834be882006-03-01 14:16:17 +0100235 /* for pin sensing */
236 unsigned int sense_updated: 1;
237 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100238};
239
240/*
241 * configuration template - to be copied to the spec instance
242 */
243struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200244 struct snd_kcontrol_new *mixers[5]; /* should be identical size
245 * with spec
246 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100247 const struct hda_verb *init_verbs[5];
248 unsigned int num_dacs;
249 hda_nid_t *dac_nids;
250 hda_nid_t dig_out_nid; /* optional */
251 hda_nid_t hp_nid; /* optional */
252 unsigned int num_adc_nids;
253 hda_nid_t *adc_nids;
254 hda_nid_t dig_in_nid;
255 unsigned int num_channel_mode;
256 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200257 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200258 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100259 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100260 void (*unsol_event)(struct hda_codec *, unsigned int);
261 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262};
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265/*
266 * input MUX handling
267 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200268static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270{
271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
272 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200273 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
274 if (mux_idx >= spec->num_mux_defs)
275 mux_idx = 0;
276 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
278
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 struct alc_spec *spec = codec->spec;
284 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
285
286 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
287 return 0;
288}
289
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200290static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
291 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292{
293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
294 struct alc_spec *spec = codec->spec;
295 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200296 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
297 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200298 spec->adc_nids[adc_idx],
299 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303/*
304 * channel mode setting
305 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200306static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
307 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308{
309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
310 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100311 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
312 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313}
314
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200315static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
316 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317{
318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
319 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100320 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200321 spec->num_channel_mode,
322 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323}
324
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200325static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200330 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
331 spec->num_channel_mode,
332 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200333 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200334 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
335 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336}
337
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100339 * Control the mode of pin widget settings via the mixer. "pc" is used
340 * instead of "%" to avoid consequences of accidently treating the % as
341 * being part of a format specifier. Maximum allowed length of a value is
342 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100343 *
344 * Note: some retasking pin complexes seem to ignore requests for input
345 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
346 * are requested. Therefore order this list so that this behaviour will not
347 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200348 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
349 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200350 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100351static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100352 "Mic 50pc bias", "Mic 80pc bias",
353 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100354};
355static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100356 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100357};
358/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200359 * in the pin being assumed to be exclusively an input or an output pin. In
360 * addition, "input" pins may or may not process the mic bias option
361 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
362 * accept requests for bias as of chip versions up to March 2006) and/or
363 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100364 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200365#define ALC_PIN_DIR_IN 0x00
366#define ALC_PIN_DIR_OUT 0x01
367#define ALC_PIN_DIR_INOUT 0x02
368#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
369#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100370
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200371/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372 * For each direction the minimum and maximum values are given.
373 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375 { 0, 2 }, /* ALC_PIN_DIR_IN */
376 { 3, 4 }, /* ALC_PIN_DIR_OUT */
377 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200378 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
379 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380};
381#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
382#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
383#define alc_pin_mode_n_items(_dir) \
384 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
385
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200388{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389 unsigned int item_num = uinfo->value.enumerated.item;
390 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
391
392 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200393 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100394 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
395
396 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
397 item_num = alc_pin_mode_min(dir);
398 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200399 return 0;
400}
401
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200404{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100408 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200409 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200410 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
411 AC_VERB_GET_PIN_WIDGET_CONTROL,
412 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200413
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100414 /* Find enumerated value for current pinctl setting */
415 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200416 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419 return 0;
420}
421
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200422static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
423 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100424{
425 signed int change;
426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
427 hda_nid_t nid = kcontrol->private_value & 0xffff;
428 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
429 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200430 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
431 AC_VERB_GET_PIN_WIDGET_CONTROL,
432 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200434 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 val = alc_pin_mode_min(dir);
436
437 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100438 if (change) {
439 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200440 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200441 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100442
443 /* Also enable the retasking pin's input/output as required
444 * for the requested pin mode. Enum values of 2 or less are
445 * input modes.
446 *
447 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200448 * reduces noise slightly (particularly on input) so we'll
449 * do it. However, having both input and output buffers
450 * enabled simultaneously doesn't seem to be problematic if
451 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100452 */
453 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454 snd_hda_codec_write(codec, nid, 0,
455 AC_VERB_SET_AMP_GAIN_MUTE,
456 AMP_OUT_MUTE);
457 snd_hda_codec_write(codec, nid, 0,
458 AC_VERB_SET_AMP_GAIN_MUTE,
459 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100460 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461 snd_hda_codec_write(codec, nid, 0,
462 AC_VERB_SET_AMP_GAIN_MUTE,
463 AMP_IN_MUTE(0));
464 snd_hda_codec_write(codec, nid, 0,
465 AC_VERB_SET_AMP_GAIN_MUTE,
466 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100467 }
468 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200469 return change;
470}
471
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200473 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474 .info = alc_pin_mode_info, \
475 .get = alc_pin_mode_get, \
476 .put = alc_pin_mode_put, \
477 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100478
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100479/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
480 * together using a mask with more than one bit set. This control is
481 * currently used only by the ALC260 test model. At this stage they are not
482 * needed for any "production" models.
483 */
484#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100487{
488 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
489 uinfo->count = 1;
490 uinfo->value.integer.min = 0;
491 uinfo->value.integer.max = 1;
492 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200493}
494
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 hda_nid_t nid = kcontrol->private_value & 0xffff;
500 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
501 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200502 unsigned int val = snd_hda_codec_read(codec, nid, 0,
503 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100504
505 *valp = (val & mask) != 0;
506 return 0;
507}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100510{
511 signed int change;
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 hda_nid_t nid = kcontrol->private_value & 0xffff;
514 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
515 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
517 AC_VERB_GET_GPIO_DATA,
518 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100519
520 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200521 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
522 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100523 gpio_data &= ~mask;
524 else
525 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100527
528 return change;
529}
530#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
532 .info = alc_gpio_data_info, \
533 .get = alc_gpio_data_get, \
534 .put = alc_gpio_data_put, \
535 .private_value = nid | (mask<<16) }
536#endif /* CONFIG_SND_DEBUG */
537
Jonathan Woithe92621f12006-02-28 11:47:47 +0100538/* A switch control to allow the enabling of the digital IO pins on the
539 * ALC260. This is incredibly simplistic; the intention of this control is
540 * to provide something in the test model allowing digital outputs to be
541 * identified if present. If models are found which can utilise these
542 * outputs a more complete mixer control can be devised for those models if
543 * necessary.
544 */
545#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100548{
549 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
550 uinfo->count = 1;
551 uinfo->value.integer.min = 0;
552 uinfo->value.integer.max = 1;
553 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200554}
555
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
561 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
562 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563 unsigned int val = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100565
566 *valp = (val & mask) != 0;
567 return 0;
568}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
570 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100571{
572 signed int change;
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 hda_nid_t nid = kcontrol->private_value & 0xffff;
575 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
576 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
578 AC_VERB_GET_DIGI_CONVERT,
579 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100580
581 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100583 if (val==0)
584 ctrl_data &= ~mask;
585 else
586 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
588 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100589
590 return change;
591}
592#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
594 .info = alc_spdif_ctrl_info, \
595 .get = alc_spdif_ctrl_get, \
596 .put = alc_spdif_ctrl_put, \
597 .private_value = nid | (mask<<16) }
598#endif /* CONFIG_SND_DEBUG */
599
Kailang Yangdf694da2005-12-05 19:42:22 +0100600/*
601 * set up from the preset table
602 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603static void setup_preset(struct alc_spec *spec,
604 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100605{
606 int i;
607
608 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
609 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200610 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
611 i++)
612 spec->init_verbs[spec->num_init_verbs++] =
613 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100614
615 spec->channel_mode = preset->channel_mode;
616 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200617 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100618
619 spec->multiout.max_channels = spec->channel_mode[0].channels;
620
621 spec->multiout.num_dacs = preset->num_dacs;
622 spec->multiout.dac_nids = preset->dac_nids;
623 spec->multiout.dig_out_nid = preset->dig_out_nid;
624 spec->multiout.hp_nid = preset->hp_nid;
625
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200626 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200627 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200628 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100629 spec->input_mux = preset->input_mux;
630
631 spec->num_adc_nids = preset->num_adc_nids;
632 spec->adc_nids = preset->adc_nids;
633 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100634
635 spec->unsol_event = preset->unsol_event;
636 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100637}
638
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200639/* Enable GPIO mask and set output */
640static struct hda_verb alc_gpio1_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
644 { }
645};
646
647static struct hda_verb alc_gpio2_init_verbs[] = {
648 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
650 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
651 { }
652};
653
Kailang Yangbdd148a2007-05-08 15:19:08 +0200654static struct hda_verb alc_gpio3_init_verbs[] = {
655 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
657 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
658 { }
659};
660
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200661/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
662 * 31 ~ 16 : Manufacture ID
663 * 15 ~ 8 : SKU ID
664 * 7 ~ 0 : Assembly ID
665 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
666 */
667static void alc_subsystem_id(struct hda_codec *codec,
668 unsigned int porta, unsigned int porte,
669 unsigned int portd)
670{
671 unsigned int ass, tmp;
672
673 ass = codec->subsystem_id;
674 if (!(ass & 1))
675 return;
676
677 /* Override */
678 tmp = (ass & 0x38) >> 3; /* external Amp control */
679 switch (tmp) {
680 case 1:
681 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
682 break;
683 case 3:
684 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
685 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200686 case 7:
687 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
688 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200689 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200690 switch (codec->vendor_id) {
691 case 0x10ec0862:
692 case 0x10ec0660:
693 case 0x10ec0662:
694 case 0x10ec0267:
695 case 0x10ec0268:
696 snd_hda_codec_write(codec, 0x14, 0,
697 AC_VERB_SET_EAPD_BTLENABLE, 2);
698 snd_hda_codec_write(codec, 0x15, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 return;
701 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200702 case 6:
703 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
704 hda_nid_t port = 0;
705 tmp = (ass & 0x1800) >> 11;
706 switch (tmp) {
707 case 0: port = porta; break;
708 case 1: port = porte; break;
709 case 2: port = portd; break;
710 }
711 if (port)
712 snd_hda_codec_write(codec, port, 0,
713 AC_VERB_SET_EAPD_BTLENABLE,
714 2);
715 }
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
717 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
718 (tmp == 5 ? 0x3040 : 0x3050));
719 break;
720 }
721}
722
Takashi Iwai41e41f12005-06-08 14:48:49 +0200723/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200724 * ALC880 3-stack model
725 *
726 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
728 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 */
730
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200731static hda_nid_t alc880_dac_nids[4] = {
732 /* front, rear, clfe, rear_surr */
733 0x02, 0x05, 0x04, 0x03
734};
735
736static hda_nid_t alc880_adc_nids[3] = {
737 /* ADC0-2 */
738 0x07, 0x08, 0x09,
739};
740
741/* The datasheet says the node 0x07 is connected from inputs,
742 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100743 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200745static hda_nid_t alc880_adc_nids_alt[2] = {
746 /* ADC1-2 */
747 0x08, 0x09,
748};
749
750#define ALC880_DIGOUT_NID 0x06
751#define ALC880_DIGIN_NID 0x0a
752
753static struct hda_input_mux alc880_capture_source = {
754 .num_items = 4,
755 .items = {
756 { "Mic", 0x0 },
757 { "Front Mic", 0x3 },
758 { "Line", 0x2 },
759 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200761};
762
763/* channel source setting (2/6 channel selection for 3-stack) */
764/* 2ch mode */
765static struct hda_verb alc880_threestack_ch2_init[] = {
766 /* set line-in to input, mute it */
767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
769 /* set mic-in to input vref 80%, mute it */
770 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
771 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 { } /* end */
773};
774
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200775/* 6ch mode */
776static struct hda_verb alc880_threestack_ch6_init[] = {
777 /* set line-in to output, unmute it */
778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
780 /* set mic-in to output, unmute it */
781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
783 { } /* end */
784};
785
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100786static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200787 { 2, alc880_threestack_ch2_init },
788 { 6, alc880_threestack_ch6_init },
789};
790
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100791static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100795 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
801 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
808 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
809 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200811 {
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100814 .info = alc_ch_mode_info,
815 .get = alc_ch_mode_get,
816 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200817 },
818 { } /* end */
819};
820
821/* capture mixer elements */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100822static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200823 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
824 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
825 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
826 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
827 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
828 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
829 {
830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
831 /* The multiple "Capture Source" controls confuse alsamixer
832 * So call somewhat different..
833 * FIXME: the controls appear in the "playback" view!
834 */
835 /* .name = "Capture Source", */
836 .name = "Input Source",
837 .count = 3,
838 .info = alc_mux_enum_info,
839 .get = alc_mux_enum_get,
840 .put = alc_mux_enum_put,
841 },
842 { } /* end */
843};
844
845/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100846static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200847 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
848 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
849 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
850 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 {
852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
853 /* The multiple "Capture Source" controls confuse alsamixer
854 * So call somewhat different..
855 * FIXME: the controls appear in the "playback" view!
856 */
857 /* .name = "Capture Source", */
858 .name = "Input Source",
859 .count = 2,
860 .info = alc_mux_enum_info,
861 .get = alc_mux_enum_get,
862 .put = alc_mux_enum_put,
863 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 { } /* end */
865};
866
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200867
868
869/*
870 * ALC880 5-stack model
871 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200872 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
873 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200874 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
875 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
876 */
877
878/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100879static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200880 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100881 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 { } /* end */
883};
884
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200885/* channel source setting (6/8 channel selection for 5-stack) */
886/* 6ch mode */
887static struct hda_verb alc880_fivestack_ch6_init[] = {
888 /* set line-in to input, mute it */
889 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
890 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200891 { } /* end */
892};
893
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200894/* 8ch mode */
895static struct hda_verb alc880_fivestack_ch8_init[] = {
896 /* set line-in to output, unmute it */
897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
899 { } /* end */
900};
901
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100902static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200903 { 6, alc880_fivestack_ch6_init },
904 { 8, alc880_fivestack_ch8_init },
905};
906
907
908/*
909 * ALC880 6-stack model
910 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200911 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
912 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200913 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
914 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
915 */
916
917static hda_nid_t alc880_6st_dac_nids[4] = {
918 /* front, rear, clfe, rear_surr */
919 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200920};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200921
922static struct hda_input_mux alc880_6stack_capture_source = {
923 .num_items = 4,
924 .items = {
925 { "Mic", 0x0 },
926 { "Front Mic", 0x1 },
927 { "Line", 0x2 },
928 { "CD", 0x4 },
929 },
930};
931
932/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100933static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200934 { 8, NULL },
935};
936
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100937static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200946 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100947 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200948 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
949 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
956 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
957 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200958 {
959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
960 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100961 .info = alc_ch_mode_info,
962 .get = alc_ch_mode_get,
963 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200964 },
965 { } /* end */
966};
967
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200968
969/*
970 * ALC880 W810 model
971 *
972 * W810 has rear IO for:
973 * Front (DAC 02)
974 * Surround (DAC 03)
975 * Center/LFE (DAC 04)
976 * Digital out (06)
977 *
978 * The system also has a pair of internal speakers, and a headphone jack.
979 * These are both connected to Line2 on the codec, hence to DAC 02.
980 *
981 * There is a variable resistor to control the speaker or headphone
982 * volume. This is a hardware-only device without a software API.
983 *
984 * Plugging headphones in will disable the internal speakers. This is
985 * implemented in hardware, not via the driver using jack sense. In
986 * a similar fashion, plugging into the rear socket marked "front" will
987 * disable both the speakers and headphones.
988 *
989 * For input, there's a microphone jack, and an "audio in" jack.
990 * These may not do anything useful with this driver yet, because I
991 * haven't setup any initialization verbs for these yet...
992 */
993
994static hda_nid_t alc880_w810_dac_nids[3] = {
995 /* front, rear/surround, clfe */
996 0x02, 0x03, 0x04
997};
998
999/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001000static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001001 { 6, NULL }
1002};
1003
1004/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001005static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001008 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001009 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1015 { } /* end */
1016};
1017
1018
1019/*
1020 * Z710V model
1021 *
1022 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001023 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1024 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001025 */
1026
1027static hda_nid_t alc880_z71v_dac_nids[1] = {
1028 0x02
1029};
1030#define ALC880_Z71V_HP_DAC 0x03
1031
1032/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001033static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001034 { 2, NULL }
1035};
1036
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001037static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001040 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001041 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1046 { } /* end */
1047};
1048
1049
1050/* FIXME! */
1051/*
1052 * ALC880 F1734 model
1053 *
1054 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1055 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1056 */
1057
1058static hda_nid_t alc880_f1734_dac_nids[1] = {
1059 0x03
1060};
1061#define ALC880_F1734_HP_DAC 0x02
1062
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001063static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001065 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001066 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001067 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001072 { } /* end */
1073};
1074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001075
1076/* FIXME! */
1077/*
1078 * ALC880 ASUS model
1079 *
1080 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1081 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1082 * Mic = 0x18, Line = 0x1a
1083 */
1084
1085#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1086#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1087
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001088static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001089 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001090 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001091 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001092 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001093 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1094 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001095 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1096 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001103 {
1104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1105 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001106 .info = alc_ch_mode_info,
1107 .get = alc_ch_mode_get,
1108 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001109 },
1110 { } /* end */
1111};
1112
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001113/* FIXME! */
1114/*
1115 * ALC880 ASUS W1V model
1116 *
1117 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1118 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1119 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1120 */
1121
1122/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001123static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001124 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1125 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001126 { } /* end */
1127};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001129/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001130static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001131 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1132 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1133 { } /* end */
1134};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001135
Kailang Yangdf694da2005-12-05 19:42:22 +01001136/* TCL S700 */
1137static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1142 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1145 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1147 {
1148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1149 /* The multiple "Capture Source" controls confuse alsamixer
1150 * So call somewhat different..
1151 * FIXME: the controls appear in the "playback" view!
1152 */
1153 /* .name = "Capture Source", */
1154 .name = "Input Source",
1155 .count = 1,
1156 .info = alc_mux_enum_info,
1157 .get = alc_mux_enum_get,
1158 .put = alc_mux_enum_put,
1159 },
1160 { } /* end */
1161};
1162
Kailang Yangccc656c2006-10-17 12:32:26 +02001163/* Uniwill */
1164static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1165 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1166 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1167 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1168 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1181 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1182 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1183 {
1184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1185 .name = "Channel Mode",
1186 .info = alc_ch_mode_info,
1187 .get = alc_ch_mode_get,
1188 .put = alc_ch_mode_put,
1189 },
1190 { } /* end */
1191};
1192
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001193static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1195 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1197 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1201 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1203 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1204 { } /* end */
1205};
1206
Kailang Yangccc656c2006-10-17 12:32:26 +02001207static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1208 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1209 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1210 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1211 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1214 { } /* end */
1215};
1216
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001218 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 */
1220static int alc_build_controls(struct hda_codec *codec)
1221{
1222 struct alc_spec *spec = codec->spec;
1223 int err;
1224 int i;
1225
1226 for (i = 0; i < spec->num_mixers; i++) {
1227 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1228 if (err < 0)
1229 return err;
1230 }
1231
1232 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001233 err = snd_hda_create_spdif_out_ctls(codec,
1234 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 if (err < 0)
1236 return err;
1237 }
1238 if (spec->dig_in_nid) {
1239 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1240 if (err < 0)
1241 return err;
1242 }
1243 return 0;
1244}
1245
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001246
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247/*
1248 * initialize the codec volumes, etc
1249 */
1250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001251/*
1252 * generic initialization of ADC, input mixers and output mixers
1253 */
1254static struct hda_verb alc880_volume_init_verbs[] = {
1255 /*
1256 * Unmute ADC0-2 and set the default input to mic-in
1257 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001258 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001260 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001262 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001265 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1266 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001267 * Note: PASD motherboards uses the Line In 2 as the input for front
1268 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001277 /*
1278 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280 /* set vol=0 to output mixers */
1281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1285 /* set up input amps for analog loopback */
1286 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295
1296 { }
1297};
1298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299/*
1300 * 3-stack pin configuration:
1301 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1302 */
1303static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1304 /*
1305 * preset connection lists of input pins
1306 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1307 */
1308 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1309 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1310 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1311
1312 /*
1313 * Set pin mode and muting
1314 */
1315 /* set front pin widgets 0x14 for output */
1316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1318 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1321 /* Mic2 (as headphone out) for HP output */
1322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1324 /* Line In pin widget for input */
1325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1327 /* Line2 (as front mic) pin widget for input and vref at 80% */
1328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1329 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1330 /* CD pin widget for input */
1331 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1332
1333 { }
1334};
1335
1336/*
1337 * 5-stack pin configuration:
1338 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1339 * line-in/side = 0x1a, f-mic = 0x1b
1340 */
1341static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1342 /*
1343 * preset connection lists of input pins
1344 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1345 */
1346 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1347 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1348
1349 /*
1350 * Set pin mode and muting
1351 */
1352 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001357 /* unmute pins for output (no gain on this amp) */
1358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* Mic2 (as headphone out) for HP output */
1367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001369 /* Line In pin widget for input */
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1372 /* Line2 (as front mic) pin widget for input and vref at 80% */
1373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1374 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1375 /* CD pin widget for input */
1376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377
1378 { }
1379};
1380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381/*
1382 * W810 pin configuration:
1383 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1384 */
1385static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 /* hphone/speaker input selector: front DAC */
1387 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1388
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395
1396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001397 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 { }
1400};
1401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402/*
1403 * Z71V pin configuration:
1404 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1405 */
1406static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001411
Takashi Iwai16ded522005-06-10 19:58:24 +02001412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001415 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001416
1417 { }
1418};
1419
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001420/*
1421 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001422 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1423 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001424 */
1425static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1426 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1427
Takashi Iwai16ded522005-06-10 19:58:24 +02001428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001433 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001435 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1436
Takashi Iwai16ded522005-06-10 19:58:24 +02001437 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001439 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1446
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001447 { }
1448};
Takashi Iwai16ded522005-06-10 19:58:24 +02001449
Kailang Yangccc656c2006-10-17 12:32:26 +02001450/*
1451 * Uniwill pin configuration:
1452 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1453 * line = 0x1a
1454 */
1455static struct hda_verb alc880_uniwill_init_verbs[] = {
1456 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1457
1458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1472
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1479 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1480 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1482
1483 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1484 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1485
1486 { }
1487};
1488
1489/*
1490* Uniwill P53
1491* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1492 */
1493static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1494 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1495
1496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1508
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515
1516 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1517 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1518
1519 { }
1520};
1521
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001522static struct hda_verb alc880_beep_init_verbs[] = {
1523 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1524 { }
1525};
1526
Kailang Yangccc656c2006-10-17 12:32:26 +02001527/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001528static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001529{
1530 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001531 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001532
1533 present = snd_hda_codec_read(codec, 0x14, 0,
1534 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001535 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001536 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001537 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001538 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001539 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001540 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001541 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001542 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001543 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001544}
1545
1546/* auto-toggle front mic */
1547static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1548{
1549 unsigned int present;
1550 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001551
1552 present = snd_hda_codec_read(codec, 0x18, 0,
1553 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001554 bits = present ? 0x80 : 0;
1555 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1556 0x80, bits);
1557 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1558 0x80, bits);
1559}
1560
1561static void alc880_uniwill_automute(struct hda_codec *codec)
1562{
1563 alc880_uniwill_hp_automute(codec);
1564 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001565}
1566
1567static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1568 unsigned int res)
1569{
1570 /* Looks like the unsol event is incompatible with the standard
1571 * definition. 4bit tag is placed at 28 bit!
1572 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001573 switch (res >> 28) {
1574 case ALC880_HP_EVENT:
1575 alc880_uniwill_hp_automute(codec);
1576 break;
1577 case ALC880_MIC_EVENT:
1578 alc880_uniwill_mic_automute(codec);
1579 break;
1580 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001581}
1582
1583static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1584{
1585 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001586 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001587
1588 present = snd_hda_codec_read(codec, 0x14, 0,
1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001590 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001591 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001592 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001593 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001594 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001595}
1596
1597static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1598{
1599 unsigned int present;
1600
1601 present = snd_hda_codec_read(codec, 0x21, 0,
1602 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1603
1604 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1605 0x7f, present);
1606 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1607 0x7f, present);
1608
1609 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1610 0x7f, present);
1611 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1612 0x7f, present);
1613
1614}
1615static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1616 unsigned int res)
1617{
1618 /* Looks like the unsol event is incompatible with the standard
1619 * definition. 4bit tag is placed at 28 bit!
1620 */
1621 if ((res >> 28) == ALC880_HP_EVENT)
1622 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001623 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001624 alc880_uniwill_p53_dcvol_automute(codec);
1625}
1626
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001627/* FIXME! */
1628/*
1629 * F1734 pin configuration:
1630 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1631 */
1632static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1633 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1634 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1635 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1637
1638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1642
1643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001652
1653 { }
1654};
1655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656/* FIXME! */
1657/*
1658 * ASUS pin configuration:
1659 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1660 */
1661static struct hda_verb alc880_pin_asus_init_verbs[] = {
1662 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1663 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1664 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1665 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1666
1667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675
1676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1677 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1680 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1685
1686 { }
1687};
1688
1689/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001690#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1691#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001692
Kailang Yangdf694da2005-12-05 19:42:22 +01001693/* Clevo m520g init */
1694static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1695 /* headphone output */
1696 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1697 /* line-out */
1698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1700 /* Line-in */
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 /* CD */
1704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1705 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 /* Mic1 (rear panel) */
1707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 /* Mic2 (front panel) */
1710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712 /* headphone */
1713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1715 /* change to EAPD mode */
1716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1717 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1718
1719 { }
1720};
1721
1722static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001723 /* change to EAPD mode */
1724 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1725 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1726
Kailang Yangdf694da2005-12-05 19:42:22 +01001727 /* Headphone output */
1728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1729 /* Front output*/
1730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1731 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1732
1733 /* Line In pin widget for input */
1734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1735 /* CD pin widget for input */
1736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1739
1740 /* change to EAPD mode */
1741 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1742 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1743
1744 { }
1745};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001746
1747/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001748 * LG m1 express dual
1749 *
1750 * Pin assignment:
1751 * Rear Line-In/Out (blue): 0x14
1752 * Build-in Mic-In: 0x15
1753 * Speaker-out: 0x17
1754 * HP-Out (green): 0x1b
1755 * Mic-In/Out (red): 0x19
1756 * SPDIF-Out: 0x1e
1757 */
1758
1759/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1760static hda_nid_t alc880_lg_dac_nids[3] = {
1761 0x05, 0x02, 0x03
1762};
1763
1764/* seems analog CD is not working */
1765static struct hda_input_mux alc880_lg_capture_source = {
1766 .num_items = 3,
1767 .items = {
1768 { "Mic", 0x1 },
1769 { "Line", 0x5 },
1770 { "Internal Mic", 0x6 },
1771 },
1772};
1773
1774/* 2,4,6 channel modes */
1775static struct hda_verb alc880_lg_ch2_init[] = {
1776 /* set line-in and mic-in to input */
1777 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1778 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1779 { }
1780};
1781
1782static struct hda_verb alc880_lg_ch4_init[] = {
1783 /* set line-in to out and mic-in to input */
1784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1785 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1786 { }
1787};
1788
1789static struct hda_verb alc880_lg_ch6_init[] = {
1790 /* set line-in and mic-in to output */
1791 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1792 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1793 { }
1794};
1795
1796static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1797 { 2, alc880_lg_ch2_init },
1798 { 4, alc880_lg_ch4_init },
1799 { 6, alc880_lg_ch6_init },
1800};
1801
1802static struct snd_kcontrol_new alc880_lg_mixer[] = {
1803 /* FIXME: it's not really "master" but front channels */
1804 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1805 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1806 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1807 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1808 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1809 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1810 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1811 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1815 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1816 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1817 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1818 {
1819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1820 .name = "Channel Mode",
1821 .info = alc_ch_mode_info,
1822 .get = alc_ch_mode_get,
1823 .put = alc_ch_mode_put,
1824 },
1825 { } /* end */
1826};
1827
1828static struct hda_verb alc880_lg_init_verbs[] = {
1829 /* set capture source to mic-in */
1830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1832 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1833 /* mute all amp mixer inputs */
1834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1837 /* line-in to input */
1838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1840 /* built-in mic */
1841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 /* speaker-out */
1844 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 /* mic-in to input */
1847 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1850 /* HP-out */
1851 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1853 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1854 /* jack sense */
1855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1856 { }
1857};
1858
1859/* toggle speaker-output according to the hp-jack state */
1860static void alc880_lg_automute(struct hda_codec *codec)
1861{
1862 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001863 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001864
1865 present = snd_hda_codec_read(codec, 0x1b, 0,
1866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001867 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001868 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001869 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001870 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001871 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001872}
1873
1874static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1875{
1876 /* Looks like the unsol event is incompatible with the standard
1877 * definition. 4bit tag is placed at 28 bit!
1878 */
1879 if ((res >> 28) == 0x01)
1880 alc880_lg_automute(codec);
1881}
1882
1883/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001884 * LG LW20
1885 *
1886 * Pin assignment:
1887 * Speaker-out: 0x14
1888 * Mic-In: 0x18
1889 * Built-in Mic-In: 0x19 (?)
1890 * HP-Out: 0x1b
1891 * SPDIF-Out: 0x1e
1892 */
1893
1894/* seems analog CD is not working */
1895static struct hda_input_mux alc880_lg_lw_capture_source = {
1896 .num_items = 2,
1897 .items = {
1898 { "Mic", 0x0 },
1899 { "Internal Mic", 0x1 },
1900 },
1901};
1902
1903static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1904 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1905 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1909 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1910 { } /* end */
1911};
1912
1913static struct hda_verb alc880_lg_lw_init_verbs[] = {
1914 /* set capture source to mic-in */
1915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1917 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1919 /* speaker-out */
1920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1921 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1922 /* HP-out */
1923 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1924 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 /* mic-in to input */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1929 /* built-in mic */
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 /* jack sense */
1933 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1934 { }
1935};
1936
1937/* toggle speaker-output according to the hp-jack state */
1938static void alc880_lg_lw_automute(struct hda_codec *codec)
1939{
1940 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001941 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001942
1943 present = snd_hda_codec_read(codec, 0x1b, 0,
1944 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001945 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001946 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001947 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001948 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001949 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001950}
1951
1952static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1953{
1954 /* Looks like the unsol event is incompatible with the standard
1955 * definition. 4bit tag is placed at 28 bit!
1956 */
1957 if ((res >> 28) == 0x01)
1958 alc880_lg_lw_automute(codec);
1959}
1960
1961/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001962 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001963 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001964
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965static int alc_init(struct hda_codec *codec)
1966{
1967 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001968 unsigned int i;
1969
1970 for (i = 0; i < spec->num_init_verbs; i++)
1971 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001972
1973 if (spec->init_hook)
1974 spec->init_hook(codec);
1975
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 return 0;
1977}
1978
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001979static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1980{
1981 struct alc_spec *spec = codec->spec;
1982
1983 if (spec->unsol_event)
1984 spec->unsol_event(codec, res);
1985}
1986
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987#ifdef CONFIG_PM
1988/*
1989 * resume
1990 */
1991static int alc_resume(struct hda_codec *codec)
1992{
1993 struct alc_spec *spec = codec->spec;
1994 int i;
1995
1996 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 if (spec->multiout.dig_out_nid)
2000 snd_hda_resume_spdif_out(codec);
2001 if (spec->dig_in_nid)
2002 snd_hda_resume_spdif_in(codec);
2003
2004 return 0;
2005}
2006#endif
2007
2008/*
2009 * Analog playback callbacks
2010 */
2011static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2012 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002013 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002014{
2015 struct alc_spec *spec = codec->spec;
2016 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2017}
2018
2019static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2020 struct hda_codec *codec,
2021 unsigned int stream_tag,
2022 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002023 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024{
2025 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002026 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2027 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028}
2029
2030static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2031 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002032 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033{
2034 struct alc_spec *spec = codec->spec;
2035 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2036}
2037
2038/*
2039 * Digital out
2040 */
2041static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2042 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002043 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044{
2045 struct alc_spec *spec = codec->spec;
2046 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2047}
2048
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002049static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2050 struct hda_codec *codec,
2051 unsigned int stream_tag,
2052 unsigned int format,
2053 struct snd_pcm_substream *substream)
2054{
2055 struct alc_spec *spec = codec->spec;
2056 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2057 stream_tag, format, substream);
2058}
2059
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002062 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063{
2064 struct alc_spec *spec = codec->spec;
2065 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2066}
2067
2068/*
2069 * Analog capture
2070 */
2071static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
2073 unsigned int stream_tag,
2074 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002075 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076{
2077 struct alc_spec *spec = codec->spec;
2078
2079 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2080 stream_tag, 0, format);
2081 return 0;
2082}
2083
2084static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2085 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002086 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087{
2088 struct alc_spec *spec = codec->spec;
2089
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002090 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2091 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 return 0;
2093}
2094
2095
2096/*
2097 */
2098static struct hda_pcm_stream alc880_pcm_analog_playback = {
2099 .substreams = 1,
2100 .channels_min = 2,
2101 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 .ops = {
2104 .open = alc880_playback_pcm_open,
2105 .prepare = alc880_playback_pcm_prepare,
2106 .cleanup = alc880_playback_pcm_cleanup
2107 },
2108};
2109
2110static struct hda_pcm_stream alc880_pcm_analog_capture = {
2111 .substreams = 2,
2112 .channels_min = 2,
2113 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 .ops = {
2116 .prepare = alc880_capture_pcm_prepare,
2117 .cleanup = alc880_capture_pcm_cleanup
2118 },
2119};
2120
2121static struct hda_pcm_stream alc880_pcm_digital_playback = {
2122 .substreams = 1,
2123 .channels_min = 2,
2124 .channels_max = 2,
2125 /* NID is set in alc_build_pcms */
2126 .ops = {
2127 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002128 .close = alc880_dig_playback_pcm_close,
2129 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130 },
2131};
2132
2133static struct hda_pcm_stream alc880_pcm_digital_capture = {
2134 .substreams = 1,
2135 .channels_min = 2,
2136 .channels_max = 2,
2137 /* NID is set in alc_build_pcms */
2138};
2139
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002140/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2141static struct hda_pcm_stream alc_pcm_null_playback = {
2142 .substreams = 0,
2143 .channels_min = 0,
2144 .channels_max = 0,
2145};
2146
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147static int alc_build_pcms(struct hda_codec *codec)
2148{
2149 struct alc_spec *spec = codec->spec;
2150 struct hda_pcm *info = spec->pcm_rec;
2151 int i;
2152
2153 codec->num_pcms = 1;
2154 codec->pcm_info = info;
2155
2156 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002157 if (spec->stream_analog_playback) {
2158 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2159 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2160 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2161 }
2162 if (spec->stream_analog_capture) {
2163 snd_assert(spec->adc_nids, return -EINVAL);
2164 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2165 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2166 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167
Takashi Iwai4a471b72005-12-07 13:56:29 +01002168 if (spec->channel_mode) {
2169 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2170 for (i = 0; i < spec->num_channel_mode; i++) {
2171 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2172 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2173 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 }
2175 }
2176
Takashi Iwaie08a0072006-09-07 17:52:14 +02002177 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002179 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002180 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002182 if (spec->multiout.dig_out_nid &&
2183 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2185 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2186 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002187 if (spec->dig_in_nid &&
2188 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2190 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2191 }
2192 }
2193
Takashi Iwaie08a0072006-09-07 17:52:14 +02002194 /* If the use of more than one ADC is requested for the current
2195 * model, configure a second analog capture-only PCM.
2196 */
2197 /* Additional Analaog capture for index #2 */
2198 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2199 spec->adc_nids) {
2200 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002201 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002202 info->name = spec->stream_name_analog;
2203 /* No playback stream for second PCM */
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2205 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2206 if (spec->stream_analog_capture) {
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2209 }
2210 }
2211
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 return 0;
2213}
2214
2215static void alc_free(struct hda_codec *codec)
2216{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002217 struct alc_spec *spec = codec->spec;
2218 unsigned int i;
2219
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002220 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221 return;
2222
2223 if (spec->kctl_alloc) {
2224 for (i = 0; i < spec->num_kctl_used; i++)
2225 kfree(spec->kctl_alloc[i].name);
2226 kfree(spec->kctl_alloc);
2227 }
2228 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229}
2230
2231/*
2232 */
2233static struct hda_codec_ops alc_patch_ops = {
2234 .build_controls = alc_build_controls,
2235 .build_pcms = alc_build_pcms,
2236 .init = alc_init,
2237 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002238 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239#ifdef CONFIG_PM
2240 .resume = alc_resume,
2241#endif
2242};
2243
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002244
2245/*
2246 * Test configuration for debugging
2247 *
2248 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2249 * enum controls.
2250 */
2251#ifdef CONFIG_SND_DEBUG
2252static hda_nid_t alc880_test_dac_nids[4] = {
2253 0x02, 0x03, 0x04, 0x05
2254};
2255
2256static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002257 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002258 .items = {
2259 { "In-1", 0x0 },
2260 { "In-2", 0x1 },
2261 { "In-3", 0x2 },
2262 { "In-4", 0x3 },
2263 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002264 { "Front", 0x5 },
2265 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002266 },
2267};
2268
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002269static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002270 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002271 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002272 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002273 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002274};
2275
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002276static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2277 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002278{
2279 static char *texts[] = {
2280 "N/A", "Line Out", "HP Out",
2281 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2282 };
2283 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2284 uinfo->count = 1;
2285 uinfo->value.enumerated.items = 8;
2286 if (uinfo->value.enumerated.item >= 8)
2287 uinfo->value.enumerated.item = 7;
2288 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2289 return 0;
2290}
2291
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002292static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2293 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002294{
2295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2296 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2297 unsigned int pin_ctl, item = 0;
2298
2299 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2300 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2301 if (pin_ctl & AC_PINCTL_OUT_EN) {
2302 if (pin_ctl & AC_PINCTL_HP_EN)
2303 item = 2;
2304 else
2305 item = 1;
2306 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2307 switch (pin_ctl & AC_PINCTL_VREFEN) {
2308 case AC_PINCTL_VREF_HIZ: item = 3; break;
2309 case AC_PINCTL_VREF_50: item = 4; break;
2310 case AC_PINCTL_VREF_GRD: item = 5; break;
2311 case AC_PINCTL_VREF_80: item = 6; break;
2312 case AC_PINCTL_VREF_100: item = 7; break;
2313 }
2314 }
2315 ucontrol->value.enumerated.item[0] = item;
2316 return 0;
2317}
2318
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002319static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2320 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002321{
2322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2323 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2324 static unsigned int ctls[] = {
2325 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2331 };
2332 unsigned int old_ctl, new_ctl;
2333
2334 old_ctl = snd_hda_codec_read(codec, nid, 0,
2335 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2336 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2337 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002338 snd_hda_codec_write(codec, nid, 0,
2339 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002340 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002341 (ucontrol->value.enumerated.item[0] >= 3 ?
2342 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002343 return 1;
2344 }
2345 return 0;
2346}
2347
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002348static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2349 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002350{
2351 static char *texts[] = {
2352 "Front", "Surround", "CLFE", "Side"
2353 };
2354 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2355 uinfo->count = 1;
2356 uinfo->value.enumerated.items = 4;
2357 if (uinfo->value.enumerated.item >= 4)
2358 uinfo->value.enumerated.item = 3;
2359 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2360 return 0;
2361}
2362
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002363static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002365{
2366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2367 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2368 unsigned int sel;
2369
2370 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2371 ucontrol->value.enumerated.item[0] = sel & 3;
2372 return 0;
2373}
2374
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002375static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2376 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002377{
2378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2379 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2380 unsigned int sel;
2381
2382 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2383 if (ucontrol->value.enumerated.item[0] != sel) {
2384 sel = ucontrol->value.enumerated.item[0] & 3;
2385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2386 return 1;
2387 }
2388 return 0;
2389}
2390
2391#define PIN_CTL_TEST(xname,nid) { \
2392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2393 .name = xname, \
2394 .info = alc_test_pin_ctl_info, \
2395 .get = alc_test_pin_ctl_get, \
2396 .put = alc_test_pin_ctl_put, \
2397 .private_value = nid \
2398 }
2399
2400#define PIN_SRC_TEST(xname,nid) { \
2401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2402 .name = xname, \
2403 .info = alc_test_pin_src_info, \
2404 .get = alc_test_pin_src_get, \
2405 .put = alc_test_pin_src_put, \
2406 .private_value = nid \
2407 }
2408
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002409static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002410 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2412 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2413 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002414 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2416 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2417 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002418 PIN_CTL_TEST("Front Pin Mode", 0x14),
2419 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2420 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2421 PIN_CTL_TEST("Side Pin Mode", 0x17),
2422 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2423 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2424 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2425 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2426 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2427 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2428 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2429 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2430 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2431 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2432 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2433 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2434 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2435 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2436 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2437 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002440 {
2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2442 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002443 .info = alc_ch_mode_info,
2444 .get = alc_ch_mode_get,
2445 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002446 },
2447 { } /* end */
2448};
2449
2450static struct hda_verb alc880_test_init_verbs[] = {
2451 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002460 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002465 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002470 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002475 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002481 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002486 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002493 /* Analog input/passthru */
2494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002499 { }
2500};
2501#endif
2502
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503/*
2504 */
2505
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002506static const char *alc880_models[ALC880_MODEL_LAST] = {
2507 [ALC880_3ST] = "3stack",
2508 [ALC880_TCL_S700] = "tcl",
2509 [ALC880_3ST_DIG] = "3stack-digout",
2510 [ALC880_CLEVO] = "clevo",
2511 [ALC880_5ST] = "5stack",
2512 [ALC880_5ST_DIG] = "5stack-digout",
2513 [ALC880_W810] = "w810",
2514 [ALC880_Z71V] = "z71v",
2515 [ALC880_6ST] = "6stack",
2516 [ALC880_6ST_DIG] = "6stack-digout",
2517 [ALC880_ASUS] = "asus",
2518 [ALC880_ASUS_W1V] = "asus-w1v",
2519 [ALC880_ASUS_DIG] = "asus-dig",
2520 [ALC880_ASUS_DIG2] = "asus-dig2",
2521 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002522 [ALC880_UNIWILL_P53] = "uniwill-p53",
2523 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002524 [ALC880_F1734] = "F1734",
2525 [ALC880_LG] = "lg",
2526 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002527#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002528 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002529#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002530 [ALC880_AUTO] = "auto",
2531};
2532
2533static struct snd_pci_quirk alc880_cfg_tbl[] = {
2534 /* Broken BIOS configuration */
2535 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2536 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2537
2538 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2539 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002540 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002541 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2542 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2543 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2544 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2545 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2546 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2547
2548 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2549 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2550
2551 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2552 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2553 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2554 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2555 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2556 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2557 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2558 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2559 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2560 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002561 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002562 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2563 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2564 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2565 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2566
2567 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2568 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2569 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2570 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2571 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2572 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2573 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2574 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2575 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2576 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2577 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2578 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2579 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2580 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2582 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2584 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2585
2586 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2587 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2588 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2589 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2590
2591 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2592 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2593 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002594 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002595
2596 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2597 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2598 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2599 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2600
2601 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2602 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2603 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2604 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2605 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2606 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2607 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2608 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2609 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2610 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2611 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002612
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 {}
2614};
2615
Takashi Iwai16ded522005-06-10 19:58:24 +02002616/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002617 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002618 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002619static struct alc_config_preset alc880_presets[] = {
2620 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002622 .init_verbs = { alc880_volume_init_verbs,
2623 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2627 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002628 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002629 .input_mux = &alc880_capture_source,
2630 },
2631 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002633 .init_verbs = { alc880_volume_init_verbs,
2634 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002636 .dac_nids = alc880_dac_nids,
2637 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 .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,
Takashi Iwai16ded522005-06-10 19:58:24 +02002641 .input_mux = &alc880_capture_source,
2642 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002643 [ALC880_TCL_S700] = {
2644 .mixers = { alc880_tcl_s700_mixer },
2645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_pin_tcl_S700_init_verbs,
2647 alc880_gpio2_init_verbs },
2648 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2649 .dac_nids = alc880_dac_nids,
2650 .hp_nid = 0x03,
2651 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2652 .channel_mode = alc880_2_jack_modes,
2653 .input_mux = &alc880_capture_source,
2654 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002655 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002656 .mixers = { alc880_three_stack_mixer,
2657 alc880_five_stack_mixer},
2658 .init_verbs = { alc880_volume_init_verbs,
2659 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2661 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2663 .channel_mode = alc880_fivestack_modes,
2664 .input_mux = &alc880_capture_source,
2665 },
2666 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002667 .mixers = { alc880_three_stack_mixer,
2668 alc880_five_stack_mixer },
2669 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2672 .dac_nids = alc880_dac_nids,
2673 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2675 .channel_mode = alc880_fivestack_modes,
2676 .input_mux = &alc880_capture_source,
2677 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002678 [ALC880_6ST] = {
2679 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002680 .init_verbs = { alc880_volume_init_verbs,
2681 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002682 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2683 .dac_nids = alc880_6st_dac_nids,
2684 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2685 .channel_mode = alc880_sixstack_modes,
2686 .input_mux = &alc880_6stack_capture_source,
2687 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2693 .dac_nids = alc880_6st_dac_nids,
2694 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002695 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2696 .channel_mode = alc880_sixstack_modes,
2697 .input_mux = &alc880_6stack_capture_source,
2698 },
2699 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002701 .init_verbs = { alc880_volume_init_verbs,
2702 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002703 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2705 .dac_nids = alc880_w810_dac_nids,
2706 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002707 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2708 .channel_mode = alc880_w810_modes,
2709 .input_mux = &alc880_capture_source,
2710 },
2711 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002713 .init_verbs = { alc880_volume_init_verbs,
2714 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2716 .dac_nids = alc880_z71v_dac_nids,
2717 .dig_out_nid = ALC880_DIGOUT_NID,
2718 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002719 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2720 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 .input_mux = &alc880_capture_source,
2722 },
2723 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002724 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002725 .init_verbs = { alc880_volume_init_verbs,
2726 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002727 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2728 .dac_nids = alc880_f1734_dac_nids,
2729 .hp_nid = 0x02,
2730 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2731 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002732 .input_mux = &alc880_capture_source,
2733 },
2734 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002736 .init_verbs = { alc880_volume_init_verbs,
2737 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002738 alc880_gpio1_init_verbs },
2739 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2740 .dac_nids = alc880_asus_dac_nids,
2741 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2742 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002743 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002744 .input_mux = &alc880_capture_source,
2745 },
2746 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002748 .init_verbs = { alc880_volume_init_verbs,
2749 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 alc880_gpio1_init_verbs },
2751 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2752 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002753 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2755 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002756 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 .input_mux = &alc880_capture_source,
2758 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002759 [ALC880_ASUS_DIG2] = {
2760 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002761 .init_verbs = { alc880_volume_init_verbs,
2762 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002763 alc880_gpio2_init_verbs }, /* use GPIO2 */
2764 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2765 .dac_nids = alc880_asus_dac_nids,
2766 .dig_out_nid = ALC880_DIGOUT_NID,
2767 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2768 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002769 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002770 .input_mux = &alc880_capture_source,
2771 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002772 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002774 .init_verbs = { alc880_volume_init_verbs,
2775 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 alc880_gpio1_init_verbs },
2777 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2778 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2781 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002782 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002783 .input_mux = &alc880_capture_source,
2784 },
2785 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002786 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002787 .init_verbs = { alc880_volume_init_verbs,
2788 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2790 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2793 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002794 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 .input_mux = &alc880_capture_source,
2796 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002797 [ALC880_UNIWILL] = {
2798 .mixers = { alc880_uniwill_mixer },
2799 .init_verbs = { alc880_volume_init_verbs,
2800 alc880_uniwill_init_verbs },
2801 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2802 .dac_nids = alc880_asus_dac_nids,
2803 .dig_out_nid = ALC880_DIGOUT_NID,
2804 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2805 .channel_mode = alc880_threestack_modes,
2806 .need_dac_fix = 1,
2807 .input_mux = &alc880_capture_source,
2808 .unsol_event = alc880_uniwill_unsol_event,
2809 .init_hook = alc880_uniwill_automute,
2810 },
2811 [ALC880_UNIWILL_P53] = {
2812 .mixers = { alc880_uniwill_p53_mixer },
2813 .init_verbs = { alc880_volume_init_verbs,
2814 alc880_uniwill_p53_init_verbs },
2815 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2816 .dac_nids = alc880_asus_dac_nids,
2817 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002818 .channel_mode = alc880_threestack_modes,
2819 .input_mux = &alc880_capture_source,
2820 .unsol_event = alc880_uniwill_p53_unsol_event,
2821 .init_hook = alc880_uniwill_p53_hp_automute,
2822 },
2823 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002824 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002825 alc880_pcbeep_mixer, },
2826 .init_verbs = { alc880_volume_init_verbs,
2827 alc880_uniwill_p53_init_verbs,
2828 alc880_beep_init_verbs },
2829 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2830 .dac_nids = alc880_dac_nids,
2831 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2832 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002833 .input_mux = &alc880_capture_source,
2834 .unsol_event = alc880_uniwill_p53_unsol_event,
2835 .init_hook = alc880_uniwill_p53_hp_automute,
2836 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002837 [ALC880_CLEVO] = {
2838 .mixers = { alc880_three_stack_mixer },
2839 .init_verbs = { alc880_volume_init_verbs,
2840 alc880_pin_clevo_init_verbs },
2841 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2842 .dac_nids = alc880_dac_nids,
2843 .hp_nid = 0x03,
2844 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2845 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002846 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002847 .input_mux = &alc880_capture_source,
2848 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002849 [ALC880_LG] = {
2850 .mixers = { alc880_lg_mixer },
2851 .init_verbs = { alc880_volume_init_verbs,
2852 alc880_lg_init_verbs },
2853 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2854 .dac_nids = alc880_lg_dac_nids,
2855 .dig_out_nid = ALC880_DIGOUT_NID,
2856 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2857 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002858 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002859 .input_mux = &alc880_lg_capture_source,
2860 .unsol_event = alc880_lg_unsol_event,
2861 .init_hook = alc880_lg_automute,
2862 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002863 [ALC880_LG_LW] = {
2864 .mixers = { alc880_lg_lw_mixer },
2865 .init_verbs = { alc880_volume_init_verbs,
2866 alc880_lg_lw_init_verbs },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002867 .num_dacs = 1,
Takashi Iwaid6815182006-03-23 16:06:23 +01002868 .dac_nids = alc880_dac_nids,
2869 .dig_out_nid = ALC880_DIGOUT_NID,
2870 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2871 .channel_mode = alc880_2_jack_modes,
2872 .input_mux = &alc880_lg_lw_capture_source,
2873 .unsol_event = alc880_lg_lw_unsol_event,
2874 .init_hook = alc880_lg_lw_automute,
2875 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002876#ifdef CONFIG_SND_DEBUG
2877 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002878 .mixers = { alc880_test_mixer },
2879 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002880 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2881 .dac_nids = alc880_test_dac_nids,
2882 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2884 .channel_mode = alc880_test_modes,
2885 .input_mux = &alc880_test_capture_source,
2886 },
2887#endif
2888};
2889
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890/*
2891 * Automatic parse of I/O pins from the BIOS configuration
2892 */
2893
2894#define NUM_CONTROL_ALLOC 32
2895#define NUM_VERB_ALLOC 32
2896
2897enum {
2898 ALC_CTL_WIDGET_VOL,
2899 ALC_CTL_WIDGET_MUTE,
2900 ALC_CTL_BIND_MUTE,
2901};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002902static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2904 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002905 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002906};
2907
2908/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002909static int add_control(struct alc_spec *spec, int type, const char *name,
2910 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002911{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002912 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913
2914 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2915 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2916
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002917 /* array + terminator */
2918 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2919 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920 return -ENOMEM;
2921 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002922 memcpy(knew, spec->kctl_alloc,
2923 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924 kfree(spec->kctl_alloc);
2925 }
2926 spec->kctl_alloc = knew;
2927 spec->num_kctl_alloc = num;
2928 }
2929
2930 knew = &spec->kctl_alloc[spec->num_kctl_used];
2931 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002932 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002933 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934 return -ENOMEM;
2935 knew->private_value = val;
2936 spec->num_kctl_used++;
2937 return 0;
2938}
2939
2940#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2941#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2942#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2943#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2944#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2945#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2946#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2947#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2948#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2949#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2950#define ALC880_PIN_CD_NID 0x1c
2951
2952/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002953static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2954 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955{
2956 hda_nid_t nid;
2957 int assigned[4];
2958 int i, j;
2959
2960 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002961 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002962
2963 /* check the pins hardwired to audio widget */
2964 for (i = 0; i < cfg->line_outs; i++) {
2965 nid = cfg->line_out_pins[i];
2966 if (alc880_is_fixed_pin(nid)) {
2967 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002968 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 assigned[idx] = 1;
2970 }
2971 }
2972 /* left pins can be connect to any audio widget */
2973 for (i = 0; i < cfg->line_outs; i++) {
2974 nid = cfg->line_out_pins[i];
2975 if (alc880_is_fixed_pin(nid))
2976 continue;
2977 /* search for an empty channel */
2978 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002979 if (!assigned[j]) {
2980 spec->multiout.dac_nids[i] =
2981 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002982 assigned[j] = 1;
2983 break;
2984 }
2985 }
2986 }
2987 spec->multiout.num_dacs = cfg->line_outs;
2988 return 0;
2989}
2990
2991/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002992static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2993 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994{
2995 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002996 static const char *chname[4] = {
2997 "Front", "Surround", NULL /*CLFE*/, "Side"
2998 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 hda_nid_t nid;
3000 int i, err;
3001
3002 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003003 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 continue;
3005 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3006 if (i == 2) {
3007 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3009 "Center Playback Volume",
3010 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3011 HDA_OUTPUT));
3012 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003013 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003014 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3015 "LFE Playback Volume",
3016 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3017 HDA_OUTPUT));
3018 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003020 err = add_control(spec, ALC_CTL_BIND_MUTE,
3021 "Center Playback Switch",
3022 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3023 HDA_INPUT));
3024 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003025 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003026 err = add_control(spec, ALC_CTL_BIND_MUTE,
3027 "LFE Playback Switch",
3028 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3029 HDA_INPUT));
3030 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031 return err;
3032 } else {
3033 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3035 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3036 HDA_OUTPUT));
3037 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003038 return err;
3039 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003040 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3041 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3042 HDA_INPUT));
3043 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003044 return err;
3045 }
3046 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 return 0;
3048}
3049
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003050/* add playback controls for speaker and HP outputs */
3051static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3052 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053{
3054 hda_nid_t nid;
3055 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003056 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 return 0;
3060
3061 if (alc880_is_fixed_pin(pin)) {
3062 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003063 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003064 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003065 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003066 else
3067 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003068 /* control HP volume/switch on the output mixer amp */
3069 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003070 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003071 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3072 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3073 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003075 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3077 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 return err;
3080 } else if (alc880_is_multi_pin(pin)) {
3081 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003083 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003084 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3085 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3086 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 return err;
3088 }
3089 return 0;
3090}
3091
3092/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003093static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3094 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003095 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096{
3097 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003098 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099
3100 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003101 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3102 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3103 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 return err;
3105 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003106 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3107 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3108 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 return err;
3110 return 0;
3111}
3112
3113/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003114static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3115 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003118 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119
3120 for (i = 0; i < AUTO_PIN_LAST; i++) {
3121 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003122 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003123 err = new_analog_input(spec, cfg->input_pins[i],
3124 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003125 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 if (err < 0)
3127 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003128 imux->items[imux->num_items].label =
3129 auto_pin_cfg_labels[i];
3130 imux->items[imux->num_items].index =
3131 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 imux->num_items++;
3133 }
3134 }
3135 return 0;
3136}
3137
Kailang Yangdf694da2005-12-05 19:42:22 +01003138static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3139 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003140 int dac_idx)
3141{
3142 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003143 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3144 pin_type);
3145 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3146 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003147 /* need the manual connection? */
3148 if (alc880_is_multi_pin(nid)) {
3149 struct alc_spec *spec = codec->spec;
3150 int idx = alc880_multi_pin_idx(nid);
3151 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3152 AC_VERB_SET_CONNECT_SEL,
3153 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3154 }
3155}
3156
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003157static int get_pin_type(int line_out_type)
3158{
3159 if (line_out_type == AUTO_PIN_HP_OUT)
3160 return PIN_HP;
3161 else
3162 return PIN_OUT;
3163}
3164
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165static void alc880_auto_init_multi_out(struct hda_codec *codec)
3166{
3167 struct alc_spec *spec = codec->spec;
3168 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003169
3170 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171 for (i = 0; i < spec->autocfg.line_outs; i++) {
3172 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003173 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3174 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003175 }
3176}
3177
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003178static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179{
3180 struct alc_spec *spec = codec->spec;
3181 hda_nid_t pin;
3182
Takashi Iwai82bc9552006-03-21 11:24:42 +01003183 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003184 if (pin) /* connect to front */
3185 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003186 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 if (pin) /* connect to front */
3188 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3189}
3190
3191static void alc880_auto_init_analog_input(struct hda_codec *codec)
3192{
3193 struct alc_spec *spec = codec->spec;
3194 int i;
3195
3196 for (i = 0; i < AUTO_PIN_LAST; i++) {
3197 hda_nid_t nid = spec->autocfg.input_pins[i];
3198 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003199 snd_hda_codec_write(codec, nid, 0,
3200 AC_VERB_SET_PIN_WIDGET_CONTROL,
3201 i <= AUTO_PIN_FRONT_MIC ?
3202 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003204 snd_hda_codec_write(codec, nid, 0,
3205 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206 AMP_OUT_MUTE);
3207 }
3208 }
3209}
3210
3211/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003212/* return 1 if successful, 0 if the proper config is not found,
3213 * or a negative error code
3214 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003215static int alc880_parse_auto_config(struct hda_codec *codec)
3216{
3217 struct alc_spec *spec = codec->spec;
3218 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003219 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003221 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3222 alc880_ignore);
3223 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003225 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003228 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3229 if (err < 0)
3230 return err;
3231 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3232 if (err < 0)
3233 return err;
3234 err = alc880_auto_create_extra_out(spec,
3235 spec->autocfg.speaker_pins[0],
3236 "Speaker");
3237 if (err < 0)
3238 return err;
3239 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3240 "Headphone");
3241 if (err < 0)
3242 return err;
3243 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3244 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003245 return err;
3246
3247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3248
3249 if (spec->autocfg.dig_out_pin)
3250 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3251 if (spec->autocfg.dig_in_pin)
3252 spec->dig_in_nid = ALC880_DIGIN_NID;
3253
3254 if (spec->kctl_alloc)
3255 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3256
3257 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3258
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003259 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 spec->input_mux = &spec->private_imux;
3261
3262 return 1;
3263}
3264
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003265/* additional initialization for auto-configuration model */
3266static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003269 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271}
3272
3273/*
3274 * OK, here we have finally the patch for ALC880
3275 */
3276
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277static int patch_alc880(struct hda_codec *codec)
3278{
3279 struct alc_spec *spec;
3280 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003281 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003282
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003283 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003284 if (spec == NULL)
3285 return -ENOMEM;
3286
3287 codec->spec = spec;
3288
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003289 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3290 alc880_models,
3291 alc880_cfg_tbl);
3292 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003293 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3294 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003295 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296 }
3297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298 if (board_config == ALC880_AUTO) {
3299 /* automatic parse from the BIOS config */
3300 err = alc880_parse_auto_config(codec);
3301 if (err < 0) {
3302 alc_free(codec);
3303 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003304 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003305 printk(KERN_INFO
3306 "hda_codec: Cannot set up configuration "
3307 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003308 board_config = ALC880_3ST;
3309 }
3310 }
3311
Kailang Yangdf694da2005-12-05 19:42:22 +01003312 if (board_config != ALC880_AUTO)
3313 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314
3315 spec->stream_name_analog = "ALC880 Analog";
3316 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3317 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3318
3319 spec->stream_name_digital = "ALC880 Digital";
3320 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3321 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3322
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003323 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003325 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003326 /* get type */
3327 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003328 if (wcap != AC_WID_AUD_IN) {
3329 spec->adc_nids = alc880_adc_nids_alt;
3330 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003331 spec->mixers[spec->num_mixers] =
3332 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003333 spec->num_mixers++;
3334 } else {
3335 spec->adc_nids = alc880_adc_nids;
3336 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3337 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3338 spec->num_mixers++;
3339 }
3340 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003341
3342 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003344 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345
3346 return 0;
3347}
3348
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350/*
3351 * ALC260 support
3352 */
3353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003354static hda_nid_t alc260_dac_nids[1] = {
3355 /* front */
3356 0x02,
3357};
3358
3359static hda_nid_t alc260_adc_nids[1] = {
3360 /* ADC0 */
3361 0x04,
3362};
3363
Kailang Yangdf694da2005-12-05 19:42:22 +01003364static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 /* ADC1 */
3366 0x05,
3367};
3368
Kailang Yangdf694da2005-12-05 19:42:22 +01003369static hda_nid_t alc260_hp_adc_nids[2] = {
3370 /* ADC1, 0 */
3371 0x05, 0x04
3372};
3373
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003374/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3375 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3376 */
3377static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003378 /* ADC0, ADC1 */
3379 0x04, 0x05
3380};
3381
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382#define ALC260_DIGOUT_NID 0x03
3383#define ALC260_DIGIN_NID 0x06
3384
3385static struct hda_input_mux alc260_capture_source = {
3386 .num_items = 4,
3387 .items = {
3388 { "Mic", 0x0 },
3389 { "Front Mic", 0x1 },
3390 { "Line", 0x2 },
3391 { "CD", 0x4 },
3392 },
3393};
3394
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003395/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003396 * headphone jack and the internal CD lines since these are the only pins at
3397 * which audio can appear. For flexibility, also allow the option of
3398 * recording the mixer output on the second ADC (ADC0 doesn't have a
3399 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003400 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003401static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3402 {
3403 .num_items = 3,
3404 .items = {
3405 { "Mic/Line", 0x0 },
3406 { "CD", 0x4 },
3407 { "Headphone", 0x2 },
3408 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003409 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003410 {
3411 .num_items = 4,
3412 .items = {
3413 { "Mic/Line", 0x0 },
3414 { "CD", 0x4 },
3415 { "Headphone", 0x2 },
3416 { "Mixer", 0x5 },
3417 },
3418 },
3419
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003420};
3421
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003422/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3423 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003424 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003425static struct hda_input_mux alc260_acer_capture_sources[2] = {
3426 {
3427 .num_items = 4,
3428 .items = {
3429 { "Mic", 0x0 },
3430 { "Line", 0x2 },
3431 { "CD", 0x4 },
3432 { "Headphone", 0x5 },
3433 },
3434 },
3435 {
3436 .num_items = 5,
3437 .items = {
3438 { "Mic", 0x0 },
3439 { "Line", 0x2 },
3440 { "CD", 0x4 },
3441 { "Headphone", 0x6 },
3442 { "Mixer", 0x5 },
3443 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003444 },
3445};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003446/*
3447 * This is just place-holder, so there's something for alc_build_pcms to look
3448 * at when it calculates the maximum number of channels. ALC260 has no mixer
3449 * element which allows changing the channel mode, so the verb list is
3450 * never used.
3451 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003452static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003453 { 2, NULL },
3454};
3455
Kailang Yangdf694da2005-12-05 19:42:22 +01003456
3457/* Mixer combinations
3458 *
3459 * basic: base_output + input + pc_beep + capture
3460 * HP: base_output + input + capture_alt
3461 * HP_3013: hp_3013 + input + capture
3462 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003463 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003464 */
3465
3466static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003467 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003468 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003469 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3470 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3471 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3472 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3473 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003474};
Kailang Yangdf694da2005-12-05 19:42:22 +01003475
3476static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3478 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3479 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3480 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3482 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003485 { } /* end */
3486};
3487
Kailang Yangdf694da2005-12-05 19:42:22 +01003488static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3489 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3490 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3491 { } /* end */
3492};
3493
3494static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3495 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3497 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3498 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3501 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3502 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003503 { } /* end */
3504};
3505
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003506/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3507 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3508 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003509static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003510 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003511 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003512 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003513 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3514 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3515 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3516 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003517 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003518 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3519 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3520 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003521 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003522 { } /* end */
3523};
3524
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003525/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3526 * versions of the ALC260 don't act on requests to enable mic bias from NID
3527 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3528 * datasheet doesn't mention this restriction. At this stage it's not clear
3529 * whether this behaviour is intentional or is a hardware bug in chip
3530 * revisions available in early 2006. Therefore for now allow the
3531 * "Headphone Jack Mode" control to span all choices, but if it turns out
3532 * that the lack of mic bias for this NID is intentional we could change the
3533 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3534 *
3535 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3536 * don't appear to make the mic bias available from the "line" jack, even
3537 * though the NID used for this jack (0x14) can supply it. The theory is
3538 * that perhaps Acer have included blocking capacitors between the ALC260
3539 * and the output jack. If this turns out to be the case for all such
3540 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3541 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003542 *
3543 * The C20x Tablet series have a mono internal speaker which is controlled
3544 * via the chip's Mono sum widget and pin complex, so include the necessary
3545 * controls for such models. On models without a "mono speaker" the control
3546 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003547 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003548static struct snd_kcontrol_new alc260_acer_mixer[] = {
3549 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3550 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003551 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003552 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3553 HDA_OUTPUT),
3554 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3555 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003556 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3557 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3559 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3560 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3561 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3562 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3563 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3564 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3565 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3566 { } /* end */
3567};
3568
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003569/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3570 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3571 */
3572static struct snd_kcontrol_new alc260_will_mixer[] = {
3573 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3574 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3576 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3577 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3578 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3579 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3580 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3581 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3582 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3583 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3584 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3585 { } /* end */
3586};
3587
3588/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3589 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3590 */
3591static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3592 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3593 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3595 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3596 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3597 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3598 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3599 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3600 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3601 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3602 { } /* end */
3603};
3604
Kailang Yangdf694da2005-12-05 19:42:22 +01003605/* capture mixer elements */
3606static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003607 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3608 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003609 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3610 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003611 {
3612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003613 /* The multiple "Capture Source" controls confuse alsamixer
3614 * So call somewhat different..
3615 * FIXME: the controls appear in the "playback" view!
3616 */
3617 /* .name = "Capture Source", */
3618 .name = "Input Source",
3619 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003620 .info = alc_mux_enum_info,
3621 .get = alc_mux_enum_get,
3622 .put = alc_mux_enum_put,
3623 },
3624 { } /* end */
3625};
3626
Kailang Yangdf694da2005-12-05 19:42:22 +01003627static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3628 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3629 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3630 {
3631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3632 /* The multiple "Capture Source" controls confuse alsamixer
3633 * So call somewhat different..
3634 * FIXME: the controls appear in the "playback" view!
3635 */
3636 /* .name = "Capture Source", */
3637 .name = "Input Source",
3638 .count = 1,
3639 .info = alc_mux_enum_info,
3640 .get = alc_mux_enum_get,
3641 .put = alc_mux_enum_put,
3642 },
3643 { } /* end */
3644};
3645
3646/*
3647 * initialization verbs
3648 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003649static struct hda_verb alc260_init_verbs[] = {
3650 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003652 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003654 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003655 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003658 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003660 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003661 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003662 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003663 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003665 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003666 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003667 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3668 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003669 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003670 /* set connection select to line in (default select for this ADC) */
3671 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003672 /* mute capture amp left and right */
3673 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3674 /* set connection select to line in (default select for this ADC) */
3675 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003676 /* set vol=0 Line-Out mixer amp left and right */
3677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3678 /* unmute pin widget amp left and right (no gain on this amp) */
3679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3680 /* set vol=0 HP mixer amp left and right */
3681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 /* unmute pin widget amp left and right (no gain on this amp) */
3683 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3684 /* set vol=0 Mono mixer amp left and right */
3685 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3686 /* unmute pin widget amp left and right (no gain on this amp) */
3687 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3688 /* unmute LINE-2 out pin */
3689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003690 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3691 * Line In 2 = 0x03
3692 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003693 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003695 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003697 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003699 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003700 /* mute Front out path */
3701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3702 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3703 /* mute Headphone out path */
3704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3706 /* mute Mono out path */
3707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3708 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709 { }
3710};
3711
Takashi Iwai474167d2006-05-17 17:17:43 +02003712#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003713static struct hda_verb alc260_hp_init_verbs[] = {
3714 /* Headphone and output */
3715 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3716 /* mono output */
3717 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3718 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3719 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3720 /* Mic2 (front panel) pin widget for input and vref at 80% */
3721 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3722 /* Line In pin widget for input */
3723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3724 /* Line-2 pin widget for output */
3725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3726 /* CD pin widget for input */
3727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3728 /* unmute amp left and right */
3729 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3730 /* set connection select to line in (default select for this ADC) */
3731 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3732 /* unmute Line-Out mixer amp left and right (volume = 0) */
3733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3734 /* mute pin widget amp left and right (no gain on this amp) */
3735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3736 /* unmute HP mixer amp left and right (volume = 0) */
3737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3738 /* mute pin widget amp left and right (no gain on this amp) */
3739 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003740 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3741 * Line In 2 = 0x03
3742 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003743 /* unmute CD */
3744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3745 /* unmute Line In */
3746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3747 /* unmute Mic */
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3749 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3750 /* Unmute Front out path */
3751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3753 /* Unmute Headphone out path */
3754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3756 /* Unmute Mono out path */
3757 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3758 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3759 { }
3760};
Takashi Iwai474167d2006-05-17 17:17:43 +02003761#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003762
3763static struct hda_verb alc260_hp_3013_init_verbs[] = {
3764 /* Line out and output */
3765 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3766 /* mono output */
3767 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3768 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3769 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3770 /* Mic2 (front panel) pin widget for input and vref at 80% */
3771 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3772 /* Line In pin widget for input */
3773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3774 /* Headphone pin widget for output */
3775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3776 /* CD pin widget for input */
3777 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3778 /* unmute amp left and right */
3779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3780 /* set connection select to line in (default select for this ADC) */
3781 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3782 /* unmute Line-Out mixer amp left and right (volume = 0) */
3783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3784 /* mute pin widget amp left and right (no gain on this amp) */
3785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3786 /* unmute HP mixer amp left and right (volume = 0) */
3787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3788 /* mute pin widget amp left and right (no gain on this amp) */
3789 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003790 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3791 * Line In 2 = 0x03
3792 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003793 /* unmute CD */
3794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3795 /* unmute Line In */
3796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3797 /* unmute Mic */
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3799 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3800 /* Unmute Front out path */
3801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3803 /* Unmute Headphone out path */
3804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3805 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3806 /* Unmute Mono out path */
3807 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3808 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3809 { }
3810};
3811
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003812/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003813 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3814 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003815 */
3816static struct hda_verb alc260_fujitsu_init_verbs[] = {
3817 /* Disable all GPIOs */
3818 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3819 /* Internal speaker is connected to headphone pin */
3820 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3821 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003823 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3824 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3825 /* Ensure all other unused pins are disabled and muted. */
3826 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3827 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003828 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003829 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003830 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003831 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003834
Jonathan Woithef7ace402006-02-28 11:46:14 +01003835 /* Disable digital (SPDIF) pins */
3836 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3837 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003838
Jonathan Woithef7ace402006-02-28 11:46:14 +01003839 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3840 * when acting as an output.
3841 */
3842 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3843
3844 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003854
Jonathan Woithef7ace402006-02-28 11:46:14 +01003855 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3856 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 /* Unmute Line1 pin widget output buffer since it starts as an output.
3858 * If the pin mode is changed by the user the pin mode control will
3859 * take care of enabling the pin's input/output buffers as needed.
3860 * Therefore there's no need to enable the input buffer at this
3861 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003862 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003864 /* Unmute input buffer of pin widget used for Line-in (no equiv
3865 * mixer ctrl)
3866 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003867 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003868
Jonathan Woithef7ace402006-02-28 11:46:14 +01003869 /* Mute capture amp left and right */
3870 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3871 /* Set ADC connection select to match default mixer setting - line
3872 * in (on mic1 pin)
3873 */
3874 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003875
Jonathan Woithef7ace402006-02-28 11:46:14 +01003876 /* Do the same for the second ADC: mute capture input amp and
3877 * set ADC connection to line in (on mic1 pin)
3878 */
3879 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3880 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003881
Jonathan Woithef7ace402006-02-28 11:46:14 +01003882 /* Mute all inputs to mixer widget (even unconnected ones) */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003891
3892 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003893};
3894
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003895/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3896 * similar laptops (adapted from Fujitsu init verbs).
3897 */
3898static struct hda_verb alc260_acer_init_verbs[] = {
3899 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3900 * the headphone jack. Turn this on and rely on the standard mute
3901 * methods whenever the user wants to turn these outputs off.
3902 */
3903 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3904 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3905 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3906 /* Internal speaker/Headphone jack is connected to Line-out pin */
3907 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3908 /* Internal microphone/Mic jack is connected to Mic1 pin */
3909 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3910 /* Line In jack is connected to Line1 pin */
3911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003912 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3913 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003914 /* Ensure all other unused pins are disabled and muted. */
3915 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3916 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003917 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3918 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3921 /* Disable digital (SPDIF) pins */
3922 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3923 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3924
3925 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3926 * bus when acting as outputs.
3927 */
3928 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3929 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3930
3931 /* Start with output sum widgets muted and their output gains at min */
3932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3935 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3938 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3939 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3941
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003942 /* Unmute Line-out pin widget amp left and right
3943 * (no equiv mixer ctrl)
3944 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003946 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3947 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003948 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3949 * inputs. If the pin mode is changed by the user the pin mode control
3950 * will take care of enabling the pin's input/output buffers as needed.
3951 * Therefore there's no need to enable the input buffer at this
3952 * stage.
3953 */
3954 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3956
3957 /* Mute capture amp left and right */
3958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 /* Set ADC connection select to match default mixer setting - mic
3960 * (on mic1 pin)
3961 */
3962 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3963
3964 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003965 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003966 */
3967 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003968 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003969
3970 /* Mute all inputs to mixer widget (even unconnected ones) */
3971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3979
3980 { }
3981};
3982
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003983static struct hda_verb alc260_will_verbs[] = {
3984 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3985 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3986 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3987 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3988 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3989 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3990 {}
3991};
3992
3993static struct hda_verb alc260_replacer_672v_verbs[] = {
3994 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3995 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3996 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3997
3998 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3999 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4000 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4001
4002 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4003 {}
4004};
4005
4006/* toggle speaker-output according to the hp-jack state */
4007static void alc260_replacer_672v_automute(struct hda_codec *codec)
4008{
4009 unsigned int present;
4010
4011 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4012 present = snd_hda_codec_read(codec, 0x0f, 0,
4013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4014 if (present) {
4015 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4016 snd_hda_codec_write(codec, 0x0f, 0,
4017 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4018 } else {
4019 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4020 snd_hda_codec_write(codec, 0x0f, 0,
4021 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4022 }
4023}
4024
4025static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4026 unsigned int res)
4027{
4028 if ((res >> 26) == ALC880_HP_EVENT)
4029 alc260_replacer_672v_automute(codec);
4030}
4031
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004032/* Test configuration for debugging, modelled after the ALC880 test
4033 * configuration.
4034 */
4035#ifdef CONFIG_SND_DEBUG
4036static hda_nid_t alc260_test_dac_nids[1] = {
4037 0x02,
4038};
4039static hda_nid_t alc260_test_adc_nids[2] = {
4040 0x04, 0x05,
4041};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004042/* For testing the ALC260, each input MUX needs its own definition since
4043 * the signal assignments are different. This assumes that the first ADC
4044 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004045 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004046static struct hda_input_mux alc260_test_capture_sources[2] = {
4047 {
4048 .num_items = 7,
4049 .items = {
4050 { "MIC1 pin", 0x0 },
4051 { "MIC2 pin", 0x1 },
4052 { "LINE1 pin", 0x2 },
4053 { "LINE2 pin", 0x3 },
4054 { "CD pin", 0x4 },
4055 { "LINE-OUT pin", 0x5 },
4056 { "HP-OUT pin", 0x6 },
4057 },
4058 },
4059 {
4060 .num_items = 8,
4061 .items = {
4062 { "MIC1 pin", 0x0 },
4063 { "MIC2 pin", 0x1 },
4064 { "LINE1 pin", 0x2 },
4065 { "LINE2 pin", 0x3 },
4066 { "CD pin", 0x4 },
4067 { "Mixer", 0x5 },
4068 { "LINE-OUT pin", 0x6 },
4069 { "HP-OUT pin", 0x7 },
4070 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004071 },
4072};
4073static struct snd_kcontrol_new alc260_test_mixer[] = {
4074 /* Output driver widgets */
4075 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4076 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4077 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4078 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4079 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4080 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4081
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004082 /* Modes for retasking pin widgets
4083 * Note: the ALC260 doesn't seem to act on requests to enable mic
4084 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4085 * mention this restriction. At this stage it's not clear whether
4086 * this behaviour is intentional or is a hardware bug in chip
4087 * revisions available at least up until early 2006. Therefore for
4088 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4089 * choices, but if it turns out that the lack of mic bias for these
4090 * NIDs is intentional we could change their modes from
4091 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4092 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004093 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4094 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4095 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4096 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4097 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4098 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4099
4100 /* Loopback mixer controls */
4101 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4102 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4103 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4104 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4105 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4106 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4107 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4108 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4109 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4110 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4111 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4112 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4113 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4114 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4115 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4116 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004117
4118 /* Controls for GPIO pins, assuming they are configured as outputs */
4119 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4120 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4121 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4122 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4123
Jonathan Woithe92621f12006-02-28 11:47:47 +01004124 /* Switches to allow the digital IO pins to be enabled. The datasheet
4125 * is ambigious as to which NID is which; testing on laptops which
4126 * make this output available should provide clarification.
4127 */
4128 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4129 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4130
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004131 { } /* end */
4132};
4133static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004134 /* Enable all GPIOs as outputs with an initial value of 0 */
4135 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4136 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4137 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4138
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004139 /* Enable retasking pins as output, initially without power amp */
4140 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4141 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4144 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4145 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4146
Jonathan Woithe92621f12006-02-28 11:47:47 +01004147 /* Disable digital (SPDIF) pins initially, but users can enable
4148 * them via a mixer switch. In the case of SPDIF-out, this initverb
4149 * payload also sets the generation to 0, output to be in "consumer"
4150 * PCM format, copyright asserted, no pre-emphasis and no validity
4151 * control.
4152 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004153 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4154 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4155
Jonathan Woithef7ace402006-02-28 11:46:14 +01004156 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004157 * OUT1 sum bus when acting as an output.
4158 */
4159 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4160 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4161 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4162 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4163
4164 /* Start with output sum widgets muted and their output gains at min */
4165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4171 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4174
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004175 /* Unmute retasking pin widget output buffers since the default
4176 * state appears to be output. As the pin mode is changed by the
4177 * user the pin mode control will take care of enabling the pin's
4178 * input/output buffers as needed.
4179 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4184 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4185 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4186 /* Also unmute the mono-out pin widget */
4187 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4188
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004189 /* Mute capture amp left and right */
4190 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004191 /* Set ADC connection select to match default mixer setting (mic1
4192 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004193 */
4194 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4195
4196 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004197 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004198 */
4199 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4200 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4201
4202 /* Mute all inputs to mixer widget (even unconnected ones) */
4203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4211
4212 { }
4213};
4214#endif
4215
Linus Torvalds1da177e2005-04-16 15:20:36 -07004216static struct hda_pcm_stream alc260_pcm_analog_playback = {
4217 .substreams = 1,
4218 .channels_min = 2,
4219 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004220};
4221
4222static struct hda_pcm_stream alc260_pcm_analog_capture = {
4223 .substreams = 1,
4224 .channels_min = 2,
4225 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004226};
4227
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004228#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4229#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4230
Kailang Yangdf694da2005-12-05 19:42:22 +01004231/*
4232 * for BIOS auto-configuration
4233 */
4234
4235static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4236 const char *pfx)
4237{
4238 hda_nid_t nid_vol;
4239 unsigned long vol_val, sw_val;
4240 char name[32];
4241 int err;
4242
4243 if (nid >= 0x0f && nid < 0x11) {
4244 nid_vol = nid - 0x7;
4245 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4246 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4247 } else if (nid == 0x11) {
4248 nid_vol = nid - 0x7;
4249 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4250 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4251 } else if (nid >= 0x12 && nid <= 0x15) {
4252 nid_vol = 0x08;
4253 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4254 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4255 } else
4256 return 0; /* N/A */
4257
4258 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004259 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4260 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004261 return err;
4262 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004263 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4264 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004265 return err;
4266 return 1;
4267}
4268
4269/* add playback controls from the parsed DAC table */
4270static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4271 const struct auto_pin_cfg *cfg)
4272{
4273 hda_nid_t nid;
4274 int err;
4275
4276 spec->multiout.num_dacs = 1;
4277 spec->multiout.dac_nids = spec->private_dac_nids;
4278 spec->multiout.dac_nids[0] = 0x02;
4279
4280 nid = cfg->line_out_pins[0];
4281 if (nid) {
4282 err = alc260_add_playback_controls(spec, nid, "Front");
4283 if (err < 0)
4284 return err;
4285 }
4286
Takashi Iwai82bc9552006-03-21 11:24:42 +01004287 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004288 if (nid) {
4289 err = alc260_add_playback_controls(spec, nid, "Speaker");
4290 if (err < 0)
4291 return err;
4292 }
4293
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004294 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004295 if (nid) {
4296 err = alc260_add_playback_controls(spec, nid, "Headphone");
4297 if (err < 0)
4298 return err;
4299 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004300 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004301}
4302
4303/* create playback/capture controls for input pins */
4304static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4305 const struct auto_pin_cfg *cfg)
4306{
Kailang Yangdf694da2005-12-05 19:42:22 +01004307 struct hda_input_mux *imux = &spec->private_imux;
4308 int i, err, idx;
4309
4310 for (i = 0; i < AUTO_PIN_LAST; i++) {
4311 if (cfg->input_pins[i] >= 0x12) {
4312 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004313 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004314 auto_pin_cfg_labels[i], idx,
4315 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 if (err < 0)
4317 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004318 imux->items[imux->num_items].label =
4319 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 imux->items[imux->num_items].index = idx;
4321 imux->num_items++;
4322 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004325 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004326 auto_pin_cfg_labels[i], idx,
4327 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004328 if (err < 0)
4329 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004330 imux->items[imux->num_items].label =
4331 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004332 imux->items[imux->num_items].index = idx;
4333 imux->num_items++;
4334 }
4335 }
4336 return 0;
4337}
4338
4339static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4340 hda_nid_t nid, int pin_type,
4341 int sel_idx)
4342{
4343 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004344 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4345 pin_type);
4346 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4347 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 /* need the manual connection? */
4349 if (nid >= 0x12) {
4350 int idx = nid - 0x12;
4351 snd_hda_codec_write(codec, idx + 0x0b, 0,
4352 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004353 }
4354}
4355
4356static void alc260_auto_init_multi_out(struct hda_codec *codec)
4357{
4358 struct alc_spec *spec = codec->spec;
4359 hda_nid_t nid;
4360
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004361 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004362 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004363 if (nid) {
4364 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4365 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4366 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004367
Takashi Iwai82bc9552006-03-21 11:24:42 +01004368 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004369 if (nid)
4370 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4371
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004372 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004374 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004375}
Kailang Yangdf694da2005-12-05 19:42:22 +01004376
4377#define ALC260_PIN_CD_NID 0x16
4378static void alc260_auto_init_analog_input(struct hda_codec *codec)
4379{
4380 struct alc_spec *spec = codec->spec;
4381 int i;
4382
4383 for (i = 0; i < AUTO_PIN_LAST; i++) {
4384 hda_nid_t nid = spec->autocfg.input_pins[i];
4385 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 snd_hda_codec_write(codec, nid, 0,
4387 AC_VERB_SET_PIN_WIDGET_CONTROL,
4388 i <= AUTO_PIN_FRONT_MIC ?
4389 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004390 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004391 snd_hda_codec_write(codec, nid, 0,
4392 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004393 AMP_OUT_MUTE);
4394 }
4395 }
4396}
4397
4398/*
4399 * generic initialization of ADC, input mixers and output mixers
4400 */
4401static struct hda_verb alc260_volume_init_verbs[] = {
4402 /*
4403 * Unmute ADC0-1 and set the default input to mic-in
4404 */
4405 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4406 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4407 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4408 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4409
4410 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4411 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004412 * Note: PASD motherboards uses the Line In 2 as the input for
4413 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004414 */
4415 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4421
4422 /*
4423 * Set up output mixers (0x08 - 0x0a)
4424 */
4425 /* set vol=0 to output mixers */
4426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4429 /* set up input amps for analog loopback */
4430 /* Amp Indices: DAC = 0, mixer = 1 */
4431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4435 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4436 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4437
4438 { }
4439};
4440
4441static int alc260_parse_auto_config(struct hda_codec *codec)
4442{
4443 struct alc_spec *spec = codec->spec;
4444 unsigned int wcap;
4445 int err;
4446 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4449 alc260_ignore);
4450 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004451 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4453 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004454 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004456 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004457 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4458 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004459 return err;
4460
4461 spec->multiout.max_channels = 2;
4462
4463 if (spec->autocfg.dig_out_pin)
4464 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4465 if (spec->kctl_alloc)
4466 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4467
4468 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4469
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004470 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004471 spec->input_mux = &spec->private_imux;
4472
4473 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004474 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004475 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4476 if (wcap != AC_WID_AUD_IN) {
4477 spec->adc_nids = alc260_adc_nids_alt;
4478 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4479 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004480 } else {
4481 spec->adc_nids = alc260_adc_nids;
4482 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4483 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004484 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004485 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004486
4487 return 1;
4488}
4489
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004490/* additional initialization for auto-configuration model */
4491static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004492{
Kailang Yangdf694da2005-12-05 19:42:22 +01004493 alc260_auto_init_multi_out(codec);
4494 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004495}
4496
4497/*
4498 * ALC260 configurations
4499 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004500static const char *alc260_models[ALC260_MODEL_LAST] = {
4501 [ALC260_BASIC] = "basic",
4502 [ALC260_HP] = "hp",
4503 [ALC260_HP_3013] = "hp-3013",
4504 [ALC260_FUJITSU_S702X] = "fujitsu",
4505 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004506 [ALC260_WILL] = "will",
4507 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004508#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004509 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004510#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 [ALC260_AUTO] = "auto",
4512};
4513
4514static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004515 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004516 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004517 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004518 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004519 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4520 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4521 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4522 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4523 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4524 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4525 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4526 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4527 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4528 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4529 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4530 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004531 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4532 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004533 {}
4534};
4535
Kailang Yangdf694da2005-12-05 19:42:22 +01004536static struct alc_config_preset alc260_presets[] = {
4537 [ALC260_BASIC] = {
4538 .mixers = { alc260_base_output_mixer,
4539 alc260_input_mixer,
4540 alc260_pc_beep_mixer,
4541 alc260_capture_mixer },
4542 .init_verbs = { alc260_init_verbs },
4543 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4544 .dac_nids = alc260_dac_nids,
4545 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4546 .adc_nids = alc260_adc_nids,
4547 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4548 .channel_mode = alc260_modes,
4549 .input_mux = &alc260_capture_source,
4550 },
4551 [ALC260_HP] = {
4552 .mixers = { alc260_base_output_mixer,
4553 alc260_input_mixer,
4554 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004555 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004556 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4557 .dac_nids = alc260_dac_nids,
4558 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4559 .adc_nids = alc260_hp_adc_nids,
4560 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4561 .channel_mode = alc260_modes,
4562 .input_mux = &alc260_capture_source,
4563 },
4564 [ALC260_HP_3013] = {
4565 .mixers = { alc260_hp_3013_mixer,
4566 alc260_input_mixer,
4567 alc260_capture_alt_mixer },
4568 .init_verbs = { alc260_hp_3013_init_verbs },
4569 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4570 .dac_nids = alc260_dac_nids,
4571 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4572 .adc_nids = alc260_hp_adc_nids,
4573 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4574 .channel_mode = alc260_modes,
4575 .input_mux = &alc260_capture_source,
4576 },
4577 [ALC260_FUJITSU_S702X] = {
4578 .mixers = { alc260_fujitsu_mixer,
4579 alc260_capture_mixer },
4580 .init_verbs = { alc260_fujitsu_init_verbs },
4581 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4582 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004583 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4584 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004585 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4586 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004587 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4588 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004589 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004590 [ALC260_ACER] = {
4591 .mixers = { alc260_acer_mixer,
4592 alc260_capture_mixer },
4593 .init_verbs = { alc260_acer_init_verbs },
4594 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4595 .dac_nids = alc260_dac_nids,
4596 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4597 .adc_nids = alc260_dual_adc_nids,
4598 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4599 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004600 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4601 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004602 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004603 [ALC260_WILL] = {
4604 .mixers = { alc260_will_mixer,
4605 alc260_capture_mixer },
4606 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4607 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4608 .dac_nids = alc260_dac_nids,
4609 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4610 .adc_nids = alc260_adc_nids,
4611 .dig_out_nid = ALC260_DIGOUT_NID,
4612 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4613 .channel_mode = alc260_modes,
4614 .input_mux = &alc260_capture_source,
4615 },
4616 [ALC260_REPLACER_672V] = {
4617 .mixers = { alc260_replacer_672v_mixer,
4618 alc260_capture_mixer },
4619 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4620 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4621 .dac_nids = alc260_dac_nids,
4622 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4623 .adc_nids = alc260_adc_nids,
4624 .dig_out_nid = ALC260_DIGOUT_NID,
4625 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4626 .channel_mode = alc260_modes,
4627 .input_mux = &alc260_capture_source,
4628 .unsol_event = alc260_replacer_672v_unsol_event,
4629 .init_hook = alc260_replacer_672v_automute,
4630 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004631#ifdef CONFIG_SND_DEBUG
4632 [ALC260_TEST] = {
4633 .mixers = { alc260_test_mixer,
4634 alc260_capture_mixer },
4635 .init_verbs = { alc260_test_init_verbs },
4636 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4637 .dac_nids = alc260_test_dac_nids,
4638 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4639 .adc_nids = alc260_test_adc_nids,
4640 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4641 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004642 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4643 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004644 },
4645#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004646};
4647
Linus Torvalds1da177e2005-04-16 15:20:36 -07004648static int patch_alc260(struct hda_codec *codec)
4649{
4650 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004651 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004652
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004653 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004654 if (spec == NULL)
4655 return -ENOMEM;
4656
4657 codec->spec = spec;
4658
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004659 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4660 alc260_models,
4661 alc260_cfg_tbl);
4662 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004663 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4664 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004665 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004666 }
4667
Kailang Yangdf694da2005-12-05 19:42:22 +01004668 if (board_config == ALC260_AUTO) {
4669 /* automatic parse from the BIOS config */
4670 err = alc260_parse_auto_config(codec);
4671 if (err < 0) {
4672 alc_free(codec);
4673 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004674 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004675 printk(KERN_INFO
4676 "hda_codec: Cannot set up configuration "
4677 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004678 board_config = ALC260_BASIC;
4679 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004681
Kailang Yangdf694da2005-12-05 19:42:22 +01004682 if (board_config != ALC260_AUTO)
4683 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004684
4685 spec->stream_name_analog = "ALC260 Analog";
4686 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4687 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4688
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004689 spec->stream_name_digital = "ALC260 Digital";
4690 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4691 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4692
Linus Torvalds1da177e2005-04-16 15:20:36 -07004693 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004694 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004695 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004696
4697 return 0;
4698}
4699
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004700
Linus Torvalds1da177e2005-04-16 15:20:36 -07004701/*
4702 * ALC882 support
4703 *
4704 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4705 * configuration. Each pin widget can choose any input DACs and a mixer.
4706 * Each ADC is connected from a mixer of all inputs. This makes possible
4707 * 6-channel independent captures.
4708 *
4709 * In addition, an independent DAC for the multi-playback (not used in this
4710 * driver yet).
4711 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004712#define ALC882_DIGOUT_NID 0x06
4713#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004714
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004715static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004716 { 8, NULL }
4717};
4718
4719static hda_nid_t alc882_dac_nids[4] = {
4720 /* front, rear, clfe, rear_surr */
4721 0x02, 0x03, 0x04, 0x05
4722};
4723
Kailang Yangdf694da2005-12-05 19:42:22 +01004724/* identical with ALC880 */
4725#define alc882_adc_nids alc880_adc_nids
4726#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004727
4728/* input MUX */
4729/* FIXME: should be a matrix-type input source selection */
4730
4731static struct hda_input_mux alc882_capture_source = {
4732 .num_items = 4,
4733 .items = {
4734 { "Mic", 0x0 },
4735 { "Front Mic", 0x1 },
4736 { "Line", 0x2 },
4737 { "CD", 0x4 },
4738 },
4739};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004740#define alc882_mux_enum_info alc_mux_enum_info
4741#define alc882_mux_enum_get alc_mux_enum_get
4742
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004743static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4744 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004745{
4746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4747 struct alc_spec *spec = codec->spec;
4748 const struct hda_input_mux *imux = spec->input_mux;
4749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4750 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4751 hda_nid_t nid = capture_mixers[adc_idx];
4752 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4753 unsigned int i, idx;
4754
4755 idx = ucontrol->value.enumerated.item[0];
4756 if (idx >= imux->num_items)
4757 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004758 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004759 return 0;
4760 for (i = 0; i < imux->num_items; i++) {
4761 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4762 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4763 v | (imux->items[i].index << 8));
4764 }
4765 *cur_val = idx;
4766 return 1;
4767}
4768
Kailang Yangdf694da2005-12-05 19:42:22 +01004769/*
Kailang Yang272a5272007-05-14 11:00:38 +02004770 * 2ch mode
4771 */
4772static struct hda_verb alc882_3ST_ch2_init[] = {
4773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4775 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4776 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4777 { } /* end */
4778};
4779
4780/*
4781 * 6ch mode
4782 */
4783static struct hda_verb alc882_3ST_ch6_init[] = {
4784 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4785 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4786 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4787 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4788 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4789 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4790 { } /* end */
4791};
4792
4793static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4794 { 2, alc882_3ST_ch2_init },
4795 { 6, alc882_3ST_ch6_init },
4796};
4797
4798/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004799 * 6ch mode
4800 */
4801static struct hda_verb alc882_sixstack_ch6_init[] = {
4802 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4803 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4804 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4805 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4806 { } /* end */
4807};
4808
4809/*
4810 * 8ch mode
4811 */
4812static struct hda_verb alc882_sixstack_ch8_init[] = {
4813 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4814 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4815 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4816 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4817 { } /* end */
4818};
4819
4820static struct hda_channel_mode alc882_sixstack_modes[2] = {
4821 { 6, alc882_sixstack_ch6_init },
4822 { 8, alc882_sixstack_ch8_init },
4823};
4824
Linus Torvalds1da177e2005-04-16 15:20:36 -07004825/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4826 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4827 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004828static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004832 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4834 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004835 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4836 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004837 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004838 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4840 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4841 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004848 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4850 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4851 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004852 { } /* end */
4853};
4854
Kailang Yangbdd148a2007-05-08 15:19:08 +02004855static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4865 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4866 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4867 { } /* end */
4868};
4869
Kailang Yang272a5272007-05-14 11:00:38 +02004870static struct snd_kcontrol_new alc882_targa_mixer[] = {
4871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4882 { } /* end */
4883};
4884
4885/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4886 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4887 */
4888static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4889 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4890 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4892 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4897 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4898 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4901 { } /* end */
4902};
4903
Kailang Yangdf694da2005-12-05 19:42:22 +01004904static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4905 {
4906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4907 .name = "Channel Mode",
4908 .info = alc_ch_mode_info,
4909 .get = alc_ch_mode_get,
4910 .put = alc_ch_mode_put,
4911 },
4912 { } /* end */
4913};
4914
Linus Torvalds1da177e2005-04-16 15:20:36 -07004915static struct hda_verb alc882_init_verbs[] = {
4916 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004933 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004937 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004943 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004944 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004945 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004948 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004949 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004950 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4952 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4955 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4958 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4959 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4960 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004963 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004964
4965 /* FIXME: use matrix-type input source selection */
4966 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4967 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004972 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4982 /* ADC1: mute amp left and right */
4983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004984 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004985 /* ADC2: mute amp left and right */
4986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004987 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004988 /* ADC3: mute amp left and right */
4989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004990 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004991
4992 { }
4993};
4994
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004995static struct hda_verb alc882_eapd_verbs[] = {
4996 /* change to EAPD mode */
4997 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004998 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004999 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005000};
5001
Tobin Davis9102cd12006-12-15 10:02:12 +01005002/* Mac Pro test */
5003static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5009 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5011 { } /* end */
5012};
5013
5014static struct hda_verb alc882_macpro_init_verbs[] = {
5015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5019 /* Front Pin: output 0 (0x0c) */
5020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5023 /* Front Mic pin: input vref at 80% */
5024 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5025 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5026 /* Speaker: output */
5027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5029 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5030 /* Headphone output (output 0 - 0x0c) */
5031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5032 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5033 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5034
5035 /* FIXME: use matrix-type input source selection */
5036 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5037 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5042 /* Input mixer2 */
5043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5047 /* Input mixer3 */
5048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5052 /* ADC1: mute amp left and right */
5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5054 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5055 /* ADC2: mute amp left and right */
5056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5058 /* ADC3: mute amp left and right */
5059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5061
5062 { }
5063};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005064
Kailang Yang272a5272007-05-14 11:00:38 +02005065static struct hda_verb alc882_targa_verbs[] = {
5066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5068
5069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5071
5072 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5073 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5075
5076 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5077 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5078 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5079 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5080 { } /* end */
5081};
5082
5083/* toggle speaker-output according to the hp-jack state */
5084static void alc882_targa_automute(struct hda_codec *codec)
5085{
5086 unsigned int present;
5087
5088 present = snd_hda_codec_read(codec, 0x14, 0,
5089 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5090 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5091 0x80, present ? 0x80 : 0);
5092 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5093 0x80, present ? 0x80 : 0);
5094 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5095}
5096
5097static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5098{
5099 /* Looks like the unsol event is incompatible with the standard
5100 * definition. 4bit tag is placed at 26 bit!
5101 */
5102 if (((res >> 26) == ALC880_HP_EVENT)) {
5103 alc882_targa_automute(codec);
5104 }
5105}
5106
5107static struct hda_verb alc882_asus_a7j_verbs[] = {
5108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5110
5111 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5112 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5113 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5114
5115 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5117 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5118
5119 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5120 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5121 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5122 { } /* end */
5123};
5124
Tobin Davis9102cd12006-12-15 10:02:12 +01005125static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5126{
5127 unsigned int gpiostate, gpiomask, gpiodir;
5128
5129 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5130 AC_VERB_GET_GPIO_DATA, 0);
5131
5132 if (!muted)
5133 gpiostate |= (1 << pin);
5134 else
5135 gpiostate &= ~(1 << pin);
5136
5137 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5138 AC_VERB_GET_GPIO_MASK, 0);
5139 gpiomask |= (1 << pin);
5140
5141 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5142 AC_VERB_GET_GPIO_DIRECTION, 0);
5143 gpiodir |= (1 << pin);
5144
5145
5146 snd_hda_codec_write(codec, codec->afg, 0,
5147 AC_VERB_SET_GPIO_MASK, gpiomask);
5148 snd_hda_codec_write(codec, codec->afg, 0,
5149 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5150
5151 msleep(1);
5152
5153 snd_hda_codec_write(codec, codec->afg, 0,
5154 AC_VERB_SET_GPIO_DATA, gpiostate);
5155}
5156
Kailang Yangdf694da2005-12-05 19:42:22 +01005157/*
5158 * generic initialization of ADC, input mixers and output mixers
5159 */
5160static struct hda_verb alc882_auto_init_verbs[] = {
5161 /*
5162 * Unmute ADC0-2 and set the default input to mic-in
5163 */
5164 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5166 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5168 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5170
5171 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5172 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005173 * Note: PASD motherboards uses the Line In 2 as the input for
5174 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005175 */
5176 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5182
5183 /*
5184 * Set up output mixers (0x0c - 0x0f)
5185 */
5186 /* set vol=0 to output mixers */
5187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5191 /* set up input amps for analog loopback */
5192 /* Amp Indices: DAC = 0, mixer = 1 */
5193 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5200 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5201 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5202 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5203
5204 /* FIXME: use matrix-type input source selection */
5205 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5206 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5211 /* Input mixer2 */
5212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5216 /* Input mixer3 */
5217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5221
5222 { }
5223};
5224
5225/* capture mixer elements */
5226static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5227 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5228 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5229 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5230 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5231 {
5232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5233 /* The multiple "Capture Source" controls confuse alsamixer
5234 * So call somewhat different..
5235 * FIXME: the controls appear in the "playback" view!
5236 */
5237 /* .name = "Capture Source", */
5238 .name = "Input Source",
5239 .count = 2,
5240 .info = alc882_mux_enum_info,
5241 .get = alc882_mux_enum_get,
5242 .put = alc882_mux_enum_put,
5243 },
5244 { } /* end */
5245};
5246
5247static struct snd_kcontrol_new alc882_capture_mixer[] = {
5248 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5249 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5250 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5251 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5252 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5253 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5254 {
5255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5256 /* The multiple "Capture Source" controls confuse alsamixer
5257 * So call somewhat different..
5258 * FIXME: the controls appear in the "playback" view!
5259 */
5260 /* .name = "Capture Source", */
5261 .name = "Input Source",
5262 .count = 3,
5263 .info = alc882_mux_enum_info,
5264 .get = alc882_mux_enum_get,
5265 .put = alc882_mux_enum_put,
5266 },
5267 { } /* end */
5268};
5269
5270/* pcm configuration: identiacal with ALC880 */
5271#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5272#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5273#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5274#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5275
5276/*
5277 * configuration and preset
5278 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005279static const char *alc882_models[ALC882_MODEL_LAST] = {
5280 [ALC882_3ST_DIG] = "3stack-dig",
5281 [ALC882_6ST_DIG] = "6stack-dig",
5282 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005283 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005284 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005285 [ALC882_AUTO] = "auto",
5286};
5287
5288static struct snd_pci_quirk alc882_cfg_tbl[] = {
5289 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5290 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5291 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005292 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005293 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005294 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005295 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005296 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005297 {}
5298};
5299
5300static struct alc_config_preset alc882_presets[] = {
5301 [ALC882_3ST_DIG] = {
5302 .mixers = { alc882_base_mixer },
5303 .init_verbs = { alc882_init_verbs },
5304 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5305 .dac_nids = alc882_dac_nids,
5306 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005307 .dig_in_nid = ALC882_DIGIN_NID,
5308 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5309 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005310 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005311 .input_mux = &alc882_capture_source,
5312 },
5313 [ALC882_6ST_DIG] = {
5314 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5315 .init_verbs = { alc882_init_verbs },
5316 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5317 .dac_nids = alc882_dac_nids,
5318 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005319 .dig_in_nid = ALC882_DIGIN_NID,
5320 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5321 .channel_mode = alc882_sixstack_modes,
5322 .input_mux = &alc882_capture_source,
5323 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005324 [ALC882_ARIMA] = {
5325 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5326 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5327 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5328 .dac_nids = alc882_dac_nids,
5329 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5330 .channel_mode = alc882_sixstack_modes,
5331 .input_mux = &alc882_capture_source,
5332 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005333 [ALC882_W2JC] = {
5334 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5335 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5336 alc880_gpio1_init_verbs },
5337 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5338 .dac_nids = alc882_dac_nids,
5339 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5340 .channel_mode = alc880_threestack_modes,
5341 .need_dac_fix = 1,
5342 .input_mux = &alc882_capture_source,
5343 .dig_out_nid = ALC882_DIGOUT_NID,
5344 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005345 [ALC885_MACPRO] = {
5346 .mixers = { alc882_macpro_mixer },
5347 .init_verbs = { alc882_macpro_init_verbs },
5348 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5349 .dac_nids = alc882_dac_nids,
5350 .dig_out_nid = ALC882_DIGOUT_NID,
5351 .dig_in_nid = ALC882_DIGIN_NID,
5352 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5353 .channel_mode = alc882_ch_modes,
5354 .input_mux = &alc882_capture_source,
5355 },
Kailang Yang272a5272007-05-14 11:00:38 +02005356 [ALC882_TARGA] = {
5357 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5358 alc882_capture_mixer },
5359 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5360 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5361 .dac_nids = alc882_dac_nids,
5362 .dig_out_nid = ALC882_DIGOUT_NID,
5363 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5364 .adc_nids = alc882_adc_nids,
5365 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5366 .channel_mode = alc882_3ST_6ch_modes,
5367 .need_dac_fix = 1,
5368 .input_mux = &alc882_capture_source,
5369 .unsol_event = alc882_targa_unsol_event,
5370 .init_hook = alc882_targa_automute,
5371 },
5372 [ALC882_ASUS_A7J] = {
5373 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5374 alc882_capture_mixer },
5375 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5376 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5377 .dac_nids = alc882_dac_nids,
5378 .dig_out_nid = ALC882_DIGOUT_NID,
5379 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5380 .adc_nids = alc882_adc_nids,
5381 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5382 .channel_mode = alc882_3ST_6ch_modes,
5383 .need_dac_fix = 1,
5384 .input_mux = &alc882_capture_source,
5385 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005386};
5387
5388
5389/*
5390 * BIOS auto configuration
5391 */
5392static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5393 hda_nid_t nid, int pin_type,
5394 int dac_idx)
5395{
5396 /* set as output */
5397 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005398 int idx;
5399
Kailang Yangdf694da2005-12-05 19:42:22 +01005400 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5401 idx = 4;
5402 else
5403 idx = spec->multiout.dac_nids[dac_idx] - 2;
5404
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5406 pin_type);
5407 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5408 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005409 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5410
5411}
5412
5413static void alc882_auto_init_multi_out(struct hda_codec *codec)
5414{
5415 struct alc_spec *spec = codec->spec;
5416 int i;
5417
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005418 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005419 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005420 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005422 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005423 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005424 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005425 }
5426}
5427
5428static void alc882_auto_init_hp_out(struct hda_codec *codec)
5429{
5430 struct alc_spec *spec = codec->spec;
5431 hda_nid_t pin;
5432
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005433 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005434 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005435 /* use dac 0 */
5436 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005437}
5438
5439#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5440#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5441
5442static void alc882_auto_init_analog_input(struct hda_codec *codec)
5443{
5444 struct alc_spec *spec = codec->spec;
5445 int i;
5446
5447 for (i = 0; i < AUTO_PIN_LAST; i++) {
5448 hda_nid_t nid = spec->autocfg.input_pins[i];
5449 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005450 snd_hda_codec_write(codec, nid, 0,
5451 AC_VERB_SET_PIN_WIDGET_CONTROL,
5452 i <= AUTO_PIN_FRONT_MIC ?
5453 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005454 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005455 snd_hda_codec_write(codec, nid, 0,
5456 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005457 AMP_OUT_MUTE);
5458 }
5459 }
5460}
5461
5462/* almost identical with ALC880 parser... */
5463static int alc882_parse_auto_config(struct hda_codec *codec)
5464{
5465 struct alc_spec *spec = codec->spec;
5466 int err = alc880_parse_auto_config(codec);
5467
5468 if (err < 0)
5469 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005470 else if (err > 0)
5471 /* hack - override the init verbs */
5472 spec->init_verbs[0] = alc882_auto_init_verbs;
5473 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005474}
5475
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005476/* additional initialization for auto-configuration model */
5477static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005478{
Kailang Yangdf694da2005-12-05 19:42:22 +01005479 alc882_auto_init_multi_out(codec);
5480 alc882_auto_init_hp_out(codec);
5481 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005482}
5483
Linus Torvalds1da177e2005-04-16 15:20:36 -07005484static int patch_alc882(struct hda_codec *codec)
5485{
5486 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005487 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005488
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005489 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005490 if (spec == NULL)
5491 return -ENOMEM;
5492
Linus Torvalds1da177e2005-04-16 15:20:36 -07005493 codec->spec = spec;
5494
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005495 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5496 alc882_models,
5497 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498
Kailang Yangdf694da2005-12-05 19:42:22 +01005499 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005500 /* Pick up systems that don't supply PCI SSID */
5501 switch (codec->subsystem_id) {
5502 case 0x106b0c00: /* Mac Pro */
5503 board_config = ALC885_MACPRO;
5504 break;
5505 default:
5506 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5507 "trying auto-probe from BIOS...\n");
5508 board_config = ALC882_AUTO;
5509 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005510 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005511
Kailang Yangdf694da2005-12-05 19:42:22 +01005512 if (board_config == ALC882_AUTO) {
5513 /* automatic parse from the BIOS config */
5514 err = alc882_parse_auto_config(codec);
5515 if (err < 0) {
5516 alc_free(codec);
5517 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005518 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005519 printk(KERN_INFO
5520 "hda_codec: Cannot set up configuration "
5521 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005522 board_config = ALC882_3ST_DIG;
5523 }
5524 }
5525
5526 if (board_config != ALC882_AUTO)
5527 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005528
Tobin Davis9102cd12006-12-15 10:02:12 +01005529 if (board_config == ALC885_MACPRO) {
5530 alc882_gpio_mute(codec, 0, 0);
5531 alc882_gpio_mute(codec, 1, 0);
5532 }
5533
Linus Torvalds1da177e2005-04-16 15:20:36 -07005534 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5536 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005537
5538 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5540 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005541
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005542 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005543 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005544 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005545 /* get type */
5546 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005547 if (wcap != AC_WID_AUD_IN) {
5548 spec->adc_nids = alc882_adc_nids_alt;
5549 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005550 spec->mixers[spec->num_mixers] =
5551 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005552 spec->num_mixers++;
5553 } else {
5554 spec->adc_nids = alc882_adc_nids;
5555 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5556 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5557 spec->num_mixers++;
5558 }
5559 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005560
5561 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005562 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005563 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005564
5565 return 0;
5566}
5567
5568/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005569 * ALC883 support
5570 *
5571 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5572 * configuration. Each pin widget can choose any input DACs and a mixer.
5573 * Each ADC is connected from a mixer of all inputs. This makes possible
5574 * 6-channel independent captures.
5575 *
5576 * In addition, an independent DAC for the multi-playback (not used in this
5577 * driver yet).
5578 */
5579#define ALC883_DIGOUT_NID 0x06
5580#define ALC883_DIGIN_NID 0x0a
5581
5582static hda_nid_t alc883_dac_nids[4] = {
5583 /* front, rear, clfe, rear_surr */
5584 0x02, 0x04, 0x03, 0x05
5585};
5586
5587static hda_nid_t alc883_adc_nids[2] = {
5588 /* ADC1-2 */
5589 0x08, 0x09,
5590};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005591
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005592/* input MUX */
5593/* FIXME: should be a matrix-type input source selection */
5594
5595static struct hda_input_mux alc883_capture_source = {
5596 .num_items = 4,
5597 .items = {
5598 { "Mic", 0x0 },
5599 { "Front Mic", 0x1 },
5600 { "Line", 0x2 },
5601 { "CD", 0x4 },
5602 },
5603};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005604
5605static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5606 .num_items = 2,
5607 .items = {
5608 { "Mic", 0x1 },
5609 { "Line", 0x2 },
5610 },
5611};
5612
Kailang Yang272a5272007-05-14 11:00:38 +02005613static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5614 .num_items = 4,
5615 .items = {
5616 { "Mic", 0x0 },
5617 { "iMic", 0x1 },
5618 { "Line", 0x2 },
5619 { "CD", 0x4 },
5620 },
5621};
5622
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005623#define alc883_mux_enum_info alc_mux_enum_info
5624#define alc883_mux_enum_get alc_mux_enum_get
5625
5626static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5627 struct snd_ctl_elem_value *ucontrol)
5628{
5629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5630 struct alc_spec *spec = codec->spec;
5631 const struct hda_input_mux *imux = spec->input_mux;
5632 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5633 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5634 hda_nid_t nid = capture_mixers[adc_idx];
5635 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5636 unsigned int i, idx;
5637
5638 idx = ucontrol->value.enumerated.item[0];
5639 if (idx >= imux->num_items)
5640 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005641 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005642 return 0;
5643 for (i = 0; i < imux->num_items; i++) {
5644 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5645 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5646 v | (imux->items[i].index << 8));
5647 }
5648 *cur_val = idx;
5649 return 1;
5650}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005651
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005652/*
5653 * 2ch mode
5654 */
5655static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5656 { 2, NULL }
5657};
5658
5659/*
5660 * 2ch mode
5661 */
5662static struct hda_verb alc883_3ST_ch2_init[] = {
5663 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5664 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5666 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5667 { } /* end */
5668};
5669
5670/*
5671 * 6ch mode
5672 */
5673static struct hda_verb alc883_3ST_ch6_init[] = {
5674 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5675 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5676 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5677 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5678 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5679 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5680 { } /* end */
5681};
5682
5683static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5684 { 2, alc883_3ST_ch2_init },
5685 { 6, alc883_3ST_ch6_init },
5686};
5687
5688/*
5689 * 6ch mode
5690 */
5691static struct hda_verb alc883_sixstack_ch6_init[] = {
5692 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5693 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5694 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5695 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5696 { } /* end */
5697};
5698
5699/*
5700 * 8ch mode
5701 */
5702static struct hda_verb alc883_sixstack_ch8_init[] = {
5703 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5704 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5706 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5707 { } /* end */
5708};
5709
5710static struct hda_channel_mode alc883_sixstack_modes[2] = {
5711 { 6, alc883_sixstack_ch6_init },
5712 { 8, alc883_sixstack_ch8_init },
5713};
5714
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005715static struct hda_verb alc883_medion_eapd_verbs[] = {
5716 /* eanable EAPD on medion laptop */
5717 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5718 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5719 { }
5720};
5721
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005722/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5723 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5724 */
5725
5726static struct snd_kcontrol_new alc883_base_mixer[] = {
5727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5728 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5730 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5733 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5734 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5735 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5736 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5738 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5739 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005746 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005747 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5748 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5749 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5750 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5751 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5752 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5753 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5754 {
5755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5756 /* .name = "Capture Source", */
5757 .name = "Input Source",
5758 .count = 2,
5759 .info = alc883_mux_enum_info,
5760 .get = alc883_mux_enum_get,
5761 .put = alc883_mux_enum_put,
5762 },
5763 { } /* end */
5764};
5765
5766static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005778 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5780 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5781 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5782 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5783 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5784 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5785 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5786 {
5787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5788 /* .name = "Capture Source", */
5789 .name = "Input Source",
5790 .count = 2,
5791 .info = alc883_mux_enum_info,
5792 .get = alc883_mux_enum_get,
5793 .put = alc883_mux_enum_put,
5794 },
5795 { } /* end */
5796};
5797
5798static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5800 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5801 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5802 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5803 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5804 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5805 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5806 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005816 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5818 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5819 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5820 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5821 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5822 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5823 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5824 {
5825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5826 /* .name = "Capture Source", */
5827 .name = "Input Source",
5828 .count = 2,
5829 .info = alc883_mux_enum_info,
5830 .get = alc883_mux_enum_get,
5831 .put = alc883_mux_enum_put,
5832 },
5833 { } /* end */
5834};
5835
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005836static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005837 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5838 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5839 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5840 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5841 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5842 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5843 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5844 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5856 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5857 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5860
5861 {
5862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5863 /* .name = "Capture Source", */
5864 .name = "Input Source",
5865 .count = 1,
5866 .info = alc883_mux_enum_info,
5867 .get = alc883_mux_enum_get,
5868 .put = alc883_mux_enum_put,
5869 },
5870 { } /* end */
5871};
5872
Kailang Yangccc656c2006-10-17 12:32:26 +02005873static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5875 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005888 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5890 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5891 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5892 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5893 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5894 {
5895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5896 /* .name = "Capture Source", */
5897 .name = "Input Source",
5898 .count = 2,
5899 .info = alc883_mux_enum_info,
5900 .get = alc883_mux_enum_get,
5901 .put = alc883_mux_enum_put,
5902 },
5903 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005904};
Kailang Yangccc656c2006-10-17 12:32:26 +02005905
5906static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5915 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5916 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5917 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5918 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5919 {
5920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5921 /* .name = "Capture Source", */
5922 .name = "Input Source",
5923 .count = 2,
5924 .info = alc883_mux_enum_info,
5925 .get = alc883_mux_enum_get,
5926 .put = alc883_mux_enum_put,
5927 },
5928 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005929};
Kailang Yangccc656c2006-10-17 12:32:26 +02005930
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005931static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5933 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5934 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5935 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5940 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5941 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5942 {
5943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5944 /* .name = "Capture Source", */
5945 .name = "Input Source",
5946 .count = 1,
5947 .info = alc883_mux_enum_info,
5948 .get = alc883_mux_enum_get,
5949 .put = alc883_mux_enum_put,
5950 },
5951 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005952};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005953
Kailang Yang272a5272007-05-14 11:00:38 +02005954static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5959 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5962 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5963 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5964 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5965 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5966 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5967 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5968 {
5969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5970 /* .name = "Capture Source", */
5971 .name = "Input Source",
5972 .count = 2,
5973 .info = alc883_mux_enum_info,
5974 .get = alc883_mux_enum_get,
5975 .put = alc883_mux_enum_put,
5976 },
5977 { } /* end */
5978};
5979
5980static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
5981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5990 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5991 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5992 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5993 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5994 {
5995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5996 /* .name = "Capture Source", */
5997 .name = "Input Source",
5998 .count = 2,
5999 .info = alc883_mux_enum_info,
6000 .get = alc883_mux_enum_get,
6001 .put = alc883_mux_enum_put,
6002 },
6003 { } /* end */
6004};
6005
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006006static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6007 {
6008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6009 .name = "Channel Mode",
6010 .info = alc_ch_mode_info,
6011 .get = alc_ch_mode_get,
6012 .put = alc_ch_mode_put,
6013 },
6014 { } /* end */
6015};
6016
6017static struct hda_verb alc883_init_verbs[] = {
6018 /* ADC1: mute amp left and right */
6019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6021 /* ADC2: mute amp left and right */
6022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6023 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6024 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6028 /* Rear mixer */
6029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6032 /* CLFE mixer */
6033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6036 /* Side mixer */
6037 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6039 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6040
6041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6046
6047 /* Front Pin: output 0 (0x0c) */
6048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6051 /* Rear Pin: output 1 (0x0d) */
6052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6054 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6055 /* CLFE Pin: output 2 (0x0e) */
6056 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6058 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6059 /* Side Pin: output 3 (0x0f) */
6060 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6061 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6062 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6063 /* Mic (rear) pin: input vref at 80% */
6064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6066 /* Front Mic pin: input vref at 80% */
6067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6069 /* Line In pin: input */
6070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6072 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6075 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6076 /* CD pin widget for input */
6077 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6078
6079 /* FIXME: use matrix-type input source selection */
6080 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6081 /* Input mixer2 */
6082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6086 /* Input mixer3 */
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6091 { }
6092};
6093
Kailang Yangccc656c2006-10-17 12:32:26 +02006094static struct hda_verb alc883_tagra_verbs[] = {
6095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6097
6098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6100
6101 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6102 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6103 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6104
6105 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6107 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6108 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006109
6110 { } /* end */
6111};
6112
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006113static struct hda_verb alc883_lenovo_101e_verbs[] = {
6114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6116 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6117 { } /* end */
6118};
6119
Kailang Yang272a5272007-05-14 11:00:38 +02006120static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6123 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6125 { } /* end */
6126};
6127
6128static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6132 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6133 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6134 { } /* end */
6135};
6136
6137/* toggle front-jack and RCA according to the hp-jack state */
6138static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6139{
6140 unsigned int present;
6141
6142 present = snd_hda_codec_read(codec, 0x1b, 0,
6143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6144 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6145 0x80, present ? 0x80 : 0);
6146 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6147 0x80, present ? 0x80 : 0);
6148 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6149 0x80, present ? 0x80 : 0);
6150 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6151 0x80, present ? 0x80 : 0);
6152
6153}
6154
6155/* toggle RCA according to the front-jack state */
6156static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6157{
6158 unsigned int present;
6159
6160 present = snd_hda_codec_read(codec, 0x14, 0,
6161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6162 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6163 0x80, present ? 0x80 : 0);
6164 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6165 0x80, present ? 0x80 : 0);
6166
6167}
6168static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6169 unsigned int res)
6170{
6171 if ((res >> 26) == ALC880_HP_EVENT)
6172 alc888_lenovo_ms7195_front_automute(codec);
6173 if ((res >> 26) == ALC880_FRONT_EVENT)
6174 alc888_lenovo_ms7195_rca_automute(codec);
6175}
6176
6177static struct hda_verb alc883_medion_md2_verbs[] = {
6178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6180
6181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6182
6183 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6184 { } /* end */
6185};
6186
6187/* toggle speaker-output according to the hp-jack state */
6188static void alc883_medion_md2_automute(struct hda_codec *codec)
6189{
6190 unsigned int present;
6191
6192 present = snd_hda_codec_read(codec, 0x14, 0,
6193 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6194 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6195 0x80, present ? 0x80 : 0);
6196 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6197 0x80, present ? 0x80 : 0);
6198}
6199
6200static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6201 unsigned int res)
6202{
6203 if ((res >> 26) == ALC880_HP_EVENT)
6204 alc883_medion_md2_automute(codec);
6205}
6206
Kailang Yangccc656c2006-10-17 12:32:26 +02006207/* toggle speaker-output according to the hp-jack state */
6208static void alc883_tagra_automute(struct hda_codec *codec)
6209{
6210 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006211 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006212
6213 present = snd_hda_codec_read(codec, 0x14, 0,
6214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006215 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006216 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006217 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006218 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006219 0x80, bits);
6220 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6221 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006222}
6223
6224static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6225{
6226 if ((res >> 26) == ALC880_HP_EVENT)
6227 alc883_tagra_automute(codec);
6228}
6229
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006230static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6231{
6232 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006233 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006234
6235 present = snd_hda_codec_read(codec, 0x14, 0,
6236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006237 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006238 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006240 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006241 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006242}
6243
6244static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6245{
6246 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006247 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006248
6249 present = snd_hda_codec_read(codec, 0x1b, 0,
6250 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006251 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006252 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006253 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006254 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006255 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006256 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006257 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006258 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006260}
6261
6262static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6263 unsigned int res)
6264{
6265 if ((res >> 26) == ALC880_HP_EVENT)
6266 alc883_lenovo_101e_all_automute(codec);
6267 if ((res >> 26) == ALC880_FRONT_EVENT)
6268 alc883_lenovo_101e_ispeaker_automute(codec);
6269}
6270
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006271/*
6272 * generic initialization of ADC, input mixers and output mixers
6273 */
6274static struct hda_verb alc883_auto_init_verbs[] = {
6275 /*
6276 * Unmute ADC0-2 and set the default input to mic-in
6277 */
6278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282
6283 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6284 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006285 * Note: PASD motherboards uses the Line In 2 as the input for
6286 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006287 */
6288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6294
6295 /*
6296 * Set up output mixers (0x0c - 0x0f)
6297 */
6298 /* set vol=0 to output mixers */
6299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303 /* set up input amps for analog loopback */
6304 /* Amp Indices: DAC = 0, mixer = 1 */
6305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6314 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6315
6316 /* FIXME: use matrix-type input source selection */
6317 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6318 /* Input mixer1 */
6319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006322 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6324 /* Input mixer2 */
6325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006328 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6330
6331 { }
6332};
6333
6334/* capture mixer elements */
6335static struct snd_kcontrol_new alc883_capture_mixer[] = {
6336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6338 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6339 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6340 {
6341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6342 /* The multiple "Capture Source" controls confuse alsamixer
6343 * So call somewhat different..
6344 * FIXME: the controls appear in the "playback" view!
6345 */
6346 /* .name = "Capture Source", */
6347 .name = "Input Source",
6348 .count = 2,
6349 .info = alc882_mux_enum_info,
6350 .get = alc882_mux_enum_get,
6351 .put = alc882_mux_enum_put,
6352 },
6353 { } /* end */
6354};
6355
6356/* pcm configuration: identiacal with ALC880 */
6357#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6358#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6359#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6360#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6361
6362/*
6363 * configuration and preset
6364 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006365static const char *alc883_models[ALC883_MODEL_LAST] = {
6366 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6367 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6368 [ALC883_3ST_6ch] = "3stack-6ch",
6369 [ALC883_6ST_DIG] = "6stack-dig",
6370 [ALC883_TARGA_DIG] = "targa-dig",
6371 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006372 [ALC883_ACER] = "acer",
6373 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006374 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006375 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006376 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006377 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6378 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006379 [ALC883_AUTO] = "auto",
6380};
6381
6382static struct snd_pci_quirk alc883_cfg_tbl[] = {
6383 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006384 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006385 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6386 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6387 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006388 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006389 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6390 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006391 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006392 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006393 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006394 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006395 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006396 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6397 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6398 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6399 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6400 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6401 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6402 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6403 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6404 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6405 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006406 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006407 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6408 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6409 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006410 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6411 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6412 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6413 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006414 {}
6415};
6416
6417static struct alc_config_preset alc883_presets[] = {
6418 [ALC883_3ST_2ch_DIG] = {
6419 .mixers = { alc883_3ST_2ch_mixer },
6420 .init_verbs = { alc883_init_verbs },
6421 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6422 .dac_nids = alc883_dac_nids,
6423 .dig_out_nid = ALC883_DIGOUT_NID,
6424 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6425 .adc_nids = alc883_adc_nids,
6426 .dig_in_nid = ALC883_DIGIN_NID,
6427 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6428 .channel_mode = alc883_3ST_2ch_modes,
6429 .input_mux = &alc883_capture_source,
6430 },
6431 [ALC883_3ST_6ch_DIG] = {
6432 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6433 .init_verbs = { alc883_init_verbs },
6434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6435 .dac_nids = alc883_dac_nids,
6436 .dig_out_nid = ALC883_DIGOUT_NID,
6437 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6438 .adc_nids = alc883_adc_nids,
6439 .dig_in_nid = ALC883_DIGIN_NID,
6440 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6441 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006442 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006443 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006444 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006445 [ALC883_3ST_6ch] = {
6446 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6447 .init_verbs = { alc883_init_verbs },
6448 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6449 .dac_nids = alc883_dac_nids,
6450 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6451 .adc_nids = alc883_adc_nids,
6452 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6453 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006454 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006455 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006456 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006457 [ALC883_6ST_DIG] = {
6458 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6459 .init_verbs = { alc883_init_verbs },
6460 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6461 .dac_nids = alc883_dac_nids,
6462 .dig_out_nid = ALC883_DIGOUT_NID,
6463 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6464 .adc_nids = alc883_adc_nids,
6465 .dig_in_nid = ALC883_DIGIN_NID,
6466 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6467 .channel_mode = alc883_sixstack_modes,
6468 .input_mux = &alc883_capture_source,
6469 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006470 [ALC883_TARGA_DIG] = {
6471 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6472 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6474 .dac_nids = alc883_dac_nids,
6475 .dig_out_nid = ALC883_DIGOUT_NID,
6476 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6477 .adc_nids = alc883_adc_nids,
6478 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6479 .channel_mode = alc883_3ST_6ch_modes,
6480 .need_dac_fix = 1,
6481 .input_mux = &alc883_capture_source,
6482 .unsol_event = alc883_tagra_unsol_event,
6483 .init_hook = alc883_tagra_automute,
6484 },
6485 [ALC883_TARGA_2ch_DIG] = {
6486 .mixers = { alc883_tagra_2ch_mixer},
6487 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6489 .dac_nids = alc883_dac_nids,
6490 .dig_out_nid = ALC883_DIGOUT_NID,
6491 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6492 .adc_nids = alc883_adc_nids,
6493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6494 .channel_mode = alc883_3ST_2ch_modes,
6495 .input_mux = &alc883_capture_source,
6496 .unsol_event = alc883_tagra_unsol_event,
6497 .init_hook = alc883_tagra_automute,
6498 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02006499 [ALC883_ACER] = {
6500 .mixers = { alc883_base_mixer,
6501 alc883_chmode_mixer },
6502 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6503 * and the headphone jack. Turn this on and rely on the
6504 * standard mute methods whenever the user wants to turn
6505 * these outputs off.
6506 */
6507 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6509 .dac_nids = alc883_dac_nids,
6510 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6511 .adc_nids = alc883_adc_nids,
6512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6513 .channel_mode = alc883_3ST_2ch_modes,
6514 .input_mux = &alc883_capture_source,
6515 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006516 [ALC883_MEDION] = {
6517 .mixers = { alc883_fivestack_mixer,
6518 alc883_chmode_mixer },
6519 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006520 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6522 .dac_nids = alc883_dac_nids,
6523 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6524 .adc_nids = alc883_adc_nids,
6525 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6526 .channel_mode = alc883_sixstack_modes,
6527 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006528 },
Kailang Yang272a5272007-05-14 11:00:38 +02006529 [ALC883_MEDION_MD2] = {
6530 .mixers = { alc883_medion_md2_mixer},
6531 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6533 .dac_nids = alc883_dac_nids,
6534 .dig_out_nid = ALC883_DIGOUT_NID,
6535 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6536 .adc_nids = alc883_adc_nids,
6537 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6538 .channel_mode = alc883_3ST_2ch_modes,
6539 .input_mux = &alc883_capture_source,
6540 .unsol_event = alc883_medion_md2_unsol_event,
6541 .init_hook = alc883_medion_md2_automute,
6542 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006543 [ALC883_LAPTOP_EAPD] = {
6544 .mixers = { alc883_base_mixer,
6545 alc883_chmode_mixer },
6546 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6548 .dac_nids = alc883_dac_nids,
6549 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6550 .adc_nids = alc883_adc_nids,
6551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6552 .channel_mode = alc883_3ST_2ch_modes,
6553 .input_mux = &alc883_capture_source,
6554 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006555 [ALC883_LENOVO_101E_2ch] = {
6556 .mixers = { alc883_lenovo_101e_2ch_mixer},
6557 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6559 .dac_nids = alc883_dac_nids,
6560 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6561 .adc_nids = alc883_adc_nids,
6562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6563 .channel_mode = alc883_3ST_2ch_modes,
6564 .input_mux = &alc883_lenovo_101e_capture_source,
6565 .unsol_event = alc883_lenovo_101e_unsol_event,
6566 .init_hook = alc883_lenovo_101e_all_automute,
6567 },
Kailang Yang272a5272007-05-14 11:00:38 +02006568 [ALC883_LENOVO_NB0763] = {
6569 .mixers = { alc883_lenovo_nb0763_mixer },
6570 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6571 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6572 .dac_nids = alc883_dac_nids,
6573 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6574 .adc_nids = alc883_adc_nids,
6575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6576 .channel_mode = alc883_3ST_2ch_modes,
6577 .need_dac_fix = 1,
6578 .input_mux = &alc883_lenovo_nb0763_capture_source,
6579 .unsol_event = alc883_medion_md2_unsol_event,
6580 .init_hook = alc883_medion_md2_automute,
6581 },
6582 [ALC888_LENOVO_MS7195_DIG] = {
6583 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6584 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6586 .dac_nids = alc883_dac_nids,
6587 .dig_out_nid = ALC883_DIGOUT_NID,
6588 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6589 .adc_nids = alc883_adc_nids,
6590 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6591 .channel_mode = alc883_3ST_6ch_modes,
6592 .need_dac_fix = 1,
6593 .input_mux = &alc883_capture_source,
6594 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6595 .init_hook = alc888_lenovo_ms7195_front_automute,
6596 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006597};
6598
6599
6600/*
6601 * BIOS auto configuration
6602 */
6603static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6604 hda_nid_t nid, int pin_type,
6605 int dac_idx)
6606{
6607 /* set as output */
6608 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006609 int idx;
6610
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006611 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6612 idx = 4;
6613 else
6614 idx = spec->multiout.dac_nids[dac_idx] - 2;
6615
6616 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6617 pin_type);
6618 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6619 AMP_OUT_UNMUTE);
6620 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6621
6622}
6623
6624static void alc883_auto_init_multi_out(struct hda_codec *codec)
6625{
6626 struct alc_spec *spec = codec->spec;
6627 int i;
6628
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006629 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006630 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006631 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006632 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006633 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006634 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006635 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006636 }
6637}
6638
6639static void alc883_auto_init_hp_out(struct hda_codec *codec)
6640{
6641 struct alc_spec *spec = codec->spec;
6642 hda_nid_t pin;
6643
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006644 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006645 if (pin) /* connect to front */
6646 /* use dac 0 */
6647 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6648}
6649
6650#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6651#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6652
6653static void alc883_auto_init_analog_input(struct hda_codec *codec)
6654{
6655 struct alc_spec *spec = codec->spec;
6656 int i;
6657
6658 for (i = 0; i < AUTO_PIN_LAST; i++) {
6659 hda_nid_t nid = spec->autocfg.input_pins[i];
6660 if (alc883_is_input_pin(nid)) {
6661 snd_hda_codec_write(codec, nid, 0,
6662 AC_VERB_SET_PIN_WIDGET_CONTROL,
6663 (i <= AUTO_PIN_FRONT_MIC ?
6664 PIN_VREF80 : PIN_IN));
6665 if (nid != ALC883_PIN_CD_NID)
6666 snd_hda_codec_write(codec, nid, 0,
6667 AC_VERB_SET_AMP_GAIN_MUTE,
6668 AMP_OUT_MUTE);
6669 }
6670 }
6671}
6672
6673/* almost identical with ALC880 parser... */
6674static int alc883_parse_auto_config(struct hda_codec *codec)
6675{
6676 struct alc_spec *spec = codec->spec;
6677 int err = alc880_parse_auto_config(codec);
6678
6679 if (err < 0)
6680 return err;
6681 else if (err > 0)
6682 /* hack - override the init verbs */
6683 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006684 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6685 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006686 return err;
6687}
6688
6689/* additional initialization for auto-configuration model */
6690static void alc883_auto_init(struct hda_codec *codec)
6691{
6692 alc883_auto_init_multi_out(codec);
6693 alc883_auto_init_hp_out(codec);
6694 alc883_auto_init_analog_input(codec);
6695}
6696
6697static int patch_alc883(struct hda_codec *codec)
6698{
6699 struct alc_spec *spec;
6700 int err, board_config;
6701
6702 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6703 if (spec == NULL)
6704 return -ENOMEM;
6705
6706 codec->spec = spec;
6707
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006708 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6709 alc883_models,
6710 alc883_cfg_tbl);
6711 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006712 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6713 "trying auto-probe from BIOS...\n");
6714 board_config = ALC883_AUTO;
6715 }
6716
6717 if (board_config == ALC883_AUTO) {
6718 /* automatic parse from the BIOS config */
6719 err = alc883_parse_auto_config(codec);
6720 if (err < 0) {
6721 alc_free(codec);
6722 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006723 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006724 printk(KERN_INFO
6725 "hda_codec: Cannot set up configuration "
6726 "from BIOS. Using base mode...\n");
6727 board_config = ALC883_3ST_2ch_DIG;
6728 }
6729 }
6730
6731 if (board_config != ALC883_AUTO)
6732 setup_preset(spec, &alc883_presets[board_config]);
6733
6734 spec->stream_name_analog = "ALC883 Analog";
6735 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6736 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6737
6738 spec->stream_name_digital = "ALC883 Digital";
6739 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6740 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6741
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006742 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006743 spec->adc_nids = alc883_adc_nids;
6744 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6745 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006746
6747 codec->patch_ops = alc_patch_ops;
6748 if (board_config == ALC883_AUTO)
6749 spec->init_hook = alc883_auto_init;
6750
6751 return 0;
6752}
6753
6754/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006755 * ALC262 support
6756 */
6757
6758#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6759#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6760
6761#define alc262_dac_nids alc260_dac_nids
6762#define alc262_adc_nids alc882_adc_nids
6763#define alc262_adc_nids_alt alc882_adc_nids_alt
6764
6765#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006766#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006767
6768static struct snd_kcontrol_new alc262_base_mixer[] = {
6769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6770 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006780 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006781 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6782 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6783 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6786 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006787 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006788};
6789
Kailang Yangccc656c2006-10-17 12:32:26 +02006790static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006803 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6804 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6805 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6807 { } /* end */
6808};
6809
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006810static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6811 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6812 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6814 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6815 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6816
6817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006820 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6821 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006822 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6827 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6828 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6829 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6830 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6831 { } /* end */
6832};
6833
Kailang Yangcd7509a2007-01-26 18:33:17 +01006834static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6838 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6839 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6840 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006843 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6848 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6849 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6850 { } /* end */
6851};
6852
6853static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6854 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6855 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006856 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006857 { } /* end */
6858};
6859
Kailang Yang272a5272007-05-14 11:00:38 +02006860static struct snd_kcontrol_new alc262_sony_mixer[] = {
6861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6865 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6866 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6867 { } /* end */
6868};
6869
6870
6871
Kailang Yangdf694da2005-12-05 19:42:22 +01006872#define alc262_capture_mixer alc882_capture_mixer
6873#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6874
6875/*
6876 * generic initialization of ADC, input mixers and output mixers
6877 */
6878static struct hda_verb alc262_init_verbs[] = {
6879 /*
6880 * Unmute ADC0-2 and set the default input to mic-in
6881 */
6882 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6884 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6888
6889 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6890 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006891 * Note: PASD motherboards uses the Line In 2 as the input for
6892 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006893 */
6894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6900
6901 /*
6902 * Set up output mixers (0x0c - 0x0e)
6903 */
6904 /* set vol=0 to output mixers */
6905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6908 /* set up input amps for analog loopback */
6909 /* Amp Indices: DAC = 0, mixer = 1 */
6910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6912 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6914 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6916
6917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6920 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6923
6924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6926 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6929
6930 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6931 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6932
6933 /* FIXME: use matrix-type input source selection */
6934 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6935 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6938 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6940 /* Input mixer2 */
6941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6945 /* Input mixer3 */
6946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01006950
6951 { }
6952};
6953
Kailang Yangccc656c2006-10-17 12:32:26 +02006954static struct hda_verb alc262_hippo_unsol_verbs[] = {
6955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6957 {}
6958};
6959
6960static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6964
6965 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6967 {}
6968};
6969
Kailang Yang272a5272007-05-14 11:00:38 +02006970static struct hda_verb alc262_sony_unsol_verbs[] = {
6971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6974
6975 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6977};
6978
Kailang Yangccc656c2006-10-17 12:32:26 +02006979/* mute/unmute internal speaker according to the hp jack and mute state */
6980static void alc262_hippo_automute(struct hda_codec *codec, int force)
6981{
6982 struct alc_spec *spec = codec->spec;
6983 unsigned int mute;
6984
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006985 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02006986 unsigned int present;
6987 /* need to execute and sync at first */
6988 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6989 present = snd_hda_codec_read(codec, 0x15, 0,
6990 AC_VERB_GET_PIN_SENSE, 0);
6991 spec->jack_present = (present & 0x80000000) != 0;
6992 spec->sense_updated = 1;
6993 }
6994 if (spec->jack_present) {
6995 /* mute internal speaker */
6996 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6997 0x80, 0x80);
6998 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6999 0x80, 0x80);
7000 } else {
7001 /* unmute internal speaker if necessary */
7002 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7003 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7004 0x80, mute & 0x80);
7005 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7006 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7007 0x80, mute & 0x80);
7008 }
7009}
7010
7011/* unsolicited event for HP jack sensing */
7012static void alc262_hippo_unsol_event(struct hda_codec *codec,
7013 unsigned int res)
7014{
7015 if ((res >> 26) != ALC880_HP_EVENT)
7016 return;
7017 alc262_hippo_automute(codec, 1);
7018}
7019
7020static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7021{
7022 struct alc_spec *spec = codec->spec;
7023 unsigned int mute;
7024
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007025 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007026 unsigned int present;
7027 /* need to execute and sync at first */
7028 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7029 present = snd_hda_codec_read(codec, 0x1b, 0,
7030 AC_VERB_GET_PIN_SENSE, 0);
7031 spec->jack_present = (present & 0x80000000) != 0;
7032 spec->sense_updated = 1;
7033 }
7034 if (spec->jack_present) {
7035 /* mute internal speaker */
7036 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7037 0x80, 0x80);
7038 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7039 0x80, 0x80);
7040 } else {
7041 /* unmute internal speaker if necessary */
7042 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7043 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7044 0x80, mute & 0x80);
7045 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7046 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7047 0x80, mute & 0x80);
7048 }
7049}
7050
7051/* unsolicited event for HP jack sensing */
7052static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7053 unsigned int res)
7054{
7055 if ((res >> 26) != ALC880_HP_EVENT)
7056 return;
7057 alc262_hippo1_automute(codec, 1);
7058}
7059
Takashi Iwai834be882006-03-01 14:16:17 +01007060/*
7061 * fujitsu model
7062 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7063 */
7064
7065#define ALC_HP_EVENT 0x37
7066
7067static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7068 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7070 {}
7071};
7072
7073static struct hda_input_mux alc262_fujitsu_capture_source = {
7074 .num_items = 2,
7075 .items = {
7076 { "Mic", 0x0 },
7077 { "CD", 0x4 },
7078 },
7079};
7080
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007081static struct hda_input_mux alc262_HP_capture_source = {
7082 .num_items = 5,
7083 .items = {
7084 { "Mic", 0x0 },
7085 { "Front Mic", 0x3 },
7086 { "Line", 0x2 },
7087 { "CD", 0x4 },
7088 { "AUX IN", 0x6 },
7089 },
7090};
7091
Takashi Iwai834be882006-03-01 14:16:17 +01007092/* mute/unmute internal speaker according to the hp jack and mute state */
7093static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7094{
7095 struct alc_spec *spec = codec->spec;
7096 unsigned int mute;
7097
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007098 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007099 unsigned int present;
7100 /* need to execute and sync at first */
7101 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7102 present = snd_hda_codec_read(codec, 0x14, 0,
7103 AC_VERB_GET_PIN_SENSE, 0);
7104 spec->jack_present = (present & 0x80000000) != 0;
7105 spec->sense_updated = 1;
7106 }
7107 if (spec->jack_present) {
7108 /* mute internal speaker */
7109 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7110 0x80, 0x80);
7111 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7112 0x80, 0x80);
7113 } else {
7114 /* unmute internal speaker if necessary */
7115 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7116 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7117 0x80, mute & 0x80);
7118 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7119 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7120 0x80, mute & 0x80);
7121 }
7122}
7123
7124/* unsolicited event for HP jack sensing */
7125static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7126 unsigned int res)
7127{
7128 if ((res >> 26) != ALC_HP_EVENT)
7129 return;
7130 alc262_fujitsu_automute(codec, 1);
7131}
7132
7133/* bind volumes of both NID 0x0c and 0x0d */
7134static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7135 struct snd_ctl_elem_value *ucontrol)
7136{
7137 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7138 long *valp = ucontrol->value.integer.value;
7139 int change;
7140
7141 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7142 0x7f, valp[0] & 0x7f);
7143 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7144 0x7f, valp[1] & 0x7f);
7145 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7146 0x7f, valp[0] & 0x7f);
7147 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7148 0x7f, valp[1] & 0x7f);
7149 return change;
7150}
7151
7152/* bind hp and internal speaker mute (with plug check) */
7153static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7154 struct snd_ctl_elem_value *ucontrol)
7155{
7156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7157 long *valp = ucontrol->value.integer.value;
7158 int change;
7159
7160 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7161 0x80, valp[0] ? 0 : 0x80);
7162 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7163 0x80, valp[1] ? 0 : 0x80);
7164 if (change || codec->in_resume)
7165 alc262_fujitsu_automute(codec, codec->in_resume);
7166 return change;
7167}
7168
7169static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7170 {
7171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7172 .name = "Master Playback Volume",
7173 .info = snd_hda_mixer_amp_volume_info,
7174 .get = snd_hda_mixer_amp_volume_get,
7175 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007176 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007177 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7178 },
7179 {
7180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7181 .name = "Master Playback Switch",
7182 .info = snd_hda_mixer_amp_switch_info,
7183 .get = snd_hda_mixer_amp_switch_get,
7184 .put = alc262_fujitsu_master_sw_put,
7185 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7186 },
7187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7192 { } /* end */
7193};
7194
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007195/* additional init verbs for Benq laptops */
7196static struct hda_verb alc262_EAPD_verbs[] = {
7197 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7198 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7199 {}
7200};
7201
Kailang Yangdf694da2005-12-05 19:42:22 +01007202/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007203static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7204 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007205{
7206 hda_nid_t nid;
7207 int err;
7208
7209 spec->multiout.num_dacs = 1; /* only use one dac */
7210 spec->multiout.dac_nids = spec->private_dac_nids;
7211 spec->multiout.dac_nids[0] = 2;
7212
7213 nid = cfg->line_out_pins[0];
7214 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007215 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7216 "Front Playback Volume",
7217 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7218 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007219 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007220 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7221 "Front Playback Switch",
7222 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7223 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007224 return err;
7225 }
7226
Takashi Iwai82bc9552006-03-21 11:24:42 +01007227 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007228 if (nid) {
7229 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007230 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7231 "Speaker Playback Volume",
7232 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7233 HDA_OUTPUT));
7234 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007235 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007236 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7237 "Speaker Playback Switch",
7238 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7239 HDA_OUTPUT));
7240 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007241 return err;
7242 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007243 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7244 "Speaker Playback Switch",
7245 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7246 HDA_OUTPUT));
7247 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007248 return err;
7249 }
7250 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007251 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007252 if (nid) {
7253 /* spec->multiout.hp_nid = 2; */
7254 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007255 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7256 "Headphone Playback Volume",
7257 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7258 HDA_OUTPUT));
7259 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007260 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007261 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7262 "Headphone Playback Switch",
7263 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7264 HDA_OUTPUT));
7265 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007266 return err;
7267 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007268 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7269 "Headphone Playback Switch",
7270 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7271 HDA_OUTPUT));
7272 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007273 return err;
7274 }
7275 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007276 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007277}
7278
7279/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007280#define alc262_auto_create_analog_input_ctls \
7281 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007282
7283/*
7284 * generic initialization of ADC, input mixers and output mixers
7285 */
7286static struct hda_verb alc262_volume_init_verbs[] = {
7287 /*
7288 * Unmute ADC0-2 and set the default input to mic-in
7289 */
7290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7296
7297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7298 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007299 * Note: PASD motherboards uses the Line In 2 as the input for
7300 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007301 */
7302 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7308
7309 /*
7310 * Set up output mixers (0x0c - 0x0f)
7311 */
7312 /* set vol=0 to output mixers */
7313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7316
7317 /* set up input amps for analog loopback */
7318 /* Amp Indices: DAC = 0, mixer = 1 */
7319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7325
7326 /* FIXME: use matrix-type input source selection */
7327 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7328 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7333 /* Input mixer2 */
7334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7338 /* Input mixer3 */
7339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7343
7344 { }
7345};
7346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007347static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7348 /*
7349 * Unmute ADC0-2 and set the default input to mic-in
7350 */
7351 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7353 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7355 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7357
7358 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7359 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007360 * Note: PASD motherboards uses the Line In 2 as the input for
7361 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007362 */
7363 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7371
7372 /*
7373 * Set up output mixers (0x0c - 0x0e)
7374 */
7375 /* set vol=0 to output mixers */
7376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379
7380 /* set up input amps for analog loopback */
7381 /* Amp Indices: DAC = 0, mixer = 1 */
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7388
7389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7392
7393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7395
7396 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7397 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7398
7399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7402 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7403 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7404
7405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7407 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7409 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7410 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7411
7412
7413 /* FIXME: use matrix-type input source selection */
7414 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7415 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7420 /* Input mixer2 */
7421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7425 /* Input mixer3 */
7426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7430
7431 { }
7432};
7433
Kailang Yangcd7509a2007-01-26 18:33:17 +01007434static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7435 /*
7436 * Unmute ADC0-2 and set the default input to mic-in
7437 */
7438 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7440 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7442 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7444
7445 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7446 * mixer widget
7447 * Note: PASD motherboards uses the Line In 2 as the input for front
7448 * panel mic (mic 2)
7449 */
7450 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7459 /*
7460 * Set up output mixers (0x0c - 0x0e)
7461 */
7462 /* set vol=0 to output mixers */
7463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7466
7467 /* set up input amps for analog loopback */
7468 /* Amp Indices: DAC = 0, mixer = 1 */
7469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7475
7476
7477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7480 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7482 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7483 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7484
7485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7487
7488 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7490
7491 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7493 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7495 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7496 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7497
7498 /* FIXME: use matrix-type input source selection */
7499 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7500 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7506 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7508 /* Input mixer2 */
7509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7514 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7516 /* Input mixer3 */
7517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7522 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7524
7525 { }
7526};
7527
Kailang Yangdf694da2005-12-05 19:42:22 +01007528/* pcm configuration: identiacal with ALC880 */
7529#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7530#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7531#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7532#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7533
7534/*
7535 * BIOS auto configuration
7536 */
7537static int alc262_parse_auto_config(struct hda_codec *codec)
7538{
7539 struct alc_spec *spec = codec->spec;
7540 int err;
7541 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7542
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007543 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7544 alc262_ignore);
7545 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007547 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007548 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007549 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7550 if (err < 0)
7551 return err;
7552 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7553 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007554 return err;
7555
7556 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7557
7558 if (spec->autocfg.dig_out_pin)
7559 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7560 if (spec->autocfg.dig_in_pin)
7561 spec->dig_in_nid = ALC262_DIGIN_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++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007567 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007568 spec->input_mux = &spec->private_imux;
7569
7570 return 1;
7571}
7572
7573#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7574#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7575#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7576
7577
7578/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007579static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007580{
Kailang Yangdf694da2005-12-05 19:42:22 +01007581 alc262_auto_init_multi_out(codec);
7582 alc262_auto_init_hp_out(codec);
7583 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007584}
7585
7586/*
7587 * configuration and preset
7588 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007589static const char *alc262_models[ALC262_MODEL_LAST] = {
7590 [ALC262_BASIC] = "basic",
7591 [ALC262_HIPPO] = "hippo",
7592 [ALC262_HIPPO_1] = "hippo_1",
7593 [ALC262_FUJITSU] = "fujitsu",
7594 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007595 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007596 [ALC262_BENQ_ED8] = "benq",
Kailang Yang272a5272007-05-14 11:00:38 +02007597 [ALC262_BENQ_ED8] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007598 [ALC262_AUTO] = "auto",
7599};
7600
7601static struct snd_pci_quirk alc262_cfg_tbl[] = {
7602 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7603 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7604 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007605 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7606 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007607 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007608 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007609 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007610 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007611 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7612 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7613 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7614 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7615 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7616 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7617 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7618 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007619 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7620 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7621 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7622 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang272a5272007-05-14 11:00:38 +02007623 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7624 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7625 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007626 {}
7627};
7628
7629static struct alc_config_preset alc262_presets[] = {
7630 [ALC262_BASIC] = {
7631 .mixers = { alc262_base_mixer },
7632 .init_verbs = { alc262_init_verbs },
7633 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7634 .dac_nids = alc262_dac_nids,
7635 .hp_nid = 0x03,
7636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7637 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007638 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007639 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007640 [ALC262_HIPPO] = {
7641 .mixers = { alc262_base_mixer },
7642 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7643 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7644 .dac_nids = alc262_dac_nids,
7645 .hp_nid = 0x03,
7646 .dig_out_nid = ALC262_DIGOUT_NID,
7647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7648 .channel_mode = alc262_modes,
7649 .input_mux = &alc262_capture_source,
7650 .unsol_event = alc262_hippo_unsol_event,
7651 },
7652 [ALC262_HIPPO_1] = {
7653 .mixers = { alc262_hippo1_mixer },
7654 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7655 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7656 .dac_nids = alc262_dac_nids,
7657 .hp_nid = 0x02,
7658 .dig_out_nid = ALC262_DIGOUT_NID,
7659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7660 .channel_mode = alc262_modes,
7661 .input_mux = &alc262_capture_source,
7662 .unsol_event = alc262_hippo1_unsol_event,
7663 },
Takashi Iwai834be882006-03-01 14:16:17 +01007664 [ALC262_FUJITSU] = {
7665 .mixers = { alc262_fujitsu_mixer },
7666 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7668 .dac_nids = alc262_dac_nids,
7669 .hp_nid = 0x03,
7670 .dig_out_nid = ALC262_DIGOUT_NID,
7671 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7672 .channel_mode = alc262_modes,
7673 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007674 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007675 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007676 [ALC262_HP_BPC] = {
7677 .mixers = { alc262_HP_BPC_mixer },
7678 .init_verbs = { alc262_HP_BPC_init_verbs },
7679 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7680 .dac_nids = alc262_dac_nids,
7681 .hp_nid = 0x03,
7682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7683 .channel_mode = alc262_modes,
7684 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007685 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007686 [ALC262_HP_BPC_D7000_WF] = {
7687 .mixers = { alc262_HP_BPC_WildWest_mixer },
7688 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7690 .dac_nids = alc262_dac_nids,
7691 .hp_nid = 0x03,
7692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7693 .channel_mode = alc262_modes,
7694 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007695 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007696 [ALC262_HP_BPC_D7000_WL] = {
7697 .mixers = { alc262_HP_BPC_WildWest_mixer,
7698 alc262_HP_BPC_WildWest_option_mixer },
7699 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7700 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7701 .dac_nids = alc262_dac_nids,
7702 .hp_nid = 0x03,
7703 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7704 .channel_mode = alc262_modes,
7705 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007706 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007707 [ALC262_BENQ_ED8] = {
7708 .mixers = { alc262_base_mixer },
7709 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7710 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7711 .dac_nids = alc262_dac_nids,
7712 .hp_nid = 0x03,
7713 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7714 .channel_mode = alc262_modes,
7715 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007716 },
Kailang Yang272a5272007-05-14 11:00:38 +02007717 [ALC262_SONY_ASSAMD] = {
7718 .mixers = { alc262_sony_mixer },
7719 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7720 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7721 .dac_nids = alc262_dac_nids,
7722 .hp_nid = 0x02,
7723 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7724 .channel_mode = alc262_modes,
7725 .input_mux = &alc262_capture_source,
7726 .unsol_event = alc262_hippo_unsol_event,
7727 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007728};
7729
7730static int patch_alc262(struct hda_codec *codec)
7731{
7732 struct alc_spec *spec;
7733 int board_config;
7734 int err;
7735
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007736 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007737 if (spec == NULL)
7738 return -ENOMEM;
7739
7740 codec->spec = spec;
7741#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007742 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7743 * under-run
7744 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007745 {
7746 int tmp;
7747 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7748 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7749 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7750 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7751 }
7752#endif
7753
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007754 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7755 alc262_models,
7756 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007757
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007758 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007759 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7760 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007761 board_config = ALC262_AUTO;
7762 }
7763
7764 if (board_config == ALC262_AUTO) {
7765 /* automatic parse from the BIOS config */
7766 err = alc262_parse_auto_config(codec);
7767 if (err < 0) {
7768 alc_free(codec);
7769 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007770 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007771 printk(KERN_INFO
7772 "hda_codec: Cannot set up configuration "
7773 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007774 board_config = ALC262_BASIC;
7775 }
7776 }
7777
7778 if (board_config != ALC262_AUTO)
7779 setup_preset(spec, &alc262_presets[board_config]);
7780
7781 spec->stream_name_analog = "ALC262 Analog";
7782 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7783 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7784
7785 spec->stream_name_digital = "ALC262 Digital";
7786 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7787 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7788
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007790 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007791 unsigned int wcap = get_wcaps(codec, 0x07);
7792
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007793 /* get type */
7794 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007795 if (wcap != AC_WID_AUD_IN) {
7796 spec->adc_nids = alc262_adc_nids_alt;
7797 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007798 spec->mixers[spec->num_mixers] =
7799 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007800 spec->num_mixers++;
7801 } else {
7802 spec->adc_nids = alc262_adc_nids;
7803 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7804 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7805 spec->num_mixers++;
7806 }
7807 }
7808
7809 codec->patch_ops = alc_patch_ops;
7810 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007811 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01007812
Kailang Yangdf694da2005-12-05 19:42:22 +01007813 return 0;
7814}
7815
Kailang Yangdf694da2005-12-05 19:42:22 +01007816/*
Kailang Yanga361d842007-06-05 12:30:55 +02007817 * ALC268 channel source setting (2 channel)
7818 */
7819#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7820#define alc268_modes alc260_modes
7821
7822static hda_nid_t alc268_dac_nids[2] = {
7823 /* front, hp */
7824 0x02, 0x03
7825};
7826
7827static hda_nid_t alc268_adc_nids[2] = {
7828 /* ADC0-1 */
7829 0x08, 0x07
7830};
7831
7832static hda_nid_t alc268_adc_nids_alt[1] = {
7833 /* ADC0 */
7834 0x08
7835};
7836
7837static struct snd_kcontrol_new alc268_base_mixer[] = {
7838 /* output mixer control */
7839 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7843 { }
7844};
7845
7846/*
7847 * generic initialization of ADC, input mixers and output mixers
7848 */
7849static struct hda_verb alc268_base_init_verbs[] = {
7850 /* Unmute DAC0-1 and set vol = 0 */
7851 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7852 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7853 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7854 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7855 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7856 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7857
7858 /*
7859 * Set up output mixers (0x0c - 0x0e)
7860 */
7861 /* set vol=0 to output mixers */
7862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7865 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7866
7867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7868 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7869
7870 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7872 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7877 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7878
7879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7882 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7883 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7885 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7886 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7887
7888 /* FIXME: use matrix-type input source selection */
7889 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
7890 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7891 /* Input mixer2 */
7892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7896
7897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7901 { }
7902};
7903
7904/*
7905 * generic initialization of ADC, input mixers and output mixers
7906 */
7907static struct hda_verb alc268_volume_init_verbs[] = {
7908 /* set output DAC */
7909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7910 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7913
7914 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7916 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7917 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7918 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7919
7920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7925
7926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7929 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7930
7931 /* set PCBEEP vol = 0 */
7932 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
7933
7934 { }
7935};
7936
7937#define alc268_mux_enum_info alc_mux_enum_info
7938#define alc268_mux_enum_get alc_mux_enum_get
7939
7940static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
7941 struct snd_ctl_elem_value *ucontrol)
7942{
7943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7944 struct alc_spec *spec = codec->spec;
7945 const struct hda_input_mux *imux = spec->input_mux;
7946 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7947 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
7948 hda_nid_t nid = capture_mixers[adc_idx];
7949 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7950 unsigned int i, idx;
7951
7952 idx = ucontrol->value.enumerated.item[0];
7953 if (idx >= imux->num_items)
7954 idx = imux->num_items - 1;
7955 if (*cur_val == idx && !codec->in_resume)
7956 return 0;
7957 for (i = 0; i < imux->num_items; i++) {
7958 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
7959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7960 v | (imux->items[i].index << 8));
7961 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
7962 idx );
7963 }
7964 *cur_val = idx;
7965 return 1;
7966}
7967
7968static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
7969 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7971 {
7972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7973 /* The multiple "Capture Source" controls confuse alsamixer
7974 * So call somewhat different..
7975 * FIXME: the controls appear in the "playback" view!
7976 */
7977 /* .name = "Capture Source", */
7978 .name = "Input Source",
7979 .count = 1,
7980 .info = alc268_mux_enum_info,
7981 .get = alc268_mux_enum_get,
7982 .put = alc268_mux_enum_put,
7983 },
7984 { } /* end */
7985};
7986
7987static struct snd_kcontrol_new alc268_capture_mixer[] = {
7988 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7989 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7990 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
7992 {
7993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7994 /* The multiple "Capture Source" controls confuse alsamixer
7995 * So call somewhat different..
7996 * FIXME: the controls appear in the "playback" view!
7997 */
7998 /* .name = "Capture Source", */
7999 .name = "Input Source",
8000 .count = 2,
8001 .info = alc268_mux_enum_info,
8002 .get = alc268_mux_enum_get,
8003 .put = alc268_mux_enum_put,
8004 },
8005 { } /* end */
8006};
8007
8008static struct hda_input_mux alc268_capture_source = {
8009 .num_items = 4,
8010 .items = {
8011 { "Mic", 0x0 },
8012 { "Front Mic", 0x1 },
8013 { "Line", 0x2 },
8014 { "CD", 0x3 },
8015 },
8016};
8017
8018/* create input playback/capture controls for the given pin */
8019static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8020 const char *ctlname, int idx)
8021{
8022 char name[32];
8023 int err;
8024
8025 sprintf(name, "%s Playback Volume", ctlname);
8026 if (nid == 0x14) {
8027 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8028 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8029 HDA_OUTPUT));
8030 if (err < 0)
8031 return err;
8032 } else if (nid == 0x15) {
8033 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8034 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8035 HDA_OUTPUT));
8036 if (err < 0)
8037 return err;
8038 } else
8039 return -1;
8040 sprintf(name, "%s Playback Switch", ctlname);
8041 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8042 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8043 if (err < 0)
8044 return err;
8045 return 0;
8046}
8047
8048/* add playback controls from the parsed DAC table */
8049static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8050 const struct auto_pin_cfg *cfg)
8051{
8052 hda_nid_t nid;
8053 int err;
8054
8055 spec->multiout.num_dacs = 2; /* only use one dac */
8056 spec->multiout.dac_nids = spec->private_dac_nids;
8057 spec->multiout.dac_nids[0] = 2;
8058 spec->multiout.dac_nids[1] = 3;
8059
8060 nid = cfg->line_out_pins[0];
8061 if (nid)
8062 alc268_new_analog_output(spec, nid, "Front", 0);
8063
8064 nid = cfg->speaker_pins[0];
8065 if (nid == 0x1d) {
8066 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8067 "Speaker Playback Volume",
8068 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8069 if (err < 0)
8070 return err;
8071 }
8072 nid = cfg->hp_pins[0];
8073 if (nid)
8074 alc268_new_analog_output(spec, nid, "Headphone", 0);
8075
8076 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8077 if (nid == 0x16) {
8078 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8079 "Mono Playback Switch",
8080 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8081 if (err < 0)
8082 return err;
8083 }
8084 return 0;
8085}
8086
8087/* create playback/capture controls for input pins */
8088static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8089 const struct auto_pin_cfg *cfg)
8090{
8091 struct hda_input_mux *imux = &spec->private_imux;
8092 int i, idx1;
8093
8094 for (i = 0; i < AUTO_PIN_LAST; i++) {
8095 switch(cfg->input_pins[i]) {
8096 case 0x18:
8097 idx1 = 0; /* Mic 1 */
8098 break;
8099 case 0x19:
8100 idx1 = 1; /* Mic 2 */
8101 break;
8102 case 0x1a:
8103 idx1 = 2; /* Line In */
8104 break;
8105 case 0x1c:
8106 idx1 = 3; /* CD */
8107 break;
8108 default:
8109 continue;
8110 }
8111 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8112 imux->items[imux->num_items].index = idx1;
8113 imux->num_items++;
8114 }
8115 return 0;
8116}
8117
8118static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8119{
8120 struct alc_spec *spec = codec->spec;
8121 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8122 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8123 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8124 unsigned int dac_vol1, dac_vol2;
8125
8126 if (speaker_nid) {
8127 snd_hda_codec_write(codec, speaker_nid, 0,
8128 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8129 snd_hda_codec_write(codec, 0x0f, 0,
8130 AC_VERB_SET_AMP_GAIN_MUTE,
8131 AMP_IN_UNMUTE(1));
8132 snd_hda_codec_write(codec, 0x10, 0,
8133 AC_VERB_SET_AMP_GAIN_MUTE,
8134 AMP_IN_UNMUTE(1));
8135 } else {
8136 snd_hda_codec_write(codec, 0x0f, 0,
8137 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8138 snd_hda_codec_write(codec, 0x10, 0,
8139 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8140 }
8141
8142 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8143 if (line_nid == 0x14)
8144 dac_vol2 = AMP_OUT_ZERO;
8145 else if (line_nid == 0x15)
8146 dac_vol1 = AMP_OUT_ZERO;
8147 if (hp_nid == 0x14)
8148 dac_vol2 = AMP_OUT_ZERO;
8149 else if (hp_nid == 0x15)
8150 dac_vol1 = AMP_OUT_ZERO;
8151 if (line_nid != 0x16 || hp_nid != 0x16 ||
8152 spec->autocfg.line_out_pins[1] != 0x16 ||
8153 spec->autocfg.line_out_pins[2] != 0x16)
8154 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8155
8156 snd_hda_codec_write(codec, 0x02, 0,
8157 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8158 snd_hda_codec_write(codec, 0x03, 0,
8159 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8160}
8161
8162/* pcm configuration: identiacal with ALC880 */
8163#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8164#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8165#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8166
8167/*
8168 * BIOS auto configuration
8169 */
8170static int alc268_parse_auto_config(struct hda_codec *codec)
8171{
8172 struct alc_spec *spec = codec->spec;
8173 int err;
8174 static hda_nid_t alc268_ignore[] = { 0 };
8175
8176 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8177 alc268_ignore);
8178 if (err < 0)
8179 return err;
8180 if (!spec->autocfg.line_outs)
8181 return 0; /* can't find valid BIOS pin config */
8182
8183 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8184 if (err < 0)
8185 return err;
8186 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8187 if (err < 0)
8188 return err;
8189
8190 spec->multiout.max_channels = 2;
8191
8192 /* digital only support output */
8193 if (spec->autocfg.dig_out_pin)
8194 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8195
8196 if (spec->kctl_alloc)
8197 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8198
8199 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8200 spec->num_mux_defs = 1;
8201 spec->input_mux = &spec->private_imux;
8202
8203 return 1;
8204}
8205
8206#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8207#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8208#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8209
8210/* init callback for auto-configuration model -- overriding the default init */
8211static void alc268_auto_init(struct hda_codec *codec)
8212{
8213 alc268_auto_init_multi_out(codec);
8214 alc268_auto_init_hp_out(codec);
8215 alc268_auto_init_mono_speaker_out(codec);
8216 alc268_auto_init_analog_input(codec);
8217}
8218
8219/*
8220 * configuration and preset
8221 */
8222static const char *alc268_models[ALC268_MODEL_LAST] = {
8223 [ALC268_3ST] = "3stack",
8224 [ALC268_AUTO] = "auto",
8225};
8226
8227static struct snd_pci_quirk alc268_cfg_tbl[] = {
8228 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8229 {}
8230};
8231
8232static struct alc_config_preset alc268_presets[] = {
8233 [ALC268_3ST] = {
8234 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8235 .init_verbs = { alc268_base_init_verbs },
8236 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8237 .dac_nids = alc268_dac_nids,
8238 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8239 .adc_nids = alc268_adc_nids_alt,
8240 .hp_nid = 0x03,
8241 .dig_out_nid = ALC268_DIGOUT_NID,
8242 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8243 .channel_mode = alc268_modes,
8244 .input_mux = &alc268_capture_source,
8245 },
8246};
8247
8248static int patch_alc268(struct hda_codec *codec)
8249{
8250 struct alc_spec *spec;
8251 int board_config;
8252 int err;
8253
8254 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8255 if (spec == NULL)
8256 return -ENOMEM;
8257
8258 codec->spec = spec;
8259
8260 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8261 alc268_models,
8262 alc268_cfg_tbl);
8263
8264 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8265 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8266 "trying auto-probe from BIOS...\n");
8267 board_config = ALC268_AUTO;
8268 }
8269
8270 if (board_config == ALC268_AUTO) {
8271 /* automatic parse from the BIOS config */
8272 err = alc268_parse_auto_config(codec);
8273 if (err < 0) {
8274 alc_free(codec);
8275 return err;
8276 } else if (!err) {
8277 printk(KERN_INFO
8278 "hda_codec: Cannot set up configuration "
8279 "from BIOS. Using base mode...\n");
8280 board_config = ALC268_3ST;
8281 }
8282 }
8283
8284 if (board_config != ALC268_AUTO)
8285 setup_preset(spec, &alc268_presets[board_config]);
8286
8287 spec->stream_name_analog = "ALC268 Analog";
8288 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8289 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8290
8291 spec->stream_name_digital = "ALC268 Digital";
8292 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8293
8294 if (board_config == ALC268_AUTO) {
8295 if (!spec->adc_nids && spec->input_mux) {
8296 /* check whether NID 0x07 is valid */
8297 unsigned int wcap = get_wcaps(codec, 0x07);
8298
8299 /* get type */
8300 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8301 if (wcap != AC_WID_AUD_IN) {
8302 spec->adc_nids = alc268_adc_nids_alt;
8303 spec->num_adc_nids =
8304 ARRAY_SIZE(alc268_adc_nids_alt);
8305 spec->mixers[spec->num_mixers] =
8306 alc268_capture_alt_mixer;
8307 spec->num_mixers++;
8308 } else {
8309 spec->adc_nids = alc268_adc_nids;
8310 spec->num_adc_nids =
8311 ARRAY_SIZE(alc268_adc_nids);
8312 spec->mixers[spec->num_mixers] =
8313 alc268_capture_mixer;
8314 spec->num_mixers++;
8315 }
8316 }
8317 }
8318 codec->patch_ops = alc_patch_ops;
8319 if (board_config == ALC268_AUTO)
8320 spec->init_hook = alc268_auto_init;
8321
8322 return 0;
8323}
8324
8325/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008326 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8327 */
8328
8329/*
8330 * set the path ways for 2 channel output
8331 * need to set the codec line out and mic 1 pin widgets to inputs
8332 */
8333static struct hda_verb alc861_threestack_ch2_init[] = {
8334 /* set pin widget 1Ah (line in) for input */
8335 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008336 /* set pin widget 18h (mic1/2) for input, for mic also enable
8337 * the vref
8338 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008339 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008341 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8342#if 0
8343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8344 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8345#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008346 { } /* end */
8347};
8348/*
8349 * 6ch mode
8350 * need to set the codec line out and mic 1 pin widgets to outputs
8351 */
8352static struct hda_verb alc861_threestack_ch6_init[] = {
8353 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8354 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8355 /* set pin widget 18h (mic1) for output (CLFE)*/
8356 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8357
8358 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008359 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008360
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8362#if 0
8363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8365#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008366 { } /* end */
8367};
8368
8369static struct hda_channel_mode alc861_threestack_modes[2] = {
8370 { 2, alc861_threestack_ch2_init },
8371 { 6, alc861_threestack_ch6_init },
8372};
Takashi Iwai22309c32006-08-09 16:57:28 +02008373/* Set mic1 as input and unmute the mixer */
8374static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8375 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8377 { } /* end */
8378};
8379/* Set mic1 as output and mute mixer */
8380static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8381 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8383 { } /* end */
8384};
8385
8386static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8387 { 2, alc861_uniwill_m31_ch2_init },
8388 { 4, alc861_uniwill_m31_ch4_init },
8389};
Kailang Yangdf694da2005-12-05 19:42:22 +01008390
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008391/* Set mic1 and line-in as input and unmute the mixer */
8392static struct hda_verb alc861_asus_ch2_init[] = {
8393 /* set pin widget 1Ah (line in) for input */
8394 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008395 /* set pin widget 18h (mic1/2) for input, for mic also enable
8396 * the vref
8397 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008398 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8399
8400 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8401#if 0
8402 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8404#endif
8405 { } /* end */
8406};
8407/* Set mic1 nad line-in as output and mute mixer */
8408static struct hda_verb alc861_asus_ch6_init[] = {
8409 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8410 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8411 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8412 /* set pin widget 18h (mic1) for output (CLFE)*/
8413 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8414 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8415 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8416 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8417
8418 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8419#if 0
8420 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8422#endif
8423 { } /* end */
8424};
8425
8426static struct hda_channel_mode alc861_asus_modes[2] = {
8427 { 2, alc861_asus_ch2_init },
8428 { 6, alc861_asus_ch6_init },
8429};
8430
Kailang Yangdf694da2005-12-05 19:42:22 +01008431/* patch-ALC861 */
8432
8433static struct snd_kcontrol_new alc861_base_mixer[] = {
8434 /* output mixer control */
8435 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8436 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8439 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8440
8441 /*Input mixer control */
8442 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8443 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8444 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8445 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8446 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8447 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8449 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8450 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008452
Kailang Yangdf694da2005-12-05 19:42:22 +01008453 /* Capture mixer control */
8454 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8455 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8456 {
8457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8458 .name = "Capture Source",
8459 .count = 1,
8460 .info = alc_mux_enum_info,
8461 .get = alc_mux_enum_get,
8462 .put = alc_mux_enum_put,
8463 },
8464 { } /* end */
8465};
8466
8467static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8468 /* output mixer control */
8469 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8470 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8471 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8472 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8473 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8474
8475 /* Input mixer control */
8476 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8477 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8478 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8479 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8480 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8481 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8483 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008486
Kailang Yangdf694da2005-12-05 19:42:22 +01008487 /* Capture mixer control */
8488 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8489 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8490 {
8491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8492 .name = "Capture Source",
8493 .count = 1,
8494 .info = alc_mux_enum_info,
8495 .get = alc_mux_enum_get,
8496 .put = alc_mux_enum_put,
8497 },
8498 {
8499 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8500 .name = "Channel Mode",
8501 .info = alc_ch_mode_info,
8502 .get = alc_ch_mode_get,
8503 .put = alc_ch_mode_put,
8504 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8505 },
8506 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008507};
8508
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008509static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008510 /* output mixer control */
8511 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8513 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8514
8515 /*Capture mixer control */
8516 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8517 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8518 {
8519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8520 .name = "Capture Source",
8521 .count = 1,
8522 .info = alc_mux_enum_info,
8523 .get = alc_mux_enum_get,
8524 .put = alc_mux_enum_put,
8525 },
8526
8527 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008528};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008529
Takashi Iwai22309c32006-08-09 16:57:28 +02008530static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8531 /* output mixer control */
8532 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8533 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8534 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8535 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8536 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8537
8538 /* Input mixer control */
8539 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8540 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8541 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8542 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8543 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8544 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8546 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008549
Takashi Iwai22309c32006-08-09 16:57:28 +02008550 /* Capture mixer control */
8551 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8552 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8553 {
8554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8555 .name = "Capture Source",
8556 .count = 1,
8557 .info = alc_mux_enum_info,
8558 .get = alc_mux_enum_get,
8559 .put = alc_mux_enum_put,
8560 },
8561 {
8562 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8563 .name = "Channel Mode",
8564 .info = alc_ch_mode_info,
8565 .get = alc_ch_mode_get,
8566 .put = alc_ch_mode_put,
8567 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8568 },
8569 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008570};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008571
8572static struct snd_kcontrol_new alc861_asus_mixer[] = {
8573 /* output mixer control */
8574 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8577 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8578 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8579
8580 /* Input mixer control */
8581 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8582 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8583 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8584 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8585 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8586 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8588 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8591
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008592 /* Capture mixer control */
8593 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8594 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8595 {
8596 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8597 .name = "Capture Source",
8598 .count = 1,
8599 .info = alc_mux_enum_info,
8600 .get = alc_mux_enum_get,
8601 .put = alc_mux_enum_put,
8602 },
8603 {
8604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8605 .name = "Channel Mode",
8606 .info = alc_ch_mode_info,
8607 .get = alc_ch_mode_get,
8608 .put = alc_ch_mode_put,
8609 .private_value = ARRAY_SIZE(alc861_asus_modes),
8610 },
8611 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008612};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008613
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008614/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008615static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008616 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8617 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8618 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8619 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8620 { }
8621};
8622
Kailang Yangdf694da2005-12-05 19:42:22 +01008623/*
8624 * generic initialization of ADC, input mixers and output mixers
8625 */
8626static struct hda_verb alc861_base_init_verbs[] = {
8627 /*
8628 * Unmute ADC0 and set the default input to mic-in
8629 */
8630 /* port-A for surround (rear panel) */
8631 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8632 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8633 /* port-B for mic-in (rear panel) with vref */
8634 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8635 /* port-C for line-in (rear panel) */
8636 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8637 /* port-D for Front */
8638 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8639 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8640 /* port-E for HP out (front panel) */
8641 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8642 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008643 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008644 /* port-F for mic-in (front panel) with vref */
8645 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8646 /* port-G for CLFE (rear panel) */
8647 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8648 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8649 /* port-H for side (rear panel) */
8650 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8651 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8652 /* CD-in */
8653 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8654 /* route front mic to ADC1*/
8655 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8657
8658 /* Unmute DAC0~3 & spdif out*/
8659 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8661 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8662 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8664
8665 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8666 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8667 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8668 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8669 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8670
8671 /* Unmute Stereo Mixer 15 */
8672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008676
8677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008685 /* hp used DAC 3 (Front) */
8686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8688
8689 { }
8690};
8691
8692static struct hda_verb alc861_threestack_init_verbs[] = {
8693 /*
8694 * Unmute ADC0 and set the default input to mic-in
8695 */
8696 /* port-A for surround (rear panel) */
8697 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8698 /* port-B for mic-in (rear panel) with vref */
8699 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8700 /* port-C for line-in (rear panel) */
8701 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8702 /* port-D for Front */
8703 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8704 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8705 /* port-E for HP out (front panel) */
8706 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8707 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008708 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008709 /* port-F for mic-in (front panel) with vref */
8710 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8711 /* port-G for CLFE (rear panel) */
8712 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8713 /* port-H for side (rear panel) */
8714 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8715 /* CD-in */
8716 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8717 /* route front mic to ADC1*/
8718 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8720 /* Unmute DAC0~3 & spdif out*/
8721 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8723 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8724 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8726
8727 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8728 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8729 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8730 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8731 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8732
8733 /* Unmute Stereo Mixer 15 */
8734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008738
8739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8741 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008747 /* hp used DAC 3 (Front) */
8748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8750 { }
8751};
Takashi Iwai22309c32006-08-09 16:57:28 +02008752
8753static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8754 /*
8755 * Unmute ADC0 and set the default input to mic-in
8756 */
8757 /* port-A for surround (rear panel) */
8758 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8759 /* port-B for mic-in (rear panel) with vref */
8760 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8761 /* port-C for line-in (rear panel) */
8762 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8763 /* port-D for Front */
8764 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8765 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8766 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008767 /* this has to be set to VREF80 */
8768 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008769 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008771 /* port-F for mic-in (front panel) with vref */
8772 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8773 /* port-G for CLFE (rear panel) */
8774 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8775 /* port-H for side (rear panel) */
8776 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8777 /* CD-in */
8778 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8779 /* route front mic to ADC1*/
8780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8782 /* Unmute DAC0~3 & spdif out*/
8783 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8784 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8785 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8786 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8788
8789 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8790 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8791 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8792 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8793 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8794
8795 /* Unmute Stereo Mixer 15 */
8796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008800
8801 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8803 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8804 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008809 /* hp used DAC 3 (Front) */
8810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02008811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8812 { }
8813};
8814
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008815static struct hda_verb alc861_asus_init_verbs[] = {
8816 /*
8817 * Unmute ADC0 and set the default input to mic-in
8818 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008819 /* port-A for surround (rear panel)
8820 * according to codec#0 this is the HP jack
8821 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008822 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8823 /* route front PCM to HP */
8824 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8825 /* port-B for mic-in (rear panel) with vref */
8826 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8827 /* port-C for line-in (rear panel) */
8828 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8829 /* port-D for Front */
8830 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8831 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8832 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008833 /* this has to be set to VREF80 */
8834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008835 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008836 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008837 /* port-F for mic-in (front panel) with vref */
8838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8839 /* port-G for CLFE (rear panel) */
8840 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8841 /* port-H for side (rear panel) */
8842 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8843 /* CD-in */
8844 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8845 /* route front mic to ADC1*/
8846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8848 /* Unmute DAC0~3 & spdif out*/
8849 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8850 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8851 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8852 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8854 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8855 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8856 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8857 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8858 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8859
8860 /* Unmute Stereo Mixer 15 */
8861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008865
8866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8872 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008874 /* hp used DAC 3 (Front) */
8875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8877 { }
8878};
8879
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008880/* additional init verbs for ASUS laptops */
8881static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8882 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8883 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8884 { }
8885};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008886
Kailang Yangdf694da2005-12-05 19:42:22 +01008887/*
8888 * generic initialization of ADC, input mixers and output mixers
8889 */
8890static struct hda_verb alc861_auto_init_verbs[] = {
8891 /*
8892 * Unmute ADC0 and set the default input to mic-in
8893 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008894 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01008895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8896
8897 /* Unmute DAC0~3 & spdif out*/
8898 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8899 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8901 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8903
8904 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8905 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8907 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8908 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8909
8910 /* Unmute Stereo Mixer 15 */
8911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8915
8916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8924
8925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8930 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008933
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008935
8936 { }
8937};
8938
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008939static struct hda_verb alc861_toshiba_init_verbs[] = {
8940 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008941
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008942 { }
8943};
8944
8945/* toggle speaker-output according to the hp-jack state */
8946static void alc861_toshiba_automute(struct hda_codec *codec)
8947{
8948 unsigned int present;
8949
8950 present = snd_hda_codec_read(codec, 0x0f, 0,
8951 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8952 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8953 0x80, present ? 0x80 : 0);
8954 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8955 0x80, present ? 0x80 : 0);
8956 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8957 0x80, present ? 0 : 0x80);
8958 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8959 0x80, present ? 0 : 0x80);
8960}
8961
8962static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8963 unsigned int res)
8964{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008965 if ((res >> 26) == ALC880_HP_EVENT)
8966 alc861_toshiba_automute(codec);
8967}
8968
Kailang Yangdf694da2005-12-05 19:42:22 +01008969/* pcm configuration: identiacal with ALC880 */
8970#define alc861_pcm_analog_playback alc880_pcm_analog_playback
8971#define alc861_pcm_analog_capture alc880_pcm_analog_capture
8972#define alc861_pcm_digital_playback alc880_pcm_digital_playback
8973#define alc861_pcm_digital_capture alc880_pcm_digital_capture
8974
8975
8976#define ALC861_DIGOUT_NID 0x07
8977
8978static struct hda_channel_mode alc861_8ch_modes[1] = {
8979 { 8, NULL }
8980};
8981
8982static hda_nid_t alc861_dac_nids[4] = {
8983 /* front, surround, clfe, side */
8984 0x03, 0x06, 0x05, 0x04
8985};
8986
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987static hda_nid_t alc660_dac_nids[3] = {
8988 /* front, clfe, surround */
8989 0x03, 0x05, 0x06
8990};
8991
Kailang Yangdf694da2005-12-05 19:42:22 +01008992static hda_nid_t alc861_adc_nids[1] = {
8993 /* ADC0-2 */
8994 0x08,
8995};
8996
8997static struct hda_input_mux alc861_capture_source = {
8998 .num_items = 5,
8999 .items = {
9000 { "Mic", 0x0 },
9001 { "Front Mic", 0x3 },
9002 { "Line", 0x1 },
9003 { "CD", 0x4 },
9004 { "Mixer", 0x5 },
9005 },
9006};
9007
9008/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009009static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9010 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009011{
9012 int i;
9013 hda_nid_t nid;
9014
9015 spec->multiout.dac_nids = spec->private_dac_nids;
9016 for (i = 0; i < cfg->line_outs; i++) {
9017 nid = cfg->line_out_pins[i];
9018 if (nid) {
9019 if (i >= ARRAY_SIZE(alc861_dac_nids))
9020 continue;
9021 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9022 }
9023 }
9024 spec->multiout.num_dacs = cfg->line_outs;
9025 return 0;
9026}
9027
9028/* add playback controls from the parsed DAC table */
9029static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9030 const struct auto_pin_cfg *cfg)
9031{
9032 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009033 static const char *chname[4] = {
9034 "Front", "Surround", NULL /*CLFE*/, "Side"
9035 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009036 hda_nid_t nid;
9037 int i, idx, err;
9038
9039 for (i = 0; i < cfg->line_outs; i++) {
9040 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009041 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009042 continue;
9043 if (nid == 0x05) {
9044 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009045 err = add_control(spec, ALC_CTL_BIND_MUTE,
9046 "Center Playback Switch",
9047 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9048 HDA_OUTPUT));
9049 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009050 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009051 err = add_control(spec, ALC_CTL_BIND_MUTE,
9052 "LFE Playback Switch",
9053 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9054 HDA_OUTPUT));
9055 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009056 return err;
9057 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009058 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9059 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009060 if (nid == alc861_dac_nids[idx])
9061 break;
9062 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009063 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9064 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9065 HDA_OUTPUT));
9066 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009067 return err;
9068 }
9069 }
9070 return 0;
9071}
9072
9073static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9074{
9075 int err;
9076 hda_nid_t nid;
9077
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009078 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009079 return 0;
9080
9081 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9082 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009083 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9084 "Headphone Playback Switch",
9085 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9086 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009087 return err;
9088 spec->multiout.hp_nid = nid;
9089 }
9090 return 0;
9091}
9092
9093/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009094static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9095 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009096{
Kailang Yangdf694da2005-12-05 19:42:22 +01009097 struct hda_input_mux *imux = &spec->private_imux;
9098 int i, err, idx, idx1;
9099
9100 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009101 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009102 case 0x0c:
9103 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009104 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009105 break;
9106 case 0x0f:
9107 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009108 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009109 break;
9110 case 0x0d:
9111 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009112 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009113 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009114 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009115 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009116 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009117 break;
9118 case 0x11:
9119 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009120 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009121 break;
9122 default:
9123 continue;
9124 }
9125
Takashi Iwai4a471b72005-12-07 13:56:29 +01009126 err = new_analog_input(spec, cfg->input_pins[i],
9127 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009128 if (err < 0)
9129 return err;
9130
Takashi Iwai4a471b72005-12-07 13:56:29 +01009131 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009132 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009133 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009134 }
9135 return 0;
9136}
9137
9138static struct snd_kcontrol_new alc861_capture_mixer[] = {
9139 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9140 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9141
9142 {
9143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9144 /* The multiple "Capture Source" controls confuse alsamixer
9145 * So call somewhat different..
9146 *FIXME: the controls appear in the "playback" view!
9147 */
9148 /* .name = "Capture Source", */
9149 .name = "Input Source",
9150 .count = 1,
9151 .info = alc_mux_enum_info,
9152 .get = alc_mux_enum_get,
9153 .put = alc_mux_enum_put,
9154 },
9155 { } /* end */
9156};
9157
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009158static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9159 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009160 int pin_type, int dac_idx)
9161{
9162 /* set as output */
9163
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009164 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9165 pin_type);
9166 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9167 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009168
9169}
9170
9171static void alc861_auto_init_multi_out(struct hda_codec *codec)
9172{
9173 struct alc_spec *spec = codec->spec;
9174 int i;
9175
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009176 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009177 for (i = 0; i < spec->autocfg.line_outs; i++) {
9178 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009179 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009180 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009181 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009182 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009183 }
9184}
9185
9186static void alc861_auto_init_hp_out(struct hda_codec *codec)
9187{
9188 struct alc_spec *spec = codec->spec;
9189 hda_nid_t pin;
9190
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009191 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009192 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009193 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9194 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009195}
9196
9197static void alc861_auto_init_analog_input(struct hda_codec *codec)
9198{
9199 struct alc_spec *spec = codec->spec;
9200 int i;
9201
9202 for (i = 0; i < AUTO_PIN_LAST; i++) {
9203 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009204 if (nid >= 0x0c && nid <= 0x11) {
9205 snd_hda_codec_write(codec, nid, 0,
9206 AC_VERB_SET_PIN_WIDGET_CONTROL,
9207 i <= AUTO_PIN_FRONT_MIC ?
9208 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009209 }
9210 }
9211}
9212
9213/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009214/* return 1 if successful, 0 if the proper config is not found,
9215 * or a negative error code
9216 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009217static int alc861_parse_auto_config(struct hda_codec *codec)
9218{
9219 struct alc_spec *spec = codec->spec;
9220 int err;
9221 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009223 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9224 alc861_ignore);
9225 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009226 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009227 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009228 return 0; /* can't find valid BIOS pin config */
9229
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009230 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9231 if (err < 0)
9232 return err;
9233 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9234 if (err < 0)
9235 return err;
9236 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9237 if (err < 0)
9238 return err;
9239 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9240 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009241 return err;
9242
9243 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9244
9245 if (spec->autocfg.dig_out_pin)
9246 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9247
9248 if (spec->kctl_alloc)
9249 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9250
9251 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9252
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009253 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009254 spec->input_mux = &spec->private_imux;
9255
9256 spec->adc_nids = alc861_adc_nids;
9257 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9258 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9259 spec->num_mixers++;
9260
9261 return 1;
9262}
9263
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009264/* additional initialization for auto-configuration model */
9265static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009266{
Kailang Yangdf694da2005-12-05 19:42:22 +01009267 alc861_auto_init_multi_out(codec);
9268 alc861_auto_init_hp_out(codec);
9269 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009270}
9271
9272
9273/*
9274 * configuration and preset
9275 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009276static const char *alc861_models[ALC861_MODEL_LAST] = {
9277 [ALC861_3ST] = "3stack",
9278 [ALC660_3ST] = "3stack-660",
9279 [ALC861_3ST_DIG] = "3stack-dig",
9280 [ALC861_6ST_DIG] = "6stack-dig",
9281 [ALC861_UNIWILL_M31] = "uniwill-m31",
9282 [ALC861_TOSHIBA] = "toshiba",
9283 [ALC861_ASUS] = "asus",
9284 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9285 [ALC861_AUTO] = "auto",
9286};
9287
9288static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009289 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009290 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9291 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009292 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009293 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Tobin Davisad5e7732007-01-08 10:57:32 +01009294 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009295 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9296 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009297 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009298 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009299 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009300 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009301 {}
9302};
9303
9304static struct alc_config_preset alc861_presets[] = {
9305 [ALC861_3ST] = {
9306 .mixers = { alc861_3ST_mixer },
9307 .init_verbs = { alc861_threestack_init_verbs },
9308 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9309 .dac_nids = alc861_dac_nids,
9310 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9311 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009312 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009313 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9314 .adc_nids = alc861_adc_nids,
9315 .input_mux = &alc861_capture_source,
9316 },
9317 [ALC861_3ST_DIG] = {
9318 .mixers = { alc861_base_mixer },
9319 .init_verbs = { alc861_threestack_init_verbs },
9320 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9321 .dac_nids = alc861_dac_nids,
9322 .dig_out_nid = ALC861_DIGOUT_NID,
9323 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9324 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009325 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009326 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9327 .adc_nids = alc861_adc_nids,
9328 .input_mux = &alc861_capture_source,
9329 },
9330 [ALC861_6ST_DIG] = {
9331 .mixers = { alc861_base_mixer },
9332 .init_verbs = { alc861_base_init_verbs },
9333 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9334 .dac_nids = alc861_dac_nids,
9335 .dig_out_nid = ALC861_DIGOUT_NID,
9336 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9337 .channel_mode = alc861_8ch_modes,
9338 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9339 .adc_nids = alc861_adc_nids,
9340 .input_mux = &alc861_capture_source,
9341 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009342 [ALC660_3ST] = {
9343 .mixers = { alc861_3ST_mixer },
9344 .init_verbs = { alc861_threestack_init_verbs },
9345 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9346 .dac_nids = alc660_dac_nids,
9347 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9348 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009349 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9351 .adc_nids = alc861_adc_nids,
9352 .input_mux = &alc861_capture_source,
9353 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009354 [ALC861_UNIWILL_M31] = {
9355 .mixers = { alc861_uniwill_m31_mixer },
9356 .init_verbs = { alc861_uniwill_m31_init_verbs },
9357 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9358 .dac_nids = alc861_dac_nids,
9359 .dig_out_nid = ALC861_DIGOUT_NID,
9360 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9361 .channel_mode = alc861_uniwill_m31_modes,
9362 .need_dac_fix = 1,
9363 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9364 .adc_nids = alc861_adc_nids,
9365 .input_mux = &alc861_capture_source,
9366 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009367 [ALC861_TOSHIBA] = {
9368 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009369 .init_verbs = { alc861_base_init_verbs,
9370 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009371 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9372 .dac_nids = alc861_dac_nids,
9373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9374 .channel_mode = alc883_3ST_2ch_modes,
9375 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9376 .adc_nids = alc861_adc_nids,
9377 .input_mux = &alc861_capture_source,
9378 .unsol_event = alc861_toshiba_unsol_event,
9379 .init_hook = alc861_toshiba_automute,
9380 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009381 [ALC861_ASUS] = {
9382 .mixers = { alc861_asus_mixer },
9383 .init_verbs = { alc861_asus_init_verbs },
9384 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9385 .dac_nids = alc861_dac_nids,
9386 .dig_out_nid = ALC861_DIGOUT_NID,
9387 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9388 .channel_mode = alc861_asus_modes,
9389 .need_dac_fix = 1,
9390 .hp_nid = 0x06,
9391 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9392 .adc_nids = alc861_adc_nids,
9393 .input_mux = &alc861_capture_source,
9394 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009395 [ALC861_ASUS_LAPTOP] = {
9396 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9397 .init_verbs = { alc861_asus_init_verbs,
9398 alc861_asus_laptop_init_verbs },
9399 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9400 .dac_nids = alc861_dac_nids,
9401 .dig_out_nid = ALC861_DIGOUT_NID,
9402 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9403 .channel_mode = alc883_3ST_2ch_modes,
9404 .need_dac_fix = 1,
9405 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9406 .adc_nids = alc861_adc_nids,
9407 .input_mux = &alc861_capture_source,
9408 },
9409};
Kailang Yangdf694da2005-12-05 19:42:22 +01009410
9411
9412static int patch_alc861(struct hda_codec *codec)
9413{
9414 struct alc_spec *spec;
9415 int board_config;
9416 int err;
9417
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009418 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009419 if (spec == NULL)
9420 return -ENOMEM;
9421
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009422 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009423
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009424 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9425 alc861_models,
9426 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009427
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009428 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009429 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9430 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009431 board_config = ALC861_AUTO;
9432 }
9433
9434 if (board_config == ALC861_AUTO) {
9435 /* automatic parse from the BIOS config */
9436 err = alc861_parse_auto_config(codec);
9437 if (err < 0) {
9438 alc_free(codec);
9439 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009440 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009441 printk(KERN_INFO
9442 "hda_codec: Cannot set up configuration "
9443 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009444 board_config = ALC861_3ST_DIG;
9445 }
9446 }
9447
9448 if (board_config != ALC861_AUTO)
9449 setup_preset(spec, &alc861_presets[board_config]);
9450
9451 spec->stream_name_analog = "ALC861 Analog";
9452 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9453 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9454
9455 spec->stream_name_digital = "ALC861 Digital";
9456 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9457 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9458
9459 codec->patch_ops = alc_patch_ops;
9460 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009461 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009462
9463 return 0;
9464}
9465
9466/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009467 * ALC861-VD support
9468 *
9469 * Based on ALC882
9470 *
9471 * In addition, an independent DAC
9472 */
9473#define ALC861VD_DIGOUT_NID 0x06
9474
9475static hda_nid_t alc861vd_dac_nids[4] = {
9476 /* front, surr, clfe, side surr */
9477 0x02, 0x03, 0x04, 0x05
9478};
9479
9480/* dac_nids for ALC660vd are in a different order - according to
9481 * Realtek's driver.
9482 * This should probably tesult in a different mixer for 6stack models
9483 * of ALC660vd codecs, but for now there is only 3stack mixer
9484 * - and it is the same as in 861vd.
9485 * adc_nids in ALC660vd are (is) the same as in 861vd
9486 */
9487static hda_nid_t alc660vd_dac_nids[3] = {
9488 /* front, rear, clfe, rear_surr */
9489 0x02, 0x04, 0x03
9490};
9491
9492static hda_nid_t alc861vd_adc_nids[1] = {
9493 /* ADC0 */
9494 0x09,
9495};
9496
9497/* input MUX */
9498/* FIXME: should be a matrix-type input source selection */
9499static struct hda_input_mux alc861vd_capture_source = {
9500 .num_items = 4,
9501 .items = {
9502 { "Mic", 0x0 },
9503 { "Front Mic", 0x1 },
9504 { "Line", 0x2 },
9505 { "CD", 0x4 },
9506 },
9507};
9508
Kailang Yang272a5272007-05-14 11:00:38 +02009509static struct hda_input_mux alc861vd_dallas_capture_source = {
9510 .num_items = 3,
9511 .items = {
9512 { "Front Mic", 0x0 },
9513 { "ATAPI Mic", 0x1 },
9514 { "Line In", 0x5 },
9515 },
9516};
9517
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009518#define alc861vd_mux_enum_info alc_mux_enum_info
9519#define alc861vd_mux_enum_get alc_mux_enum_get
9520
9521static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9522 struct snd_ctl_elem_value *ucontrol)
9523{
9524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9525 struct alc_spec *spec = codec->spec;
9526 const struct hda_input_mux *imux = spec->input_mux;
9527 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9528 static hda_nid_t capture_mixers[1] = { 0x22 };
9529 hda_nid_t nid = capture_mixers[adc_idx];
9530 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9531 unsigned int i, idx;
9532
9533 idx = ucontrol->value.enumerated.item[0];
9534 if (idx >= imux->num_items)
9535 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009536 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009537 return 0;
9538 for (i = 0; i < imux->num_items; i++) {
9539 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9540 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9541 v | (imux->items[i].index << 8));
9542 }
9543 *cur_val = idx;
9544 return 1;
9545}
9546
9547/*
9548 * 2ch mode
9549 */
9550static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9551 { 2, NULL }
9552};
9553
9554/*
9555 * 6ch mode
9556 */
9557static struct hda_verb alc861vd_6stack_ch6_init[] = {
9558 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9559 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9560 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9561 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9562 { } /* end */
9563};
9564
9565/*
9566 * 8ch mode
9567 */
9568static struct hda_verb alc861vd_6stack_ch8_init[] = {
9569 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9570 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9571 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9572 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9573 { } /* end */
9574};
9575
9576static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9577 { 6, alc861vd_6stack_ch6_init },
9578 { 8, alc861vd_6stack_ch8_init },
9579};
9580
9581static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9582 {
9583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9584 .name = "Channel Mode",
9585 .info = alc_ch_mode_info,
9586 .get = alc_ch_mode_get,
9587 .put = alc_ch_mode_put,
9588 },
9589 { } /* end */
9590};
9591
9592static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9593 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9594 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9595
9596 {
9597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9598 /* The multiple "Capture Source" controls confuse alsamixer
9599 * So call somewhat different..
9600 *FIXME: the controls appear in the "playback" view!
9601 */
9602 /* .name = "Capture Source", */
9603 .name = "Input Source",
9604 .count = 1,
9605 .info = alc861vd_mux_enum_info,
9606 .get = alc861vd_mux_enum_get,
9607 .put = alc861vd_mux_enum_put,
9608 },
9609 { } /* end */
9610};
9611
9612/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9613 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9614 */
9615static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9616 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9617 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9618
9619 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9620 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9621
9622 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9623 HDA_OUTPUT),
9624 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9625 HDA_OUTPUT),
9626 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9627 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9628
9629 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9630 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9631
9632 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9633
9634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9637
9638 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9639 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9641
9642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9644
9645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9647
9648 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9649 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9650
9651 { } /* end */
9652};
9653
9654static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9655 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9656 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9657
9658 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9659
9660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9663
9664 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9666 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9667
9668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9670
9671 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9672 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9673
9674 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9675 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9676
9677 { } /* end */
9678};
9679
Kailang Yangbdd148a2007-05-08 15:19:08 +02009680static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9681 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9682 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9683 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9684
9685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9686
9687 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9690
9691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9692 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9693 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9694
9695 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9696 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9697
9698 { } /* end */
9699};
9700
Kailang Yang272a5272007-05-14 11:00:38 +02009701/* Pin assignment: Front=0x14, HP = 0x15,
9702 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9703 */
9704static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9705 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9706 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9711 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9712 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9713 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9714 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9715 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9716 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9717 {
9718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9719 /* .name = "Capture Source", */
9720 .name = "Input Source",
9721 .count = 1,
9722 .info = alc882_mux_enum_info,
9723 .get = alc882_mux_enum_get,
9724 .put = alc882_mux_enum_put,
9725 },
9726 { } /* end */
9727};
9728
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009729/*
9730 * generic initialization of ADC, input mixers and output mixers
9731 */
9732static struct hda_verb alc861vd_volume_init_verbs[] = {
9733 /*
9734 * Unmute ADC0 and set the default input to mic-in
9735 */
9736 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9738
9739 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9740 * the analog-loopback mixer widget
9741 */
9742 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9748
9749 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009754
9755 /*
9756 * Set up output mixers (0x02 - 0x05)
9757 */
9758 /* set vol=0 to output mixers */
9759 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9760 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9761 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9762 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9763
9764 /* set up input amps for analog loopback */
9765 /* Amp Indices: DAC = 0, mixer = 1 */
9766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9774
9775 { }
9776};
9777
9778/*
9779 * 3-stack pin configuration:
9780 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9781 */
9782static struct hda_verb alc861vd_3stack_init_verbs[] = {
9783 /*
9784 * Set pin mode and muting
9785 */
9786 /* set front pin widgets 0x14 for output */
9787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9789 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9790
9791 /* Mic (rear) pin: input vref at 80% */
9792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9793 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9794 /* Front Mic pin: input vref at 80% */
9795 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9797 /* Line In pin: input */
9798 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9799 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9800 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9801 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9803 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9804 /* CD pin widget for input */
9805 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9806
9807 { }
9808};
9809
9810/*
9811 * 6-stack pin configuration:
9812 */
9813static struct hda_verb alc861vd_6stack_init_verbs[] = {
9814 /*
9815 * Set pin mode and muting
9816 */
9817 /* set front pin widgets 0x14 for output */
9818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9821
9822 /* Rear Pin: output 1 (0x0d) */
9823 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9825 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9826 /* CLFE Pin: output 2 (0x0e) */
9827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9829 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9830 /* Side Pin: output 3 (0x0f) */
9831 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9833 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9834
9835 /* Mic (rear) pin: input vref at 80% */
9836 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9838 /* Front Mic pin: input vref at 80% */
9839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9841 /* Line In pin: input */
9842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9844 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9846 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9847 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9848 /* CD pin widget for input */
9849 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9850
9851 { }
9852};
9853
Kailang Yangbdd148a2007-05-08 15:19:08 +02009854static struct hda_verb alc861vd_eapd_verbs[] = {
9855 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9856 { }
9857};
9858
9859static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9863 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9864 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9865 {}
9866};
9867
9868/* toggle speaker-output according to the hp-jack state */
9869static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9870{
9871 unsigned int present;
9872 unsigned char bits;
9873
9874 present = snd_hda_codec_read(codec, 0x1b, 0,
9875 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9876 bits = present ? 0x80 : 0;
9877 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9878 0x80, bits);
9879 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9880 0x80, bits);
9881}
9882
9883static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9884{
9885 unsigned int present;
9886 unsigned char bits;
9887
9888 present = snd_hda_codec_read(codec, 0x18, 0,
9889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9890 bits = present ? 0x80 : 0;
9891 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9892 0x80, bits);
9893 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9894 0x80, bits);
9895}
9896
9897static void alc861vd_lenovo_automute(struct hda_codec *codec)
9898{
9899 alc861vd_lenovo_hp_automute(codec);
9900 alc861vd_lenovo_mic_automute(codec);
9901}
9902
9903static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9904 unsigned int res)
9905{
9906 switch (res >> 26) {
9907 case ALC880_HP_EVENT:
9908 alc861vd_lenovo_hp_automute(codec);
9909 break;
9910 case ALC880_MIC_EVENT:
9911 alc861vd_lenovo_mic_automute(codec);
9912 break;
9913 }
9914}
9915
Kailang Yang272a5272007-05-14 11:00:38 +02009916static struct hda_verb alc861vd_dallas_verbs[] = {
9917 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9918 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9919 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9920 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9921
9922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9930
9931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9935 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9936 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9937 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9938 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9939
9940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9942 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9945 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9947 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9948
9949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9953
9954 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9955 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9957
9958 { } /* end */
9959};
9960
9961/* toggle speaker-output according to the hp-jack state */
9962static void alc861vd_dallas_automute(struct hda_codec *codec)
9963{
9964 unsigned int present;
9965
9966 present = snd_hda_codec_read(codec, 0x15, 0,
9967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9968 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9969 0x80, present ? 0x80 : 0);
9970 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9971 0x80, present ? 0x80 : 0);
9972}
9973
9974static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9975{
9976 if ((res >> 26) == ALC880_HP_EVENT)
9977 alc861vd_dallas_automute(codec);
9978}
9979
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009980/* pcm configuration: identiacal with ALC880 */
9981#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
9982#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
9983#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
9984#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
9985
9986/*
9987 * configuration and preset
9988 */
9989static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
9990 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +02009991 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009992 [ALC861VD_3ST] = "3stack",
9993 [ALC861VD_3ST_DIG] = "3stack-digout",
9994 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +02009995 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +02009996 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009997 [ALC861VD_AUTO] = "auto",
9998};
9999
10000static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010001 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010002 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010003 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010004 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10005 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10006
Kailang Yang272a5272007-05-14 11:00:38 +020010007 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10008 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010009 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10010 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010011 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010012 {}
10013};
10014
10015static struct alc_config_preset alc861vd_presets[] = {
10016 [ALC660VD_3ST] = {
10017 .mixers = { alc861vd_3st_mixer },
10018 .init_verbs = { alc861vd_volume_init_verbs,
10019 alc861vd_3stack_init_verbs },
10020 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10021 .dac_nids = alc660vd_dac_nids,
10022 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10023 .adc_nids = alc861vd_adc_nids,
10024 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10025 .channel_mode = alc861vd_3stack_2ch_modes,
10026 .input_mux = &alc861vd_capture_source,
10027 },
Mike Crash6963f842007-06-25 12:12:51 +020010028 [ALC660VD_3ST_DIG] = {
10029 .mixers = { alc861vd_3st_mixer },
10030 .init_verbs = { alc861vd_volume_init_verbs,
10031 alc861vd_3stack_init_verbs },
10032 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10033 .dac_nids = alc660vd_dac_nids,
10034 .dig_out_nid = ALC861VD_DIGOUT_NID,
10035 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10036 .adc_nids = alc861vd_adc_nids,
10037 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10038 .channel_mode = alc861vd_3stack_2ch_modes,
10039 .input_mux = &alc861vd_capture_source,
10040 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010041 [ALC861VD_3ST] = {
10042 .mixers = { alc861vd_3st_mixer },
10043 .init_verbs = { alc861vd_volume_init_verbs,
10044 alc861vd_3stack_init_verbs },
10045 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10046 .dac_nids = alc861vd_dac_nids,
10047 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10048 .channel_mode = alc861vd_3stack_2ch_modes,
10049 .input_mux = &alc861vd_capture_source,
10050 },
10051 [ALC861VD_3ST_DIG] = {
10052 .mixers = { alc861vd_3st_mixer },
10053 .init_verbs = { alc861vd_volume_init_verbs,
10054 alc861vd_3stack_init_verbs },
10055 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10056 .dac_nids = alc861vd_dac_nids,
10057 .dig_out_nid = ALC861VD_DIGOUT_NID,
10058 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10059 .channel_mode = alc861vd_3stack_2ch_modes,
10060 .input_mux = &alc861vd_capture_source,
10061 },
10062 [ALC861VD_6ST_DIG] = {
10063 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10064 .init_verbs = { alc861vd_volume_init_verbs,
10065 alc861vd_6stack_init_verbs },
10066 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10067 .dac_nids = alc861vd_dac_nids,
10068 .dig_out_nid = ALC861VD_DIGOUT_NID,
10069 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10070 .channel_mode = alc861vd_6stack_modes,
10071 .input_mux = &alc861vd_capture_source,
10072 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010073 [ALC861VD_LENOVO] = {
10074 .mixers = { alc861vd_lenovo_mixer },
10075 .init_verbs = { alc861vd_volume_init_verbs,
10076 alc861vd_3stack_init_verbs,
10077 alc861vd_eapd_verbs,
10078 alc861vd_lenovo_unsol_verbs },
10079 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10080 .dac_nids = alc660vd_dac_nids,
10081 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10082 .adc_nids = alc861vd_adc_nids,
10083 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10084 .channel_mode = alc861vd_3stack_2ch_modes,
10085 .input_mux = &alc861vd_capture_source,
10086 .unsol_event = alc861vd_lenovo_unsol_event,
10087 .init_hook = alc861vd_lenovo_automute,
10088 },
Kailang Yang272a5272007-05-14 11:00:38 +020010089 [ALC861VD_DALLAS] = {
10090 .mixers = { alc861vd_dallas_mixer },
10091 .init_verbs = { alc861vd_dallas_verbs },
10092 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10093 .dac_nids = alc861vd_dac_nids,
10094 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10095 .adc_nids = alc861vd_adc_nids,
10096 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10097 .channel_mode = alc861vd_3stack_2ch_modes,
10098 .input_mux = &alc861vd_dallas_capture_source,
10099 .unsol_event = alc861vd_dallas_unsol_event,
10100 .init_hook = alc861vd_dallas_automute,
10101 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010102};
10103
10104/*
10105 * BIOS auto configuration
10106 */
10107static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10108 hda_nid_t nid, int pin_type, int dac_idx)
10109{
10110 /* set as output */
10111 snd_hda_codec_write(codec, nid, 0,
10112 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10113 snd_hda_codec_write(codec, nid, 0,
10114 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10115}
10116
10117static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10118{
10119 struct alc_spec *spec = codec->spec;
10120 int i;
10121
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010122 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010123 for (i = 0; i <= HDA_SIDE; i++) {
10124 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010125 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010126 if (nid)
10127 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010128 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010129 }
10130}
10131
10132
10133static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10134{
10135 struct alc_spec *spec = codec->spec;
10136 hda_nid_t pin;
10137
10138 pin = spec->autocfg.hp_pins[0];
10139 if (pin) /* connect to front and use dac 0 */
10140 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10141}
10142
10143#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10144#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10145
10146static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10147{
10148 struct alc_spec *spec = codec->spec;
10149 int i;
10150
10151 for (i = 0; i < AUTO_PIN_LAST; i++) {
10152 hda_nid_t nid = spec->autocfg.input_pins[i];
10153 if (alc861vd_is_input_pin(nid)) {
10154 snd_hda_codec_write(codec, nid, 0,
10155 AC_VERB_SET_PIN_WIDGET_CONTROL,
10156 i <= AUTO_PIN_FRONT_MIC ?
10157 PIN_VREF80 : PIN_IN);
10158 if (nid != ALC861VD_PIN_CD_NID)
10159 snd_hda_codec_write(codec, nid, 0,
10160 AC_VERB_SET_AMP_GAIN_MUTE,
10161 AMP_OUT_MUTE);
10162 }
10163 }
10164}
10165
10166#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10167#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10168
10169/* add playback controls from the parsed DAC table */
10170/* Based on ALC880 version. But ALC861VD has separate,
10171 * different NIDs for mute/unmute switch and volume control */
10172static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10173 const struct auto_pin_cfg *cfg)
10174{
10175 char name[32];
10176 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10177 hda_nid_t nid_v, nid_s;
10178 int i, err;
10179
10180 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010181 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010182 continue;
10183 nid_v = alc861vd_idx_to_mixer_vol(
10184 alc880_dac_to_idx(
10185 spec->multiout.dac_nids[i]));
10186 nid_s = alc861vd_idx_to_mixer_switch(
10187 alc880_dac_to_idx(
10188 spec->multiout.dac_nids[i]));
10189
10190 if (i == 2) {
10191 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010192 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10193 "Center Playback Volume",
10194 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10195 HDA_OUTPUT));
10196 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010197 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010198 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10199 "LFE Playback Volume",
10200 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10201 HDA_OUTPUT));
10202 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010203 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010204 err = add_control(spec, ALC_CTL_BIND_MUTE,
10205 "Center Playback Switch",
10206 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10207 HDA_INPUT));
10208 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010209 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010210 err = add_control(spec, ALC_CTL_BIND_MUTE,
10211 "LFE Playback Switch",
10212 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10213 HDA_INPUT));
10214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010215 return err;
10216 } else {
10217 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010218 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10219 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10220 HDA_OUTPUT));
10221 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010222 return err;
10223 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010224 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010225 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010226 HDA_INPUT));
10227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010228 return err;
10229 }
10230 }
10231 return 0;
10232}
10233
10234/* add playback controls for speaker and HP outputs */
10235/* Based on ALC880 version. But ALC861VD has separate,
10236 * different NIDs for mute/unmute switch and volume control */
10237static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10238 hda_nid_t pin, const char *pfx)
10239{
10240 hda_nid_t nid_v, nid_s;
10241 int err;
10242 char name[32];
10243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010244 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010245 return 0;
10246
10247 if (alc880_is_fixed_pin(pin)) {
10248 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10249 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010250 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010251 spec->multiout.hp_nid = nid_v;
10252 else
10253 spec->multiout.extra_out_nid[0] = nid_v;
10254 /* control HP volume/switch on the output mixer amp */
10255 nid_v = alc861vd_idx_to_mixer_vol(
10256 alc880_fixed_pin_idx(pin));
10257 nid_s = alc861vd_idx_to_mixer_switch(
10258 alc880_fixed_pin_idx(pin));
10259
10260 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010261 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10262 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10263 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010264 return err;
10265 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010266 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10267 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10268 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010269 return err;
10270 } else if (alc880_is_multi_pin(pin)) {
10271 /* set manual connection */
10272 /* we have only a switch on HP-out PIN */
10273 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010274 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10275 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10276 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010277 return err;
10278 }
10279 return 0;
10280}
10281
10282/* parse the BIOS configuration and set up the alc_spec
10283 * return 1 if successful, 0 if the proper config is not found,
10284 * or a negative error code
10285 * Based on ALC880 version - had to change it to override
10286 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10287static int alc861vd_parse_auto_config(struct hda_codec *codec)
10288{
10289 struct alc_spec *spec = codec->spec;
10290 int err;
10291 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10292
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010293 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10294 alc861vd_ignore);
10295 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010296 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010297 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010298 return 0; /* can't find valid BIOS pin config */
10299
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010300 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10301 if (err < 0)
10302 return err;
10303 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10304 if (err < 0)
10305 return err;
10306 err = alc861vd_auto_create_extra_out(spec,
10307 spec->autocfg.speaker_pins[0],
10308 "Speaker");
10309 if (err < 0)
10310 return err;
10311 err = alc861vd_auto_create_extra_out(spec,
10312 spec->autocfg.hp_pins[0],
10313 "Headphone");
10314 if (err < 0)
10315 return err;
10316 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10317 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010318 return err;
10319
10320 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10321
10322 if (spec->autocfg.dig_out_pin)
10323 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10324
10325 if (spec->kctl_alloc)
10326 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10327
10328 spec->init_verbs[spec->num_init_verbs++]
10329 = alc861vd_volume_init_verbs;
10330
10331 spec->num_mux_defs = 1;
10332 spec->input_mux = &spec->private_imux;
10333
10334 return 1;
10335}
10336
10337/* additional initialization for auto-configuration model */
10338static void alc861vd_auto_init(struct hda_codec *codec)
10339{
10340 alc861vd_auto_init_multi_out(codec);
10341 alc861vd_auto_init_hp_out(codec);
10342 alc861vd_auto_init_analog_input(codec);
10343}
10344
10345static int patch_alc861vd(struct hda_codec *codec)
10346{
10347 struct alc_spec *spec;
10348 int err, board_config;
10349
10350 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10351 if (spec == NULL)
10352 return -ENOMEM;
10353
10354 codec->spec = spec;
10355
10356 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10357 alc861vd_models,
10358 alc861vd_cfg_tbl);
10359
10360 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10361 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10362 "ALC861VD, trying auto-probe from BIOS...\n");
10363 board_config = ALC861VD_AUTO;
10364 }
10365
10366 if (board_config == ALC861VD_AUTO) {
10367 /* automatic parse from the BIOS config */
10368 err = alc861vd_parse_auto_config(codec);
10369 if (err < 0) {
10370 alc_free(codec);
10371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010372 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010373 printk(KERN_INFO
10374 "hda_codec: Cannot set up configuration "
10375 "from BIOS. Using base mode...\n");
10376 board_config = ALC861VD_3ST;
10377 }
10378 }
10379
10380 if (board_config != ALC861VD_AUTO)
10381 setup_preset(spec, &alc861vd_presets[board_config]);
10382
10383 spec->stream_name_analog = "ALC861VD Analog";
10384 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10385 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10386
10387 spec->stream_name_digital = "ALC861VD Digital";
10388 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10389 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10390
10391 spec->adc_nids = alc861vd_adc_nids;
10392 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10393
10394 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10395 spec->num_mixers++;
10396
10397 codec->patch_ops = alc_patch_ops;
10398
10399 if (board_config == ALC861VD_AUTO)
10400 spec->init_hook = alc861vd_auto_init;
10401
10402 return 0;
10403}
10404
10405/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010406 * ALC662 support
10407 *
10408 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10409 * configuration. Each pin widget can choose any input DACs and a mixer.
10410 * Each ADC is connected from a mixer of all inputs. This makes possible
10411 * 6-channel independent captures.
10412 *
10413 * In addition, an independent DAC for the multi-playback (not used in this
10414 * driver yet).
10415 */
10416#define ALC662_DIGOUT_NID 0x06
10417#define ALC662_DIGIN_NID 0x0a
10418
10419static hda_nid_t alc662_dac_nids[4] = {
10420 /* front, rear, clfe, rear_surr */
10421 0x02, 0x03, 0x04
10422};
10423
10424static hda_nid_t alc662_adc_nids[1] = {
10425 /* ADC1-2 */
10426 0x09,
10427};
10428/* input MUX */
10429/* FIXME: should be a matrix-type input source selection */
10430
10431static struct hda_input_mux alc662_capture_source = {
10432 .num_items = 4,
10433 .items = {
10434 { "Mic", 0x0 },
10435 { "Front Mic", 0x1 },
10436 { "Line", 0x2 },
10437 { "CD", 0x4 },
10438 },
10439};
10440
10441static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10442 .num_items = 2,
10443 .items = {
10444 { "Mic", 0x1 },
10445 { "Line", 0x2 },
10446 },
10447};
10448#define alc662_mux_enum_info alc_mux_enum_info
10449#define alc662_mux_enum_get alc_mux_enum_get
10450
10451static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10452 struct snd_ctl_elem_value *ucontrol)
10453{
10454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10455 struct alc_spec *spec = codec->spec;
10456 const struct hda_input_mux *imux = spec->input_mux;
10457 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10458 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10459 hda_nid_t nid = capture_mixers[adc_idx];
10460 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10461 unsigned int i, idx;
10462
10463 idx = ucontrol->value.enumerated.item[0];
10464 if (idx >= imux->num_items)
10465 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010466 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010467 return 0;
10468 for (i = 0; i < imux->num_items; i++) {
10469 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10470 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10471 v | (imux->items[i].index << 8));
10472 }
10473 *cur_val = idx;
10474 return 1;
10475}
10476/*
10477 * 2ch mode
10478 */
10479static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10480 { 2, NULL }
10481};
10482
10483/*
10484 * 2ch mode
10485 */
10486static struct hda_verb alc662_3ST_ch2_init[] = {
10487 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10488 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10489 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10490 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10491 { } /* end */
10492};
10493
10494/*
10495 * 6ch mode
10496 */
10497static struct hda_verb alc662_3ST_ch6_init[] = {
10498 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10499 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10500 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10501 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10502 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10503 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10504 { } /* end */
10505};
10506
10507static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10508 { 2, alc662_3ST_ch2_init },
10509 { 6, alc662_3ST_ch6_init },
10510};
10511
10512/*
10513 * 2ch mode
10514 */
10515static struct hda_verb alc662_sixstack_ch6_init[] = {
10516 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10517 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10518 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10519 { } /* end */
10520};
10521
10522/*
10523 * 6ch mode
10524 */
10525static struct hda_verb alc662_sixstack_ch8_init[] = {
10526 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10527 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10528 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10529 { } /* end */
10530};
10531
10532static struct hda_channel_mode alc662_5stack_modes[2] = {
10533 { 2, alc662_sixstack_ch6_init },
10534 { 6, alc662_sixstack_ch8_init },
10535};
10536
10537/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10538 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10539 */
10540
10541static struct snd_kcontrol_new alc662_base_mixer[] = {
10542 /* output mixer control */
10543 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10544 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10545 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10546 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10547 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10548 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10549 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10550 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10552
10553 /*Input mixer control */
10554 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10555 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10556 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10557 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10558 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10559 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10562
10563 /* Capture mixer control */
10564 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10565 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10566 {
10567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10568 .name = "Capture Source",
10569 .count = 1,
10570 .info = alc_mux_enum_info,
10571 .get = alc_mux_enum_get,
10572 .put = alc_mux_enum_put,
10573 },
10574 { } /* end */
10575};
10576
10577static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10578 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10579 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10581 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10582 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10583 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10584 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10587 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10588 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10589 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10590 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10591 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10592 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10593 {
10594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10595 /* .name = "Capture Source", */
10596 .name = "Input Source",
10597 .count = 1,
10598 .info = alc662_mux_enum_info,
10599 .get = alc662_mux_enum_get,
10600 .put = alc662_mux_enum_put,
10601 },
10602 { } /* end */
10603};
10604
10605static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10606 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10607 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10608 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10609 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10610 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10611 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10612 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10613 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10614 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10615 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10616 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10617 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10618 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10621 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10622 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10623 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10624 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10625 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10626 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10627 {
10628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10629 /* .name = "Capture Source", */
10630 .name = "Input Source",
10631 .count = 1,
10632 .info = alc662_mux_enum_info,
10633 .get = alc662_mux_enum_get,
10634 .put = alc662_mux_enum_put,
10635 },
10636 { } /* end */
10637};
10638
10639static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10640 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10641 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10642 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10643 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10649 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10650 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10651 {
10652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10653 /* .name = "Capture Source", */
10654 .name = "Input Source",
10655 .count = 1,
10656 .info = alc662_mux_enum_info,
10657 .get = alc662_mux_enum_get,
10658 .put = alc662_mux_enum_put,
10659 },
10660 { } /* end */
10661};
10662
10663static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10664 {
10665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10666 .name = "Channel Mode",
10667 .info = alc_ch_mode_info,
10668 .get = alc_ch_mode_get,
10669 .put = alc_ch_mode_put,
10670 },
10671 { } /* end */
10672};
10673
10674static struct hda_verb alc662_init_verbs[] = {
10675 /* ADC: mute amp left and right */
10676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10677 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10678 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10679
10680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10685
10686 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10687 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10688 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10689 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10690 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10692
10693 /* Front Pin: output 0 (0x0c) */
10694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10696
10697 /* Rear Pin: output 1 (0x0d) */
10698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10700
10701 /* CLFE Pin: output 2 (0x0e) */
10702 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10704
10705 /* Mic (rear) pin: input vref at 80% */
10706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10708 /* Front Mic pin: input vref at 80% */
10709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10711 /* Line In pin: input */
10712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10714 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10718 /* CD pin widget for input */
10719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10720
10721 /* FIXME: use matrix-type input source selection */
10722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10723 /* Input mixer */
10724 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10728 { }
10729};
10730
10731static struct hda_verb alc662_sue_init_verbs[] = {
10732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10733 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10734 {}
10735};
10736
10737/*
10738 * generic initialization of ADC, input mixers and output mixers
10739 */
10740static struct hda_verb alc662_auto_init_verbs[] = {
10741 /*
10742 * Unmute ADC and set the default input to mic-in
10743 */
10744 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10746
10747 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10748 * mixer widget
10749 * Note: PASD motherboards uses the Line In 2 as the input for front
10750 * panel mic (mic 2)
10751 */
10752 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10758
10759 /*
10760 * Set up output mixers (0x0c - 0x0f)
10761 */
10762 /* set vol=0 to output mixers */
10763 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10764 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10765 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10766
10767 /* set up input amps for analog loopback */
10768 /* Amp Indices: DAC = 0, mixer = 1 */
10769 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10770 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10771 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10772 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10773 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10774 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10775
10776
10777 /* FIXME: use matrix-type input source selection */
10778 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10779 /* Input mixer */
10780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10783 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10785
10786 { }
10787};
10788
10789/* capture mixer elements */
10790static struct snd_kcontrol_new alc662_capture_mixer[] = {
10791 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10792 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10793 {
10794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10795 /* The multiple "Capture Source" controls confuse alsamixer
10796 * So call somewhat different..
10797 * FIXME: the controls appear in the "playback" view!
10798 */
10799 /* .name = "Capture Source", */
10800 .name = "Input Source",
10801 .count = 1,
10802 .info = alc882_mux_enum_info,
10803 .get = alc882_mux_enum_get,
10804 .put = alc882_mux_enum_put,
10805 },
10806 { } /* end */
10807};
10808
10809static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10810{
10811 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010812 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010813
10814 present = snd_hda_codec_read(codec, 0x14, 0,
10815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010816 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010817 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010819 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010820 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010821}
10822
10823static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10824{
10825 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010826 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010827
10828 present = snd_hda_codec_read(codec, 0x1b, 0,
10829 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010830 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010831 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010832 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010833 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010834 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010835 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010836 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010837 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010838 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010839}
10840
10841static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10842 unsigned int res)
10843{
10844 if ((res >> 26) == ALC880_HP_EVENT)
10845 alc662_lenovo_101e_all_automute(codec);
10846 if ((res >> 26) == ALC880_FRONT_EVENT)
10847 alc662_lenovo_101e_ispeaker_automute(codec);
10848}
10849
10850
10851/* pcm configuration: identiacal with ALC880 */
10852#define alc662_pcm_analog_playback alc880_pcm_analog_playback
10853#define alc662_pcm_analog_capture alc880_pcm_analog_capture
10854#define alc662_pcm_digital_playback alc880_pcm_digital_playback
10855#define alc662_pcm_digital_capture alc880_pcm_digital_capture
10856
10857/*
10858 * configuration and preset
10859 */
10860static const char *alc662_models[ALC662_MODEL_LAST] = {
10861 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10862 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10863 [ALC662_3ST_6ch] = "3stack-6ch",
10864 [ALC662_5ST_DIG] = "6stack-dig",
10865 [ALC662_LENOVO_101E] = "lenovo-101e",
10866 [ALC662_AUTO] = "auto",
10867};
10868
10869static struct snd_pci_quirk alc662_cfg_tbl[] = {
10870 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10871 {}
10872};
10873
10874static struct alc_config_preset alc662_presets[] = {
10875 [ALC662_3ST_2ch_DIG] = {
10876 .mixers = { alc662_3ST_2ch_mixer },
10877 .init_verbs = { alc662_init_verbs },
10878 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10879 .dac_nids = alc662_dac_nids,
10880 .dig_out_nid = ALC662_DIGOUT_NID,
10881 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10882 .adc_nids = alc662_adc_nids,
10883 .dig_in_nid = ALC662_DIGIN_NID,
10884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10885 .channel_mode = alc662_3ST_2ch_modes,
10886 .input_mux = &alc662_capture_source,
10887 },
10888 [ALC662_3ST_6ch_DIG] = {
10889 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10890 .init_verbs = { alc662_init_verbs },
10891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10892 .dac_nids = alc662_dac_nids,
10893 .dig_out_nid = ALC662_DIGOUT_NID,
10894 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10895 .adc_nids = alc662_adc_nids,
10896 .dig_in_nid = ALC662_DIGIN_NID,
10897 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10898 .channel_mode = alc662_3ST_6ch_modes,
10899 .need_dac_fix = 1,
10900 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010901 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010902 [ALC662_3ST_6ch] = {
10903 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10904 .init_verbs = { alc662_init_verbs },
10905 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10906 .dac_nids = alc662_dac_nids,
10907 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10908 .adc_nids = alc662_adc_nids,
10909 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10910 .channel_mode = alc662_3ST_6ch_modes,
10911 .need_dac_fix = 1,
10912 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010913 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010914 [ALC662_5ST_DIG] = {
10915 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10916 .init_verbs = { alc662_init_verbs },
10917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10918 .dac_nids = alc662_dac_nids,
10919 .dig_out_nid = ALC662_DIGOUT_NID,
10920 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10921 .adc_nids = alc662_adc_nids,
10922 .dig_in_nid = ALC662_DIGIN_NID,
10923 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10924 .channel_mode = alc662_5stack_modes,
10925 .input_mux = &alc662_capture_source,
10926 },
10927 [ALC662_LENOVO_101E] = {
10928 .mixers = { alc662_lenovo_101e_mixer },
10929 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10930 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10931 .dac_nids = alc662_dac_nids,
10932 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10933 .adc_nids = alc662_adc_nids,
10934 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10935 .channel_mode = alc662_3ST_2ch_modes,
10936 .input_mux = &alc662_lenovo_101e_capture_source,
10937 .unsol_event = alc662_lenovo_101e_unsol_event,
10938 .init_hook = alc662_lenovo_101e_all_automute,
10939 },
10940
10941};
10942
10943
10944/*
10945 * BIOS auto configuration
10946 */
10947
10948/* add playback controls from the parsed DAC table */
10949static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10950 const struct auto_pin_cfg *cfg)
10951{
10952 char name[32];
10953 static const char *chname[4] = {
10954 "Front", "Surround", NULL /*CLFE*/, "Side"
10955 };
10956 hda_nid_t nid;
10957 int i, err;
10958
10959 for (i = 0; i < cfg->line_outs; i++) {
10960 if (!spec->multiout.dac_nids[i])
10961 continue;
10962 nid = alc880_idx_to_dac(i);
10963 if (i == 2) {
10964 /* Center/LFE */
10965 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10966 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010967 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10968 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010969 if (err < 0)
10970 return err;
10971 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10972 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010973 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10974 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010975 if (err < 0)
10976 return err;
10977 err = add_control(spec, ALC_CTL_BIND_MUTE,
10978 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010979 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
10980 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010981 if (err < 0)
10982 return err;
10983 err = add_control(spec, ALC_CTL_BIND_MUTE,
10984 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010985 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
10986 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010987 if (err < 0)
10988 return err;
10989 } else {
10990 sprintf(name, "%s Playback Volume", chname[i]);
10991 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010992 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10993 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010994 if (err < 0)
10995 return err;
10996 sprintf(name, "%s Playback Switch", chname[i]);
10997 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010998 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
10999 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011000 if (err < 0)
11001 return err;
11002 }
11003 }
11004 return 0;
11005}
11006
11007/* add playback controls for speaker and HP outputs */
11008static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11009 const char *pfx)
11010{
11011 hda_nid_t nid;
11012 int err;
11013 char name[32];
11014
11015 if (!pin)
11016 return 0;
11017
11018 if (alc880_is_fixed_pin(pin)) {
11019 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11020 /* printk("DAC nid=%x\n",nid); */
11021 /* specify the DAC as the extra output */
11022 if (!spec->multiout.hp_nid)
11023 spec->multiout.hp_nid = nid;
11024 else
11025 spec->multiout.extra_out_nid[0] = nid;
11026 /* control HP volume/switch on the output mixer amp */
11027 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11028 sprintf(name, "%s Playback Volume", pfx);
11029 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11030 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11031 if (err < 0)
11032 return err;
11033 sprintf(name, "%s Playback Switch", pfx);
11034 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11035 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11036 if (err < 0)
11037 return err;
11038 } else if (alc880_is_multi_pin(pin)) {
11039 /* set manual connection */
11040 /* we have only a switch on HP-out PIN */
11041 sprintf(name, "%s Playback Switch", pfx);
11042 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11043 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11044 if (err < 0)
11045 return err;
11046 }
11047 return 0;
11048}
11049
11050/* create playback/capture controls for input pins */
11051static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11052 const struct auto_pin_cfg *cfg)
11053{
11054 struct hda_input_mux *imux = &spec->private_imux;
11055 int i, err, idx;
11056
11057 for (i = 0; i < AUTO_PIN_LAST; i++) {
11058 if (alc880_is_input_pin(cfg->input_pins[i])) {
11059 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11060 err = new_analog_input(spec, cfg->input_pins[i],
11061 auto_pin_cfg_labels[i],
11062 idx, 0x0b);
11063 if (err < 0)
11064 return err;
11065 imux->items[imux->num_items].label =
11066 auto_pin_cfg_labels[i];
11067 imux->items[imux->num_items].index =
11068 alc880_input_pin_idx(cfg->input_pins[i]);
11069 imux->num_items++;
11070 }
11071 }
11072 return 0;
11073}
11074
11075static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11076 hda_nid_t nid, int pin_type,
11077 int dac_idx)
11078{
11079 /* set as output */
11080 snd_hda_codec_write(codec, nid, 0,
11081 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11082 snd_hda_codec_write(codec, nid, 0,
11083 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11084 /* need the manual connection? */
11085 if (alc880_is_multi_pin(nid)) {
11086 struct alc_spec *spec = codec->spec;
11087 int idx = alc880_multi_pin_idx(nid);
11088 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11089 AC_VERB_SET_CONNECT_SEL,
11090 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11091 }
11092}
11093
11094static void alc662_auto_init_multi_out(struct hda_codec *codec)
11095{
11096 struct alc_spec *spec = codec->spec;
11097 int i;
11098
11099 for (i = 0; i <= HDA_SIDE; i++) {
11100 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011101 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011102 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011103 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011104 i);
11105 }
11106}
11107
11108static void alc662_auto_init_hp_out(struct hda_codec *codec)
11109{
11110 struct alc_spec *spec = codec->spec;
11111 hda_nid_t pin;
11112
11113 pin = spec->autocfg.hp_pins[0];
11114 if (pin) /* connect to front */
11115 /* use dac 0 */
11116 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11117}
11118
11119#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11120#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11121
11122static void alc662_auto_init_analog_input(struct hda_codec *codec)
11123{
11124 struct alc_spec *spec = codec->spec;
11125 int i;
11126
11127 for (i = 0; i < AUTO_PIN_LAST; i++) {
11128 hda_nid_t nid = spec->autocfg.input_pins[i];
11129 if (alc662_is_input_pin(nid)) {
11130 snd_hda_codec_write(codec, nid, 0,
11131 AC_VERB_SET_PIN_WIDGET_CONTROL,
11132 (i <= AUTO_PIN_FRONT_MIC ?
11133 PIN_VREF80 : PIN_IN));
11134 if (nid != ALC662_PIN_CD_NID)
11135 snd_hda_codec_write(codec, nid, 0,
11136 AC_VERB_SET_AMP_GAIN_MUTE,
11137 AMP_OUT_MUTE);
11138 }
11139 }
11140}
11141
11142static int alc662_parse_auto_config(struct hda_codec *codec)
11143{
11144 struct alc_spec *spec = codec->spec;
11145 int err;
11146 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11147
11148 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11149 alc662_ignore);
11150 if (err < 0)
11151 return err;
11152 if (!spec->autocfg.line_outs)
11153 return 0; /* can't find valid BIOS pin config */
11154
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011155 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11156 if (err < 0)
11157 return err;
11158 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11159 if (err < 0)
11160 return err;
11161 err = alc662_auto_create_extra_out(spec,
11162 spec->autocfg.speaker_pins[0],
11163 "Speaker");
11164 if (err < 0)
11165 return err;
11166 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11167 "Headphone");
11168 if (err < 0)
11169 return err;
11170 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11171 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011172 return err;
11173
11174 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11175
11176 if (spec->autocfg.dig_out_pin)
11177 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11178
11179 if (spec->kctl_alloc)
11180 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11181
11182 spec->num_mux_defs = 1;
11183 spec->input_mux = &spec->private_imux;
11184
11185 if (err < 0)
11186 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020011187 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011188 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11189 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020011190 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011191}
11192
11193/* additional initialization for auto-configuration model */
11194static void alc662_auto_init(struct hda_codec *codec)
11195{
11196 alc662_auto_init_multi_out(codec);
11197 alc662_auto_init_hp_out(codec);
11198 alc662_auto_init_analog_input(codec);
11199}
11200
11201static int patch_alc662(struct hda_codec *codec)
11202{
11203 struct alc_spec *spec;
11204 int err, board_config;
11205
11206 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11207 if (!spec)
11208 return -ENOMEM;
11209
11210 codec->spec = spec;
11211
11212 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11213 alc662_models,
11214 alc662_cfg_tbl);
11215 if (board_config < 0) {
11216 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11217 "trying auto-probe from BIOS...\n");
11218 board_config = ALC662_AUTO;
11219 }
11220
11221 if (board_config == ALC662_AUTO) {
11222 /* automatic parse from the BIOS config */
11223 err = alc662_parse_auto_config(codec);
11224 if (err < 0) {
11225 alc_free(codec);
11226 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020011227 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011228 printk(KERN_INFO
11229 "hda_codec: Cannot set up configuration "
11230 "from BIOS. Using base mode...\n");
11231 board_config = ALC662_3ST_2ch_DIG;
11232 }
11233 }
11234
11235 if (board_config != ALC662_AUTO)
11236 setup_preset(spec, &alc662_presets[board_config]);
11237
11238 spec->stream_name_analog = "ALC662 Analog";
11239 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11240 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11241
11242 spec->stream_name_digital = "ALC662 Digital";
11243 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11244 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11245
11246 if (!spec->adc_nids && spec->input_mux) {
11247 spec->adc_nids = alc662_adc_nids;
11248 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11249 }
11250
11251 codec->patch_ops = alc_patch_ops;
11252 if (board_config == ALC662_AUTO)
11253 spec->init_hook = alc662_auto_init;
11254
11255 return 0;
11256}
11257
11258/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011259 * patch entries
11260 */
11261struct hda_codec_preset snd_hda_preset_realtek[] = {
11262 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011264 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011265 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011266 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011267 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11268 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11269 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011270 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11271 .patch = patch_alc883 },
11272 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11273 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011274 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011275 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011276 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011278 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011279 {} /* terminator */
11280};