blob: 8deca0f7d7ce1fc1abbaa9101ee11c379983ff15 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
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 Woithe7cf51e482006-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 Avdoninbab282b92006-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 Iwaic8b6bf92005-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001903#define alc880_lg_lw_modes alc880_threestack_modes
1904
Takashi Iwaid6815182006-03-23 16:06:23 +01001905static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1909 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1910 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1911 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1912 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1913 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1914 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1915 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1919 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001920 {
1921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1922 .name = "Channel Mode",
1923 .info = alc_ch_mode_info,
1924 .get = alc_ch_mode_get,
1925 .put = alc_ch_mode_put,
1926 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001927 { } /* end */
1928};
1929
1930static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001931 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1932 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1933 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1934
Takashi Iwaid6815182006-03-23 16:06:23 +01001935 /* set capture source to mic-in */
1936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1940 /* speaker-out */
1941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1946 /* mic-in to input */
1947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1949 /* built-in mic */
1950 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1952 /* jack sense */
1953 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1954 { }
1955};
1956
1957/* toggle speaker-output according to the hp-jack state */
1958static void alc880_lg_lw_automute(struct hda_codec *codec)
1959{
1960 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001961 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001962
1963 present = snd_hda_codec_read(codec, 0x1b, 0,
1964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001965 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001966 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001967 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001968 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001969 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001970}
1971
1972static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1973{
1974 /* Looks like the unsol event is incompatible with the standard
1975 * definition. 4bit tag is placed at 28 bit!
1976 */
1977 if ((res >> 28) == 0x01)
1978 alc880_lg_lw_automute(codec);
1979}
1980
1981/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001982 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001983 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001984
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985static int alc_init(struct hda_codec *codec)
1986{
1987 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001988 unsigned int i;
1989
1990 for (i = 0; i < spec->num_init_verbs; i++)
1991 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001992
1993 if (spec->init_hook)
1994 spec->init_hook(codec);
1995
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996 return 0;
1997}
1998
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001999static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2000{
2001 struct alc_spec *spec = codec->spec;
2002
2003 if (spec->unsol_event)
2004 spec->unsol_event(codec, res);
2005}
2006
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007#ifdef CONFIG_PM
2008/*
2009 * resume
2010 */
2011static int alc_resume(struct hda_codec *codec)
2012{
2013 struct alc_spec *spec = codec->spec;
2014 int i;
2015
2016 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019 if (spec->multiout.dig_out_nid)
2020 snd_hda_resume_spdif_out(codec);
2021 if (spec->dig_in_nid)
2022 snd_hda_resume_spdif_in(codec);
2023
2024 return 0;
2025}
2026#endif
2027
2028/*
2029 * Analog playback callbacks
2030 */
2031static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2032 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002033 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034{
2035 struct alc_spec *spec = codec->spec;
2036 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2037}
2038
2039static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2040 struct hda_codec *codec,
2041 unsigned int stream_tag,
2042 unsigned int format,
Takashi Iwaic8b6bf92005-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;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002046 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2047 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048}
2049
2050static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2051 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002052 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053{
2054 struct alc_spec *spec = codec->spec;
2055 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2056}
2057
2058/*
2059 * Digital out
2060 */
2061static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2062 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002063 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064{
2065 struct alc_spec *spec = codec->spec;
2066 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2067}
2068
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002069static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2070 struct hda_codec *codec,
2071 unsigned int stream_tag,
2072 unsigned int format,
2073 struct snd_pcm_substream *substream)
2074{
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2077 stream_tag, format, substream);
2078}
2079
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2081 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002082 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083{
2084 struct alc_spec *spec = codec->spec;
2085 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2086}
2087
2088/*
2089 * Analog capture
2090 */
2091static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2092 struct hda_codec *codec,
2093 unsigned int stream_tag,
2094 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002095 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096{
2097 struct alc_spec *spec = codec->spec;
2098
2099 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2100 stream_tag, 0, format);
2101 return 0;
2102}
2103
2104static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2105 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002106 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107{
2108 struct alc_spec *spec = codec->spec;
2109
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002110 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2111 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112 return 0;
2113}
2114
2115
2116/*
2117 */
2118static struct hda_pcm_stream alc880_pcm_analog_playback = {
2119 .substreams = 1,
2120 .channels_min = 2,
2121 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 .ops = {
2124 .open = alc880_playback_pcm_open,
2125 .prepare = alc880_playback_pcm_prepare,
2126 .cleanup = alc880_playback_pcm_cleanup
2127 },
2128};
2129
2130static struct hda_pcm_stream alc880_pcm_analog_capture = {
2131 .substreams = 2,
2132 .channels_min = 2,
2133 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002134 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135 .ops = {
2136 .prepare = alc880_capture_pcm_prepare,
2137 .cleanup = alc880_capture_pcm_cleanup
2138 },
2139};
2140
2141static struct hda_pcm_stream alc880_pcm_digital_playback = {
2142 .substreams = 1,
2143 .channels_min = 2,
2144 .channels_max = 2,
2145 /* NID is set in alc_build_pcms */
2146 .ops = {
2147 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002148 .close = alc880_dig_playback_pcm_close,
2149 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 },
2151};
2152
2153static struct hda_pcm_stream alc880_pcm_digital_capture = {
2154 .substreams = 1,
2155 .channels_min = 2,
2156 .channels_max = 2,
2157 /* NID is set in alc_build_pcms */
2158};
2159
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002160/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2161static struct hda_pcm_stream alc_pcm_null_playback = {
2162 .substreams = 0,
2163 .channels_min = 0,
2164 .channels_max = 0,
2165};
2166
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167static int alc_build_pcms(struct hda_codec *codec)
2168{
2169 struct alc_spec *spec = codec->spec;
2170 struct hda_pcm *info = spec->pcm_rec;
2171 int i;
2172
2173 codec->num_pcms = 1;
2174 codec->pcm_info = info;
2175
2176 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002177 if (spec->stream_analog_playback) {
2178 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2179 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2180 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2181 }
2182 if (spec->stream_analog_capture) {
2183 snd_assert(spec->adc_nids, return -EINVAL);
2184 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2185 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187
Takashi Iwai4a471b72005-12-07 13:56:29 +01002188 if (spec->channel_mode) {
2189 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2190 for (i = 0; i < spec->num_channel_mode; i++) {
2191 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 }
2195 }
2196
Takashi Iwaie08a0072006-09-07 17:52:14 +02002197 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002199 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002200 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002202 if (spec->multiout.dig_out_nid &&
2203 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2205 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2206 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002207 if (spec->dig_in_nid &&
2208 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2210 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2211 }
2212 }
2213
Takashi Iwaie08a0072006-09-07 17:52:14 +02002214 /* If the use of more than one ADC is requested for the current
2215 * model, configure a second analog capture-only PCM.
2216 */
2217 /* Additional Analaog capture for index #2 */
2218 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2219 spec->adc_nids) {
2220 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002221 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002222 info->name = spec->stream_name_analog;
2223 /* No playback stream for second PCM */
2224 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2225 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2226 if (spec->stream_analog_capture) {
2227 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2228 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2229 }
2230 }
2231
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 return 0;
2233}
2234
2235static void alc_free(struct hda_codec *codec)
2236{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237 struct alc_spec *spec = codec->spec;
2238 unsigned int i;
2239
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002240 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 return;
2242
2243 if (spec->kctl_alloc) {
2244 for (i = 0; i < spec->num_kctl_used; i++)
2245 kfree(spec->kctl_alloc[i].name);
2246 kfree(spec->kctl_alloc);
2247 }
2248 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249}
2250
2251/*
2252 */
2253static struct hda_codec_ops alc_patch_ops = {
2254 .build_controls = alc_build_controls,
2255 .build_pcms = alc_build_pcms,
2256 .init = alc_init,
2257 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002258 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259#ifdef CONFIG_PM
2260 .resume = alc_resume,
2261#endif
2262};
2263
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002264
2265/*
2266 * Test configuration for debugging
2267 *
2268 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2269 * enum controls.
2270 */
2271#ifdef CONFIG_SND_DEBUG
2272static hda_nid_t alc880_test_dac_nids[4] = {
2273 0x02, 0x03, 0x04, 0x05
2274};
2275
2276static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002277 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002278 .items = {
2279 { "In-1", 0x0 },
2280 { "In-2", 0x1 },
2281 { "In-3", 0x2 },
2282 { "In-4", 0x3 },
2283 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002284 { "Front", 0x5 },
2285 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002286 },
2287};
2288
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002289static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002290 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002291 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002292 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002293 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002294};
2295
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002296static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2297 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002298{
2299 static char *texts[] = {
2300 "N/A", "Line Out", "HP Out",
2301 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2302 };
2303 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2304 uinfo->count = 1;
2305 uinfo->value.enumerated.items = 8;
2306 if (uinfo->value.enumerated.item >= 8)
2307 uinfo->value.enumerated.item = 7;
2308 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2309 return 0;
2310}
2311
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002312static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2313 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002314{
2315 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2316 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2317 unsigned int pin_ctl, item = 0;
2318
2319 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2320 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2321 if (pin_ctl & AC_PINCTL_OUT_EN) {
2322 if (pin_ctl & AC_PINCTL_HP_EN)
2323 item = 2;
2324 else
2325 item = 1;
2326 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2327 switch (pin_ctl & AC_PINCTL_VREFEN) {
2328 case AC_PINCTL_VREF_HIZ: item = 3; break;
2329 case AC_PINCTL_VREF_50: item = 4; break;
2330 case AC_PINCTL_VREF_GRD: item = 5; break;
2331 case AC_PINCTL_VREF_80: item = 6; break;
2332 case AC_PINCTL_VREF_100: item = 7; break;
2333 }
2334 }
2335 ucontrol->value.enumerated.item[0] = item;
2336 return 0;
2337}
2338
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002339static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2340 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002341{
2342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2344 static unsigned int ctls[] = {
2345 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2346 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2347 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2348 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2349 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2350 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2351 };
2352 unsigned int old_ctl, new_ctl;
2353
2354 old_ctl = snd_hda_codec_read(codec, nid, 0,
2355 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2356 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2357 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002358 snd_hda_codec_write(codec, nid, 0,
2359 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002360 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002361 (ucontrol->value.enumerated.item[0] >= 3 ?
2362 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002363 return 1;
2364 }
2365 return 0;
2366}
2367
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002368static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2369 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002370{
2371 static char *texts[] = {
2372 "Front", "Surround", "CLFE", "Side"
2373 };
2374 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2375 uinfo->count = 1;
2376 uinfo->value.enumerated.items = 4;
2377 if (uinfo->value.enumerated.item >= 4)
2378 uinfo->value.enumerated.item = 3;
2379 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2380 return 0;
2381}
2382
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002383static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2384 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002385{
2386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2387 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2388 unsigned int sel;
2389
2390 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2391 ucontrol->value.enumerated.item[0] = sel & 3;
2392 return 0;
2393}
2394
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002395static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2396 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002397{
2398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2399 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2400 unsigned int sel;
2401
2402 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2403 if (ucontrol->value.enumerated.item[0] != sel) {
2404 sel = ucontrol->value.enumerated.item[0] & 3;
2405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2406 return 1;
2407 }
2408 return 0;
2409}
2410
2411#define PIN_CTL_TEST(xname,nid) { \
2412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2413 .name = xname, \
2414 .info = alc_test_pin_ctl_info, \
2415 .get = alc_test_pin_ctl_get, \
2416 .put = alc_test_pin_ctl_put, \
2417 .private_value = nid \
2418 }
2419
2420#define PIN_SRC_TEST(xname,nid) { \
2421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2422 .name = xname, \
2423 .info = alc_test_pin_src_info, \
2424 .get = alc_test_pin_src_get, \
2425 .put = alc_test_pin_src_put, \
2426 .private_value = nid \
2427 }
2428
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002429static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2431 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2432 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2433 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2436 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2437 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002438 PIN_CTL_TEST("Front Pin Mode", 0x14),
2439 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2440 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2441 PIN_CTL_TEST("Side Pin Mode", 0x17),
2442 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2443 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2444 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2445 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2446 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2447 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2448 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2449 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2450 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2451 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2452 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2453 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2454 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2455 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2456 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2457 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002460 {
2461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2462 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002463 .info = alc_ch_mode_info,
2464 .get = alc_ch_mode_get,
2465 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002466 },
2467 { } /* end */
2468};
2469
2470static struct hda_verb alc880_test_init_verbs[] = {
2471 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002480 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2483 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002485 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2488 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2489 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002490 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002495 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2497 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2500 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002501 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2504 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002506 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002508 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002510 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002512 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002513 /* Analog input/passthru */
2514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002519 { }
2520};
2521#endif
2522
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523/*
2524 */
2525
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002526static const char *alc880_models[ALC880_MODEL_LAST] = {
2527 [ALC880_3ST] = "3stack",
2528 [ALC880_TCL_S700] = "tcl",
2529 [ALC880_3ST_DIG] = "3stack-digout",
2530 [ALC880_CLEVO] = "clevo",
2531 [ALC880_5ST] = "5stack",
2532 [ALC880_5ST_DIG] = "5stack-digout",
2533 [ALC880_W810] = "w810",
2534 [ALC880_Z71V] = "z71v",
2535 [ALC880_6ST] = "6stack",
2536 [ALC880_6ST_DIG] = "6stack-digout",
2537 [ALC880_ASUS] = "asus",
2538 [ALC880_ASUS_W1V] = "asus-w1v",
2539 [ALC880_ASUS_DIG] = "asus-dig",
2540 [ALC880_ASUS_DIG2] = "asus-dig2",
2541 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002542 [ALC880_UNIWILL_P53] = "uniwill-p53",
2543 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002544 [ALC880_F1734] = "F1734",
2545 [ALC880_LG] = "lg",
2546 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002547#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002548 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002549#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002550 [ALC880_AUTO] = "auto",
2551};
2552
2553static struct snd_pci_quirk alc880_cfg_tbl[] = {
2554 /* Broken BIOS configuration */
2555 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2556 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2557
2558 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2559 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002560 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002561 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2562 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2563 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2564 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2565 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2566 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2567
2568 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2569 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2570
2571 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2572 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2573 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2574 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2575 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2576 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2577 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2578 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2579 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2580 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002581 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002582 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2583 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2584 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2585 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2586
2587 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2588 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2589 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2590 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2591 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2592 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2593 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2594 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2595 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2596 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2597 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2598 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2599 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2600 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2601 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2602 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2603 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2604 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2605
2606 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2607 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2608 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2609 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2610
2611 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2612 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2613 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002614 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002615
2616 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2617 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2618 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2619 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2620
2621 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2622 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2623 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2624 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2625 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2626 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2627 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2628 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2629 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2630 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2631 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002632
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 {}
2634};
2635
Takashi Iwai16ded522005-06-10 19:58:24 +02002636/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002637 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002639static struct alc_config_preset alc880_presets[] = {
2640 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002642 .init_verbs = { alc880_volume_init_verbs,
2643 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002645 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002646 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2647 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002648 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002649 .input_mux = &alc880_capture_source,
2650 },
2651 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002652 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002653 .init_verbs = { alc880_volume_init_verbs,
2654 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002655 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002656 .dac_nids = alc880_dac_nids,
2657 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2659 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002660 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 .input_mux = &alc880_capture_source,
2662 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002663 [ALC880_TCL_S700] = {
2664 .mixers = { alc880_tcl_s700_mixer },
2665 .init_verbs = { alc880_volume_init_verbs,
2666 alc880_pin_tcl_S700_init_verbs,
2667 alc880_gpio2_init_verbs },
2668 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2669 .dac_nids = alc880_dac_nids,
2670 .hp_nid = 0x03,
2671 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2672 .channel_mode = alc880_2_jack_modes,
2673 .input_mux = &alc880_capture_source,
2674 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002676 .mixers = { alc880_three_stack_mixer,
2677 alc880_five_stack_mixer},
2678 .init_verbs = { alc880_volume_init_verbs,
2679 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2681 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2683 .channel_mode = alc880_fivestack_modes,
2684 .input_mux = &alc880_capture_source,
2685 },
2686 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002687 .mixers = { alc880_three_stack_mixer,
2688 alc880_five_stack_mixer },
2689 .init_verbs = { alc880_volume_init_verbs,
2690 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2692 .dac_nids = alc880_dac_nids,
2693 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2695 .channel_mode = alc880_fivestack_modes,
2696 .input_mux = &alc880_capture_source,
2697 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002698 [ALC880_6ST] = {
2699 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002700 .init_verbs = { alc880_volume_init_verbs,
2701 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002702 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2703 .dac_nids = alc880_6st_dac_nids,
2704 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2705 .channel_mode = alc880_sixstack_modes,
2706 .input_mux = &alc880_6stack_capture_source,
2707 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002708 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002709 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002710 .init_verbs = { alc880_volume_init_verbs,
2711 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002712 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2713 .dac_nids = alc880_6st_dac_nids,
2714 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2716 .channel_mode = alc880_sixstack_modes,
2717 .input_mux = &alc880_6stack_capture_source,
2718 },
2719 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002721 .init_verbs = { alc880_volume_init_verbs,
2722 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002723 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2725 .dac_nids = alc880_w810_dac_nids,
2726 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2728 .channel_mode = alc880_w810_modes,
2729 .input_mux = &alc880_capture_source,
2730 },
2731 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002732 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002733 .init_verbs = { alc880_volume_init_verbs,
2734 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2736 .dac_nids = alc880_z71v_dac_nids,
2737 .dig_out_nid = ALC880_DIGOUT_NID,
2738 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002739 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2740 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002741 .input_mux = &alc880_capture_source,
2742 },
2743 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002745 .init_verbs = { alc880_volume_init_verbs,
2746 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2748 .dac_nids = alc880_f1734_dac_nids,
2749 .hp_nid = 0x02,
2750 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2751 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002752 .input_mux = &alc880_capture_source,
2753 },
2754 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002755 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002756 .init_verbs = { alc880_volume_init_verbs,
2757 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002758 alc880_gpio1_init_verbs },
2759 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2760 .dac_nids = alc880_asus_dac_nids,
2761 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2762 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002763 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002764 .input_mux = &alc880_capture_source,
2765 },
2766 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002768 .init_verbs = { alc880_volume_init_verbs,
2769 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002770 alc880_gpio1_init_verbs },
2771 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2772 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002773 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2775 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002776 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 .input_mux = &alc880_capture_source,
2778 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002779 [ALC880_ASUS_DIG2] = {
2780 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002781 .init_verbs = { alc880_volume_init_verbs,
2782 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002783 alc880_gpio2_init_verbs }, /* use GPIO2 */
2784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2785 .dac_nids = alc880_asus_dac_nids,
2786 .dig_out_nid = ALC880_DIGOUT_NID,
2787 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2788 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002789 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002790 .input_mux = &alc880_capture_source,
2791 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002794 .init_verbs = { alc880_volume_init_verbs,
2795 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 alc880_gpio1_init_verbs },
2797 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2798 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2801 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002802 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002803 .input_mux = &alc880_capture_source,
2804 },
2805 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002806 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002807 .init_verbs = { alc880_volume_init_verbs,
2808 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2810 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002811 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2813 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002814 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002815 .input_mux = &alc880_capture_source,
2816 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002817 [ALC880_UNIWILL] = {
2818 .mixers = { alc880_uniwill_mixer },
2819 .init_verbs = { alc880_volume_init_verbs,
2820 alc880_uniwill_init_verbs },
2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2822 .dac_nids = alc880_asus_dac_nids,
2823 .dig_out_nid = ALC880_DIGOUT_NID,
2824 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2825 .channel_mode = alc880_threestack_modes,
2826 .need_dac_fix = 1,
2827 .input_mux = &alc880_capture_source,
2828 .unsol_event = alc880_uniwill_unsol_event,
2829 .init_hook = alc880_uniwill_automute,
2830 },
2831 [ALC880_UNIWILL_P53] = {
2832 .mixers = { alc880_uniwill_p53_mixer },
2833 .init_verbs = { alc880_volume_init_verbs,
2834 alc880_uniwill_p53_init_verbs },
2835 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2836 .dac_nids = alc880_asus_dac_nids,
2837 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002838 .channel_mode = alc880_threestack_modes,
2839 .input_mux = &alc880_capture_source,
2840 .unsol_event = alc880_uniwill_p53_unsol_event,
2841 .init_hook = alc880_uniwill_p53_hp_automute,
2842 },
2843 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002844 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002845 alc880_pcbeep_mixer, },
2846 .init_verbs = { alc880_volume_init_verbs,
2847 alc880_uniwill_p53_init_verbs,
2848 alc880_beep_init_verbs },
2849 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2850 .dac_nids = alc880_dac_nids,
2851 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2852 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002853 .input_mux = &alc880_capture_source,
2854 .unsol_event = alc880_uniwill_p53_unsol_event,
2855 .init_hook = alc880_uniwill_p53_hp_automute,
2856 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002857 [ALC880_CLEVO] = {
2858 .mixers = { alc880_three_stack_mixer },
2859 .init_verbs = { alc880_volume_init_verbs,
2860 alc880_pin_clevo_init_verbs },
2861 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2862 .dac_nids = alc880_dac_nids,
2863 .hp_nid = 0x03,
2864 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2865 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002866 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002867 .input_mux = &alc880_capture_source,
2868 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002869 [ALC880_LG] = {
2870 .mixers = { alc880_lg_mixer },
2871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_lg_init_verbs },
2873 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2874 .dac_nids = alc880_lg_dac_nids,
2875 .dig_out_nid = ALC880_DIGOUT_NID,
2876 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2877 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002878 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002879 .input_mux = &alc880_lg_capture_source,
2880 .unsol_event = alc880_lg_unsol_event,
2881 .init_hook = alc880_lg_automute,
2882 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002883 [ALC880_LG_LW] = {
2884 .mixers = { alc880_lg_lw_mixer },
2885 .init_verbs = { alc880_volume_init_verbs,
2886 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002887 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002888 .dac_nids = alc880_dac_nids,
2889 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002890 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2891 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002892 .input_mux = &alc880_lg_lw_capture_source,
2893 .unsol_event = alc880_lg_lw_unsol_event,
2894 .init_hook = alc880_lg_lw_automute,
2895 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002896#ifdef CONFIG_SND_DEBUG
2897 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 .mixers = { alc880_test_mixer },
2899 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002900 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2901 .dac_nids = alc880_test_dac_nids,
2902 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002903 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2904 .channel_mode = alc880_test_modes,
2905 .input_mux = &alc880_test_capture_source,
2906 },
2907#endif
2908};
2909
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002910/*
2911 * Automatic parse of I/O pins from the BIOS configuration
2912 */
2913
2914#define NUM_CONTROL_ALLOC 32
2915#define NUM_VERB_ALLOC 32
2916
2917enum {
2918 ALC_CTL_WIDGET_VOL,
2919 ALC_CTL_WIDGET_MUTE,
2920 ALC_CTL_BIND_MUTE,
2921};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002922static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002923 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2924 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002925 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926};
2927
2928/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002929static int add_control(struct alc_spec *spec, int type, const char *name,
2930 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002931{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002932 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002933
2934 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2935 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2936
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002937 /* array + terminator */
2938 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2939 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002940 return -ENOMEM;
2941 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002942 memcpy(knew, spec->kctl_alloc,
2943 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944 kfree(spec->kctl_alloc);
2945 }
2946 spec->kctl_alloc = knew;
2947 spec->num_kctl_alloc = num;
2948 }
2949
2950 knew = &spec->kctl_alloc[spec->num_kctl_used];
2951 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002952 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002953 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 return -ENOMEM;
2955 knew->private_value = val;
2956 spec->num_kctl_used++;
2957 return 0;
2958}
2959
2960#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2961#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2962#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2963#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2964#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2965#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2966#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2967#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2968#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2969#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2970#define ALC880_PIN_CD_NID 0x1c
2971
2972/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002973static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2974 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975{
2976 hda_nid_t nid;
2977 int assigned[4];
2978 int i, j;
2979
2980 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002981 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002982
2983 /* check the pins hardwired to audio widget */
2984 for (i = 0; i < cfg->line_outs; i++) {
2985 nid = cfg->line_out_pins[i];
2986 if (alc880_is_fixed_pin(nid)) {
2987 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002988 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002989 assigned[idx] = 1;
2990 }
2991 }
2992 /* left pins can be connect to any audio widget */
2993 for (i = 0; i < cfg->line_outs; i++) {
2994 nid = cfg->line_out_pins[i];
2995 if (alc880_is_fixed_pin(nid))
2996 continue;
2997 /* search for an empty channel */
2998 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002999 if (!assigned[j]) {
3000 spec->multiout.dac_nids[i] =
3001 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 assigned[j] = 1;
3003 break;
3004 }
3005 }
3006 }
3007 spec->multiout.num_dacs = cfg->line_outs;
3008 return 0;
3009}
3010
3011/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003012static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3013 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003014{
3015 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003016 static const char *chname[4] = {
3017 "Front", "Surround", NULL /*CLFE*/, "Side"
3018 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 hda_nid_t nid;
3020 int i, err;
3021
3022 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003023 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 continue;
3025 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3026 if (i == 2) {
3027 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003028 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3029 "Center Playback Volume",
3030 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3031 HDA_OUTPUT));
3032 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003033 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003034 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3035 "LFE Playback Volume",
3036 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3037 HDA_OUTPUT));
3038 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003040 err = add_control(spec, ALC_CTL_BIND_MUTE,
3041 "Center Playback Switch",
3042 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3043 HDA_INPUT));
3044 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003046 err = add_control(spec, ALC_CTL_BIND_MUTE,
3047 "LFE Playback Switch",
3048 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3049 HDA_INPUT));
3050 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003051 return err;
3052 } else {
3053 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003054 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3055 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3056 HDA_OUTPUT));
3057 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003058 return err;
3059 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003060 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3061 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3062 HDA_INPUT));
3063 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 return err;
3065 }
3066 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 return 0;
3068}
3069
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003070/* add playback controls for speaker and HP outputs */
3071static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3072 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073{
3074 hda_nid_t nid;
3075 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003076 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003078 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 return 0;
3080
3081 if (alc880_is_fixed_pin(pin)) {
3082 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003083 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003084 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003086 else
3087 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 /* control HP volume/switch on the output mixer amp */
3089 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003090 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003095 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003096 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3097 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3098 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099 return err;
3100 } else if (alc880_is_multi_pin(pin)) {
3101 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003103 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003104 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3105 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3106 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 return err;
3108 }
3109 return 0;
3110}
3111
3112/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003113static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3114 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003115 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116{
3117 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003118 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119
3120 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3122 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 return err;
3125 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003126 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3127 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3128 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 return err;
3130 return 0;
3131}
3132
3133/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003134static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3135 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003138 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139
3140 for (i = 0; i < AUTO_PIN_LAST; i++) {
3141 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003142 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003143 err = new_analog_input(spec, cfg->input_pins[i],
3144 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003145 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 if (err < 0)
3147 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003148 imux->items[imux->num_items].label =
3149 auto_pin_cfg_labels[i];
3150 imux->items[imux->num_items].index =
3151 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003152 imux->num_items++;
3153 }
3154 }
3155 return 0;
3156}
3157
Kailang Yangdf694da2005-12-05 19:42:22 +01003158static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3159 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003160 int dac_idx)
3161{
3162 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3164 pin_type);
3165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3166 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167 /* need the manual connection? */
3168 if (alc880_is_multi_pin(nid)) {
3169 struct alc_spec *spec = codec->spec;
3170 int idx = alc880_multi_pin_idx(nid);
3171 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3172 AC_VERB_SET_CONNECT_SEL,
3173 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3174 }
3175}
3176
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003177static int get_pin_type(int line_out_type)
3178{
3179 if (line_out_type == AUTO_PIN_HP_OUT)
3180 return PIN_HP;
3181 else
3182 return PIN_OUT;
3183}
3184
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185static void alc880_auto_init_multi_out(struct hda_codec *codec)
3186{
3187 struct alc_spec *spec = codec->spec;
3188 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003189
3190 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003191 for (i = 0; i < spec->autocfg.line_outs; i++) {
3192 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003193 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3194 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 }
3196}
3197
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003198static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199{
3200 struct alc_spec *spec = codec->spec;
3201 hda_nid_t pin;
3202
Takashi Iwai82bc9552006-03-21 11:24:42 +01003203 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003204 if (pin) /* connect to front */
3205 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003206 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207 if (pin) /* connect to front */
3208 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3209}
3210
3211static void alc880_auto_init_analog_input(struct hda_codec *codec)
3212{
3213 struct alc_spec *spec = codec->spec;
3214 int i;
3215
3216 for (i = 0; i < AUTO_PIN_LAST; i++) {
3217 hda_nid_t nid = spec->autocfg.input_pins[i];
3218 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003219 snd_hda_codec_write(codec, nid, 0,
3220 AC_VERB_SET_PIN_WIDGET_CONTROL,
3221 i <= AUTO_PIN_FRONT_MIC ?
3222 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 snd_hda_codec_write(codec, nid, 0,
3225 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 AMP_OUT_MUTE);
3227 }
3228 }
3229}
3230
3231/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003232/* return 1 if successful, 0 if the proper config is not found,
3233 * or a negative error code
3234 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235static int alc880_parse_auto_config(struct hda_codec *codec)
3236{
3237 struct alc_spec *spec = codec->spec;
3238 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003239 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003240
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003241 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3242 alc880_ignore);
3243 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003245 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003247
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3249 if (err < 0)
3250 return err;
3251 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3252 if (err < 0)
3253 return err;
3254 err = alc880_auto_create_extra_out(spec,
3255 spec->autocfg.speaker_pins[0],
3256 "Speaker");
3257 if (err < 0)
3258 return err;
3259 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3260 "Headphone");
3261 if (err < 0)
3262 return err;
3263 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3264 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 return err;
3266
3267 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3268
3269 if (spec->autocfg.dig_out_pin)
3270 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3271 if (spec->autocfg.dig_in_pin)
3272 spec->dig_in_nid = ALC880_DIGIN_NID;
3273
3274 if (spec->kctl_alloc)
3275 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3276
3277 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3278
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003279 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 spec->input_mux = &spec->private_imux;
3281
3282 return 1;
3283}
3284
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003285/* additional initialization for auto-configuration model */
3286static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003289 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291}
3292
3293/*
3294 * OK, here we have finally the patch for ALC880
3295 */
3296
Linus Torvalds1da177e2005-04-16 15:20:36 -07003297static int patch_alc880(struct hda_codec *codec)
3298{
3299 struct alc_spec *spec;
3300 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003301 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003302
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003303 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003304 if (spec == NULL)
3305 return -ENOMEM;
3306
3307 codec->spec = spec;
3308
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003309 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3310 alc880_models,
3311 alc880_cfg_tbl);
3312 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003313 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3314 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003316 }
3317
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 if (board_config == ALC880_AUTO) {
3319 /* automatic parse from the BIOS config */
3320 err = alc880_parse_auto_config(codec);
3321 if (err < 0) {
3322 alc_free(codec);
3323 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003324 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003325 printk(KERN_INFO
3326 "hda_codec: Cannot set up configuration "
3327 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003328 board_config = ALC880_3ST;
3329 }
3330 }
3331
Kailang Yangdf694da2005-12-05 19:42:22 +01003332 if (board_config != ALC880_AUTO)
3333 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334
3335 spec->stream_name_analog = "ALC880 Analog";
3336 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3337 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3338
3339 spec->stream_name_digital = "ALC880 Digital";
3340 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3341 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3342
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003343 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003344 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003345 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346 /* get type */
3347 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348 if (wcap != AC_WID_AUD_IN) {
3349 spec->adc_nids = alc880_adc_nids_alt;
3350 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003351 spec->mixers[spec->num_mixers] =
3352 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353 spec->num_mixers++;
3354 } else {
3355 spec->adc_nids = alc880_adc_nids;
3356 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3357 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3358 spec->num_mixers++;
3359 }
3360 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003361
3362 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003363 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003364 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365
3366 return 0;
3367}
3368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003369
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370/*
3371 * ALC260 support
3372 */
3373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374static hda_nid_t alc260_dac_nids[1] = {
3375 /* front */
3376 0x02,
3377};
3378
3379static hda_nid_t alc260_adc_nids[1] = {
3380 /* ADC0 */
3381 0x04,
3382};
3383
Kailang Yangdf694da2005-12-05 19:42:22 +01003384static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 /* ADC1 */
3386 0x05,
3387};
3388
Kailang Yangdf694da2005-12-05 19:42:22 +01003389static hda_nid_t alc260_hp_adc_nids[2] = {
3390 /* ADC1, 0 */
3391 0x05, 0x04
3392};
3393
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003394/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3395 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3396 */
3397static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003398 /* ADC0, ADC1 */
3399 0x04, 0x05
3400};
3401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003402#define ALC260_DIGOUT_NID 0x03
3403#define ALC260_DIGIN_NID 0x06
3404
3405static struct hda_input_mux alc260_capture_source = {
3406 .num_items = 4,
3407 .items = {
3408 { "Mic", 0x0 },
3409 { "Front Mic", 0x1 },
3410 { "Line", 0x2 },
3411 { "CD", 0x4 },
3412 },
3413};
3414
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003415/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003416 * headphone jack and the internal CD lines since these are the only pins at
3417 * which audio can appear. For flexibility, also allow the option of
3418 * recording the mixer output on the second ADC (ADC0 doesn't have a
3419 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003420 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003421static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3422 {
3423 .num_items = 3,
3424 .items = {
3425 { "Mic/Line", 0x0 },
3426 { "CD", 0x4 },
3427 { "Headphone", 0x2 },
3428 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003429 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003430 {
3431 .num_items = 4,
3432 .items = {
3433 { "Mic/Line", 0x0 },
3434 { "CD", 0x4 },
3435 { "Headphone", 0x2 },
3436 { "Mixer", 0x5 },
3437 },
3438 },
3439
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003440};
3441
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003442/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3443 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003444 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003445static struct hda_input_mux alc260_acer_capture_sources[2] = {
3446 {
3447 .num_items = 4,
3448 .items = {
3449 { "Mic", 0x0 },
3450 { "Line", 0x2 },
3451 { "CD", 0x4 },
3452 { "Headphone", 0x5 },
3453 },
3454 },
3455 {
3456 .num_items = 5,
3457 .items = {
3458 { "Mic", 0x0 },
3459 { "Line", 0x2 },
3460 { "CD", 0x4 },
3461 { "Headphone", 0x6 },
3462 { "Mixer", 0x5 },
3463 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003464 },
3465};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003466/*
3467 * This is just place-holder, so there's something for alc_build_pcms to look
3468 * at when it calculates the maximum number of channels. ALC260 has no mixer
3469 * element which allows changing the channel mode, so the verb list is
3470 * never used.
3471 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003472static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003473 { 2, NULL },
3474};
3475
Kailang Yangdf694da2005-12-05 19:42:22 +01003476
3477/* Mixer combinations
3478 *
3479 * basic: base_output + input + pc_beep + capture
3480 * HP: base_output + input + capture_alt
3481 * HP_3013: hp_3013 + input + capture
3482 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003483 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003484 */
3485
3486static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003487 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003488 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3490 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3491 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3492 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3493 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003494};
Kailang Yangdf694da2005-12-05 19:42:22 +01003495
3496static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3498 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3500 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3502 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 { } /* end */
3506};
3507
Kailang Yangdf694da2005-12-05 19:42:22 +01003508static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3511 { } /* end */
3512};
3513
3514static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3515 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3516 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3517 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3518 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3521 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3522 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003523 { } /* end */
3524};
3525
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003526/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3527 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3528 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003529static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003531 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003532 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003533 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3536 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003537 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003538 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3539 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3540 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003541 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003542 { } /* end */
3543};
3544
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003545/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3546 * versions of the ALC260 don't act on requests to enable mic bias from NID
3547 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3548 * datasheet doesn't mention this restriction. At this stage it's not clear
3549 * whether this behaviour is intentional or is a hardware bug in chip
3550 * revisions available in early 2006. Therefore for now allow the
3551 * "Headphone Jack Mode" control to span all choices, but if it turns out
3552 * that the lack of mic bias for this NID is intentional we could change the
3553 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3554 *
3555 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3556 * don't appear to make the mic bias available from the "line" jack, even
3557 * though the NID used for this jack (0x14) can supply it. The theory is
3558 * that perhaps Acer have included blocking capacitors between the ALC260
3559 * and the output jack. If this turns out to be the case for all such
3560 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3561 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003562 *
3563 * The C20x Tablet series have a mono internal speaker which is controlled
3564 * via the chip's Mono sum widget and pin complex, so include the necessary
3565 * controls for such models. On models without a "mono speaker" the control
3566 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003567 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003568static struct snd_kcontrol_new alc260_acer_mixer[] = {
3569 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3570 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003571 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003572 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3573 HDA_OUTPUT),
3574 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3575 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003576 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3577 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3579 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3580 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3581 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3582 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3583 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3584 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3585 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3586 { } /* end */
3587};
3588
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003589/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3590 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3591 */
3592static struct snd_kcontrol_new alc260_will_mixer[] = {
3593 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3594 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3595 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3596 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3597 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3598 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3599 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3600 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3601 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3602 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3603 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3604 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3605 { } /* end */
3606};
3607
3608/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3609 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3610 */
3611static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3612 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3613 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3615 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3616 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3617 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3621 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3622 { } /* end */
3623};
3624
Kailang Yangdf694da2005-12-05 19:42:22 +01003625/* capture mixer elements */
3626static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003627 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003629 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3630 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003631 {
3632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003633 /* The multiple "Capture Source" controls confuse alsamixer
3634 * So call somewhat different..
3635 * FIXME: the controls appear in the "playback" view!
3636 */
3637 /* .name = "Capture Source", */
3638 .name = "Input Source",
3639 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003640 .info = alc_mux_enum_info,
3641 .get = alc_mux_enum_get,
3642 .put = alc_mux_enum_put,
3643 },
3644 { } /* end */
3645};
3646
Kailang Yangdf694da2005-12-05 19:42:22 +01003647static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3648 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3649 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3650 {
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3652 /* The multiple "Capture Source" controls confuse alsamixer
3653 * So call somewhat different..
3654 * FIXME: the controls appear in the "playback" view!
3655 */
3656 /* .name = "Capture Source", */
3657 .name = "Input Source",
3658 .count = 1,
3659 .info = alc_mux_enum_info,
3660 .get = alc_mux_enum_get,
3661 .put = alc_mux_enum_put,
3662 },
3663 { } /* end */
3664};
3665
3666/*
3667 * initialization verbs
3668 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003669static struct hda_verb alc260_init_verbs[] = {
3670 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003672 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003675 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003676 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003677 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003678 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003680 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003681 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003683 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003685 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003686 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3688 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003689 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003690 /* set connection select to line in (default select for this ADC) */
3691 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003692 /* mute capture amp left and right */
3693 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3694 /* set connection select to line in (default select for this ADC) */
3695 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003696 /* set vol=0 Line-Out mixer amp left and right */
3697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3698 /* unmute pin widget amp left and right (no gain on this amp) */
3699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3700 /* set vol=0 HP mixer amp left and right */
3701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3702 /* unmute pin widget amp left and right (no gain on this amp) */
3703 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3704 /* set vol=0 Mono mixer amp left and right */
3705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3706 /* unmute pin widget amp left and right (no gain on this amp) */
3707 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3708 /* unmute LINE-2 out pin */
3709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003710 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3711 * Line In 2 = 0x03
3712 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003713 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003719 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003720 /* mute Front out path */
3721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3723 /* mute Headphone out path */
3724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3726 /* mute Mono out path */
3727 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3728 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003729 { }
3730};
3731
Takashi Iwai474167d2006-05-17 17:17:43 +02003732#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003733static struct hda_verb alc260_hp_init_verbs[] = {
3734 /* Headphone and output */
3735 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3736 /* mono output */
3737 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3738 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3739 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3740 /* Mic2 (front panel) pin widget for input and vref at 80% */
3741 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3742 /* Line In pin widget for input */
3743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3744 /* Line-2 pin widget for output */
3745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3746 /* CD pin widget for input */
3747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3748 /* unmute amp left and right */
3749 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3750 /* set connection select to line in (default select for this ADC) */
3751 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3752 /* unmute Line-Out mixer amp left and right (volume = 0) */
3753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3754 /* mute pin widget amp left and right (no gain on this amp) */
3755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3756 /* unmute HP mixer amp left and right (volume = 0) */
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3758 /* mute pin widget amp left and right (no gain on this amp) */
3759 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3761 * Line In 2 = 0x03
3762 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003763 /* unmute CD */
3764 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3765 /* unmute Line In */
3766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3767 /* unmute Mic */
3768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3769 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3770 /* Unmute Front out path */
3771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3773 /* Unmute Headphone out path */
3774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3776 /* Unmute Mono out path */
3777 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3778 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3779 { }
3780};
Takashi Iwai474167d2006-05-17 17:17:43 +02003781#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003782
3783static struct hda_verb alc260_hp_3013_init_verbs[] = {
3784 /* Line out and output */
3785 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3786 /* mono output */
3787 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3788 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3789 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3790 /* Mic2 (front panel) pin widget for input and vref at 80% */
3791 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3792 /* Line In pin widget for input */
3793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3794 /* Headphone pin widget for output */
3795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3796 /* CD pin widget for input */
3797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3798 /* unmute amp left and right */
3799 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3800 /* set connection select to line in (default select for this ADC) */
3801 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3802 /* unmute Line-Out mixer amp left and right (volume = 0) */
3803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3804 /* mute pin widget amp left and right (no gain on this amp) */
3805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3806 /* unmute HP mixer amp left and right (volume = 0) */
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3808 /* mute pin widget amp left and right (no gain on this amp) */
3809 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3811 * Line In 2 = 0x03
3812 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003813 /* unmute CD */
3814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3815 /* unmute Line In */
3816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3817 /* unmute Mic */
3818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3819 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3820 /* Unmute Front out path */
3821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3823 /* Unmute Headphone out path */
3824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3826 /* Unmute Mono out path */
3827 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3828 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3829 { }
3830};
3831
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003832/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003833 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3834 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003835 */
3836static struct hda_verb alc260_fujitsu_init_verbs[] = {
3837 /* Disable all GPIOs */
3838 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3839 /* Internal speaker is connected to headphone pin */
3840 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3841 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003843 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3844 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 /* Ensure all other unused pins are disabled and muted. */
3846 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003848 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003849 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003850 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003851 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003854
Jonathan Woithef7ace402006-02-28 11:46:14 +01003855 /* Disable digital (SPDIF) pins */
3856 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3857 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003858
Jonathan Woithef7ace402006-02-28 11:46:14 +01003859 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3860 * when acting as an output.
3861 */
3862 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3863
3864 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003874
Jonathan Woithef7ace402006-02-28 11:46:14 +01003875 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3876 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3877 /* Unmute Line1 pin widget output buffer since it starts as an output.
3878 * If the pin mode is changed by the user the pin mode control will
3879 * take care of enabling the pin's input/output buffers as needed.
3880 * Therefore there's no need to enable the input buffer at this
3881 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003882 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003884 /* Unmute input buffer of pin widget used for Line-in (no equiv
3885 * mixer ctrl)
3886 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003887 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003888
Jonathan Woithef7ace402006-02-28 11:46:14 +01003889 /* Mute capture amp left and right */
3890 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3891 /* Set ADC connection select to match default mixer setting - line
3892 * in (on mic1 pin)
3893 */
3894 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003895
Jonathan Woithef7ace402006-02-28 11:46:14 +01003896 /* Do the same for the second ADC: mute capture input amp and
3897 * set ADC connection to line in (on mic1 pin)
3898 */
3899 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3900 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003901
Jonathan Woithef7ace402006-02-28 11:46:14 +01003902 /* Mute all inputs to mixer widget (even unconnected ones) */
3903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003911
3912 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003913};
3914
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003915/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3916 * similar laptops (adapted from Fujitsu init verbs).
3917 */
3918static struct hda_verb alc260_acer_init_verbs[] = {
3919 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3920 * the headphone jack. Turn this on and rely on the standard mute
3921 * methods whenever the user wants to turn these outputs off.
3922 */
3923 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3925 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3926 /* Internal speaker/Headphone jack is connected to Line-out pin */
3927 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3928 /* Internal microphone/Mic jack is connected to Mic1 pin */
3929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3930 /* Line In jack is connected to Line1 pin */
3931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003932 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3933 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003934 /* Ensure all other unused pins are disabled and muted. */
3935 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3936 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003937 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3938 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3941 /* Disable digital (SPDIF) pins */
3942 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3943 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3944
3945 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3946 * bus when acting as outputs.
3947 */
3948 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3949 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3950
3951 /* Start with output sum widgets muted and their output gains at min */
3952 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3958 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3961
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003962 /* Unmute Line-out pin widget amp left and right
3963 * (no equiv mixer ctrl)
3964 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003966 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3967 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003968 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3969 * inputs. If the pin mode is changed by the user the pin mode control
3970 * will take care of enabling the pin's input/output buffers as needed.
3971 * Therefore there's no need to enable the input buffer at this
3972 * stage.
3973 */
3974 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3976
3977 /* Mute capture amp left and right */
3978 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3979 /* Set ADC connection select to match default mixer setting - mic
3980 * (on mic1 pin)
3981 */
3982 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3983
3984 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003985 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003986 */
3987 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003988 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003989
3990 /* Mute all inputs to mixer widget (even unconnected ones) */
3991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3999
4000 { }
4001};
4002
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004003static struct hda_verb alc260_will_verbs[] = {
4004 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4005 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4006 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4007 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4008 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4009 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4010 {}
4011};
4012
4013static struct hda_verb alc260_replacer_672v_verbs[] = {
4014 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4015 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4016 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4017
4018 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4019 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4020 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4021
4022 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4023 {}
4024};
4025
4026/* toggle speaker-output according to the hp-jack state */
4027static void alc260_replacer_672v_automute(struct hda_codec *codec)
4028{
4029 unsigned int present;
4030
4031 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4032 present = snd_hda_codec_read(codec, 0x0f, 0,
4033 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4034 if (present) {
4035 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4036 snd_hda_codec_write(codec, 0x0f, 0,
4037 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4038 } else {
4039 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4040 snd_hda_codec_write(codec, 0x0f, 0,
4041 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4042 }
4043}
4044
4045static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4046 unsigned int res)
4047{
4048 if ((res >> 26) == ALC880_HP_EVENT)
4049 alc260_replacer_672v_automute(codec);
4050}
4051
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004052/* Test configuration for debugging, modelled after the ALC880 test
4053 * configuration.
4054 */
4055#ifdef CONFIG_SND_DEBUG
4056static hda_nid_t alc260_test_dac_nids[1] = {
4057 0x02,
4058};
4059static hda_nid_t alc260_test_adc_nids[2] = {
4060 0x04, 0x05,
4061};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004062/* For testing the ALC260, each input MUX needs its own definition since
4063 * the signal assignments are different. This assumes that the first ADC
4064 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004065 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004066static struct hda_input_mux alc260_test_capture_sources[2] = {
4067 {
4068 .num_items = 7,
4069 .items = {
4070 { "MIC1 pin", 0x0 },
4071 { "MIC2 pin", 0x1 },
4072 { "LINE1 pin", 0x2 },
4073 { "LINE2 pin", 0x3 },
4074 { "CD pin", 0x4 },
4075 { "LINE-OUT pin", 0x5 },
4076 { "HP-OUT pin", 0x6 },
4077 },
4078 },
4079 {
4080 .num_items = 8,
4081 .items = {
4082 { "MIC1 pin", 0x0 },
4083 { "MIC2 pin", 0x1 },
4084 { "LINE1 pin", 0x2 },
4085 { "LINE2 pin", 0x3 },
4086 { "CD pin", 0x4 },
4087 { "Mixer", 0x5 },
4088 { "LINE-OUT pin", 0x6 },
4089 { "HP-OUT pin", 0x7 },
4090 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004091 },
4092};
4093static struct snd_kcontrol_new alc260_test_mixer[] = {
4094 /* Output driver widgets */
4095 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4096 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4097 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4098 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4099 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4100 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4101
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004102 /* Modes for retasking pin widgets
4103 * Note: the ALC260 doesn't seem to act on requests to enable mic
4104 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4105 * mention this restriction. At this stage it's not clear whether
4106 * this behaviour is intentional or is a hardware bug in chip
4107 * revisions available at least up until early 2006. Therefore for
4108 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4109 * choices, but if it turns out that the lack of mic bias for these
4110 * NIDs is intentional we could change their modes from
4111 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4112 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004113 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4114 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4115 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4116 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4117 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4118 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4119
4120 /* Loopback mixer controls */
4121 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4122 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4123 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4124 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4125 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4126 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4127 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4128 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4129 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4130 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4131 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4132 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4133 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4134 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4135 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4136 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004137
4138 /* Controls for GPIO pins, assuming they are configured as outputs */
4139 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4140 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4141 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4142 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4143
Jonathan Woithe92621f12006-02-28 11:47:47 +01004144 /* Switches to allow the digital IO pins to be enabled. The datasheet
4145 * is ambigious as to which NID is which; testing on laptops which
4146 * make this output available should provide clarification.
4147 */
4148 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4149 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4150
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004151 { } /* end */
4152};
4153static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004154 /* Enable all GPIOs as outputs with an initial value of 0 */
4155 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4156 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4157 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4158
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004159 /* Enable retasking pins as output, initially without power amp */
4160 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4161 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4164 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4165 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4166
Jonathan Woithe92621f12006-02-28 11:47:47 +01004167 /* Disable digital (SPDIF) pins initially, but users can enable
4168 * them via a mixer switch. In the case of SPDIF-out, this initverb
4169 * payload also sets the generation to 0, output to be in "consumer"
4170 * PCM format, copyright asserted, no pre-emphasis and no validity
4171 * control.
4172 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004173 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4174 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4175
Jonathan Woithef7ace402006-02-28 11:46:14 +01004176 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004177 * OUT1 sum bus when acting as an output.
4178 */
4179 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4180 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4181 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4182 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4183
4184 /* Start with output sum widgets muted and their output gains at min */
4185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4186 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4192 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4193 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4194
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004195 /* Unmute retasking pin widget output buffers since the default
4196 * state appears to be output. As the pin mode is changed by the
4197 * user the pin mode control will take care of enabling the pin's
4198 * input/output buffers as needed.
4199 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004200 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4203 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4204 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4205 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4206 /* Also unmute the mono-out pin widget */
4207 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4208
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004209 /* Mute capture amp left and right */
4210 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004211 /* Set ADC connection select to match default mixer setting (mic1
4212 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004213 */
4214 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4215
4216 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004217 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004218 */
4219 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4220 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4221
4222 /* Mute all inputs to mixer widget (even unconnected ones) */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4231
4232 { }
4233};
4234#endif
4235
Linus Torvalds1da177e2005-04-16 15:20:36 -07004236static struct hda_pcm_stream alc260_pcm_analog_playback = {
4237 .substreams = 1,
4238 .channels_min = 2,
4239 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004240};
4241
4242static struct hda_pcm_stream alc260_pcm_analog_capture = {
4243 .substreams = 1,
4244 .channels_min = 2,
4245 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004246};
4247
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004248#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4249#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4250
Kailang Yangdf694da2005-12-05 19:42:22 +01004251/*
4252 * for BIOS auto-configuration
4253 */
4254
4255static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4256 const char *pfx)
4257{
4258 hda_nid_t nid_vol;
4259 unsigned long vol_val, sw_val;
4260 char name[32];
4261 int err;
4262
4263 if (nid >= 0x0f && nid < 0x11) {
4264 nid_vol = nid - 0x7;
4265 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4266 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4267 } else if (nid == 0x11) {
4268 nid_vol = nid - 0x7;
4269 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4270 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4271 } else if (nid >= 0x12 && nid <= 0x15) {
4272 nid_vol = 0x08;
4273 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4274 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4275 } else
4276 return 0; /* N/A */
4277
4278 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004279 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4280 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004281 return err;
4282 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4284 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004285 return err;
4286 return 1;
4287}
4288
4289/* add playback controls from the parsed DAC table */
4290static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4291 const struct auto_pin_cfg *cfg)
4292{
4293 hda_nid_t nid;
4294 int err;
4295
4296 spec->multiout.num_dacs = 1;
4297 spec->multiout.dac_nids = spec->private_dac_nids;
4298 spec->multiout.dac_nids[0] = 0x02;
4299
4300 nid = cfg->line_out_pins[0];
4301 if (nid) {
4302 err = alc260_add_playback_controls(spec, nid, "Front");
4303 if (err < 0)
4304 return err;
4305 }
4306
Takashi Iwai82bc9552006-03-21 11:24:42 +01004307 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004308 if (nid) {
4309 err = alc260_add_playback_controls(spec, nid, "Speaker");
4310 if (err < 0)
4311 return err;
4312 }
4313
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004314 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004315 if (nid) {
4316 err = alc260_add_playback_controls(spec, nid, "Headphone");
4317 if (err < 0)
4318 return err;
4319 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004320 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004321}
4322
4323/* create playback/capture controls for input pins */
4324static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4325 const struct auto_pin_cfg *cfg)
4326{
Kailang Yangdf694da2005-12-05 19:42:22 +01004327 struct hda_input_mux *imux = &spec->private_imux;
4328 int i, err, idx;
4329
4330 for (i = 0; i < AUTO_PIN_LAST; i++) {
4331 if (cfg->input_pins[i] >= 0x12) {
4332 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004333 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004334 auto_pin_cfg_labels[i], idx,
4335 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004336 if (err < 0)
4337 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004338 imux->items[imux->num_items].label =
4339 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004340 imux->items[imux->num_items].index = idx;
4341 imux->num_items++;
4342 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004343 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004344 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004345 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004346 auto_pin_cfg_labels[i], idx,
4347 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 if (err < 0)
4349 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004350 imux->items[imux->num_items].label =
4351 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004352 imux->items[imux->num_items].index = idx;
4353 imux->num_items++;
4354 }
4355 }
4356 return 0;
4357}
4358
4359static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4360 hda_nid_t nid, int pin_type,
4361 int sel_idx)
4362{
4363 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4365 pin_type);
4366 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4367 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004368 /* need the manual connection? */
4369 if (nid >= 0x12) {
4370 int idx = nid - 0x12;
4371 snd_hda_codec_write(codec, idx + 0x0b, 0,
4372 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 }
4374}
4375
4376static void alc260_auto_init_multi_out(struct hda_codec *codec)
4377{
4378 struct alc_spec *spec = codec->spec;
4379 hda_nid_t nid;
4380
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004381 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004382 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004383 if (nid) {
4384 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4385 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4386 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004387
Takashi Iwai82bc9552006-03-21 11:24:42 +01004388 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004389 if (nid)
4390 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4391
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004392 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004393 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004394 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395}
Kailang Yangdf694da2005-12-05 19:42:22 +01004396
4397#define ALC260_PIN_CD_NID 0x16
4398static void alc260_auto_init_analog_input(struct hda_codec *codec)
4399{
4400 struct alc_spec *spec = codec->spec;
4401 int i;
4402
4403 for (i = 0; i < AUTO_PIN_LAST; i++) {
4404 hda_nid_t nid = spec->autocfg.input_pins[i];
4405 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004406 snd_hda_codec_write(codec, nid, 0,
4407 AC_VERB_SET_PIN_WIDGET_CONTROL,
4408 i <= AUTO_PIN_FRONT_MIC ?
4409 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004410 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004411 snd_hda_codec_write(codec, nid, 0,
4412 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004413 AMP_OUT_MUTE);
4414 }
4415 }
4416}
4417
4418/*
4419 * generic initialization of ADC, input mixers and output mixers
4420 */
4421static struct hda_verb alc260_volume_init_verbs[] = {
4422 /*
4423 * Unmute ADC0-1 and set the default input to mic-in
4424 */
4425 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4426 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4427 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4428 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4429
4430 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4431 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432 * Note: PASD motherboards uses the Line In 2 as the input for
4433 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004434 */
4435 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4441
4442 /*
4443 * Set up output mixers (0x08 - 0x0a)
4444 */
4445 /* set vol=0 to output mixers */
4446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4448 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4449 /* set up input amps for analog loopback */
4450 /* Amp Indices: DAC = 0, mixer = 1 */
4451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4455 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4456 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4457
4458 { }
4459};
4460
4461static int alc260_parse_auto_config(struct hda_codec *codec)
4462{
4463 struct alc_spec *spec = codec->spec;
4464 unsigned int wcap;
4465 int err;
4466 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004468 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4469 alc260_ignore);
4470 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004471 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4473 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004474 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004476 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4478 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004479 return err;
4480
4481 spec->multiout.max_channels = 2;
4482
4483 if (spec->autocfg.dig_out_pin)
4484 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4485 if (spec->kctl_alloc)
4486 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4487
4488 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4489
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004490 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004491 spec->input_mux = &spec->private_imux;
4492
4493 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004494 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004495 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4496 if (wcap != AC_WID_AUD_IN) {
4497 spec->adc_nids = alc260_adc_nids_alt;
4498 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4499 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 } else {
4501 spec->adc_nids = alc260_adc_nids;
4502 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4503 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004504 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004505 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004506
4507 return 1;
4508}
4509
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004510/* additional initialization for auto-configuration model */
4511static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004512{
Kailang Yangdf694da2005-12-05 19:42:22 +01004513 alc260_auto_init_multi_out(codec);
4514 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004515}
4516
4517/*
4518 * ALC260 configurations
4519 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004520static const char *alc260_models[ALC260_MODEL_LAST] = {
4521 [ALC260_BASIC] = "basic",
4522 [ALC260_HP] = "hp",
4523 [ALC260_HP_3013] = "hp-3013",
4524 [ALC260_FUJITSU_S702X] = "fujitsu",
4525 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004526 [ALC260_WILL] = "will",
4527 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004528#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004529 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004530#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004531 [ALC260_AUTO] = "auto",
4532};
4533
4534static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004535 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004536 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004537 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004538 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004539 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4540 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4541 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4542 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4543 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4544 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4545 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4546 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4547 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4548 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4549 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4550 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004551 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4552 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004553 {}
4554};
4555
Kailang Yangdf694da2005-12-05 19:42:22 +01004556static struct alc_config_preset alc260_presets[] = {
4557 [ALC260_BASIC] = {
4558 .mixers = { alc260_base_output_mixer,
4559 alc260_input_mixer,
4560 alc260_pc_beep_mixer,
4561 alc260_capture_mixer },
4562 .init_verbs = { alc260_init_verbs },
4563 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4564 .dac_nids = alc260_dac_nids,
4565 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4566 .adc_nids = alc260_adc_nids,
4567 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4568 .channel_mode = alc260_modes,
4569 .input_mux = &alc260_capture_source,
4570 },
4571 [ALC260_HP] = {
4572 .mixers = { alc260_base_output_mixer,
4573 alc260_input_mixer,
4574 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004575 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004576 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4577 .dac_nids = alc260_dac_nids,
4578 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4579 .adc_nids = alc260_hp_adc_nids,
4580 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4581 .channel_mode = alc260_modes,
4582 .input_mux = &alc260_capture_source,
4583 },
4584 [ALC260_HP_3013] = {
4585 .mixers = { alc260_hp_3013_mixer,
4586 alc260_input_mixer,
4587 alc260_capture_alt_mixer },
4588 .init_verbs = { alc260_hp_3013_init_verbs },
4589 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4590 .dac_nids = alc260_dac_nids,
4591 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4592 .adc_nids = alc260_hp_adc_nids,
4593 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4594 .channel_mode = alc260_modes,
4595 .input_mux = &alc260_capture_source,
4596 },
4597 [ALC260_FUJITSU_S702X] = {
4598 .mixers = { alc260_fujitsu_mixer,
4599 alc260_capture_mixer },
4600 .init_verbs = { alc260_fujitsu_init_verbs },
4601 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4602 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004603 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4604 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004605 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4606 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004607 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4608 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004610 [ALC260_ACER] = {
4611 .mixers = { alc260_acer_mixer,
4612 alc260_capture_mixer },
4613 .init_verbs = { alc260_acer_init_verbs },
4614 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4615 .dac_nids = alc260_dac_nids,
4616 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4617 .adc_nids = alc260_dual_adc_nids,
4618 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4619 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004620 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4621 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004622 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004623 [ALC260_WILL] = {
4624 .mixers = { alc260_will_mixer,
4625 alc260_capture_mixer },
4626 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4627 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4628 .dac_nids = alc260_dac_nids,
4629 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4630 .adc_nids = alc260_adc_nids,
4631 .dig_out_nid = ALC260_DIGOUT_NID,
4632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4633 .channel_mode = alc260_modes,
4634 .input_mux = &alc260_capture_source,
4635 },
4636 [ALC260_REPLACER_672V] = {
4637 .mixers = { alc260_replacer_672v_mixer,
4638 alc260_capture_mixer },
4639 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4640 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4641 .dac_nids = alc260_dac_nids,
4642 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4643 .adc_nids = alc260_adc_nids,
4644 .dig_out_nid = ALC260_DIGOUT_NID,
4645 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4646 .channel_mode = alc260_modes,
4647 .input_mux = &alc260_capture_source,
4648 .unsol_event = alc260_replacer_672v_unsol_event,
4649 .init_hook = alc260_replacer_672v_automute,
4650 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004651#ifdef CONFIG_SND_DEBUG
4652 [ALC260_TEST] = {
4653 .mixers = { alc260_test_mixer,
4654 alc260_capture_mixer },
4655 .init_verbs = { alc260_test_init_verbs },
4656 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4657 .dac_nids = alc260_test_dac_nids,
4658 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4659 .adc_nids = alc260_test_adc_nids,
4660 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4661 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004662 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4663 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004664 },
4665#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004666};
4667
Linus Torvalds1da177e2005-04-16 15:20:36 -07004668static int patch_alc260(struct hda_codec *codec)
4669{
4670 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004671 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004672
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004673 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004674 if (spec == NULL)
4675 return -ENOMEM;
4676
4677 codec->spec = spec;
4678
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004679 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4680 alc260_models,
4681 alc260_cfg_tbl);
4682 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004683 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4684 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004685 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 }
4687
Kailang Yangdf694da2005-12-05 19:42:22 +01004688 if (board_config == ALC260_AUTO) {
4689 /* automatic parse from the BIOS config */
4690 err = alc260_parse_auto_config(codec);
4691 if (err < 0) {
4692 alc_free(codec);
4693 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004694 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004695 printk(KERN_INFO
4696 "hda_codec: Cannot set up configuration "
4697 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 board_config = ALC260_BASIC;
4699 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004700 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004701
Kailang Yangdf694da2005-12-05 19:42:22 +01004702 if (board_config != ALC260_AUTO)
4703 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004704
4705 spec->stream_name_analog = "ALC260 Analog";
4706 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4707 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4708
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004709 spec->stream_name_digital = "ALC260 Digital";
4710 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4711 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4712
Linus Torvalds1da177e2005-04-16 15:20:36 -07004713 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004714 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004715 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004716
4717 return 0;
4718}
4719
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720
Linus Torvalds1da177e2005-04-16 15:20:36 -07004721/*
4722 * ALC882 support
4723 *
4724 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4725 * configuration. Each pin widget can choose any input DACs and a mixer.
4726 * Each ADC is connected from a mixer of all inputs. This makes possible
4727 * 6-channel independent captures.
4728 *
4729 * In addition, an independent DAC for the multi-playback (not used in this
4730 * driver yet).
4731 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004732#define ALC882_DIGOUT_NID 0x06
4733#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004734
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004735static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004736 { 8, NULL }
4737};
4738
4739static hda_nid_t alc882_dac_nids[4] = {
4740 /* front, rear, clfe, rear_surr */
4741 0x02, 0x03, 0x04, 0x05
4742};
4743
Kailang Yangdf694da2005-12-05 19:42:22 +01004744/* identical with ALC880 */
4745#define alc882_adc_nids alc880_adc_nids
4746#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747
4748/* input MUX */
4749/* FIXME: should be a matrix-type input source selection */
4750
4751static struct hda_input_mux alc882_capture_source = {
4752 .num_items = 4,
4753 .items = {
4754 { "Mic", 0x0 },
4755 { "Front Mic", 0x1 },
4756 { "Line", 0x2 },
4757 { "CD", 0x4 },
4758 },
4759};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004760#define alc882_mux_enum_info alc_mux_enum_info
4761#define alc882_mux_enum_get alc_mux_enum_get
4762
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004763static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4764 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004765{
4766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4767 struct alc_spec *spec = codec->spec;
4768 const struct hda_input_mux *imux = spec->input_mux;
4769 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4770 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4771 hda_nid_t nid = capture_mixers[adc_idx];
4772 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4773 unsigned int i, idx;
4774
4775 idx = ucontrol->value.enumerated.item[0];
4776 if (idx >= imux->num_items)
4777 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004778 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004779 return 0;
4780 for (i = 0; i < imux->num_items; i++) {
4781 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4783 v | (imux->items[i].index << 8));
4784 }
4785 *cur_val = idx;
4786 return 1;
4787}
4788
Kailang Yangdf694da2005-12-05 19:42:22 +01004789/*
Kailang Yang272a5272007-05-14 11:00:38 +02004790 * 2ch mode
4791 */
4792static struct hda_verb alc882_3ST_ch2_init[] = {
4793 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4794 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4795 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4796 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4797 { } /* end */
4798};
4799
4800/*
4801 * 6ch mode
4802 */
4803static struct hda_verb alc882_3ST_ch6_init[] = {
4804 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4805 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4806 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4807 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4808 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4809 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4810 { } /* end */
4811};
4812
4813static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4814 { 2, alc882_3ST_ch2_init },
4815 { 6, alc882_3ST_ch6_init },
4816};
4817
4818/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004819 * 6ch mode
4820 */
4821static struct hda_verb alc882_sixstack_ch6_init[] = {
4822 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4823 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4824 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4825 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4826 { } /* end */
4827};
4828
4829/*
4830 * 8ch mode
4831 */
4832static struct hda_verb alc882_sixstack_ch8_init[] = {
4833 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4834 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4835 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4836 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4837 { } /* end */
4838};
4839
4840static struct hda_channel_mode alc882_sixstack_modes[2] = {
4841 { 6, alc882_sixstack_ch6_init },
4842 { 8, alc882_sixstack_ch8_init },
4843};
4844
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4846 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4847 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004848static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004851 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004852 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004853 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4854 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004855 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4856 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004857 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004858 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4870 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4871 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004872 { } /* end */
4873};
4874
Kailang Yangbdd148a2007-05-08 15:19:08 +02004875static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4883 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4885 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4886 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4887 { } /* end */
4888};
4889
Kailang Yang272a5272007-05-14 11:00:38 +02004890static struct snd_kcontrol_new alc882_targa_mixer[] = {
4891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4896 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4897 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4902 { } /* end */
4903};
4904
4905/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4906 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4907 */
4908static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4910 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4912 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4918 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4921 { } /* end */
4922};
4923
Kailang Yangdf694da2005-12-05 19:42:22 +01004924static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4925 {
4926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4927 .name = "Channel Mode",
4928 .info = alc_ch_mode_info,
4929 .get = alc_ch_mode_get,
4930 .put = alc_ch_mode_put,
4931 },
4932 { } /* end */
4933};
4934
Linus Torvalds1da177e2005-04-16 15:20:36 -07004935static struct hda_verb alc882_init_verbs[] = {
4936 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004944 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004948 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004952
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004953 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004956 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004961 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004964 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004965 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004966 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004968 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004969 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004971 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4972 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4975 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004976 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4978 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4980 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4981 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004982 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004983 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004984
4985 /* FIXME: use matrix-type input source selection */
4986 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4987 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004992 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5002 /* ADC1: mute amp left and right */
5003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005004 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005005 /* ADC2: mute amp left and right */
5006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005007 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005008 /* ADC3: mute amp left and right */
5009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005011
5012 { }
5013};
5014
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005015static struct hda_verb alc882_eapd_verbs[] = {
5016 /* change to EAPD mode */
5017 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005018 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005019 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005020};
5021
Tobin Davis9102cd12006-12-15 10:02:12 +01005022/* Mac Pro test */
5023static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5025 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5029 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5030 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5031 { } /* end */
5032};
5033
5034static struct hda_verb alc882_macpro_init_verbs[] = {
5035 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5039 /* Front Pin: output 0 (0x0c) */
5040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5043 /* Front Mic pin: input vref at 80% */
5044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5046 /* Speaker: output */
5047 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5049 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5050 /* Headphone output (output 0 - 0x0c) */
5051 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5053 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5054
5055 /* FIXME: use matrix-type input source selection */
5056 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5057 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5062 /* Input mixer2 */
5063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5067 /* Input mixer3 */
5068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5072 /* ADC1: mute amp left and right */
5073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5074 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5075 /* ADC2: mute amp left and right */
5076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5077 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5078 /* ADC3: mute amp left and right */
5079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5081
5082 { }
5083};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005084
Kailang Yang272a5272007-05-14 11:00:38 +02005085static struct hda_verb alc882_targa_verbs[] = {
5086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5088
5089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5091
5092 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5093 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5095
5096 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5097 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5098 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5099 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5100 { } /* end */
5101};
5102
5103/* toggle speaker-output according to the hp-jack state */
5104static void alc882_targa_automute(struct hda_codec *codec)
5105{
5106 unsigned int present;
5107
5108 present = snd_hda_codec_read(codec, 0x14, 0,
5109 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5110 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5111 0x80, present ? 0x80 : 0);
5112 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5113 0x80, present ? 0x80 : 0);
5114 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5115}
5116
5117static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5118{
5119 /* Looks like the unsol event is incompatible with the standard
5120 * definition. 4bit tag is placed at 26 bit!
5121 */
5122 if (((res >> 26) == ALC880_HP_EVENT)) {
5123 alc882_targa_automute(codec);
5124 }
5125}
5126
5127static struct hda_verb alc882_asus_a7j_verbs[] = {
5128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5130
5131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5134
5135 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5137 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5138
5139 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5140 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5141 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5142 { } /* end */
5143};
5144
Tobin Davis9102cd12006-12-15 10:02:12 +01005145static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5146{
5147 unsigned int gpiostate, gpiomask, gpiodir;
5148
5149 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5150 AC_VERB_GET_GPIO_DATA, 0);
5151
5152 if (!muted)
5153 gpiostate |= (1 << pin);
5154 else
5155 gpiostate &= ~(1 << pin);
5156
5157 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5158 AC_VERB_GET_GPIO_MASK, 0);
5159 gpiomask |= (1 << pin);
5160
5161 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5162 AC_VERB_GET_GPIO_DIRECTION, 0);
5163 gpiodir |= (1 << pin);
5164
5165
5166 snd_hda_codec_write(codec, codec->afg, 0,
5167 AC_VERB_SET_GPIO_MASK, gpiomask);
5168 snd_hda_codec_write(codec, codec->afg, 0,
5169 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5170
5171 msleep(1);
5172
5173 snd_hda_codec_write(codec, codec->afg, 0,
5174 AC_VERB_SET_GPIO_DATA, gpiostate);
5175}
5176
Kailang Yangdf694da2005-12-05 19:42:22 +01005177/*
5178 * generic initialization of ADC, input mixers and output mixers
5179 */
5180static struct hda_verb alc882_auto_init_verbs[] = {
5181 /*
5182 * Unmute ADC0-2 and set the default input to mic-in
5183 */
5184 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5188 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190
5191 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5192 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005193 * Note: PASD motherboards uses the Line In 2 as the input for
5194 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005195 */
5196 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5202
5203 /*
5204 * Set up output mixers (0x0c - 0x0f)
5205 */
5206 /* set vol=0 to output mixers */
5207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5210 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211 /* set up input amps for analog loopback */
5212 /* Amp Indices: DAC = 0, mixer = 1 */
5213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5217 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5222 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5223
5224 /* FIXME: use matrix-type input source selection */
5225 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5226 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5231 /* Input mixer2 */
5232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5236 /* Input mixer3 */
5237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5241
5242 { }
5243};
5244
5245/* capture mixer elements */
5246static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5247 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5251 {
5252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5253 /* The multiple "Capture Source" controls confuse alsamixer
5254 * So call somewhat different..
5255 * FIXME: the controls appear in the "playback" view!
5256 */
5257 /* .name = "Capture Source", */
5258 .name = "Input Source",
5259 .count = 2,
5260 .info = alc882_mux_enum_info,
5261 .get = alc882_mux_enum_get,
5262 .put = alc882_mux_enum_put,
5263 },
5264 { } /* end */
5265};
5266
5267static struct snd_kcontrol_new alc882_capture_mixer[] = {
5268 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5269 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5270 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5271 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5272 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5273 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5274 {
5275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5276 /* The multiple "Capture Source" controls confuse alsamixer
5277 * So call somewhat different..
5278 * FIXME: the controls appear in the "playback" view!
5279 */
5280 /* .name = "Capture Source", */
5281 .name = "Input Source",
5282 .count = 3,
5283 .info = alc882_mux_enum_info,
5284 .get = alc882_mux_enum_get,
5285 .put = alc882_mux_enum_put,
5286 },
5287 { } /* end */
5288};
5289
5290/* pcm configuration: identiacal with ALC880 */
5291#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5292#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5293#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5294#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5295
5296/*
5297 * configuration and preset
5298 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005299static const char *alc882_models[ALC882_MODEL_LAST] = {
5300 [ALC882_3ST_DIG] = "3stack-dig",
5301 [ALC882_6ST_DIG] = "6stack-dig",
5302 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005303 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005304 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005305 [ALC882_AUTO] = "auto",
5306};
5307
5308static struct snd_pci_quirk alc882_cfg_tbl[] = {
5309 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5310 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5311 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005312 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005313 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005314 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005315 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005316 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005317 {}
5318};
5319
5320static struct alc_config_preset alc882_presets[] = {
5321 [ALC882_3ST_DIG] = {
5322 .mixers = { alc882_base_mixer },
5323 .init_verbs = { alc882_init_verbs },
5324 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5325 .dac_nids = alc882_dac_nids,
5326 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005327 .dig_in_nid = ALC882_DIGIN_NID,
5328 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5329 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005330 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005331 .input_mux = &alc882_capture_source,
5332 },
5333 [ALC882_6ST_DIG] = {
5334 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5335 .init_verbs = { alc882_init_verbs },
5336 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5337 .dac_nids = alc882_dac_nids,
5338 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005339 .dig_in_nid = ALC882_DIGIN_NID,
5340 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5341 .channel_mode = alc882_sixstack_modes,
5342 .input_mux = &alc882_capture_source,
5343 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005344 [ALC882_ARIMA] = {
5345 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5346 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5347 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5348 .dac_nids = alc882_dac_nids,
5349 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5350 .channel_mode = alc882_sixstack_modes,
5351 .input_mux = &alc882_capture_source,
5352 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005353 [ALC882_W2JC] = {
5354 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5355 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5356 alc880_gpio1_init_verbs },
5357 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5358 .dac_nids = alc882_dac_nids,
5359 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5360 .channel_mode = alc880_threestack_modes,
5361 .need_dac_fix = 1,
5362 .input_mux = &alc882_capture_source,
5363 .dig_out_nid = ALC882_DIGOUT_NID,
5364 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005365 [ALC885_MACPRO] = {
5366 .mixers = { alc882_macpro_mixer },
5367 .init_verbs = { alc882_macpro_init_verbs },
5368 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5369 .dac_nids = alc882_dac_nids,
5370 .dig_out_nid = ALC882_DIGOUT_NID,
5371 .dig_in_nid = ALC882_DIGIN_NID,
5372 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5373 .channel_mode = alc882_ch_modes,
5374 .input_mux = &alc882_capture_source,
5375 },
Kailang Yang272a5272007-05-14 11:00:38 +02005376 [ALC882_TARGA] = {
5377 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5378 alc882_capture_mixer },
5379 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5380 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5381 .dac_nids = alc882_dac_nids,
5382 .dig_out_nid = ALC882_DIGOUT_NID,
5383 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5384 .adc_nids = alc882_adc_nids,
5385 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5386 .channel_mode = alc882_3ST_6ch_modes,
5387 .need_dac_fix = 1,
5388 .input_mux = &alc882_capture_source,
5389 .unsol_event = alc882_targa_unsol_event,
5390 .init_hook = alc882_targa_automute,
5391 },
5392 [ALC882_ASUS_A7J] = {
5393 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5394 alc882_capture_mixer },
5395 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5396 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5397 .dac_nids = alc882_dac_nids,
5398 .dig_out_nid = ALC882_DIGOUT_NID,
5399 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5400 .adc_nids = alc882_adc_nids,
5401 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5402 .channel_mode = alc882_3ST_6ch_modes,
5403 .need_dac_fix = 1,
5404 .input_mux = &alc882_capture_source,
5405 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005406};
5407
5408
5409/*
5410 * BIOS auto configuration
5411 */
5412static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5413 hda_nid_t nid, int pin_type,
5414 int dac_idx)
5415{
5416 /* set as output */
5417 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005418 int idx;
5419
Kailang Yangdf694da2005-12-05 19:42:22 +01005420 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5421 idx = 4;
5422 else
5423 idx = spec->multiout.dac_nids[dac_idx] - 2;
5424
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005425 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5426 pin_type);
5427 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5428 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005429 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5430
5431}
5432
5433static void alc882_auto_init_multi_out(struct hda_codec *codec)
5434{
5435 struct alc_spec *spec = codec->spec;
5436 int i;
5437
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005438 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005439 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005440 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005441 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005442 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005443 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005444 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005445 }
5446}
5447
5448static void alc882_auto_init_hp_out(struct hda_codec *codec)
5449{
5450 struct alc_spec *spec = codec->spec;
5451 hda_nid_t pin;
5452
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005453 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005454 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005455 /* use dac 0 */
5456 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005457}
5458
5459#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5460#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5461
5462static void alc882_auto_init_analog_input(struct hda_codec *codec)
5463{
5464 struct alc_spec *spec = codec->spec;
5465 int i;
5466
5467 for (i = 0; i < AUTO_PIN_LAST; i++) {
5468 hda_nid_t nid = spec->autocfg.input_pins[i];
5469 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005470 snd_hda_codec_write(codec, nid, 0,
5471 AC_VERB_SET_PIN_WIDGET_CONTROL,
5472 i <= AUTO_PIN_FRONT_MIC ?
5473 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005474 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005475 snd_hda_codec_write(codec, nid, 0,
5476 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005477 AMP_OUT_MUTE);
5478 }
5479 }
5480}
5481
5482/* almost identical with ALC880 parser... */
5483static int alc882_parse_auto_config(struct hda_codec *codec)
5484{
5485 struct alc_spec *spec = codec->spec;
5486 int err = alc880_parse_auto_config(codec);
5487
5488 if (err < 0)
5489 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005490 else if (err > 0)
5491 /* hack - override the init verbs */
5492 spec->init_verbs[0] = alc882_auto_init_verbs;
5493 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005494}
5495
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005496/* additional initialization for auto-configuration model */
5497static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005498{
Kailang Yangdf694da2005-12-05 19:42:22 +01005499 alc882_auto_init_multi_out(codec);
5500 alc882_auto_init_hp_out(codec);
5501 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005502}
5503
Linus Torvalds1da177e2005-04-16 15:20:36 -07005504static int patch_alc882(struct hda_codec *codec)
5505{
5506 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005507 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005508
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 if (spec == NULL)
5511 return -ENOMEM;
5512
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 codec->spec = spec;
5514
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005515 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5516 alc882_models,
5517 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518
Kailang Yangdf694da2005-12-05 19:42:22 +01005519 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005520 /* Pick up systems that don't supply PCI SSID */
5521 switch (codec->subsystem_id) {
5522 case 0x106b0c00: /* Mac Pro */
5523 board_config = ALC885_MACPRO;
5524 break;
5525 default:
5526 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5527 "trying auto-probe from BIOS...\n");
5528 board_config = ALC882_AUTO;
5529 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005530 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005531
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 if (board_config == ALC882_AUTO) {
5533 /* automatic parse from the BIOS config */
5534 err = alc882_parse_auto_config(codec);
5535 if (err < 0) {
5536 alc_free(codec);
5537 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005538 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005539 printk(KERN_INFO
5540 "hda_codec: Cannot set up configuration "
5541 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005542 board_config = ALC882_3ST_DIG;
5543 }
5544 }
5545
5546 if (board_config != ALC882_AUTO)
5547 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005548
Tobin Davis9102cd12006-12-15 10:02:12 +01005549 if (board_config == ALC885_MACPRO) {
5550 alc882_gpio_mute(codec, 0, 0);
5551 alc882_gpio_mute(codec, 1, 0);
5552 }
5553
Linus Torvalds1da177e2005-04-16 15:20:36 -07005554 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5556 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557
5558 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005559 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5560 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005561
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005562 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005563 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005564 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 /* get type */
5566 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005567 if (wcap != AC_WID_AUD_IN) {
5568 spec->adc_nids = alc882_adc_nids_alt;
5569 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005570 spec->mixers[spec->num_mixers] =
5571 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005572 spec->num_mixers++;
5573 } else {
5574 spec->adc_nids = alc882_adc_nids;
5575 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5576 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5577 spec->num_mixers++;
5578 }
5579 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005580
5581 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005582 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005583 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005584
5585 return 0;
5586}
5587
5588/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005589 * ALC883 support
5590 *
5591 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5592 * configuration. Each pin widget can choose any input DACs and a mixer.
5593 * Each ADC is connected from a mixer of all inputs. This makes possible
5594 * 6-channel independent captures.
5595 *
5596 * In addition, an independent DAC for the multi-playback (not used in this
5597 * driver yet).
5598 */
5599#define ALC883_DIGOUT_NID 0x06
5600#define ALC883_DIGIN_NID 0x0a
5601
5602static hda_nid_t alc883_dac_nids[4] = {
5603 /* front, rear, clfe, rear_surr */
5604 0x02, 0x04, 0x03, 0x05
5605};
5606
5607static hda_nid_t alc883_adc_nids[2] = {
5608 /* ADC1-2 */
5609 0x08, 0x09,
5610};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005611
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005612/* input MUX */
5613/* FIXME: should be a matrix-type input source selection */
5614
5615static struct hda_input_mux alc883_capture_source = {
5616 .num_items = 4,
5617 .items = {
5618 { "Mic", 0x0 },
5619 { "Front Mic", 0x1 },
5620 { "Line", 0x2 },
5621 { "CD", 0x4 },
5622 },
5623};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005624
5625static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5626 .num_items = 2,
5627 .items = {
5628 { "Mic", 0x1 },
5629 { "Line", 0x2 },
5630 },
5631};
5632
Kailang Yang272a5272007-05-14 11:00:38 +02005633static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5634 .num_items = 4,
5635 .items = {
5636 { "Mic", 0x0 },
5637 { "iMic", 0x1 },
5638 { "Line", 0x2 },
5639 { "CD", 0x4 },
5640 },
5641};
5642
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005643#define alc883_mux_enum_info alc_mux_enum_info
5644#define alc883_mux_enum_get alc_mux_enum_get
5645
5646static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5647 struct snd_ctl_elem_value *ucontrol)
5648{
5649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5650 struct alc_spec *spec = codec->spec;
5651 const struct hda_input_mux *imux = spec->input_mux;
5652 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5653 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5654 hda_nid_t nid = capture_mixers[adc_idx];
5655 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5656 unsigned int i, idx;
5657
5658 idx = ucontrol->value.enumerated.item[0];
5659 if (idx >= imux->num_items)
5660 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005661 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005662 return 0;
5663 for (i = 0; i < imux->num_items; i++) {
5664 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5665 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5666 v | (imux->items[i].index << 8));
5667 }
5668 *cur_val = idx;
5669 return 1;
5670}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005672/*
5673 * 2ch mode
5674 */
5675static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5676 { 2, NULL }
5677};
5678
5679/*
5680 * 2ch mode
5681 */
5682static struct hda_verb alc883_3ST_ch2_init[] = {
5683 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5684 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5685 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5686 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5687 { } /* end */
5688};
5689
5690/*
5691 * 6ch mode
5692 */
5693static struct hda_verb alc883_3ST_ch6_init[] = {
5694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5696 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5699 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5700 { } /* end */
5701};
5702
5703static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5704 { 2, alc883_3ST_ch2_init },
5705 { 6, alc883_3ST_ch6_init },
5706};
5707
5708/*
5709 * 6ch mode
5710 */
5711static struct hda_verb alc883_sixstack_ch6_init[] = {
5712 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5713 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5714 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5715 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5716 { } /* end */
5717};
5718
5719/*
5720 * 8ch mode
5721 */
5722static struct hda_verb alc883_sixstack_ch8_init[] = {
5723 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5724 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5725 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5726 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5727 { } /* end */
5728};
5729
5730static struct hda_channel_mode alc883_sixstack_modes[2] = {
5731 { 6, alc883_sixstack_ch6_init },
5732 { 8, alc883_sixstack_ch8_init },
5733};
5734
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005735static struct hda_verb alc883_medion_eapd_verbs[] = {
5736 /* eanable EAPD on medion laptop */
5737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5738 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5739 { }
5740};
5741
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005742/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5743 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5744 */
5745
5746static struct snd_kcontrol_new alc883_base_mixer[] = {
5747 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5748 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5750 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5751 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5752 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5753 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5754 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005766 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5768 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5769 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5770 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5771 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5772 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5773 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5774 {
5775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5776 /* .name = "Capture Source", */
5777 .name = "Input Source",
5778 .count = 2,
5779 .info = alc883_mux_enum_info,
5780 .get = alc883_mux_enum_get,
5781 .put = alc883_mux_enum_put,
5782 },
5783 { } /* end */
5784};
5785
5786static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5790 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5791 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5797 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005798 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5800 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5801 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5804 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5805 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5806 {
5807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5808 /* .name = "Capture Source", */
5809 .name = "Input Source",
5810 .count = 2,
5811 .info = alc883_mux_enum_info,
5812 .get = alc883_mux_enum_get,
5813 .put = alc883_mux_enum_put,
5814 },
5815 { } /* end */
5816};
5817
5818static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5820 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5822 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5823 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5825 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5826 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5829 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005833 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005836 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5838 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5839 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5840 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5841 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5842 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5843 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5844 {
5845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5846 /* .name = "Capture Source", */
5847 .name = "Input Source",
5848 .count = 2,
5849 .info = alc883_mux_enum_info,
5850 .get = alc883_mux_enum_get,
5851 .put = alc883_mux_enum_put,
5852 },
5853 { } /* end */
5854};
5855
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005856static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5858 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5860 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005875 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5876 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5877 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5878 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5879 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5880
5881 {
5882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5883 /* .name = "Capture Source", */
5884 .name = "Input Source",
5885 .count = 1,
5886 .info = alc883_mux_enum_info,
5887 .get = alc883_mux_enum_get,
5888 .put = alc883_mux_enum_put,
5889 },
5890 { } /* end */
5891};
5892
Kailang Yangccc656c2006-10-17 12:32:26 +02005893static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5896 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5897 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5898 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5899 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5901 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5902 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5903 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5904 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005908 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5910 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5911 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5912 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5913 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5914 {
5915 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5916 /* .name = "Capture Source", */
5917 .name = "Input Source",
5918 .count = 2,
5919 .info = alc883_mux_enum_info,
5920 .get = alc883_mux_enum_get,
5921 .put = alc883_mux_enum_put,
5922 },
5923 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005924};
Kailang Yangccc656c2006-10-17 12:32:26 +02005925
5926static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5929 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005933 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5935 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5936 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5937 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5938 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5939 {
5940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5941 /* .name = "Capture Source", */
5942 .name = "Input Source",
5943 .count = 2,
5944 .info = alc883_mux_enum_info,
5945 .get = alc883_mux_enum_get,
5946 .put = alc883_mux_enum_put,
5947 },
5948 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005949};
Kailang Yangccc656c2006-10-17 12:32:26 +02005950
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005951static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5952 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5953 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5954 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5955 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5960 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5962 {
5963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5964 /* .name = "Capture Source", */
5965 .name = "Input Source",
5966 .count = 1,
5967 .info = alc883_mux_enum_info,
5968 .get = alc883_mux_enum_get,
5969 .put = alc883_mux_enum_put,
5970 },
5971 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005972};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005973
Kailang Yang272a5272007-05-14 11:00:38 +02005974static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5975 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5976 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5979 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5982 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5983 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5984 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5985 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5986 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5988 {
5989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5990 /* .name = "Capture Source", */
5991 .name = "Input Source",
5992 .count = 2,
5993 .info = alc883_mux_enum_info,
5994 .get = alc883_mux_enum_get,
5995 .put = alc883_mux_enum_put,
5996 },
5997 { } /* end */
5998};
5999
6000static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6001 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6003 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6010 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6011 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6012 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6013 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6014 {
6015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6016 /* .name = "Capture Source", */
6017 .name = "Input Source",
6018 .count = 2,
6019 .info = alc883_mux_enum_info,
6020 .get = alc883_mux_enum_get,
6021 .put = alc883_mux_enum_put,
6022 },
6023 { } /* end */
6024};
6025
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006026static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6027 {
6028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6029 .name = "Channel Mode",
6030 .info = alc_ch_mode_info,
6031 .get = alc_ch_mode_get,
6032 .put = alc_ch_mode_put,
6033 },
6034 { } /* end */
6035};
6036
6037static struct hda_verb alc883_init_verbs[] = {
6038 /* ADC1: mute amp left and right */
6039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6040 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6041 /* ADC2: mute amp left and right */
6042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6043 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6044 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6048 /* Rear mixer */
6049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6052 /* CLFE mixer */
6053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6056 /* Side mixer */
6057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6059 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6060
6061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6066
6067 /* Front Pin: output 0 (0x0c) */
6068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6070 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6071 /* Rear Pin: output 1 (0x0d) */
6072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6075 /* CLFE Pin: output 2 (0x0e) */
6076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6078 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6079 /* Side Pin: output 3 (0x0f) */
6080 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6082 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6083 /* Mic (rear) pin: input vref at 80% */
6084 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6086 /* Front Mic pin: input vref at 80% */
6087 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6089 /* Line In pin: input */
6090 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6092 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6094 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6096 /* CD pin widget for input */
6097 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6098
6099 /* FIXME: use matrix-type input source selection */
6100 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6101 /* Input mixer2 */
6102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6106 /* Input mixer3 */
6107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6111 { }
6112};
6113
Kailang Yangccc656c2006-10-17 12:32:26 +02006114static struct hda_verb alc883_tagra_verbs[] = {
6115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6117
6118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6120
6121 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6122 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6123 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6124
6125 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006126 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6127 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6128 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006129
6130 { } /* end */
6131};
6132
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006133static struct hda_verb alc883_lenovo_101e_verbs[] = {
6134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6136 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6137 { } /* end */
6138};
6139
Kailang Yang272a5272007-05-14 11:00:38 +02006140static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6141 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6145 { } /* end */
6146};
6147
6148static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6152 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6153 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6154 { } /* end */
6155};
6156
6157/* toggle front-jack and RCA according to the hp-jack state */
6158static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6159{
6160 unsigned int present;
6161
6162 present = snd_hda_codec_read(codec, 0x1b, 0,
6163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6164 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6165 0x80, present ? 0x80 : 0);
6166 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6167 0x80, present ? 0x80 : 0);
6168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6169 0x80, present ? 0x80 : 0);
6170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6171 0x80, present ? 0x80 : 0);
6172
6173}
6174
6175/* toggle RCA according to the front-jack state */
6176static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6177{
6178 unsigned int present;
6179
6180 present = snd_hda_codec_read(codec, 0x14, 0,
6181 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6182 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6183 0x80, present ? 0x80 : 0);
6184 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6185 0x80, present ? 0x80 : 0);
6186
6187}
6188static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6189 unsigned int res)
6190{
6191 if ((res >> 26) == ALC880_HP_EVENT)
6192 alc888_lenovo_ms7195_front_automute(codec);
6193 if ((res >> 26) == ALC880_FRONT_EVENT)
6194 alc888_lenovo_ms7195_rca_automute(codec);
6195}
6196
6197static struct hda_verb alc883_medion_md2_verbs[] = {
6198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6200
6201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6202
6203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6204 { } /* end */
6205};
6206
6207/* toggle speaker-output according to the hp-jack state */
6208static void alc883_medion_md2_automute(struct hda_codec *codec)
6209{
6210 unsigned int present;
6211
6212 present = snd_hda_codec_read(codec, 0x14, 0,
6213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6214 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6215 0x80, present ? 0x80 : 0);
6216 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6217 0x80, present ? 0x80 : 0);
6218}
6219
6220static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6221 unsigned int res)
6222{
6223 if ((res >> 26) == ALC880_HP_EVENT)
6224 alc883_medion_md2_automute(codec);
6225}
6226
Kailang Yangccc656c2006-10-17 12:32:26 +02006227/* toggle speaker-output according to the hp-jack state */
6228static void alc883_tagra_automute(struct hda_codec *codec)
6229{
6230 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006231 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006232
6233 present = snd_hda_codec_read(codec, 0x14, 0,
6234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006235 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006236 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006237 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006238 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 0x80, bits);
6240 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6241 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006242}
6243
6244static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6245{
6246 if ((res >> 26) == ALC880_HP_EVENT)
6247 alc883_tagra_automute(codec);
6248}
6249
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006250static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6251{
6252 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006253 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006254
6255 present = snd_hda_codec_read(codec, 0x14, 0,
6256 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006257 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006258 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006260 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006261 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006262}
6263
6264static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6265{
6266 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006267 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006268
6269 present = snd_hda_codec_read(codec, 0x1b, 0,
6270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006271 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006272 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006273 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006274 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006275 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006276 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006277 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006278 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006279 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006280}
6281
6282static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6283 unsigned int res)
6284{
6285 if ((res >> 26) == ALC880_HP_EVENT)
6286 alc883_lenovo_101e_all_automute(codec);
6287 if ((res >> 26) == ALC880_FRONT_EVENT)
6288 alc883_lenovo_101e_ispeaker_automute(codec);
6289}
6290
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006291/*
6292 * generic initialization of ADC, input mixers and output mixers
6293 */
6294static struct hda_verb alc883_auto_init_verbs[] = {
6295 /*
6296 * Unmute ADC0-2 and set the default input to mic-in
6297 */
6298 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6302
6303 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6304 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006305 * Note: PASD motherboards uses the Line In 2 as the input for
6306 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006307 */
6308 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6314
6315 /*
6316 * Set up output mixers (0x0c - 0x0f)
6317 */
6318 /* set vol=0 to output mixers */
6319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6322 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6323 /* set up input amps for analog loopback */
6324 /* Amp Indices: DAC = 0, mixer = 1 */
6325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6332 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6333 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6334 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6335
6336 /* FIXME: use matrix-type input source selection */
6337 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6338 /* Input mixer1 */
6339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006342 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6344 /* Input mixer2 */
6345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006348 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6350
6351 { }
6352};
6353
6354/* capture mixer elements */
6355static struct snd_kcontrol_new alc883_capture_mixer[] = {
6356 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6358 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6359 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6360 {
6361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6362 /* The multiple "Capture Source" controls confuse alsamixer
6363 * So call somewhat different..
6364 * FIXME: the controls appear in the "playback" view!
6365 */
6366 /* .name = "Capture Source", */
6367 .name = "Input Source",
6368 .count = 2,
6369 .info = alc882_mux_enum_info,
6370 .get = alc882_mux_enum_get,
6371 .put = alc882_mux_enum_put,
6372 },
6373 { } /* end */
6374};
6375
6376/* pcm configuration: identiacal with ALC880 */
6377#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6378#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6379#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6380#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6381
6382/*
6383 * configuration and preset
6384 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006385static const char *alc883_models[ALC883_MODEL_LAST] = {
6386 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6387 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6388 [ALC883_3ST_6ch] = "3stack-6ch",
6389 [ALC883_6ST_DIG] = "6stack-dig",
6390 [ALC883_TARGA_DIG] = "targa-dig",
6391 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006392 [ALC883_ACER] = "acer",
6393 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006394 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006395 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006396 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006397 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6398 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006399 [ALC883_AUTO] = "auto",
6400};
6401
6402static struct snd_pci_quirk alc883_cfg_tbl[] = {
6403 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006404 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006405 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6406 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6407 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006408 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006409 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6410 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006411 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006412 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006413 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006414 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006415 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006416 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6417 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6418 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6419 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6420 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6421 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6422 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6423 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6424 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6425 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006426 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006427 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6428 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6429 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006430 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6431 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6432 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka8f41b562007-07-03 20:02:49 +02006433 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006434 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006435 {}
6436};
6437
6438static struct alc_config_preset alc883_presets[] = {
6439 [ALC883_3ST_2ch_DIG] = {
6440 .mixers = { alc883_3ST_2ch_mixer },
6441 .init_verbs = { alc883_init_verbs },
6442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6443 .dac_nids = alc883_dac_nids,
6444 .dig_out_nid = ALC883_DIGOUT_NID,
6445 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6446 .adc_nids = alc883_adc_nids,
6447 .dig_in_nid = ALC883_DIGIN_NID,
6448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6449 .channel_mode = alc883_3ST_2ch_modes,
6450 .input_mux = &alc883_capture_source,
6451 },
6452 [ALC883_3ST_6ch_DIG] = {
6453 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6454 .init_verbs = { alc883_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6456 .dac_nids = alc883_dac_nids,
6457 .dig_out_nid = ALC883_DIGOUT_NID,
6458 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6459 .adc_nids = alc883_adc_nids,
6460 .dig_in_nid = ALC883_DIGIN_NID,
6461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6462 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006463 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006464 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006465 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006466 [ALC883_3ST_6ch] = {
6467 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6468 .init_verbs = { alc883_init_verbs },
6469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6470 .dac_nids = alc883_dac_nids,
6471 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6472 .adc_nids = alc883_adc_nids,
6473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6474 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006475 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006476 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006477 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006478 [ALC883_6ST_DIG] = {
6479 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6480 .init_verbs = { alc883_init_verbs },
6481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6482 .dac_nids = alc883_dac_nids,
6483 .dig_out_nid = ALC883_DIGOUT_NID,
6484 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6485 .adc_nids = alc883_adc_nids,
6486 .dig_in_nid = ALC883_DIGIN_NID,
6487 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6488 .channel_mode = alc883_sixstack_modes,
6489 .input_mux = &alc883_capture_source,
6490 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006491 [ALC883_TARGA_DIG] = {
6492 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6493 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6494 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6495 .dac_nids = alc883_dac_nids,
6496 .dig_out_nid = ALC883_DIGOUT_NID,
6497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6498 .adc_nids = alc883_adc_nids,
6499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6500 .channel_mode = alc883_3ST_6ch_modes,
6501 .need_dac_fix = 1,
6502 .input_mux = &alc883_capture_source,
6503 .unsol_event = alc883_tagra_unsol_event,
6504 .init_hook = alc883_tagra_automute,
6505 },
6506 [ALC883_TARGA_2ch_DIG] = {
6507 .mixers = { alc883_tagra_2ch_mixer},
6508 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6510 .dac_nids = alc883_dac_nids,
6511 .dig_out_nid = ALC883_DIGOUT_NID,
6512 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6513 .adc_nids = alc883_adc_nids,
6514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6515 .channel_mode = alc883_3ST_2ch_modes,
6516 .input_mux = &alc883_capture_source,
6517 .unsol_event = alc883_tagra_unsol_event,
6518 .init_hook = alc883_tagra_automute,
6519 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006520 [ALC883_ACER] = {
6521 .mixers = { alc883_base_mixer,
6522 alc883_chmode_mixer },
6523 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6524 * and the headphone jack. Turn this on and rely on the
6525 * standard mute methods whenever the user wants to turn
6526 * these outputs off.
6527 */
6528 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6530 .dac_nids = alc883_dac_nids,
6531 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6532 .adc_nids = alc883_adc_nids,
6533 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6534 .channel_mode = alc883_3ST_2ch_modes,
6535 .input_mux = &alc883_capture_source,
6536 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006537 [ALC883_MEDION] = {
6538 .mixers = { alc883_fivestack_mixer,
6539 alc883_chmode_mixer },
6540 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006541 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6543 .dac_nids = alc883_dac_nids,
6544 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6545 .adc_nids = alc883_adc_nids,
6546 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6547 .channel_mode = alc883_sixstack_modes,
6548 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006549 },
Kailang Yang272a5272007-05-14 11:00:38 +02006550 [ALC883_MEDION_MD2] = {
6551 .mixers = { alc883_medion_md2_mixer},
6552 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6553 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6554 .dac_nids = alc883_dac_nids,
6555 .dig_out_nid = ALC883_DIGOUT_NID,
6556 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6557 .adc_nids = alc883_adc_nids,
6558 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6559 .channel_mode = alc883_3ST_2ch_modes,
6560 .input_mux = &alc883_capture_source,
6561 .unsol_event = alc883_medion_md2_unsol_event,
6562 .init_hook = alc883_medion_md2_automute,
6563 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006564 [ALC883_LAPTOP_EAPD] = {
6565 .mixers = { alc883_base_mixer,
6566 alc883_chmode_mixer },
6567 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6569 .dac_nids = alc883_dac_nids,
6570 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6571 .adc_nids = alc883_adc_nids,
6572 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6573 .channel_mode = alc883_3ST_2ch_modes,
6574 .input_mux = &alc883_capture_source,
6575 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006576 [ALC883_LENOVO_101E_2ch] = {
6577 .mixers = { alc883_lenovo_101e_2ch_mixer},
6578 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6579 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6580 .dac_nids = alc883_dac_nids,
6581 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6582 .adc_nids = alc883_adc_nids,
6583 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6584 .channel_mode = alc883_3ST_2ch_modes,
6585 .input_mux = &alc883_lenovo_101e_capture_source,
6586 .unsol_event = alc883_lenovo_101e_unsol_event,
6587 .init_hook = alc883_lenovo_101e_all_automute,
6588 },
Kailang Yang272a5272007-05-14 11:00:38 +02006589 [ALC883_LENOVO_NB0763] = {
6590 .mixers = { alc883_lenovo_nb0763_mixer },
6591 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6592 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6593 .dac_nids = alc883_dac_nids,
6594 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6595 .adc_nids = alc883_adc_nids,
6596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6597 .channel_mode = alc883_3ST_2ch_modes,
6598 .need_dac_fix = 1,
6599 .input_mux = &alc883_lenovo_nb0763_capture_source,
6600 .unsol_event = alc883_medion_md2_unsol_event,
6601 .init_hook = alc883_medion_md2_automute,
6602 },
6603 [ALC888_LENOVO_MS7195_DIG] = {
6604 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6605 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6607 .dac_nids = alc883_dac_nids,
6608 .dig_out_nid = ALC883_DIGOUT_NID,
6609 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6610 .adc_nids = alc883_adc_nids,
6611 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6612 .channel_mode = alc883_3ST_6ch_modes,
6613 .need_dac_fix = 1,
6614 .input_mux = &alc883_capture_source,
6615 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6616 .init_hook = alc888_lenovo_ms7195_front_automute,
6617 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006618};
6619
6620
6621/*
6622 * BIOS auto configuration
6623 */
6624static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6625 hda_nid_t nid, int pin_type,
6626 int dac_idx)
6627{
6628 /* set as output */
6629 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006630 int idx;
6631
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006632 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6633 idx = 4;
6634 else
6635 idx = spec->multiout.dac_nids[dac_idx] - 2;
6636
6637 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6638 pin_type);
6639 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6640 AMP_OUT_UNMUTE);
6641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6642
6643}
6644
6645static void alc883_auto_init_multi_out(struct hda_codec *codec)
6646{
6647 struct alc_spec *spec = codec->spec;
6648 int i;
6649
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006650 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006651 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006652 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006653 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006654 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006655 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006656 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006657 }
6658}
6659
6660static void alc883_auto_init_hp_out(struct hda_codec *codec)
6661{
6662 struct alc_spec *spec = codec->spec;
6663 hda_nid_t pin;
6664
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006665 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006666 if (pin) /* connect to front */
6667 /* use dac 0 */
6668 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6669}
6670
6671#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6672#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6673
6674static void alc883_auto_init_analog_input(struct hda_codec *codec)
6675{
6676 struct alc_spec *spec = codec->spec;
6677 int i;
6678
6679 for (i = 0; i < AUTO_PIN_LAST; i++) {
6680 hda_nid_t nid = spec->autocfg.input_pins[i];
6681 if (alc883_is_input_pin(nid)) {
6682 snd_hda_codec_write(codec, nid, 0,
6683 AC_VERB_SET_PIN_WIDGET_CONTROL,
6684 (i <= AUTO_PIN_FRONT_MIC ?
6685 PIN_VREF80 : PIN_IN));
6686 if (nid != ALC883_PIN_CD_NID)
6687 snd_hda_codec_write(codec, nid, 0,
6688 AC_VERB_SET_AMP_GAIN_MUTE,
6689 AMP_OUT_MUTE);
6690 }
6691 }
6692}
6693
6694/* almost identical with ALC880 parser... */
6695static int alc883_parse_auto_config(struct hda_codec *codec)
6696{
6697 struct alc_spec *spec = codec->spec;
6698 int err = alc880_parse_auto_config(codec);
6699
6700 if (err < 0)
6701 return err;
6702 else if (err > 0)
6703 /* hack - override the init verbs */
6704 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006705 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6706 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006707 return err;
6708}
6709
6710/* additional initialization for auto-configuration model */
6711static void alc883_auto_init(struct hda_codec *codec)
6712{
6713 alc883_auto_init_multi_out(codec);
6714 alc883_auto_init_hp_out(codec);
6715 alc883_auto_init_analog_input(codec);
6716}
6717
6718static int patch_alc883(struct hda_codec *codec)
6719{
6720 struct alc_spec *spec;
6721 int err, board_config;
6722
6723 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6724 if (spec == NULL)
6725 return -ENOMEM;
6726
6727 codec->spec = spec;
6728
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006729 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6730 alc883_models,
6731 alc883_cfg_tbl);
6732 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006733 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6734 "trying auto-probe from BIOS...\n");
6735 board_config = ALC883_AUTO;
6736 }
6737
6738 if (board_config == ALC883_AUTO) {
6739 /* automatic parse from the BIOS config */
6740 err = alc883_parse_auto_config(codec);
6741 if (err < 0) {
6742 alc_free(codec);
6743 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006744 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006745 printk(KERN_INFO
6746 "hda_codec: Cannot set up configuration "
6747 "from BIOS. Using base mode...\n");
6748 board_config = ALC883_3ST_2ch_DIG;
6749 }
6750 }
6751
6752 if (board_config != ALC883_AUTO)
6753 setup_preset(spec, &alc883_presets[board_config]);
6754
6755 spec->stream_name_analog = "ALC883 Analog";
6756 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6757 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6758
6759 spec->stream_name_digital = "ALC883 Digital";
6760 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6761 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6762
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006763 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006764 spec->adc_nids = alc883_adc_nids;
6765 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6766 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006767
6768 codec->patch_ops = alc_patch_ops;
6769 if (board_config == ALC883_AUTO)
6770 spec->init_hook = alc883_auto_init;
6771
6772 return 0;
6773}
6774
6775/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006776 * ALC262 support
6777 */
6778
6779#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6780#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6781
6782#define alc262_dac_nids alc260_dac_nids
6783#define alc262_adc_nids alc882_adc_nids
6784#define alc262_adc_nids_alt alc882_adc_nids_alt
6785
6786#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006787#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006788
6789static struct snd_kcontrol_new alc262_base_mixer[] = {
6790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006802 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6803 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6806 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6807 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006808 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006809};
6810
Kailang Yangccc656c2006-10-17 12:32:26 +02006811static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006821 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006824 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6825 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6826 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6828 { } /* end */
6829};
6830
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006831static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6833 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6835 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6837
6838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6851 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6852 { } /* end */
6853};
6854
Kailang Yangcd7509a2007-01-26 18:33:17 +01006855static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6860 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006864 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6869 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6870 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6871 { } /* end */
6872};
6873
6874static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6875 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6876 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006877 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006878 { } /* end */
6879};
6880
Kailang Yang272a5272007-05-14 11:00:38 +02006881static struct snd_kcontrol_new alc262_sony_mixer[] = {
6882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6886 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6887 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6888 { } /* end */
6889};
6890
6891
6892
Kailang Yangdf694da2005-12-05 19:42:22 +01006893#define alc262_capture_mixer alc882_capture_mixer
6894#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6895
6896/*
6897 * generic initialization of ADC, input mixers and output mixers
6898 */
6899static struct hda_verb alc262_init_verbs[] = {
6900 /*
6901 * Unmute ADC0-2 and set the default input to mic-in
6902 */
6903 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6907 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6909
6910 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6911 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006912 * Note: PASD motherboards uses the Line In 2 as the input for
6913 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 */
6915 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6921
6922 /*
6923 * Set up output mixers (0x0c - 0x0e)
6924 */
6925 /* set vol=0 to output mixers */
6926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6927 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6929 /* set up input amps for analog loopback */
6930 /* Amp Indices: DAC = 0, mixer = 1 */
6931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6937
6938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6940 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6941 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6942 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6943 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6944
6945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6947 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6950
6951 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6952 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6953
6954 /* FIXME: use matrix-type input source selection */
6955 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6956 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6961 /* Input mixer2 */
6962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6966 /* Input mixer3 */
6967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01006971
6972 { }
6973};
6974
Kailang Yangccc656c2006-10-17 12:32:26 +02006975static struct hda_verb alc262_hippo_unsol_verbs[] = {
6976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6978 {}
6979};
6980
6981static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6984 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6985
6986 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6988 {}
6989};
6990
Kailang Yang272a5272007-05-14 11:00:38 +02006991static struct hda_verb alc262_sony_unsol_verbs[] = {
6992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6994 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6995
6996 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6998};
6999
Kailang Yangccc656c2006-10-17 12:32:26 +02007000/* mute/unmute internal speaker according to the hp jack and mute state */
7001static void alc262_hippo_automute(struct hda_codec *codec, int force)
7002{
7003 struct alc_spec *spec = codec->spec;
7004 unsigned int mute;
7005
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007006 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007007 unsigned int present;
7008 /* need to execute and sync at first */
7009 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7010 present = snd_hda_codec_read(codec, 0x15, 0,
7011 AC_VERB_GET_PIN_SENSE, 0);
7012 spec->jack_present = (present & 0x80000000) != 0;
7013 spec->sense_updated = 1;
7014 }
7015 if (spec->jack_present) {
7016 /* mute internal speaker */
7017 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7018 0x80, 0x80);
7019 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7020 0x80, 0x80);
7021 } else {
7022 /* unmute internal speaker if necessary */
7023 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7024 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7025 0x80, mute & 0x80);
7026 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7027 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7028 0x80, mute & 0x80);
7029 }
7030}
7031
7032/* unsolicited event for HP jack sensing */
7033static void alc262_hippo_unsol_event(struct hda_codec *codec,
7034 unsigned int res)
7035{
7036 if ((res >> 26) != ALC880_HP_EVENT)
7037 return;
7038 alc262_hippo_automute(codec, 1);
7039}
7040
7041static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7042{
7043 struct alc_spec *spec = codec->spec;
7044 unsigned int mute;
7045
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007046 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007047 unsigned int present;
7048 /* need to execute and sync at first */
7049 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7050 present = snd_hda_codec_read(codec, 0x1b, 0,
7051 AC_VERB_GET_PIN_SENSE, 0);
7052 spec->jack_present = (present & 0x80000000) != 0;
7053 spec->sense_updated = 1;
7054 }
7055 if (spec->jack_present) {
7056 /* mute internal speaker */
7057 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7058 0x80, 0x80);
7059 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7060 0x80, 0x80);
7061 } else {
7062 /* unmute internal speaker if necessary */
7063 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7064 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7065 0x80, mute & 0x80);
7066 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7067 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7068 0x80, mute & 0x80);
7069 }
7070}
7071
7072/* unsolicited event for HP jack sensing */
7073static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7074 unsigned int res)
7075{
7076 if ((res >> 26) != ALC880_HP_EVENT)
7077 return;
7078 alc262_hippo1_automute(codec, 1);
7079}
7080
Takashi Iwai834be882006-03-01 14:16:17 +01007081/*
7082 * fujitsu model
7083 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7084 */
7085
7086#define ALC_HP_EVENT 0x37
7087
7088static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7089 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7091 {}
7092};
7093
7094static struct hda_input_mux alc262_fujitsu_capture_source = {
7095 .num_items = 2,
7096 .items = {
7097 { "Mic", 0x0 },
7098 { "CD", 0x4 },
7099 },
7100};
7101
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007102static struct hda_input_mux alc262_HP_capture_source = {
7103 .num_items = 5,
7104 .items = {
7105 { "Mic", 0x0 },
7106 { "Front Mic", 0x3 },
7107 { "Line", 0x2 },
7108 { "CD", 0x4 },
7109 { "AUX IN", 0x6 },
7110 },
7111};
7112
Takashi Iwai834be882006-03-01 14:16:17 +01007113/* mute/unmute internal speaker according to the hp jack and mute state */
7114static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7115{
7116 struct alc_spec *spec = codec->spec;
7117 unsigned int mute;
7118
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007119 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007120 unsigned int present;
7121 /* need to execute and sync at first */
7122 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7123 present = snd_hda_codec_read(codec, 0x14, 0,
7124 AC_VERB_GET_PIN_SENSE, 0);
7125 spec->jack_present = (present & 0x80000000) != 0;
7126 spec->sense_updated = 1;
7127 }
7128 if (spec->jack_present) {
7129 /* mute internal speaker */
7130 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7131 0x80, 0x80);
7132 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7133 0x80, 0x80);
7134 } else {
7135 /* unmute internal speaker if necessary */
7136 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7137 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7138 0x80, mute & 0x80);
7139 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7140 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7141 0x80, mute & 0x80);
7142 }
7143}
7144
7145/* unsolicited event for HP jack sensing */
7146static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7147 unsigned int res)
7148{
7149 if ((res >> 26) != ALC_HP_EVENT)
7150 return;
7151 alc262_fujitsu_automute(codec, 1);
7152}
7153
7154/* bind volumes of both NID 0x0c and 0x0d */
7155static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7156 struct snd_ctl_elem_value *ucontrol)
7157{
7158 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7159 long *valp = ucontrol->value.integer.value;
7160 int change;
7161
7162 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7163 0x7f, valp[0] & 0x7f);
7164 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7165 0x7f, valp[1] & 0x7f);
7166 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7167 0x7f, valp[0] & 0x7f);
7168 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7169 0x7f, valp[1] & 0x7f);
7170 return change;
7171}
7172
7173/* bind hp and internal speaker mute (with plug check) */
7174static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7175 struct snd_ctl_elem_value *ucontrol)
7176{
7177 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7178 long *valp = ucontrol->value.integer.value;
7179 int change;
7180
7181 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7182 0x80, valp[0] ? 0 : 0x80);
7183 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7184 0x80, valp[1] ? 0 : 0x80);
7185 if (change || codec->in_resume)
7186 alc262_fujitsu_automute(codec, codec->in_resume);
7187 return change;
7188}
7189
7190static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7191 {
7192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7193 .name = "Master Playback Volume",
7194 .info = snd_hda_mixer_amp_volume_info,
7195 .get = snd_hda_mixer_amp_volume_get,
7196 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007197 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007198 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7199 },
7200 {
7201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7202 .name = "Master Playback Switch",
7203 .info = snd_hda_mixer_amp_switch_info,
7204 .get = snd_hda_mixer_amp_switch_get,
7205 .put = alc262_fujitsu_master_sw_put,
7206 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7207 },
7208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7213 { } /* end */
7214};
7215
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007216/* additional init verbs for Benq laptops */
7217static struct hda_verb alc262_EAPD_verbs[] = {
7218 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7219 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7220 {}
7221};
7222
Kailang Yangdf694da2005-12-05 19:42:22 +01007223/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007224static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7225 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007226{
7227 hda_nid_t nid;
7228 int err;
7229
7230 spec->multiout.num_dacs = 1; /* only use one dac */
7231 spec->multiout.dac_nids = spec->private_dac_nids;
7232 spec->multiout.dac_nids[0] = 2;
7233
7234 nid = cfg->line_out_pins[0];
7235 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007236 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7237 "Front Playback Volume",
7238 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7239 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007241 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7242 "Front Playback Switch",
7243 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7244 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007245 return err;
7246 }
7247
Takashi Iwai82bc9552006-03-21 11:24:42 +01007248 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 if (nid) {
7250 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007251 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7252 "Speaker Playback Volume",
7253 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7254 HDA_OUTPUT));
7255 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007256 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007257 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7258 "Speaker Playback Switch",
7259 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7260 HDA_OUTPUT));
7261 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007262 return err;
7263 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007264 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7265 "Speaker Playback Switch",
7266 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7267 HDA_OUTPUT));
7268 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007269 return err;
7270 }
7271 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007272 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007273 if (nid) {
7274 /* spec->multiout.hp_nid = 2; */
7275 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007276 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7277 "Headphone Playback Volume",
7278 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7279 HDA_OUTPUT));
7280 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007281 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007282 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7283 "Headphone Playback Switch",
7284 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7285 HDA_OUTPUT));
7286 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007287 return err;
7288 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007289 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7290 "Headphone Playback Switch",
7291 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7292 HDA_OUTPUT));
7293 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007294 return err;
7295 }
7296 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007297 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007298}
7299
7300/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007301#define alc262_auto_create_analog_input_ctls \
7302 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007303
7304/*
7305 * generic initialization of ADC, input mixers and output mixers
7306 */
7307static struct hda_verb alc262_volume_init_verbs[] = {
7308 /*
7309 * Unmute ADC0-2 and set the default input to mic-in
7310 */
7311 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7317
7318 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7319 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007320 * Note: PASD motherboards uses the Line In 2 as the input for
7321 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 */
7323 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7329
7330 /*
7331 * Set up output mixers (0x0c - 0x0f)
7332 */
7333 /* set vol=0 to output mixers */
7334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7337
7338 /* set up input amps for analog loopback */
7339 /* Amp Indices: DAC = 0, mixer = 1 */
7340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7346
7347 /* FIXME: use matrix-type input source selection */
7348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7349 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7354 /* Input mixer2 */
7355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7359 /* Input mixer3 */
7360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7364
7365 { }
7366};
7367
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007368static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7369 /*
7370 * Unmute ADC0-2 and set the default input to mic-in
7371 */
7372 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7374 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7376 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7378
7379 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7380 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007381 * Note: PASD motherboards uses the Line In 2 as the input for
7382 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007383 */
7384 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7392
7393 /*
7394 * Set up output mixers (0x0c - 0x0e)
7395 */
7396 /* set vol=0 to output mixers */
7397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7400
7401 /* set up input amps for analog loopback */
7402 /* Amp Indices: DAC = 0, mixer = 1 */
7403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7408 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7409
7410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7413
7414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7416
7417 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7419
7420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7421 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7424 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7425
7426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7430 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7431 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7432
7433
7434 /* FIXME: use matrix-type input source selection */
7435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7441 /* Input mixer2 */
7442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7446 /* Input mixer3 */
7447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7451
7452 { }
7453};
7454
Kailang Yangcd7509a2007-01-26 18:33:17 +01007455static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7456 /*
7457 * Unmute ADC0-2 and set the default input to mic-in
7458 */
7459 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7461 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7463 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7465
7466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7467 * mixer widget
7468 * Note: PASD motherboards uses the Line In 2 as the input for front
7469 * panel mic (mic 2)
7470 */
7471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7480 /*
7481 * Set up output mixers (0x0c - 0x0e)
7482 */
7483 /* set vol=0 to output mixers */
7484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7487
7488 /* set up input amps for analog loopback */
7489 /* Amp Indices: DAC = 0, mixer = 1 */
7490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7496
7497
7498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7503 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7504 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7505
7506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7508
7509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7511
7512 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7516 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7517 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7518
7519 /* FIXME: use matrix-type input source selection */
7520 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7521 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7527 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7529 /* Input mixer2 */
7530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7535 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7537 /* Input mixer3 */
7538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7543 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7545
7546 { }
7547};
7548
Kailang Yangdf694da2005-12-05 19:42:22 +01007549/* pcm configuration: identiacal with ALC880 */
7550#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7551#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7552#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7553#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7554
7555/*
7556 * BIOS auto configuration
7557 */
7558static int alc262_parse_auto_config(struct hda_codec *codec)
7559{
7560 struct alc_spec *spec = codec->spec;
7561 int err;
7562 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007564 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7565 alc262_ignore);
7566 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007567 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007568 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007569 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007570 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7571 if (err < 0)
7572 return err;
7573 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7574 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007575 return err;
7576
7577 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7578
7579 if (spec->autocfg.dig_out_pin)
7580 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7581 if (spec->autocfg.dig_in_pin)
7582 spec->dig_in_nid = ALC262_DIGIN_NID;
7583
7584 if (spec->kctl_alloc)
7585 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7586
7587 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007588 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007589 spec->input_mux = &spec->private_imux;
7590
7591 return 1;
7592}
7593
7594#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7595#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7596#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7597
7598
7599/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007600static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007601{
Kailang Yangdf694da2005-12-05 19:42:22 +01007602 alc262_auto_init_multi_out(codec);
7603 alc262_auto_init_hp_out(codec);
7604 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007605}
7606
7607/*
7608 * configuration and preset
7609 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007610static const char *alc262_models[ALC262_MODEL_LAST] = {
7611 [ALC262_BASIC] = "basic",
7612 [ALC262_HIPPO] = "hippo",
7613 [ALC262_HIPPO_1] = "hippo_1",
7614 [ALC262_FUJITSU] = "fujitsu",
7615 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007616 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007617 [ALC262_BENQ_ED8] = "benq",
Kailang Yang272a5272007-05-14 11:00:38 +02007618 [ALC262_BENQ_ED8] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007619 [ALC262_AUTO] = "auto",
7620};
7621
7622static struct snd_pci_quirk alc262_cfg_tbl[] = {
7623 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7624 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7625 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007626 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7627 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007628 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007629 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007630 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007631 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007632 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7633 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7634 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7635 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7636 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7637 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7638 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7639 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007640 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7641 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7642 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7643 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang272a5272007-05-14 11:00:38 +02007644 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7645 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7646 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007647 {}
7648};
7649
7650static struct alc_config_preset alc262_presets[] = {
7651 [ALC262_BASIC] = {
7652 .mixers = { alc262_base_mixer },
7653 .init_verbs = { alc262_init_verbs },
7654 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7655 .dac_nids = alc262_dac_nids,
7656 .hp_nid = 0x03,
7657 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7658 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007659 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007660 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007661 [ALC262_HIPPO] = {
7662 .mixers = { alc262_base_mixer },
7663 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7664 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7665 .dac_nids = alc262_dac_nids,
7666 .hp_nid = 0x03,
7667 .dig_out_nid = ALC262_DIGOUT_NID,
7668 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7669 .channel_mode = alc262_modes,
7670 .input_mux = &alc262_capture_source,
7671 .unsol_event = alc262_hippo_unsol_event,
7672 },
7673 [ALC262_HIPPO_1] = {
7674 .mixers = { alc262_hippo1_mixer },
7675 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7677 .dac_nids = alc262_dac_nids,
7678 .hp_nid = 0x02,
7679 .dig_out_nid = ALC262_DIGOUT_NID,
7680 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7681 .channel_mode = alc262_modes,
7682 .input_mux = &alc262_capture_source,
7683 .unsol_event = alc262_hippo1_unsol_event,
7684 },
Takashi Iwai834be882006-03-01 14:16:17 +01007685 [ALC262_FUJITSU] = {
7686 .mixers = { alc262_fujitsu_mixer },
7687 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7688 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7689 .dac_nids = alc262_dac_nids,
7690 .hp_nid = 0x03,
7691 .dig_out_nid = ALC262_DIGOUT_NID,
7692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7693 .channel_mode = alc262_modes,
7694 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007695 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007696 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007697 [ALC262_HP_BPC] = {
7698 .mixers = { alc262_HP_BPC_mixer },
7699 .init_verbs = { alc262_HP_BPC_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 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007707 [ALC262_HP_BPC_D7000_WF] = {
7708 .mixers = { alc262_HP_BPC_WildWest_mixer },
7709 .init_verbs = { alc262_HP_BPC_WildWest_init_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_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007716 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007717 [ALC262_HP_BPC_D7000_WL] = {
7718 .mixers = { alc262_HP_BPC_WildWest_mixer,
7719 alc262_HP_BPC_WildWest_option_mixer },
7720 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7721 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7722 .dac_nids = alc262_dac_nids,
7723 .hp_nid = 0x03,
7724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7725 .channel_mode = alc262_modes,
7726 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007727 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007728 [ALC262_BENQ_ED8] = {
7729 .mixers = { alc262_base_mixer },
7730 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7732 .dac_nids = alc262_dac_nids,
7733 .hp_nid = 0x03,
7734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7735 .channel_mode = alc262_modes,
7736 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007737 },
Kailang Yang272a5272007-05-14 11:00:38 +02007738 [ALC262_SONY_ASSAMD] = {
7739 .mixers = { alc262_sony_mixer },
7740 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7742 .dac_nids = alc262_dac_nids,
7743 .hp_nid = 0x02,
7744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7745 .channel_mode = alc262_modes,
7746 .input_mux = &alc262_capture_source,
7747 .unsol_event = alc262_hippo_unsol_event,
7748 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007749};
7750
7751static int patch_alc262(struct hda_codec *codec)
7752{
7753 struct alc_spec *spec;
7754 int board_config;
7755 int err;
7756
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007757 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007758 if (spec == NULL)
7759 return -ENOMEM;
7760
7761 codec->spec = spec;
7762#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007763 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7764 * under-run
7765 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007766 {
7767 int tmp;
7768 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7769 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7770 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7771 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7772 }
7773#endif
7774
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007775 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7776 alc262_models,
7777 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007778
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007779 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007780 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7781 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007782 board_config = ALC262_AUTO;
7783 }
7784
7785 if (board_config == ALC262_AUTO) {
7786 /* automatic parse from the BIOS config */
7787 err = alc262_parse_auto_config(codec);
7788 if (err < 0) {
7789 alc_free(codec);
7790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007791 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007792 printk(KERN_INFO
7793 "hda_codec: Cannot set up configuration "
7794 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007795 board_config = ALC262_BASIC;
7796 }
7797 }
7798
7799 if (board_config != ALC262_AUTO)
7800 setup_preset(spec, &alc262_presets[board_config]);
7801
7802 spec->stream_name_analog = "ALC262 Analog";
7803 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7804 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7805
7806 spec->stream_name_digital = "ALC262 Digital";
7807 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7808 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7809
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007810 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007811 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007812 unsigned int wcap = get_wcaps(codec, 0x07);
7813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007814 /* get type */
7815 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007816 if (wcap != AC_WID_AUD_IN) {
7817 spec->adc_nids = alc262_adc_nids_alt;
7818 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007819 spec->mixers[spec->num_mixers] =
7820 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007821 spec->num_mixers++;
7822 } else {
7823 spec->adc_nids = alc262_adc_nids;
7824 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7825 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7826 spec->num_mixers++;
7827 }
7828 }
7829
7830 codec->patch_ops = alc_patch_ops;
7831 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007832 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01007833
Kailang Yangdf694da2005-12-05 19:42:22 +01007834 return 0;
7835}
7836
Kailang Yangdf694da2005-12-05 19:42:22 +01007837/*
Kailang Yanga361d842007-06-05 12:30:55 +02007838 * ALC268 channel source setting (2 channel)
7839 */
7840#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7841#define alc268_modes alc260_modes
7842
7843static hda_nid_t alc268_dac_nids[2] = {
7844 /* front, hp */
7845 0x02, 0x03
7846};
7847
7848static hda_nid_t alc268_adc_nids[2] = {
7849 /* ADC0-1 */
7850 0x08, 0x07
7851};
7852
7853static hda_nid_t alc268_adc_nids_alt[1] = {
7854 /* ADC0 */
7855 0x08
7856};
7857
7858static struct snd_kcontrol_new alc268_base_mixer[] = {
7859 /* output mixer control */
7860 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7863 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7864 { }
7865};
7866
7867/*
7868 * generic initialization of ADC, input mixers and output mixers
7869 */
7870static struct hda_verb alc268_base_init_verbs[] = {
7871 /* Unmute DAC0-1 and set vol = 0 */
7872 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7873 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7874 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7875 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7876 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7877 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7878
7879 /*
7880 * Set up output mixers (0x0c - 0x0e)
7881 */
7882 /* set vol=0 to output mixers */
7883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7886 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7887
7888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7889 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7890
7891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7893 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7896 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7898 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7899
7900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7904 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7906 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7907 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7908
7909 /* FIXME: use matrix-type input source selection */
7910 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
7911 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7912 /* Input mixer2 */
7913 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7914 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7917
7918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7922 { }
7923};
7924
7925/*
7926 * generic initialization of ADC, input mixers and output mixers
7927 */
7928static struct hda_verb alc268_volume_init_verbs[] = {
7929 /* set output DAC */
7930 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7931 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7932 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7933 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7934
7935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7938 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7939 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7940
7941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7945 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7946
7947 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7950 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7951
7952 /* set PCBEEP vol = 0 */
7953 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
7954
7955 { }
7956};
7957
7958#define alc268_mux_enum_info alc_mux_enum_info
7959#define alc268_mux_enum_get alc_mux_enum_get
7960
7961static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
7962 struct snd_ctl_elem_value *ucontrol)
7963{
7964 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7965 struct alc_spec *spec = codec->spec;
7966 const struct hda_input_mux *imux = spec->input_mux;
7967 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7968 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
7969 hda_nid_t nid = capture_mixers[adc_idx];
7970 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7971 unsigned int i, idx;
7972
7973 idx = ucontrol->value.enumerated.item[0];
7974 if (idx >= imux->num_items)
7975 idx = imux->num_items - 1;
7976 if (*cur_val == idx && !codec->in_resume)
7977 return 0;
7978 for (i = 0; i < imux->num_items; i++) {
7979 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
7980 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7981 v | (imux->items[i].index << 8));
7982 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
7983 idx );
7984 }
7985 *cur_val = idx;
7986 return 1;
7987}
7988
7989static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
7990 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_MUTE("Capture Switch", 0x23, 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 = 1,
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 snd_kcontrol_new alc268_capture_mixer[] = {
8009 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8011 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8012 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8013 {
8014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8015 /* The multiple "Capture Source" controls confuse alsamixer
8016 * So call somewhat different..
8017 * FIXME: the controls appear in the "playback" view!
8018 */
8019 /* .name = "Capture Source", */
8020 .name = "Input Source",
8021 .count = 2,
8022 .info = alc268_mux_enum_info,
8023 .get = alc268_mux_enum_get,
8024 .put = alc268_mux_enum_put,
8025 },
8026 { } /* end */
8027};
8028
8029static struct hda_input_mux alc268_capture_source = {
8030 .num_items = 4,
8031 .items = {
8032 { "Mic", 0x0 },
8033 { "Front Mic", 0x1 },
8034 { "Line", 0x2 },
8035 { "CD", 0x3 },
8036 },
8037};
8038
8039/* create input playback/capture controls for the given pin */
8040static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8041 const char *ctlname, int idx)
8042{
8043 char name[32];
8044 int err;
8045
8046 sprintf(name, "%s Playback Volume", ctlname);
8047 if (nid == 0x14) {
8048 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8049 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8050 HDA_OUTPUT));
8051 if (err < 0)
8052 return err;
8053 } else if (nid == 0x15) {
8054 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8055 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8056 HDA_OUTPUT));
8057 if (err < 0)
8058 return err;
8059 } else
8060 return -1;
8061 sprintf(name, "%s Playback Switch", ctlname);
8062 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8063 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8064 if (err < 0)
8065 return err;
8066 return 0;
8067}
8068
8069/* add playback controls from the parsed DAC table */
8070static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8071 const struct auto_pin_cfg *cfg)
8072{
8073 hda_nid_t nid;
8074 int err;
8075
8076 spec->multiout.num_dacs = 2; /* only use one dac */
8077 spec->multiout.dac_nids = spec->private_dac_nids;
8078 spec->multiout.dac_nids[0] = 2;
8079 spec->multiout.dac_nids[1] = 3;
8080
8081 nid = cfg->line_out_pins[0];
8082 if (nid)
8083 alc268_new_analog_output(spec, nid, "Front", 0);
8084
8085 nid = cfg->speaker_pins[0];
8086 if (nid == 0x1d) {
8087 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8088 "Speaker Playback Volume",
8089 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8090 if (err < 0)
8091 return err;
8092 }
8093 nid = cfg->hp_pins[0];
8094 if (nid)
8095 alc268_new_analog_output(spec, nid, "Headphone", 0);
8096
8097 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8098 if (nid == 0x16) {
8099 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8100 "Mono Playback Switch",
8101 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8102 if (err < 0)
8103 return err;
8104 }
8105 return 0;
8106}
8107
8108/* create playback/capture controls for input pins */
8109static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8110 const struct auto_pin_cfg *cfg)
8111{
8112 struct hda_input_mux *imux = &spec->private_imux;
8113 int i, idx1;
8114
8115 for (i = 0; i < AUTO_PIN_LAST; i++) {
8116 switch(cfg->input_pins[i]) {
8117 case 0x18:
8118 idx1 = 0; /* Mic 1 */
8119 break;
8120 case 0x19:
8121 idx1 = 1; /* Mic 2 */
8122 break;
8123 case 0x1a:
8124 idx1 = 2; /* Line In */
8125 break;
8126 case 0x1c:
8127 idx1 = 3; /* CD */
8128 break;
8129 default:
8130 continue;
8131 }
8132 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8133 imux->items[imux->num_items].index = idx1;
8134 imux->num_items++;
8135 }
8136 return 0;
8137}
8138
8139static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8140{
8141 struct alc_spec *spec = codec->spec;
8142 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8143 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8144 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8145 unsigned int dac_vol1, dac_vol2;
8146
8147 if (speaker_nid) {
8148 snd_hda_codec_write(codec, speaker_nid, 0,
8149 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8150 snd_hda_codec_write(codec, 0x0f, 0,
8151 AC_VERB_SET_AMP_GAIN_MUTE,
8152 AMP_IN_UNMUTE(1));
8153 snd_hda_codec_write(codec, 0x10, 0,
8154 AC_VERB_SET_AMP_GAIN_MUTE,
8155 AMP_IN_UNMUTE(1));
8156 } else {
8157 snd_hda_codec_write(codec, 0x0f, 0,
8158 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8159 snd_hda_codec_write(codec, 0x10, 0,
8160 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8161 }
8162
8163 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8164 if (line_nid == 0x14)
8165 dac_vol2 = AMP_OUT_ZERO;
8166 else if (line_nid == 0x15)
8167 dac_vol1 = AMP_OUT_ZERO;
8168 if (hp_nid == 0x14)
8169 dac_vol2 = AMP_OUT_ZERO;
8170 else if (hp_nid == 0x15)
8171 dac_vol1 = AMP_OUT_ZERO;
8172 if (line_nid != 0x16 || hp_nid != 0x16 ||
8173 spec->autocfg.line_out_pins[1] != 0x16 ||
8174 spec->autocfg.line_out_pins[2] != 0x16)
8175 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8176
8177 snd_hda_codec_write(codec, 0x02, 0,
8178 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8179 snd_hda_codec_write(codec, 0x03, 0,
8180 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8181}
8182
8183/* pcm configuration: identiacal with ALC880 */
8184#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8185#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8186#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8187
8188/*
8189 * BIOS auto configuration
8190 */
8191static int alc268_parse_auto_config(struct hda_codec *codec)
8192{
8193 struct alc_spec *spec = codec->spec;
8194 int err;
8195 static hda_nid_t alc268_ignore[] = { 0 };
8196
8197 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8198 alc268_ignore);
8199 if (err < 0)
8200 return err;
8201 if (!spec->autocfg.line_outs)
8202 return 0; /* can't find valid BIOS pin config */
8203
8204 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8205 if (err < 0)
8206 return err;
8207 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8208 if (err < 0)
8209 return err;
8210
8211 spec->multiout.max_channels = 2;
8212
8213 /* digital only support output */
8214 if (spec->autocfg.dig_out_pin)
8215 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8216
8217 if (spec->kctl_alloc)
8218 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8219
8220 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8221 spec->num_mux_defs = 1;
8222 spec->input_mux = &spec->private_imux;
8223
8224 return 1;
8225}
8226
8227#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8228#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8229#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8230
8231/* init callback for auto-configuration model -- overriding the default init */
8232static void alc268_auto_init(struct hda_codec *codec)
8233{
8234 alc268_auto_init_multi_out(codec);
8235 alc268_auto_init_hp_out(codec);
8236 alc268_auto_init_mono_speaker_out(codec);
8237 alc268_auto_init_analog_input(codec);
8238}
8239
8240/*
8241 * configuration and preset
8242 */
8243static const char *alc268_models[ALC268_MODEL_LAST] = {
8244 [ALC268_3ST] = "3stack",
8245 [ALC268_AUTO] = "auto",
8246};
8247
8248static struct snd_pci_quirk alc268_cfg_tbl[] = {
8249 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8250 {}
8251};
8252
8253static struct alc_config_preset alc268_presets[] = {
8254 [ALC268_3ST] = {
8255 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8256 .init_verbs = { alc268_base_init_verbs },
8257 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8258 .dac_nids = alc268_dac_nids,
8259 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8260 .adc_nids = alc268_adc_nids_alt,
8261 .hp_nid = 0x03,
8262 .dig_out_nid = ALC268_DIGOUT_NID,
8263 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8264 .channel_mode = alc268_modes,
8265 .input_mux = &alc268_capture_source,
8266 },
8267};
8268
8269static int patch_alc268(struct hda_codec *codec)
8270{
8271 struct alc_spec *spec;
8272 int board_config;
8273 int err;
8274
8275 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8276 if (spec == NULL)
8277 return -ENOMEM;
8278
8279 codec->spec = spec;
8280
8281 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8282 alc268_models,
8283 alc268_cfg_tbl);
8284
8285 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8286 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8287 "trying auto-probe from BIOS...\n");
8288 board_config = ALC268_AUTO;
8289 }
8290
8291 if (board_config == ALC268_AUTO) {
8292 /* automatic parse from the BIOS config */
8293 err = alc268_parse_auto_config(codec);
8294 if (err < 0) {
8295 alc_free(codec);
8296 return err;
8297 } else if (!err) {
8298 printk(KERN_INFO
8299 "hda_codec: Cannot set up configuration "
8300 "from BIOS. Using base mode...\n");
8301 board_config = ALC268_3ST;
8302 }
8303 }
8304
8305 if (board_config != ALC268_AUTO)
8306 setup_preset(spec, &alc268_presets[board_config]);
8307
8308 spec->stream_name_analog = "ALC268 Analog";
8309 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8310 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8311
8312 spec->stream_name_digital = "ALC268 Digital";
8313 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8314
8315 if (board_config == ALC268_AUTO) {
8316 if (!spec->adc_nids && spec->input_mux) {
8317 /* check whether NID 0x07 is valid */
8318 unsigned int wcap = get_wcaps(codec, 0x07);
8319
8320 /* get type */
8321 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8322 if (wcap != AC_WID_AUD_IN) {
8323 spec->adc_nids = alc268_adc_nids_alt;
8324 spec->num_adc_nids =
8325 ARRAY_SIZE(alc268_adc_nids_alt);
8326 spec->mixers[spec->num_mixers] =
8327 alc268_capture_alt_mixer;
8328 spec->num_mixers++;
8329 } else {
8330 spec->adc_nids = alc268_adc_nids;
8331 spec->num_adc_nids =
8332 ARRAY_SIZE(alc268_adc_nids);
8333 spec->mixers[spec->num_mixers] =
8334 alc268_capture_mixer;
8335 spec->num_mixers++;
8336 }
8337 }
8338 }
8339 codec->patch_ops = alc_patch_ops;
8340 if (board_config == ALC268_AUTO)
8341 spec->init_hook = alc268_auto_init;
8342
8343 return 0;
8344}
8345
8346/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008347 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8348 */
8349
8350/*
8351 * set the path ways for 2 channel output
8352 * need to set the codec line out and mic 1 pin widgets to inputs
8353 */
8354static struct hda_verb alc861_threestack_ch2_init[] = {
8355 /* set pin widget 1Ah (line in) for input */
8356 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008357 /* set pin widget 18h (mic1/2) for input, for mic also enable
8358 * the vref
8359 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8363#if 0
8364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8366#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008367 { } /* end */
8368};
8369/*
8370 * 6ch mode
8371 * need to set the codec line out and mic 1 pin widgets to outputs
8372 */
8373static struct hda_verb alc861_threestack_ch6_init[] = {
8374 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8375 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8376 /* set pin widget 18h (mic1) for output (CLFE)*/
8377 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8378
8379 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008381
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8383#if 0
8384 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8385 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8386#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008387 { } /* end */
8388};
8389
8390static struct hda_channel_mode alc861_threestack_modes[2] = {
8391 { 2, alc861_threestack_ch2_init },
8392 { 6, alc861_threestack_ch6_init },
8393};
Takashi Iwai22309c32006-08-09 16:57:28 +02008394/* Set mic1 as input and unmute the mixer */
8395static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8396 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8397 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8398 { } /* end */
8399};
8400/* Set mic1 as output and mute mixer */
8401static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8402 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8404 { } /* end */
8405};
8406
8407static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8408 { 2, alc861_uniwill_m31_ch2_init },
8409 { 4, alc861_uniwill_m31_ch4_init },
8410};
Kailang Yangdf694da2005-12-05 19:42:22 +01008411
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008412/* Set mic1 and line-in as input and unmute the mixer */
8413static struct hda_verb alc861_asus_ch2_init[] = {
8414 /* set pin widget 1Ah (line in) for input */
8415 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008416 /* set pin widget 18h (mic1/2) for input, for mic also enable
8417 * the vref
8418 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008419 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8420
8421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8422#if 0
8423 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8424 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8425#endif
8426 { } /* end */
8427};
8428/* Set mic1 nad line-in as output and mute mixer */
8429static struct hda_verb alc861_asus_ch6_init[] = {
8430 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8431 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8432 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8433 /* set pin widget 18h (mic1) for output (CLFE)*/
8434 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8435 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8436 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8437 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8438
8439 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8440#if 0
8441 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8442 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8443#endif
8444 { } /* end */
8445};
8446
8447static struct hda_channel_mode alc861_asus_modes[2] = {
8448 { 2, alc861_asus_ch2_init },
8449 { 6, alc861_asus_ch6_init },
8450};
8451
Kailang Yangdf694da2005-12-05 19:42:22 +01008452/* patch-ALC861 */
8453
8454static struct snd_kcontrol_new alc861_base_mixer[] = {
8455 /* output mixer control */
8456 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8457 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8458 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8460 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8461
8462 /*Input mixer control */
8463 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8464 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8465 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8466 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8467 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8468 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8470 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008473
Kailang Yangdf694da2005-12-05 19:42:22 +01008474 /* Capture mixer control */
8475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8477 {
8478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8479 .name = "Capture Source",
8480 .count = 1,
8481 .info = alc_mux_enum_info,
8482 .get = alc_mux_enum_get,
8483 .put = alc_mux_enum_put,
8484 },
8485 { } /* end */
8486};
8487
8488static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8489 /* output mixer control */
8490 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8491 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8492 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8493 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8494 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8495
8496 /* Input mixer control */
8497 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8498 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8499 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8500 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8501 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8502 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8504 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008507
Kailang Yangdf694da2005-12-05 19:42:22 +01008508 /* Capture mixer control */
8509 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8510 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8511 {
8512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8513 .name = "Capture Source",
8514 .count = 1,
8515 .info = alc_mux_enum_info,
8516 .get = alc_mux_enum_get,
8517 .put = alc_mux_enum_put,
8518 },
8519 {
8520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8521 .name = "Channel Mode",
8522 .info = alc_ch_mode_info,
8523 .get = alc_ch_mode_get,
8524 .put = alc_ch_mode_put,
8525 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8526 },
8527 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008528};
8529
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008530static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008531 /* output mixer control */
8532 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8534 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8535
8536 /*Capture mixer control */
8537 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8538 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8539 {
8540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8541 .name = "Capture Source",
8542 .count = 1,
8543 .info = alc_mux_enum_info,
8544 .get = alc_mux_enum_get,
8545 .put = alc_mux_enum_put,
8546 },
8547
8548 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008549};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008550
Takashi Iwai22309c32006-08-09 16:57:28 +02008551static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8552 /* output mixer control */
8553 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8555 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8556 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8557 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8558
8559 /* Input mixer control */
8560 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8561 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8562 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8563 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8564 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8565 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8567 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008570
Takashi Iwai22309c32006-08-09 16:57:28 +02008571 /* Capture mixer control */
8572 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8573 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8574 {
8575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8576 .name = "Capture Source",
8577 .count = 1,
8578 .info = alc_mux_enum_info,
8579 .get = alc_mux_enum_get,
8580 .put = alc_mux_enum_put,
8581 },
8582 {
8583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8584 .name = "Channel Mode",
8585 .info = alc_ch_mode_info,
8586 .get = alc_ch_mode_get,
8587 .put = alc_ch_mode_put,
8588 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8589 },
8590 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008591};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008592
8593static struct snd_kcontrol_new alc861_asus_mixer[] = {
8594 /* output mixer control */
8595 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8596 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8597 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8598 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8599 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8600
8601 /* Input mixer control */
8602 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8603 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8604 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8605 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8606 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8607 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8609 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8610 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8612
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008613 /* Capture mixer control */
8614 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8615 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8616 {
8617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8618 .name = "Capture Source",
8619 .count = 1,
8620 .info = alc_mux_enum_info,
8621 .get = alc_mux_enum_get,
8622 .put = alc_mux_enum_put,
8623 },
8624 {
8625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8626 .name = "Channel Mode",
8627 .info = alc_ch_mode_info,
8628 .get = alc_ch_mode_get,
8629 .put = alc_ch_mode_put,
8630 .private_value = ARRAY_SIZE(alc861_asus_modes),
8631 },
8632 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008633};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008634
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008635/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008636static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008637 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8638 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8639 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8640 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8641 { }
8642};
8643
Kailang Yangdf694da2005-12-05 19:42:22 +01008644/*
8645 * generic initialization of ADC, input mixers and output mixers
8646 */
8647static struct hda_verb alc861_base_init_verbs[] = {
8648 /*
8649 * Unmute ADC0 and set the default input to mic-in
8650 */
8651 /* port-A for surround (rear panel) */
8652 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8653 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8654 /* port-B for mic-in (rear panel) with vref */
8655 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8656 /* port-C for line-in (rear panel) */
8657 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8658 /* port-D for Front */
8659 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8660 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8661 /* port-E for HP out (front panel) */
8662 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8663 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008664 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008665 /* port-F for mic-in (front panel) with vref */
8666 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8667 /* port-G for CLFE (rear panel) */
8668 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8669 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8670 /* port-H for side (rear panel) */
8671 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8672 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8673 /* CD-in */
8674 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8675 /* route front mic to ADC1*/
8676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678
8679 /* Unmute DAC0~3 & spdif out*/
8680 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8681 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8683 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8685
8686 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8687 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8688 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8689 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8690 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8691
8692 /* Unmute Stereo Mixer 15 */
8693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008697
8698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8705 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008706 /* hp used DAC 3 (Front) */
8707 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8709
8710 { }
8711};
8712
8713static struct hda_verb alc861_threestack_init_verbs[] = {
8714 /*
8715 * Unmute ADC0 and set the default input to mic-in
8716 */
8717 /* port-A for surround (rear panel) */
8718 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8719 /* port-B for mic-in (rear panel) with vref */
8720 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8721 /* port-C for line-in (rear panel) */
8722 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8723 /* port-D for Front */
8724 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8725 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8726 /* port-E for HP out (front panel) */
8727 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8728 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008729 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008730 /* port-F for mic-in (front panel) with vref */
8731 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8732 /* port-G for CLFE (rear panel) */
8733 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8734 /* port-H for side (rear panel) */
8735 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8736 /* CD-in */
8737 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8738 /* route front mic to ADC1*/
8739 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 /* Unmute DAC0~3 & spdif out*/
8742 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8743 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8745 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8747
8748 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8749 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8750 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8751 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8752 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8753
8754 /* Unmute Stereo Mixer 15 */
8755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008759
8760 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008768 /* hp used DAC 3 (Front) */
8769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8771 { }
8772};
Takashi Iwai22309c32006-08-09 16:57:28 +02008773
8774static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8775 /*
8776 * Unmute ADC0 and set the default input to mic-in
8777 */
8778 /* port-A for surround (rear panel) */
8779 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8780 /* port-B for mic-in (rear panel) with vref */
8781 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8782 /* port-C for line-in (rear panel) */
8783 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8784 /* port-D for Front */
8785 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8786 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8787 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008788 /* this has to be set to VREF80 */
8789 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008790 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008791 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008792 /* port-F for mic-in (front panel) with vref */
8793 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8794 /* port-G for CLFE (rear panel) */
8795 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8796 /* port-H for side (rear panel) */
8797 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8798 /* CD-in */
8799 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8800 /* route front mic to ADC1*/
8801 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 /* Unmute DAC0~3 & spdif out*/
8804 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8805 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8806 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8807 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8808 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8809
8810 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8811 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8812 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8813 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8814 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8815
8816 /* Unmute Stereo Mixer 15 */
8817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008821
8822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8823 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8826 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8829 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008830 /* hp used DAC 3 (Front) */
8831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02008832 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8833 { }
8834};
8835
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008836static struct hda_verb alc861_asus_init_verbs[] = {
8837 /*
8838 * Unmute ADC0 and set the default input to mic-in
8839 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008840 /* port-A for surround (rear panel)
8841 * according to codec#0 this is the HP jack
8842 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008843 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8844 /* route front PCM to HP */
8845 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8846 /* port-B for mic-in (rear panel) with vref */
8847 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8848 /* port-C for line-in (rear panel) */
8849 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8850 /* port-D for Front */
8851 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8852 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8853 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008854 /* this has to be set to VREF80 */
8855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008856 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008857 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008858 /* port-F for mic-in (front panel) with vref */
8859 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8860 /* port-G for CLFE (rear panel) */
8861 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8862 /* port-H for side (rear panel) */
8863 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8864 /* CD-in */
8865 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8866 /* route front mic to ADC1*/
8867 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8869 /* Unmute DAC0~3 & spdif out*/
8870 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8871 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8872 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8873 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8875 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8877 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8879 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8880
8881 /* Unmute Stereo Mixer 15 */
8882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008886
8887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008895 /* hp used DAC 3 (Front) */
8896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8898 { }
8899};
8900
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008901/* additional init verbs for ASUS laptops */
8902static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8903 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8904 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8905 { }
8906};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008907
Kailang Yangdf694da2005-12-05 19:42:22 +01008908/*
8909 * generic initialization of ADC, input mixers and output mixers
8910 */
8911static struct hda_verb alc861_auto_init_verbs[] = {
8912 /*
8913 * Unmute ADC0 and set the default input to mic-in
8914 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008915 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01008916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917
8918 /* Unmute DAC0~3 & spdif out*/
8919 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8922 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8924
8925 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8926 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8927 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8928 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8929 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8930
8931 /* Unmute Stereo Mixer 15 */
8932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8936
8937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8938 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8940 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8945
8946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008948 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008950 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8953 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008954
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008955 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008956
8957 { }
8958};
8959
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008960static struct hda_verb alc861_toshiba_init_verbs[] = {
8961 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008962
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008963 { }
8964};
8965
8966/* toggle speaker-output according to the hp-jack state */
8967static void alc861_toshiba_automute(struct hda_codec *codec)
8968{
8969 unsigned int present;
8970
8971 present = snd_hda_codec_read(codec, 0x0f, 0,
8972 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8973 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8974 0x80, present ? 0x80 : 0);
8975 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8976 0x80, present ? 0x80 : 0);
8977 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8978 0x80, present ? 0 : 0x80);
8979 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8980 0x80, present ? 0 : 0x80);
8981}
8982
8983static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8984 unsigned int res)
8985{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008986 if ((res >> 26) == ALC880_HP_EVENT)
8987 alc861_toshiba_automute(codec);
8988}
8989
Kailang Yangdf694da2005-12-05 19:42:22 +01008990/* pcm configuration: identiacal with ALC880 */
8991#define alc861_pcm_analog_playback alc880_pcm_analog_playback
8992#define alc861_pcm_analog_capture alc880_pcm_analog_capture
8993#define alc861_pcm_digital_playback alc880_pcm_digital_playback
8994#define alc861_pcm_digital_capture alc880_pcm_digital_capture
8995
8996
8997#define ALC861_DIGOUT_NID 0x07
8998
8999static struct hda_channel_mode alc861_8ch_modes[1] = {
9000 { 8, NULL }
9001};
9002
9003static hda_nid_t alc861_dac_nids[4] = {
9004 /* front, surround, clfe, side */
9005 0x03, 0x06, 0x05, 0x04
9006};
9007
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009008static hda_nid_t alc660_dac_nids[3] = {
9009 /* front, clfe, surround */
9010 0x03, 0x05, 0x06
9011};
9012
Kailang Yangdf694da2005-12-05 19:42:22 +01009013static hda_nid_t alc861_adc_nids[1] = {
9014 /* ADC0-2 */
9015 0x08,
9016};
9017
9018static struct hda_input_mux alc861_capture_source = {
9019 .num_items = 5,
9020 .items = {
9021 { "Mic", 0x0 },
9022 { "Front Mic", 0x3 },
9023 { "Line", 0x1 },
9024 { "CD", 0x4 },
9025 { "Mixer", 0x5 },
9026 },
9027};
9028
9029/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009030static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9031 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009032{
9033 int i;
9034 hda_nid_t nid;
9035
9036 spec->multiout.dac_nids = spec->private_dac_nids;
9037 for (i = 0; i < cfg->line_outs; i++) {
9038 nid = cfg->line_out_pins[i];
9039 if (nid) {
9040 if (i >= ARRAY_SIZE(alc861_dac_nids))
9041 continue;
9042 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9043 }
9044 }
9045 spec->multiout.num_dacs = cfg->line_outs;
9046 return 0;
9047}
9048
9049/* add playback controls from the parsed DAC table */
9050static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9051 const struct auto_pin_cfg *cfg)
9052{
9053 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009054 static const char *chname[4] = {
9055 "Front", "Surround", NULL /*CLFE*/, "Side"
9056 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009057 hda_nid_t nid;
9058 int i, idx, err;
9059
9060 for (i = 0; i < cfg->line_outs; i++) {
9061 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009062 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009063 continue;
9064 if (nid == 0x05) {
9065 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009066 err = add_control(spec, ALC_CTL_BIND_MUTE,
9067 "Center Playback Switch",
9068 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9069 HDA_OUTPUT));
9070 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009071 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009072 err = add_control(spec, ALC_CTL_BIND_MUTE,
9073 "LFE Playback Switch",
9074 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9075 HDA_OUTPUT));
9076 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009077 return err;
9078 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009079 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9080 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009081 if (nid == alc861_dac_nids[idx])
9082 break;
9083 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009084 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9085 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9086 HDA_OUTPUT));
9087 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009088 return err;
9089 }
9090 }
9091 return 0;
9092}
9093
9094static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9095{
9096 int err;
9097 hda_nid_t nid;
9098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009099 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009100 return 0;
9101
9102 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9103 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009104 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9105 "Headphone Playback Switch",
9106 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9107 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009108 return err;
9109 spec->multiout.hp_nid = nid;
9110 }
9111 return 0;
9112}
9113
9114/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009115static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9116 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009117{
Kailang Yangdf694da2005-12-05 19:42:22 +01009118 struct hda_input_mux *imux = &spec->private_imux;
9119 int i, err, idx, idx1;
9120
9121 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009122 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009123 case 0x0c:
9124 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009125 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009126 break;
9127 case 0x0f:
9128 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009129 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009130 break;
9131 case 0x0d:
9132 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009133 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009134 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009135 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009136 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009137 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009138 break;
9139 case 0x11:
9140 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009141 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009142 break;
9143 default:
9144 continue;
9145 }
9146
Takashi Iwai4a471b72005-12-07 13:56:29 +01009147 err = new_analog_input(spec, cfg->input_pins[i],
9148 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009149 if (err < 0)
9150 return err;
9151
Takashi Iwai4a471b72005-12-07 13:56:29 +01009152 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009153 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009154 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009155 }
9156 return 0;
9157}
9158
9159static struct snd_kcontrol_new alc861_capture_mixer[] = {
9160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9162
9163 {
9164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9165 /* The multiple "Capture Source" controls confuse alsamixer
9166 * So call somewhat different..
9167 *FIXME: the controls appear in the "playback" view!
9168 */
9169 /* .name = "Capture Source", */
9170 .name = "Input Source",
9171 .count = 1,
9172 .info = alc_mux_enum_info,
9173 .get = alc_mux_enum_get,
9174 .put = alc_mux_enum_put,
9175 },
9176 { } /* end */
9177};
9178
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009179static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9180 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009181 int pin_type, int dac_idx)
9182{
9183 /* set as output */
9184
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009185 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9186 pin_type);
9187 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9188 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009189
9190}
9191
9192static void alc861_auto_init_multi_out(struct hda_codec *codec)
9193{
9194 struct alc_spec *spec = codec->spec;
9195 int i;
9196
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009197 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009198 for (i = 0; i < spec->autocfg.line_outs; i++) {
9199 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009200 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009201 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009202 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009203 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009204 }
9205}
9206
9207static void alc861_auto_init_hp_out(struct hda_codec *codec)
9208{
9209 struct alc_spec *spec = codec->spec;
9210 hda_nid_t pin;
9211
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009212 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009213 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009214 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9215 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009216}
9217
9218static void alc861_auto_init_analog_input(struct hda_codec *codec)
9219{
9220 struct alc_spec *spec = codec->spec;
9221 int i;
9222
9223 for (i = 0; i < AUTO_PIN_LAST; i++) {
9224 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009225 if (nid >= 0x0c && nid <= 0x11) {
9226 snd_hda_codec_write(codec, nid, 0,
9227 AC_VERB_SET_PIN_WIDGET_CONTROL,
9228 i <= AUTO_PIN_FRONT_MIC ?
9229 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009230 }
9231 }
9232}
9233
9234/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009235/* return 1 if successful, 0 if the proper config is not found,
9236 * or a negative error code
9237 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009238static int alc861_parse_auto_config(struct hda_codec *codec)
9239{
9240 struct alc_spec *spec = codec->spec;
9241 int err;
9242 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009244 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9245 alc861_ignore);
9246 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009248 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009249 return 0; /* can't find valid BIOS pin config */
9250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009251 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9252 if (err < 0)
9253 return err;
9254 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9255 if (err < 0)
9256 return err;
9257 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9258 if (err < 0)
9259 return err;
9260 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9261 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009262 return err;
9263
9264 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9265
9266 if (spec->autocfg.dig_out_pin)
9267 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9268
9269 if (spec->kctl_alloc)
9270 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9271
9272 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9273
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009274 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009275 spec->input_mux = &spec->private_imux;
9276
9277 spec->adc_nids = alc861_adc_nids;
9278 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9279 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9280 spec->num_mixers++;
9281
9282 return 1;
9283}
9284
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009285/* additional initialization for auto-configuration model */
9286static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009287{
Kailang Yangdf694da2005-12-05 19:42:22 +01009288 alc861_auto_init_multi_out(codec);
9289 alc861_auto_init_hp_out(codec);
9290 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009291}
9292
9293
9294/*
9295 * configuration and preset
9296 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009297static const char *alc861_models[ALC861_MODEL_LAST] = {
9298 [ALC861_3ST] = "3stack",
9299 [ALC660_3ST] = "3stack-660",
9300 [ALC861_3ST_DIG] = "3stack-dig",
9301 [ALC861_6ST_DIG] = "6stack-dig",
9302 [ALC861_UNIWILL_M31] = "uniwill-m31",
9303 [ALC861_TOSHIBA] = "toshiba",
9304 [ALC861_ASUS] = "asus",
9305 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9306 [ALC861_AUTO] = "auto",
9307};
9308
9309static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009310 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009311 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9312 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009313 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009314 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Tobin Davisad5e7732007-01-08 10:57:32 +01009315 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009316 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9317 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009318 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009319 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009320 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009321 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009322 {}
9323};
9324
9325static struct alc_config_preset alc861_presets[] = {
9326 [ALC861_3ST] = {
9327 .mixers = { alc861_3ST_mixer },
9328 .init_verbs = { alc861_threestack_init_verbs },
9329 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9330 .dac_nids = alc861_dac_nids,
9331 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9332 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009333 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009334 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9335 .adc_nids = alc861_adc_nids,
9336 .input_mux = &alc861_capture_source,
9337 },
9338 [ALC861_3ST_DIG] = {
9339 .mixers = { alc861_base_mixer },
9340 .init_verbs = { alc861_threestack_init_verbs },
9341 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9342 .dac_nids = alc861_dac_nids,
9343 .dig_out_nid = ALC861_DIGOUT_NID,
9344 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9345 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009346 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009347 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9348 .adc_nids = alc861_adc_nids,
9349 .input_mux = &alc861_capture_source,
9350 },
9351 [ALC861_6ST_DIG] = {
9352 .mixers = { alc861_base_mixer },
9353 .init_verbs = { alc861_base_init_verbs },
9354 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9355 .dac_nids = alc861_dac_nids,
9356 .dig_out_nid = ALC861_DIGOUT_NID,
9357 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9358 .channel_mode = alc861_8ch_modes,
9359 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9360 .adc_nids = alc861_adc_nids,
9361 .input_mux = &alc861_capture_source,
9362 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009363 [ALC660_3ST] = {
9364 .mixers = { alc861_3ST_mixer },
9365 .init_verbs = { alc861_threestack_init_verbs },
9366 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9367 .dac_nids = alc660_dac_nids,
9368 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9369 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009370 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009371 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9372 .adc_nids = alc861_adc_nids,
9373 .input_mux = &alc861_capture_source,
9374 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009375 [ALC861_UNIWILL_M31] = {
9376 .mixers = { alc861_uniwill_m31_mixer },
9377 .init_verbs = { alc861_uniwill_m31_init_verbs },
9378 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9379 .dac_nids = alc861_dac_nids,
9380 .dig_out_nid = ALC861_DIGOUT_NID,
9381 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9382 .channel_mode = alc861_uniwill_m31_modes,
9383 .need_dac_fix = 1,
9384 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9385 .adc_nids = alc861_adc_nids,
9386 .input_mux = &alc861_capture_source,
9387 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009388 [ALC861_TOSHIBA] = {
9389 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009390 .init_verbs = { alc861_base_init_verbs,
9391 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009392 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9393 .dac_nids = alc861_dac_nids,
9394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9395 .channel_mode = alc883_3ST_2ch_modes,
9396 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9397 .adc_nids = alc861_adc_nids,
9398 .input_mux = &alc861_capture_source,
9399 .unsol_event = alc861_toshiba_unsol_event,
9400 .init_hook = alc861_toshiba_automute,
9401 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009402 [ALC861_ASUS] = {
9403 .mixers = { alc861_asus_mixer },
9404 .init_verbs = { alc861_asus_init_verbs },
9405 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9406 .dac_nids = alc861_dac_nids,
9407 .dig_out_nid = ALC861_DIGOUT_NID,
9408 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9409 .channel_mode = alc861_asus_modes,
9410 .need_dac_fix = 1,
9411 .hp_nid = 0x06,
9412 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9413 .adc_nids = alc861_adc_nids,
9414 .input_mux = &alc861_capture_source,
9415 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009416 [ALC861_ASUS_LAPTOP] = {
9417 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9418 .init_verbs = { alc861_asus_init_verbs,
9419 alc861_asus_laptop_init_verbs },
9420 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9421 .dac_nids = alc861_dac_nids,
9422 .dig_out_nid = ALC861_DIGOUT_NID,
9423 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9424 .channel_mode = alc883_3ST_2ch_modes,
9425 .need_dac_fix = 1,
9426 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9427 .adc_nids = alc861_adc_nids,
9428 .input_mux = &alc861_capture_source,
9429 },
9430};
Kailang Yangdf694da2005-12-05 19:42:22 +01009431
9432
9433static int patch_alc861(struct hda_codec *codec)
9434{
9435 struct alc_spec *spec;
9436 int board_config;
9437 int err;
9438
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009439 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009440 if (spec == NULL)
9441 return -ENOMEM;
9442
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009443 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009444
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009445 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9446 alc861_models,
9447 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009448
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009449 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009450 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9451 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009452 board_config = ALC861_AUTO;
9453 }
9454
9455 if (board_config == ALC861_AUTO) {
9456 /* automatic parse from the BIOS config */
9457 err = alc861_parse_auto_config(codec);
9458 if (err < 0) {
9459 alc_free(codec);
9460 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009461 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009462 printk(KERN_INFO
9463 "hda_codec: Cannot set up configuration "
9464 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009465 board_config = ALC861_3ST_DIG;
9466 }
9467 }
9468
9469 if (board_config != ALC861_AUTO)
9470 setup_preset(spec, &alc861_presets[board_config]);
9471
9472 spec->stream_name_analog = "ALC861 Analog";
9473 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9474 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9475
9476 spec->stream_name_digital = "ALC861 Digital";
9477 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9478 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9479
9480 codec->patch_ops = alc_patch_ops;
9481 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009482 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009483
9484 return 0;
9485}
9486
9487/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009488 * ALC861-VD support
9489 *
9490 * Based on ALC882
9491 *
9492 * In addition, an independent DAC
9493 */
9494#define ALC861VD_DIGOUT_NID 0x06
9495
9496static hda_nid_t alc861vd_dac_nids[4] = {
9497 /* front, surr, clfe, side surr */
9498 0x02, 0x03, 0x04, 0x05
9499};
9500
9501/* dac_nids for ALC660vd are in a different order - according to
9502 * Realtek's driver.
9503 * This should probably tesult in a different mixer for 6stack models
9504 * of ALC660vd codecs, but for now there is only 3stack mixer
9505 * - and it is the same as in 861vd.
9506 * adc_nids in ALC660vd are (is) the same as in 861vd
9507 */
9508static hda_nid_t alc660vd_dac_nids[3] = {
9509 /* front, rear, clfe, rear_surr */
9510 0x02, 0x04, 0x03
9511};
9512
9513static hda_nid_t alc861vd_adc_nids[1] = {
9514 /* ADC0 */
9515 0x09,
9516};
9517
9518/* input MUX */
9519/* FIXME: should be a matrix-type input source selection */
9520static struct hda_input_mux alc861vd_capture_source = {
9521 .num_items = 4,
9522 .items = {
9523 { "Mic", 0x0 },
9524 { "Front Mic", 0x1 },
9525 { "Line", 0x2 },
9526 { "CD", 0x4 },
9527 },
9528};
9529
Kailang Yang272a5272007-05-14 11:00:38 +02009530static struct hda_input_mux alc861vd_dallas_capture_source = {
9531 .num_items = 3,
9532 .items = {
9533 { "Front Mic", 0x0 },
9534 { "ATAPI Mic", 0x1 },
9535 { "Line In", 0x5 },
9536 },
9537};
9538
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009539#define alc861vd_mux_enum_info alc_mux_enum_info
9540#define alc861vd_mux_enum_get alc_mux_enum_get
9541
9542static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9543 struct snd_ctl_elem_value *ucontrol)
9544{
9545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9546 struct alc_spec *spec = codec->spec;
9547 const struct hda_input_mux *imux = spec->input_mux;
9548 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9549 static hda_nid_t capture_mixers[1] = { 0x22 };
9550 hda_nid_t nid = capture_mixers[adc_idx];
9551 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9552 unsigned int i, idx;
9553
9554 idx = ucontrol->value.enumerated.item[0];
9555 if (idx >= imux->num_items)
9556 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009558 return 0;
9559 for (i = 0; i < imux->num_items; i++) {
9560 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9561 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9562 v | (imux->items[i].index << 8));
9563 }
9564 *cur_val = idx;
9565 return 1;
9566}
9567
9568/*
9569 * 2ch mode
9570 */
9571static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9572 { 2, NULL }
9573};
9574
9575/*
9576 * 6ch mode
9577 */
9578static struct hda_verb alc861vd_6stack_ch6_init[] = {
9579 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9580 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9581 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9583 { } /* end */
9584};
9585
9586/*
9587 * 8ch mode
9588 */
9589static struct hda_verb alc861vd_6stack_ch8_init[] = {
9590 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9591 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9592 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9593 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9594 { } /* end */
9595};
9596
9597static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9598 { 6, alc861vd_6stack_ch6_init },
9599 { 8, alc861vd_6stack_ch8_init },
9600};
9601
9602static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9603 {
9604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9605 .name = "Channel Mode",
9606 .info = alc_ch_mode_info,
9607 .get = alc_ch_mode_get,
9608 .put = alc_ch_mode_put,
9609 },
9610 { } /* end */
9611};
9612
9613static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9614 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9615 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9616
9617 {
9618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9619 /* The multiple "Capture Source" controls confuse alsamixer
9620 * So call somewhat different..
9621 *FIXME: the controls appear in the "playback" view!
9622 */
9623 /* .name = "Capture Source", */
9624 .name = "Input Source",
9625 .count = 1,
9626 .info = alc861vd_mux_enum_info,
9627 .get = alc861vd_mux_enum_get,
9628 .put = alc861vd_mux_enum_put,
9629 },
9630 { } /* end */
9631};
9632
9633/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9634 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9635 */
9636static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9637 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9639
9640 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9641 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9642
9643 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9644 HDA_OUTPUT),
9645 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9646 HDA_OUTPUT),
9647 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9648 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9649
9650 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9651 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9652
9653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9654
9655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9658
9659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9662
9663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9665
9666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9668
9669 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9670 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9671
9672 { } /* end */
9673};
9674
9675static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9676 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9678
9679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9680
9681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9684
9685 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9688
9689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9691
9692 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9693 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9694
9695 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9696 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9697
9698 { } /* end */
9699};
9700
Kailang Yangbdd148a2007-05-08 15:19:08 +02009701static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9702 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9703 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9704 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9705
9706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9707
9708 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9711
9712 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9713 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9714 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9715
9716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9718
9719 { } /* end */
9720};
9721
Kailang Yang272a5272007-05-14 11:00:38 +02009722/* Pin assignment: Front=0x14, HP = 0x15,
9723 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9724 */
9725static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9726 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9728 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9729 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9736 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9737 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9738 {
9739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9740 /* .name = "Capture Source", */
9741 .name = "Input Source",
9742 .count = 1,
9743 .info = alc882_mux_enum_info,
9744 .get = alc882_mux_enum_get,
9745 .put = alc882_mux_enum_put,
9746 },
9747 { } /* end */
9748};
9749
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009750/*
9751 * generic initialization of ADC, input mixers and output mixers
9752 */
9753static struct hda_verb alc861vd_volume_init_verbs[] = {
9754 /*
9755 * Unmute ADC0 and set the default input to mic-in
9756 */
9757 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9759
9760 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9761 * the analog-loopback mixer widget
9762 */
9763 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9769
9770 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009775
9776 /*
9777 * Set up output mixers (0x02 - 0x05)
9778 */
9779 /* set vol=0 to output mixers */
9780 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9781 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9782 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9783 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9784
9785 /* set up input amps for analog loopback */
9786 /* Amp Indices: DAC = 0, mixer = 1 */
9787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9790 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9795
9796 { }
9797};
9798
9799/*
9800 * 3-stack pin configuration:
9801 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9802 */
9803static struct hda_verb alc861vd_3stack_init_verbs[] = {
9804 /*
9805 * Set pin mode and muting
9806 */
9807 /* set front pin widgets 0x14 for output */
9808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9810 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9811
9812 /* Mic (rear) pin: input vref at 80% */
9813 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9814 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9815 /* Front Mic pin: input vref at 80% */
9816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9818 /* Line In pin: input */
9819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9821 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9824 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9825 /* CD pin widget for input */
9826 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9827
9828 { }
9829};
9830
9831/*
9832 * 6-stack pin configuration:
9833 */
9834static struct hda_verb alc861vd_6stack_init_verbs[] = {
9835 /*
9836 * Set pin mode and muting
9837 */
9838 /* set front pin widgets 0x14 for output */
9839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9841 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9842
9843 /* Rear Pin: output 1 (0x0d) */
9844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9847 /* CLFE Pin: output 2 (0x0e) */
9848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9850 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9851 /* Side Pin: output 3 (0x0f) */
9852 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9854 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9855
9856 /* Mic (rear) pin: input vref at 80% */
9857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9859 /* Front Mic pin: input vref at 80% */
9860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9862 /* Line In pin: input */
9863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9865 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9869 /* CD pin widget for input */
9870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9871
9872 { }
9873};
9874
Kailang Yangbdd148a2007-05-08 15:19:08 +02009875static struct hda_verb alc861vd_eapd_verbs[] = {
9876 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9877 { }
9878};
9879
9880static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9884 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9886 {}
9887};
9888
9889/* toggle speaker-output according to the hp-jack state */
9890static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9891{
9892 unsigned int present;
9893 unsigned char bits;
9894
9895 present = snd_hda_codec_read(codec, 0x1b, 0,
9896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9897 bits = present ? 0x80 : 0;
9898 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9899 0x80, bits);
9900 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9901 0x80, bits);
9902}
9903
9904static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9905{
9906 unsigned int present;
9907 unsigned char bits;
9908
9909 present = snd_hda_codec_read(codec, 0x18, 0,
9910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9911 bits = present ? 0x80 : 0;
9912 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9913 0x80, bits);
9914 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9915 0x80, bits);
9916}
9917
9918static void alc861vd_lenovo_automute(struct hda_codec *codec)
9919{
9920 alc861vd_lenovo_hp_automute(codec);
9921 alc861vd_lenovo_mic_automute(codec);
9922}
9923
9924static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9925 unsigned int res)
9926{
9927 switch (res >> 26) {
9928 case ALC880_HP_EVENT:
9929 alc861vd_lenovo_hp_automute(codec);
9930 break;
9931 case ALC880_MIC_EVENT:
9932 alc861vd_lenovo_mic_automute(codec);
9933 break;
9934 }
9935}
9936
Kailang Yang272a5272007-05-14 11:00:38 +02009937static struct hda_verb alc861vd_dallas_verbs[] = {
9938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9939 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9941 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9942
9943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9951
9952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9957 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9958 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9959 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9960
9961 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9962 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9964 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9968 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9969
9970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9974
9975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9978
9979 { } /* end */
9980};
9981
9982/* toggle speaker-output according to the hp-jack state */
9983static void alc861vd_dallas_automute(struct hda_codec *codec)
9984{
9985 unsigned int present;
9986
9987 present = snd_hda_codec_read(codec, 0x15, 0,
9988 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9989 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9990 0x80, present ? 0x80 : 0);
9991 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9992 0x80, present ? 0x80 : 0);
9993}
9994
9995static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9996{
9997 if ((res >> 26) == ALC880_HP_EVENT)
9998 alc861vd_dallas_automute(codec);
9999}
10000
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010001/* pcm configuration: identiacal with ALC880 */
10002#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10003#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10004#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10005#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10006
10007/*
10008 * configuration and preset
10009 */
10010static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10011 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010012 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010013 [ALC861VD_3ST] = "3stack",
10014 [ALC861VD_3ST_DIG] = "3stack-digout",
10015 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010016 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010017 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010018 [ALC861VD_AUTO] = "auto",
10019};
10020
10021static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010022 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010023 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010024 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010025 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10026 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10027
Kailang Yang272a5272007-05-14 11:00:38 +020010028 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10029 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010030 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10031 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010032 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010033 {}
10034};
10035
10036static struct alc_config_preset alc861vd_presets[] = {
10037 [ALC660VD_3ST] = {
10038 .mixers = { alc861vd_3st_mixer },
10039 .init_verbs = { alc861vd_volume_init_verbs,
10040 alc861vd_3stack_init_verbs },
10041 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10042 .dac_nids = alc660vd_dac_nids,
10043 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10044 .adc_nids = alc861vd_adc_nids,
10045 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10046 .channel_mode = alc861vd_3stack_2ch_modes,
10047 .input_mux = &alc861vd_capture_source,
10048 },
Mike Crash6963f842007-06-25 12:12:51 +020010049 [ALC660VD_3ST_DIG] = {
10050 .mixers = { alc861vd_3st_mixer },
10051 .init_verbs = { alc861vd_volume_init_verbs,
10052 alc861vd_3stack_init_verbs },
10053 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10054 .dac_nids = alc660vd_dac_nids,
10055 .dig_out_nid = ALC861VD_DIGOUT_NID,
10056 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10057 .adc_nids = alc861vd_adc_nids,
10058 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10059 .channel_mode = alc861vd_3stack_2ch_modes,
10060 .input_mux = &alc861vd_capture_source,
10061 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010062 [ALC861VD_3ST] = {
10063 .mixers = { alc861vd_3st_mixer },
10064 .init_verbs = { alc861vd_volume_init_verbs,
10065 alc861vd_3stack_init_verbs },
10066 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10067 .dac_nids = alc861vd_dac_nids,
10068 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10069 .channel_mode = alc861vd_3stack_2ch_modes,
10070 .input_mux = &alc861vd_capture_source,
10071 },
10072 [ALC861VD_3ST_DIG] = {
10073 .mixers = { alc861vd_3st_mixer },
10074 .init_verbs = { alc861vd_volume_init_verbs,
10075 alc861vd_3stack_init_verbs },
10076 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10077 .dac_nids = alc861vd_dac_nids,
10078 .dig_out_nid = ALC861VD_DIGOUT_NID,
10079 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10080 .channel_mode = alc861vd_3stack_2ch_modes,
10081 .input_mux = &alc861vd_capture_source,
10082 },
10083 [ALC861VD_6ST_DIG] = {
10084 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10085 .init_verbs = { alc861vd_volume_init_verbs,
10086 alc861vd_6stack_init_verbs },
10087 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10088 .dac_nids = alc861vd_dac_nids,
10089 .dig_out_nid = ALC861VD_DIGOUT_NID,
10090 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10091 .channel_mode = alc861vd_6stack_modes,
10092 .input_mux = &alc861vd_capture_source,
10093 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010094 [ALC861VD_LENOVO] = {
10095 .mixers = { alc861vd_lenovo_mixer },
10096 .init_verbs = { alc861vd_volume_init_verbs,
10097 alc861vd_3stack_init_verbs,
10098 alc861vd_eapd_verbs,
10099 alc861vd_lenovo_unsol_verbs },
10100 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10101 .dac_nids = alc660vd_dac_nids,
10102 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10103 .adc_nids = alc861vd_adc_nids,
10104 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10105 .channel_mode = alc861vd_3stack_2ch_modes,
10106 .input_mux = &alc861vd_capture_source,
10107 .unsol_event = alc861vd_lenovo_unsol_event,
10108 .init_hook = alc861vd_lenovo_automute,
10109 },
Kailang Yang272a5272007-05-14 11:00:38 +020010110 [ALC861VD_DALLAS] = {
10111 .mixers = { alc861vd_dallas_mixer },
10112 .init_verbs = { alc861vd_dallas_verbs },
10113 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10114 .dac_nids = alc861vd_dac_nids,
10115 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10116 .adc_nids = alc861vd_adc_nids,
10117 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10118 .channel_mode = alc861vd_3stack_2ch_modes,
10119 .input_mux = &alc861vd_dallas_capture_source,
10120 .unsol_event = alc861vd_dallas_unsol_event,
10121 .init_hook = alc861vd_dallas_automute,
10122 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010123};
10124
10125/*
10126 * BIOS auto configuration
10127 */
10128static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10129 hda_nid_t nid, int pin_type, int dac_idx)
10130{
10131 /* set as output */
10132 snd_hda_codec_write(codec, nid, 0,
10133 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10134 snd_hda_codec_write(codec, nid, 0,
10135 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10136}
10137
10138static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10139{
10140 struct alc_spec *spec = codec->spec;
10141 int i;
10142
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010143 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010144 for (i = 0; i <= HDA_SIDE; i++) {
10145 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010146 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010147 if (nid)
10148 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010149 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010150 }
10151}
10152
10153
10154static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10155{
10156 struct alc_spec *spec = codec->spec;
10157 hda_nid_t pin;
10158
10159 pin = spec->autocfg.hp_pins[0];
10160 if (pin) /* connect to front and use dac 0 */
10161 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10162}
10163
10164#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10165#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10166
10167static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10168{
10169 struct alc_spec *spec = codec->spec;
10170 int i;
10171
10172 for (i = 0; i < AUTO_PIN_LAST; i++) {
10173 hda_nid_t nid = spec->autocfg.input_pins[i];
10174 if (alc861vd_is_input_pin(nid)) {
10175 snd_hda_codec_write(codec, nid, 0,
10176 AC_VERB_SET_PIN_WIDGET_CONTROL,
10177 i <= AUTO_PIN_FRONT_MIC ?
10178 PIN_VREF80 : PIN_IN);
10179 if (nid != ALC861VD_PIN_CD_NID)
10180 snd_hda_codec_write(codec, nid, 0,
10181 AC_VERB_SET_AMP_GAIN_MUTE,
10182 AMP_OUT_MUTE);
10183 }
10184 }
10185}
10186
10187#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10188#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10189
10190/* add playback controls from the parsed DAC table */
10191/* Based on ALC880 version. But ALC861VD has separate,
10192 * different NIDs for mute/unmute switch and volume control */
10193static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10194 const struct auto_pin_cfg *cfg)
10195{
10196 char name[32];
10197 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10198 hda_nid_t nid_v, nid_s;
10199 int i, err;
10200
10201 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010202 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010203 continue;
10204 nid_v = alc861vd_idx_to_mixer_vol(
10205 alc880_dac_to_idx(
10206 spec->multiout.dac_nids[i]));
10207 nid_s = alc861vd_idx_to_mixer_switch(
10208 alc880_dac_to_idx(
10209 spec->multiout.dac_nids[i]));
10210
10211 if (i == 2) {
10212 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010213 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10214 "Center Playback Volume",
10215 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10216 HDA_OUTPUT));
10217 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010218 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010219 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10220 "LFE Playback Volume",
10221 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10222 HDA_OUTPUT));
10223 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010224 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010225 err = add_control(spec, ALC_CTL_BIND_MUTE,
10226 "Center Playback Switch",
10227 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10228 HDA_INPUT));
10229 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010230 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010231 err = add_control(spec, ALC_CTL_BIND_MUTE,
10232 "LFE Playback Switch",
10233 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10234 HDA_INPUT));
10235 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010236 return err;
10237 } else {
10238 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010239 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10240 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10241 HDA_OUTPUT));
10242 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010243 return err;
10244 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010245 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010246 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010247 HDA_INPUT));
10248 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010249 return err;
10250 }
10251 }
10252 return 0;
10253}
10254
10255/* add playback controls for speaker and HP outputs */
10256/* Based on ALC880 version. But ALC861VD has separate,
10257 * different NIDs for mute/unmute switch and volume control */
10258static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10259 hda_nid_t pin, const char *pfx)
10260{
10261 hda_nid_t nid_v, nid_s;
10262 int err;
10263 char name[32];
10264
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010265 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010266 return 0;
10267
10268 if (alc880_is_fixed_pin(pin)) {
10269 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10270 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010271 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010272 spec->multiout.hp_nid = nid_v;
10273 else
10274 spec->multiout.extra_out_nid[0] = nid_v;
10275 /* control HP volume/switch on the output mixer amp */
10276 nid_v = alc861vd_idx_to_mixer_vol(
10277 alc880_fixed_pin_idx(pin));
10278 nid_s = alc861vd_idx_to_mixer_switch(
10279 alc880_fixed_pin_idx(pin));
10280
10281 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10283 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10284 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010285 return err;
10286 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010287 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10288 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10289 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010290 return err;
10291 } else if (alc880_is_multi_pin(pin)) {
10292 /* set manual connection */
10293 /* we have only a switch on HP-out PIN */
10294 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010295 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10296 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10297 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010298 return err;
10299 }
10300 return 0;
10301}
10302
10303/* parse the BIOS configuration and set up the alc_spec
10304 * return 1 if successful, 0 if the proper config is not found,
10305 * or a negative error code
10306 * Based on ALC880 version - had to change it to override
10307 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10308static int alc861vd_parse_auto_config(struct hda_codec *codec)
10309{
10310 struct alc_spec *spec = codec->spec;
10311 int err;
10312 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10313
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010314 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10315 alc861vd_ignore);
10316 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010317 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010318 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010319 return 0; /* can't find valid BIOS pin config */
10320
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010321 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10322 if (err < 0)
10323 return err;
10324 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10325 if (err < 0)
10326 return err;
10327 err = alc861vd_auto_create_extra_out(spec,
10328 spec->autocfg.speaker_pins[0],
10329 "Speaker");
10330 if (err < 0)
10331 return err;
10332 err = alc861vd_auto_create_extra_out(spec,
10333 spec->autocfg.hp_pins[0],
10334 "Headphone");
10335 if (err < 0)
10336 return err;
10337 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10338 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010339 return err;
10340
10341 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10342
10343 if (spec->autocfg.dig_out_pin)
10344 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10345
10346 if (spec->kctl_alloc)
10347 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10348
10349 spec->init_verbs[spec->num_init_verbs++]
10350 = alc861vd_volume_init_verbs;
10351
10352 spec->num_mux_defs = 1;
10353 spec->input_mux = &spec->private_imux;
10354
10355 return 1;
10356}
10357
10358/* additional initialization for auto-configuration model */
10359static void alc861vd_auto_init(struct hda_codec *codec)
10360{
10361 alc861vd_auto_init_multi_out(codec);
10362 alc861vd_auto_init_hp_out(codec);
10363 alc861vd_auto_init_analog_input(codec);
10364}
10365
10366static int patch_alc861vd(struct hda_codec *codec)
10367{
10368 struct alc_spec *spec;
10369 int err, board_config;
10370
10371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10372 if (spec == NULL)
10373 return -ENOMEM;
10374
10375 codec->spec = spec;
10376
10377 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10378 alc861vd_models,
10379 alc861vd_cfg_tbl);
10380
10381 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10382 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10383 "ALC861VD, trying auto-probe from BIOS...\n");
10384 board_config = ALC861VD_AUTO;
10385 }
10386
10387 if (board_config == ALC861VD_AUTO) {
10388 /* automatic parse from the BIOS config */
10389 err = alc861vd_parse_auto_config(codec);
10390 if (err < 0) {
10391 alc_free(codec);
10392 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010393 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010394 printk(KERN_INFO
10395 "hda_codec: Cannot set up configuration "
10396 "from BIOS. Using base mode...\n");
10397 board_config = ALC861VD_3ST;
10398 }
10399 }
10400
10401 if (board_config != ALC861VD_AUTO)
10402 setup_preset(spec, &alc861vd_presets[board_config]);
10403
10404 spec->stream_name_analog = "ALC861VD Analog";
10405 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10406 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10407
10408 spec->stream_name_digital = "ALC861VD Digital";
10409 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10410 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10411
10412 spec->adc_nids = alc861vd_adc_nids;
10413 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10414
10415 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10416 spec->num_mixers++;
10417
10418 codec->patch_ops = alc_patch_ops;
10419
10420 if (board_config == ALC861VD_AUTO)
10421 spec->init_hook = alc861vd_auto_init;
10422
10423 return 0;
10424}
10425
10426/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010427 * ALC662 support
10428 *
10429 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10430 * configuration. Each pin widget can choose any input DACs and a mixer.
10431 * Each ADC is connected from a mixer of all inputs. This makes possible
10432 * 6-channel independent captures.
10433 *
10434 * In addition, an independent DAC for the multi-playback (not used in this
10435 * driver yet).
10436 */
10437#define ALC662_DIGOUT_NID 0x06
10438#define ALC662_DIGIN_NID 0x0a
10439
10440static hda_nid_t alc662_dac_nids[4] = {
10441 /* front, rear, clfe, rear_surr */
10442 0x02, 0x03, 0x04
10443};
10444
10445static hda_nid_t alc662_adc_nids[1] = {
10446 /* ADC1-2 */
10447 0x09,
10448};
10449/* input MUX */
10450/* FIXME: should be a matrix-type input source selection */
10451
10452static struct hda_input_mux alc662_capture_source = {
10453 .num_items = 4,
10454 .items = {
10455 { "Mic", 0x0 },
10456 { "Front Mic", 0x1 },
10457 { "Line", 0x2 },
10458 { "CD", 0x4 },
10459 },
10460};
10461
10462static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10463 .num_items = 2,
10464 .items = {
10465 { "Mic", 0x1 },
10466 { "Line", 0x2 },
10467 },
10468};
10469#define alc662_mux_enum_info alc_mux_enum_info
10470#define alc662_mux_enum_get alc_mux_enum_get
10471
10472static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10473 struct snd_ctl_elem_value *ucontrol)
10474{
10475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10476 struct alc_spec *spec = codec->spec;
10477 const struct hda_input_mux *imux = spec->input_mux;
10478 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10479 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10480 hda_nid_t nid = capture_mixers[adc_idx];
10481 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10482 unsigned int i, idx;
10483
10484 idx = ucontrol->value.enumerated.item[0];
10485 if (idx >= imux->num_items)
10486 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010487 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010488 return 0;
10489 for (i = 0; i < imux->num_items; i++) {
10490 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10491 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10492 v | (imux->items[i].index << 8));
10493 }
10494 *cur_val = idx;
10495 return 1;
10496}
10497/*
10498 * 2ch mode
10499 */
10500static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10501 { 2, NULL }
10502};
10503
10504/*
10505 * 2ch mode
10506 */
10507static struct hda_verb alc662_3ST_ch2_init[] = {
10508 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10509 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10510 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10511 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10512 { } /* end */
10513};
10514
10515/*
10516 * 6ch mode
10517 */
10518static struct hda_verb alc662_3ST_ch6_init[] = {
10519 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10520 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10521 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10522 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10523 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10524 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10525 { } /* end */
10526};
10527
10528static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10529 { 2, alc662_3ST_ch2_init },
10530 { 6, alc662_3ST_ch6_init },
10531};
10532
10533/*
10534 * 2ch mode
10535 */
10536static struct hda_verb alc662_sixstack_ch6_init[] = {
10537 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10538 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10539 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10540 { } /* end */
10541};
10542
10543/*
10544 * 6ch mode
10545 */
10546static struct hda_verb alc662_sixstack_ch8_init[] = {
10547 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10548 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10549 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10550 { } /* end */
10551};
10552
10553static struct hda_channel_mode alc662_5stack_modes[2] = {
10554 { 2, alc662_sixstack_ch6_init },
10555 { 6, alc662_sixstack_ch8_init },
10556};
10557
10558/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10559 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10560 */
10561
10562static struct snd_kcontrol_new alc662_base_mixer[] = {
10563 /* output mixer control */
10564 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10567 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10573
10574 /*Input mixer control */
10575 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10576 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10577 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10578 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10579 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10580 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10583
10584 /* Capture mixer control */
10585 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10586 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10587 {
10588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10589 .name = "Capture Source",
10590 .count = 1,
10591 .info = alc_mux_enum_info,
10592 .get = alc_mux_enum_get,
10593 .put = alc_mux_enum_put,
10594 },
10595 { } /* end */
10596};
10597
10598static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10599 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10600 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10604 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10605 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10606 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10607 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10608 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10609 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10610 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10611 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10612 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10613 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10614 {
10615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10616 /* .name = "Capture Source", */
10617 .name = "Input Source",
10618 .count = 1,
10619 .info = alc662_mux_enum_info,
10620 .get = alc662_mux_enum_get,
10621 .put = alc662_mux_enum_put,
10622 },
10623 { } /* end */
10624};
10625
10626static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10627 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10628 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10629 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10630 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10631 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10632 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10633 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10634 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10644 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10645 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10646 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10647 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10648 {
10649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10650 /* .name = "Capture Source", */
10651 .name = "Input Source",
10652 .count = 1,
10653 .info = alc662_mux_enum_info,
10654 .get = alc662_mux_enum_get,
10655 .put = alc662_mux_enum_put,
10656 },
10657 { } /* end */
10658};
10659
10660static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10661 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10662 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10663 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10664 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10666 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10667 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10671 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10672 {
10673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10674 /* .name = "Capture Source", */
10675 .name = "Input Source",
10676 .count = 1,
10677 .info = alc662_mux_enum_info,
10678 .get = alc662_mux_enum_get,
10679 .put = alc662_mux_enum_put,
10680 },
10681 { } /* end */
10682};
10683
10684static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10685 {
10686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10687 .name = "Channel Mode",
10688 .info = alc_ch_mode_info,
10689 .get = alc_ch_mode_get,
10690 .put = alc_ch_mode_put,
10691 },
10692 { } /* end */
10693};
10694
10695static struct hda_verb alc662_init_verbs[] = {
10696 /* ADC: mute amp left and right */
10697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10699 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10700
10701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10706
10707 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10708 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10709 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10710 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10711 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10712 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10713
10714 /* Front Pin: output 0 (0x0c) */
10715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10717
10718 /* Rear Pin: output 1 (0x0d) */
10719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10721
10722 /* CLFE Pin: output 2 (0x0e) */
10723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10725
10726 /* Mic (rear) pin: input vref at 80% */
10727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10729 /* Front Mic pin: input vref at 80% */
10730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10732 /* Line In pin: input */
10733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10735 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10739 /* CD pin widget for input */
10740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10741
10742 /* FIXME: use matrix-type input source selection */
10743 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10744 /* Input mixer */
10745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10749 { }
10750};
10751
10752static struct hda_verb alc662_sue_init_verbs[] = {
10753 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10754 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10755 {}
10756};
10757
10758/*
10759 * generic initialization of ADC, input mixers and output mixers
10760 */
10761static struct hda_verb alc662_auto_init_verbs[] = {
10762 /*
10763 * Unmute ADC and set the default input to mic-in
10764 */
10765 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10767
10768 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10769 * mixer widget
10770 * Note: PASD motherboards uses the Line In 2 as the input for front
10771 * panel mic (mic 2)
10772 */
10773 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10776 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10778 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10779
10780 /*
10781 * Set up output mixers (0x0c - 0x0f)
10782 */
10783 /* set vol=0 to output mixers */
10784 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10787
10788 /* set up input amps for analog loopback */
10789 /* Amp Indices: DAC = 0, mixer = 1 */
10790 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10791 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10792 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10793 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10794 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10795 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10796
10797
10798 /* FIXME: use matrix-type input source selection */
10799 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10800 /* Input mixer */
10801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10804 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10806
10807 { }
10808};
10809
10810/* capture mixer elements */
10811static struct snd_kcontrol_new alc662_capture_mixer[] = {
10812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10814 {
10815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10816 /* The multiple "Capture Source" controls confuse alsamixer
10817 * So call somewhat different..
10818 * FIXME: the controls appear in the "playback" view!
10819 */
10820 /* .name = "Capture Source", */
10821 .name = "Input Source",
10822 .count = 1,
10823 .info = alc882_mux_enum_info,
10824 .get = alc882_mux_enum_get,
10825 .put = alc882_mux_enum_put,
10826 },
10827 { } /* end */
10828};
10829
10830static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10831{
10832 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010833 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010834
10835 present = snd_hda_codec_read(codec, 0x14, 0,
10836 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010837 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010838 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010839 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010840 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010841 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010842}
10843
10844static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10845{
10846 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010847 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010848
10849 present = snd_hda_codec_read(codec, 0x1b, 0,
10850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010851 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010852 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010853 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010854 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010856 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010857 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010858 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010859 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010860}
10861
10862static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10863 unsigned int res)
10864{
10865 if ((res >> 26) == ALC880_HP_EVENT)
10866 alc662_lenovo_101e_all_automute(codec);
10867 if ((res >> 26) == ALC880_FRONT_EVENT)
10868 alc662_lenovo_101e_ispeaker_automute(codec);
10869}
10870
10871
10872/* pcm configuration: identiacal with ALC880 */
10873#define alc662_pcm_analog_playback alc880_pcm_analog_playback
10874#define alc662_pcm_analog_capture alc880_pcm_analog_capture
10875#define alc662_pcm_digital_playback alc880_pcm_digital_playback
10876#define alc662_pcm_digital_capture alc880_pcm_digital_capture
10877
10878/*
10879 * configuration and preset
10880 */
10881static const char *alc662_models[ALC662_MODEL_LAST] = {
10882 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10883 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10884 [ALC662_3ST_6ch] = "3stack-6ch",
10885 [ALC662_5ST_DIG] = "6stack-dig",
10886 [ALC662_LENOVO_101E] = "lenovo-101e",
10887 [ALC662_AUTO] = "auto",
10888};
10889
10890static struct snd_pci_quirk alc662_cfg_tbl[] = {
10891 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10892 {}
10893};
10894
10895static struct alc_config_preset alc662_presets[] = {
10896 [ALC662_3ST_2ch_DIG] = {
10897 .mixers = { alc662_3ST_2ch_mixer },
10898 .init_verbs = { alc662_init_verbs },
10899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10900 .dac_nids = alc662_dac_nids,
10901 .dig_out_nid = ALC662_DIGOUT_NID,
10902 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10903 .adc_nids = alc662_adc_nids,
10904 .dig_in_nid = ALC662_DIGIN_NID,
10905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10906 .channel_mode = alc662_3ST_2ch_modes,
10907 .input_mux = &alc662_capture_source,
10908 },
10909 [ALC662_3ST_6ch_DIG] = {
10910 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10911 .init_verbs = { alc662_init_verbs },
10912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10913 .dac_nids = alc662_dac_nids,
10914 .dig_out_nid = ALC662_DIGOUT_NID,
10915 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10916 .adc_nids = alc662_adc_nids,
10917 .dig_in_nid = ALC662_DIGIN_NID,
10918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10919 .channel_mode = alc662_3ST_6ch_modes,
10920 .need_dac_fix = 1,
10921 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010922 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010923 [ALC662_3ST_6ch] = {
10924 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10925 .init_verbs = { alc662_init_verbs },
10926 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10927 .dac_nids = alc662_dac_nids,
10928 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10929 .adc_nids = alc662_adc_nids,
10930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10931 .channel_mode = alc662_3ST_6ch_modes,
10932 .need_dac_fix = 1,
10933 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010934 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010935 [ALC662_5ST_DIG] = {
10936 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10937 .init_verbs = { alc662_init_verbs },
10938 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10939 .dac_nids = alc662_dac_nids,
10940 .dig_out_nid = ALC662_DIGOUT_NID,
10941 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10942 .adc_nids = alc662_adc_nids,
10943 .dig_in_nid = ALC662_DIGIN_NID,
10944 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10945 .channel_mode = alc662_5stack_modes,
10946 .input_mux = &alc662_capture_source,
10947 },
10948 [ALC662_LENOVO_101E] = {
10949 .mixers = { alc662_lenovo_101e_mixer },
10950 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10951 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10952 .dac_nids = alc662_dac_nids,
10953 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10954 .adc_nids = alc662_adc_nids,
10955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10956 .channel_mode = alc662_3ST_2ch_modes,
10957 .input_mux = &alc662_lenovo_101e_capture_source,
10958 .unsol_event = alc662_lenovo_101e_unsol_event,
10959 .init_hook = alc662_lenovo_101e_all_automute,
10960 },
10961
10962};
10963
10964
10965/*
10966 * BIOS auto configuration
10967 */
10968
10969/* add playback controls from the parsed DAC table */
10970static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10971 const struct auto_pin_cfg *cfg)
10972{
10973 char name[32];
10974 static const char *chname[4] = {
10975 "Front", "Surround", NULL /*CLFE*/, "Side"
10976 };
10977 hda_nid_t nid;
10978 int i, err;
10979
10980 for (i = 0; i < cfg->line_outs; i++) {
10981 if (!spec->multiout.dac_nids[i])
10982 continue;
10983 nid = alc880_idx_to_dac(i);
10984 if (i == 2) {
10985 /* Center/LFE */
10986 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10987 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010988 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10989 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010990 if (err < 0)
10991 return err;
10992 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10993 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010994 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10995 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010996 if (err < 0)
10997 return err;
10998 err = add_control(spec, ALC_CTL_BIND_MUTE,
10999 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011000 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11001 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011002 if (err < 0)
11003 return err;
11004 err = add_control(spec, ALC_CTL_BIND_MUTE,
11005 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011006 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11007 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011008 if (err < 0)
11009 return err;
11010 } else {
11011 sprintf(name, "%s Playback Volume", chname[i]);
11012 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011013 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11014 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011015 if (err < 0)
11016 return err;
11017 sprintf(name, "%s Playback Switch", chname[i]);
11018 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011019 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11020 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011021 if (err < 0)
11022 return err;
11023 }
11024 }
11025 return 0;
11026}
11027
11028/* add playback controls for speaker and HP outputs */
11029static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11030 const char *pfx)
11031{
11032 hda_nid_t nid;
11033 int err;
11034 char name[32];
11035
11036 if (!pin)
11037 return 0;
11038
11039 if (alc880_is_fixed_pin(pin)) {
11040 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11041 /* printk("DAC nid=%x\n",nid); */
11042 /* specify the DAC as the extra output */
11043 if (!spec->multiout.hp_nid)
11044 spec->multiout.hp_nid = nid;
11045 else
11046 spec->multiout.extra_out_nid[0] = nid;
11047 /* control HP volume/switch on the output mixer amp */
11048 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11049 sprintf(name, "%s Playback Volume", pfx);
11050 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11051 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11052 if (err < 0)
11053 return err;
11054 sprintf(name, "%s Playback Switch", pfx);
11055 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11056 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11057 if (err < 0)
11058 return err;
11059 } else if (alc880_is_multi_pin(pin)) {
11060 /* set manual connection */
11061 /* we have only a switch on HP-out PIN */
11062 sprintf(name, "%s Playback Switch", pfx);
11063 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11064 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11065 if (err < 0)
11066 return err;
11067 }
11068 return 0;
11069}
11070
11071/* create playback/capture controls for input pins */
11072static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11073 const struct auto_pin_cfg *cfg)
11074{
11075 struct hda_input_mux *imux = &spec->private_imux;
11076 int i, err, idx;
11077
11078 for (i = 0; i < AUTO_PIN_LAST; i++) {
11079 if (alc880_is_input_pin(cfg->input_pins[i])) {
11080 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11081 err = new_analog_input(spec, cfg->input_pins[i],
11082 auto_pin_cfg_labels[i],
11083 idx, 0x0b);
11084 if (err < 0)
11085 return err;
11086 imux->items[imux->num_items].label =
11087 auto_pin_cfg_labels[i];
11088 imux->items[imux->num_items].index =
11089 alc880_input_pin_idx(cfg->input_pins[i]);
11090 imux->num_items++;
11091 }
11092 }
11093 return 0;
11094}
11095
11096static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11097 hda_nid_t nid, int pin_type,
11098 int dac_idx)
11099{
11100 /* set as output */
11101 snd_hda_codec_write(codec, nid, 0,
11102 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11103 snd_hda_codec_write(codec, nid, 0,
11104 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11105 /* need the manual connection? */
11106 if (alc880_is_multi_pin(nid)) {
11107 struct alc_spec *spec = codec->spec;
11108 int idx = alc880_multi_pin_idx(nid);
11109 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11110 AC_VERB_SET_CONNECT_SEL,
11111 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11112 }
11113}
11114
11115static void alc662_auto_init_multi_out(struct hda_codec *codec)
11116{
11117 struct alc_spec *spec = codec->spec;
11118 int i;
11119
11120 for (i = 0; i <= HDA_SIDE; i++) {
11121 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011122 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011123 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011124 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011125 i);
11126 }
11127}
11128
11129static void alc662_auto_init_hp_out(struct hda_codec *codec)
11130{
11131 struct alc_spec *spec = codec->spec;
11132 hda_nid_t pin;
11133
11134 pin = spec->autocfg.hp_pins[0];
11135 if (pin) /* connect to front */
11136 /* use dac 0 */
11137 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11138}
11139
11140#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11141#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11142
11143static void alc662_auto_init_analog_input(struct hda_codec *codec)
11144{
11145 struct alc_spec *spec = codec->spec;
11146 int i;
11147
11148 for (i = 0; i < AUTO_PIN_LAST; i++) {
11149 hda_nid_t nid = spec->autocfg.input_pins[i];
11150 if (alc662_is_input_pin(nid)) {
11151 snd_hda_codec_write(codec, nid, 0,
11152 AC_VERB_SET_PIN_WIDGET_CONTROL,
11153 (i <= AUTO_PIN_FRONT_MIC ?
11154 PIN_VREF80 : PIN_IN));
11155 if (nid != ALC662_PIN_CD_NID)
11156 snd_hda_codec_write(codec, nid, 0,
11157 AC_VERB_SET_AMP_GAIN_MUTE,
11158 AMP_OUT_MUTE);
11159 }
11160 }
11161}
11162
11163static int alc662_parse_auto_config(struct hda_codec *codec)
11164{
11165 struct alc_spec *spec = codec->spec;
11166 int err;
11167 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11168
11169 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11170 alc662_ignore);
11171 if (err < 0)
11172 return err;
11173 if (!spec->autocfg.line_outs)
11174 return 0; /* can't find valid BIOS pin config */
11175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011176 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11177 if (err < 0)
11178 return err;
11179 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11180 if (err < 0)
11181 return err;
11182 err = alc662_auto_create_extra_out(spec,
11183 spec->autocfg.speaker_pins[0],
11184 "Speaker");
11185 if (err < 0)
11186 return err;
11187 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11188 "Headphone");
11189 if (err < 0)
11190 return err;
11191 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11192 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011193 return err;
11194
11195 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11196
11197 if (spec->autocfg.dig_out_pin)
11198 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11199
11200 if (spec->kctl_alloc)
11201 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11202
11203 spec->num_mux_defs = 1;
11204 spec->input_mux = &spec->private_imux;
11205
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011206 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011207 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11208 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011209 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011210}
11211
11212/* additional initialization for auto-configuration model */
11213static void alc662_auto_init(struct hda_codec *codec)
11214{
11215 alc662_auto_init_multi_out(codec);
11216 alc662_auto_init_hp_out(codec);
11217 alc662_auto_init_analog_input(codec);
11218}
11219
11220static int patch_alc662(struct hda_codec *codec)
11221{
11222 struct alc_spec *spec;
11223 int err, board_config;
11224
11225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11226 if (!spec)
11227 return -ENOMEM;
11228
11229 codec->spec = spec;
11230
11231 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11232 alc662_models,
11233 alc662_cfg_tbl);
11234 if (board_config < 0) {
11235 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11236 "trying auto-probe from BIOS...\n");
11237 board_config = ALC662_AUTO;
11238 }
11239
11240 if (board_config == ALC662_AUTO) {
11241 /* automatic parse from the BIOS config */
11242 err = alc662_parse_auto_config(codec);
11243 if (err < 0) {
11244 alc_free(codec);
11245 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011246 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011247 printk(KERN_INFO
11248 "hda_codec: Cannot set up configuration "
11249 "from BIOS. Using base mode...\n");
11250 board_config = ALC662_3ST_2ch_DIG;
11251 }
11252 }
11253
11254 if (board_config != ALC662_AUTO)
11255 setup_preset(spec, &alc662_presets[board_config]);
11256
11257 spec->stream_name_analog = "ALC662 Analog";
11258 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11259 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11260
11261 spec->stream_name_digital = "ALC662 Digital";
11262 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11263 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11264
11265 if (!spec->adc_nids && spec->input_mux) {
11266 spec->adc_nids = alc662_adc_nids;
11267 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11268 }
11269
11270 codec->patch_ops = alc_patch_ops;
11271 if (board_config == ALC662_AUTO)
11272 spec->init_hook = alc662_auto_init;
11273
11274 return 0;
11275}
11276
11277/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011278 * patch entries
11279 */
11280struct hda_codec_preset snd_hda_preset_realtek[] = {
11281 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011282 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011283 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011284 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011285 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011286 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11287 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11288 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011289 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11290 .patch = patch_alc883 },
11291 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11292 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011293 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011294 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011295 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011296 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011297 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011298 {} /* terminator */
11299};