blob: 1950875b694cb651f620c0ec6a92ba33f4da886d [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,
125 ALC861VD_3ST,
126 ALC861VD_3ST_DIG,
127 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200128 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200129 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100130 ALC861VD_AUTO,
131 ALC861VD_MODEL_LAST,
132};
133
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200134/* ALC662 models */
135enum {
136 ALC662_3ST_2ch_DIG,
137 ALC662_3ST_6ch_DIG,
138 ALC662_3ST_6ch,
139 ALC662_5ST_DIG,
140 ALC662_LENOVO_101E,
141 ALC662_AUTO,
142 ALC662_MODEL_LAST,
143};
144
Kailang Yangdf694da2005-12-05 19:42:22 +0100145/* ALC882 models */
146enum {
147 ALC882_3ST_DIG,
148 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200149 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200150 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200151 ALC882_TARGA,
152 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100153 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200154 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100155 ALC882_MODEL_LAST,
156};
157
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200158/* ALC883 models */
159enum {
160 ALC883_3ST_2ch_DIG,
161 ALC883_3ST_6ch_DIG,
162 ALC883_3ST_6ch,
163 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200164 ALC883_TARGA_DIG,
165 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200166 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200167 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200168 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100169 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC883_LENOVO_NB0763,
172 ALC888_LENOVO_MS7195_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200173 ALC883_AUTO,
174 ALC883_MODEL_LAST,
175};
176
Kailang Yangdf694da2005-12-05 19:42:22 +0100177/* for GPIO Poll */
178#define GPIO_MASK 0x03
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180struct alc_spec {
181 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100182 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 unsigned int num_mixers;
184
Kailang Yangdf694da2005-12-05 19:42:22 +0100185 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200186 * don't forget NULL
187 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200188 */
189 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Takashi Iwai16ded522005-06-10 19:58:24 +0200191 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 struct hda_pcm_stream *stream_analog_playback;
193 struct hda_pcm_stream *stream_analog_capture;
194
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200195 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 struct hda_pcm_stream *stream_digital_playback;
197 struct hda_pcm_stream *stream_digital_capture;
198
199 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200200 struct hda_multi_out multiout; /* playback set-up
201 * max_channels, dacs must be set
202 * dig_out_nid and hp_nid are optional
203 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 /* capture */
206 unsigned int num_adc_nids;
207 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200208 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200211 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 const struct hda_input_mux *input_mux;
213 unsigned int cur_mux[3];
214
215 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100216 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200218 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100221 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200222
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200223 /* dynamic controls, init_verbs and input_mux */
224 struct auto_pin_cfg autocfg;
225 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100226 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200227 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100228 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100229
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100230 /* hooks */
231 void (*init_hook)(struct hda_codec *codec);
232 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
233
Takashi Iwai834be882006-03-01 14:16:17 +0100234 /* for pin sensing */
235 unsigned int sense_updated: 1;
236 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100237};
238
239/*
240 * configuration template - to be copied to the spec instance
241 */
242struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200243 struct snd_kcontrol_new *mixers[5]; /* should be identical size
244 * with spec
245 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 const struct hda_verb *init_verbs[5];
247 unsigned int num_dacs;
248 hda_nid_t *dac_nids;
249 hda_nid_t dig_out_nid; /* optional */
250 hda_nid_t hp_nid; /* optional */
251 unsigned int num_adc_nids;
252 hda_nid_t *adc_nids;
253 hda_nid_t dig_in_nid;
254 unsigned int num_channel_mode;
255 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200256 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200257 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100258 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100259 void (*unsol_event)(struct hda_codec *, unsigned int);
260 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261};
262
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
264/*
265 * input MUX handling
266 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200267static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
268 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269{
270 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
271 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200272 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
273 if (mux_idx >= spec->num_mux_defs)
274 mux_idx = 0;
275 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276}
277
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200278static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
279 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280{
281 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
282 struct alc_spec *spec = codec->spec;
283 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
284
285 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
286 return 0;
287}
288
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200289static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
290 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
293 struct alc_spec *spec = codec->spec;
294 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200295 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
296 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200297 spec->adc_nids[adc_idx],
298 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299}
300
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302/*
303 * channel mode setting
304 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200305static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100310 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
311 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312}
313
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316{
317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
318 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100319 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200320 spec->num_channel_mode,
321 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322}
323
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200324static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
328 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200329 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
330 spec->num_channel_mode,
331 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200332 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200333 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
334 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100338 * Control the mode of pin widget settings via the mixer. "pc" is used
339 * instead of "%" to avoid consequences of accidently treating the % as
340 * being part of a format specifier. Maximum allowed length of a value is
341 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100342 *
343 * Note: some retasking pin complexes seem to ignore requests for input
344 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
345 * are requested. Therefore order this list so that this behaviour will not
346 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
348 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200349 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100350static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100351 "Mic 50pc bias", "Mic 80pc bias",
352 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100353};
354static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100355 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356};
357/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200358 * in the pin being assumed to be exclusively an input or an output pin. In
359 * addition, "input" pins may or may not process the mic bias option
360 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
361 * accept requests for bias as of chip versions up to March 2006) and/or
362 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100363 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364#define ALC_PIN_DIR_IN 0x00
365#define ALC_PIN_DIR_OUT 0x01
366#define ALC_PIN_DIR_INOUT 0x02
367#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
368#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100371 * For each direction the minimum and maximum values are given.
372 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200373static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 { 0, 2 }, /* ALC_PIN_DIR_IN */
375 { 3, 4 }, /* ALC_PIN_DIR_OUT */
376 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200377 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
378 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100379};
380#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
381#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
382#define alc_pin_mode_n_items(_dir) \
383 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
384
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200385static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200387{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100388 unsigned int item_num = uinfo->value.enumerated.item;
389 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
390
391 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200392 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
394
395 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
396 item_num = alc_pin_mode_min(dir);
397 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200398 return 0;
399}
400
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200401static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200403{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200409 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
410 AC_VERB_GET_PIN_WIDGET_CONTROL,
411 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200412
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 /* Find enumerated value for current pinctl setting */
414 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 return 0;
419}
420
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200421static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
422 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423{
424 signed int change;
425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
426 hda_nid_t nid = kcontrol->private_value & 0xffff;
427 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
428 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200429 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
430 AC_VERB_GET_PIN_WIDGET_CONTROL,
431 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200433 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 val = alc_pin_mode_min(dir);
435
436 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100437 if (change) {
438 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200439 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100441
442 /* Also enable the retasking pin's input/output as required
443 * for the requested pin mode. Enum values of 2 or less are
444 * input modes.
445 *
446 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200447 * reduces noise slightly (particularly on input) so we'll
448 * do it. However, having both input and output buffers
449 * enabled simultaneously doesn't seem to be problematic if
450 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100451 */
452 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453 snd_hda_codec_write(codec, nid, 0,
454 AC_VERB_SET_AMP_GAIN_MUTE,
455 AMP_OUT_MUTE);
456 snd_hda_codec_write(codec, nid, 0,
457 AC_VERB_SET_AMP_GAIN_MUTE,
458 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100459 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460 snd_hda_codec_write(codec, nid, 0,
461 AC_VERB_SET_AMP_GAIN_MUTE,
462 AMP_IN_MUTE(0));
463 snd_hda_codec_write(codec, nid, 0,
464 AC_VERB_SET_AMP_GAIN_MUTE,
465 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100466 }
467 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200468 return change;
469}
470
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 .info = alc_pin_mode_info, \
474 .get = alc_pin_mode_get, \
475 .put = alc_pin_mode_put, \
476 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100477
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100478/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
479 * together using a mask with more than one bit set. This control is
480 * currently used only by the ALC260 test model. At this stage they are not
481 * needed for any "production" models.
482 */
483#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100486{
487 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
488 uinfo->count = 1;
489 uinfo->value.integer.min = 0;
490 uinfo->value.integer.max = 1;
491 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200492}
493
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100496{
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 hda_nid_t nid = kcontrol->private_value & 0xffff;
499 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
500 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200501 unsigned int val = snd_hda_codec_read(codec, nid, 0,
502 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100503
504 *valp = (val & mask) != 0;
505 return 0;
506}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200507static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100509{
510 signed int change;
511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
512 hda_nid_t nid = kcontrol->private_value & 0xffff;
513 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
514 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
516 AC_VERB_GET_GPIO_DATA,
517 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100518
519 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
521 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100522 gpio_data &= ~mask;
523 else
524 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100526
527 return change;
528}
529#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
530 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
531 .info = alc_gpio_data_info, \
532 .get = alc_gpio_data_get, \
533 .put = alc_gpio_data_put, \
534 .private_value = nid | (mask<<16) }
535#endif /* CONFIG_SND_DEBUG */
536
Jonathan Woithe92621f12006-02-28 11:47:47 +0100537/* A switch control to allow the enabling of the digital IO pins on the
538 * ALC260. This is incredibly simplistic; the intention of this control is
539 * to provide something in the test model allowing digital outputs to be
540 * identified if present. If models are found which can utilise these
541 * outputs a more complete mixer control can be devised for those models if
542 * necessary.
543 */
544#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100547{
548 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
549 uinfo->count = 1;
550 uinfo->value.integer.min = 0;
551 uinfo->value.integer.max = 1;
552 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200553}
554
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 hda_nid_t nid = kcontrol->private_value & 0xffff;
560 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
561 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 unsigned int val = snd_hda_codec_read(codec, nid, 0,
563 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100564
565 *valp = (val & mask) != 0;
566 return 0;
567}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100570{
571 signed int change;
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_DIGI_CONVERT,
578 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100579
580 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100582 if (val==0)
583 ctrl_data &= ~mask;
584 else
585 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
587 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100588
589 return change;
590}
591#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
592 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
593 .info = alc_spdif_ctrl_info, \
594 .get = alc_spdif_ctrl_get, \
595 .put = alc_spdif_ctrl_put, \
596 .private_value = nid | (mask<<16) }
597#endif /* CONFIG_SND_DEBUG */
598
Kailang Yangdf694da2005-12-05 19:42:22 +0100599/*
600 * set up from the preset table
601 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602static void setup_preset(struct alc_spec *spec,
603 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100604{
605 int i;
606
607 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
608 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
610 i++)
611 spec->init_verbs[spec->num_init_verbs++] =
612 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100613
614 spec->channel_mode = preset->channel_mode;
615 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200616 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100617
618 spec->multiout.max_channels = spec->channel_mode[0].channels;
619
620 spec->multiout.num_dacs = preset->num_dacs;
621 spec->multiout.dac_nids = preset->dac_nids;
622 spec->multiout.dig_out_nid = preset->dig_out_nid;
623 spec->multiout.hp_nid = preset->hp_nid;
624
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200625 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200626 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200627 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100628 spec->input_mux = preset->input_mux;
629
630 spec->num_adc_nids = preset->num_adc_nids;
631 spec->adc_nids = preset->adc_nids;
632 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100633
634 spec->unsol_event = preset->unsol_event;
635 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100636}
637
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200638/* Enable GPIO mask and set output */
639static struct hda_verb alc_gpio1_init_verbs[] = {
640 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
641 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
643 { }
644};
645
646static struct hda_verb alc_gpio2_init_verbs[] = {
647 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
650 { }
651};
652
Kailang Yangbdd148a2007-05-08 15:19:08 +0200653static struct hda_verb alc_gpio3_init_verbs[] = {
654 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
655 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
657 { }
658};
659
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200660/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
661 * 31 ~ 16 : Manufacture ID
662 * 15 ~ 8 : SKU ID
663 * 7 ~ 0 : Assembly ID
664 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
665 */
666static void alc_subsystem_id(struct hda_codec *codec,
667 unsigned int porta, unsigned int porte,
668 unsigned int portd)
669{
670 unsigned int ass, tmp;
671
672 ass = codec->subsystem_id;
673 if (!(ass & 1))
674 return;
675
676 /* Override */
677 tmp = (ass & 0x38) >> 3; /* external Amp control */
678 switch (tmp) {
679 case 1:
680 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
681 break;
682 case 3:
683 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
684 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200685 case 7:
686 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
687 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200688 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200689 switch (codec->vendor_id) {
690 case 0x10ec0862:
691 case 0x10ec0660:
692 case 0x10ec0662:
693 case 0x10ec0267:
694 case 0x10ec0268:
695 snd_hda_codec_write(codec, 0x14, 0,
696 AC_VERB_SET_EAPD_BTLENABLE, 2);
697 snd_hda_codec_write(codec, 0x15, 0,
698 AC_VERB_SET_EAPD_BTLENABLE, 2);
699 return;
700 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200701 case 6:
702 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
703 hda_nid_t port = 0;
704 tmp = (ass & 0x1800) >> 11;
705 switch (tmp) {
706 case 0: port = porta; break;
707 case 1: port = porte; break;
708 case 2: port = portd; break;
709 }
710 if (port)
711 snd_hda_codec_write(codec, port, 0,
712 AC_VERB_SET_EAPD_BTLENABLE,
713 2);
714 }
715 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
717 (tmp == 5 ? 0x3040 : 0x3050));
718 break;
719 }
720}
721
Takashi Iwai41e41f12005-06-08 14:48:49 +0200722/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200723 * ALC880 3-stack model
724 *
725 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
727 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 */
729
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200730static hda_nid_t alc880_dac_nids[4] = {
731 /* front, rear, clfe, rear_surr */
732 0x02, 0x05, 0x04, 0x03
733};
734
735static hda_nid_t alc880_adc_nids[3] = {
736 /* ADC0-2 */
737 0x07, 0x08, 0x09,
738};
739
740/* The datasheet says the node 0x07 is connected from inputs,
741 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100742 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200744static hda_nid_t alc880_adc_nids_alt[2] = {
745 /* ADC1-2 */
746 0x08, 0x09,
747};
748
749#define ALC880_DIGOUT_NID 0x06
750#define ALC880_DIGIN_NID 0x0a
751
752static struct hda_input_mux alc880_capture_source = {
753 .num_items = 4,
754 .items = {
755 { "Mic", 0x0 },
756 { "Front Mic", 0x3 },
757 { "Line", 0x2 },
758 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200760};
761
762/* channel source setting (2/6 channel selection for 3-stack) */
763/* 2ch mode */
764static struct hda_verb alc880_threestack_ch2_init[] = {
765 /* set line-in to input, mute it */
766 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
767 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
768 /* set mic-in to input vref 80%, mute it */
769 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
770 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 { } /* end */
772};
773
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200774/* 6ch mode */
775static struct hda_verb alc880_threestack_ch6_init[] = {
776 /* set line-in to output, unmute it */
777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
779 /* set mic-in to output, unmute it */
780 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
781 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
782 { } /* end */
783};
784
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100785static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200786 { 2, alc880_threestack_ch2_init },
787 { 6, alc880_threestack_ch6_init },
788};
789
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100790static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100794 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
805 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
806 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
807 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
808 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200810 {
811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
812 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100813 .info = alc_ch_mode_info,
814 .get = alc_ch_mode_get,
815 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200816 },
817 { } /* end */
818};
819
820/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100821static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200822 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
823 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
824 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
825 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
827 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
828 {
829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
830 /* The multiple "Capture Source" controls confuse alsamixer
831 * So call somewhat different..
832 * FIXME: the controls appear in the "playback" view!
833 */
834 /* .name = "Capture Source", */
835 .name = "Input Source",
836 .count = 3,
837 .info = alc_mux_enum_info,
838 .get = alc_mux_enum_get,
839 .put = alc_mux_enum_put,
840 },
841 { } /* end */
842};
843
844/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100845static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200846 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
847 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
848 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
849 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 {
851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
852 /* The multiple "Capture Source" controls confuse alsamixer
853 * So call somewhat different..
854 * FIXME: the controls appear in the "playback" view!
855 */
856 /* .name = "Capture Source", */
857 .name = "Input Source",
858 .count = 2,
859 .info = alc_mux_enum_info,
860 .get = alc_mux_enum_get,
861 .put = alc_mux_enum_put,
862 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 { } /* end */
864};
865
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200866
867
868/*
869 * ALC880 5-stack model
870 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200871 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
872 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200873 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
874 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
875 */
876
877/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100878static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200879 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100880 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 { } /* end */
882};
883
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200884/* channel source setting (6/8 channel selection for 5-stack) */
885/* 6ch mode */
886static struct hda_verb alc880_fivestack_ch6_init[] = {
887 /* set line-in to input, mute it */
888 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
889 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200890 { } /* end */
891};
892
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200893/* 8ch mode */
894static struct hda_verb alc880_fivestack_ch8_init[] = {
895 /* set line-in to output, unmute it */
896 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
897 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
898 { } /* end */
899};
900
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100901static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200902 { 6, alc880_fivestack_ch6_init },
903 { 8, alc880_fivestack_ch8_init },
904};
905
906
907/*
908 * ALC880 6-stack model
909 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200910 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
911 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200912 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
913 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
914 */
915
916static hda_nid_t alc880_6st_dac_nids[4] = {
917 /* front, rear, clfe, rear_surr */
918 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200919};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200920
921static struct hda_input_mux alc880_6stack_capture_source = {
922 .num_items = 4,
923 .items = {
924 { "Mic", 0x0 },
925 { "Front Mic", 0x1 },
926 { "Line", 0x2 },
927 { "CD", 0x4 },
928 },
929};
930
931/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100932static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200933 { 8, NULL },
934};
935
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100936static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100938 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200939 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100940 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200941 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
942 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100943 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
944 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200945 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100946 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
955 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
956 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200957 {
958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
959 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100960 .info = alc_ch_mode_info,
961 .get = alc_ch_mode_get,
962 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200963 },
964 { } /* end */
965};
966
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200967
968/*
969 * ALC880 W810 model
970 *
971 * W810 has rear IO for:
972 * Front (DAC 02)
973 * Surround (DAC 03)
974 * Center/LFE (DAC 04)
975 * Digital out (06)
976 *
977 * The system also has a pair of internal speakers, and a headphone jack.
978 * These are both connected to Line2 on the codec, hence to DAC 02.
979 *
980 * There is a variable resistor to control the speaker or headphone
981 * volume. This is a hardware-only device without a software API.
982 *
983 * Plugging headphones in will disable the internal speakers. This is
984 * implemented in hardware, not via the driver using jack sense. In
985 * a similar fashion, plugging into the rear socket marked "front" will
986 * disable both the speakers and headphones.
987 *
988 * For input, there's a microphone jack, and an "audio in" jack.
989 * These may not do anything useful with this driver yet, because I
990 * haven't setup any initialization verbs for these yet...
991 */
992
993static hda_nid_t alc880_w810_dac_nids[3] = {
994 /* front, rear/surround, clfe */
995 0x02, 0x03, 0x04
996};
997
998/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100999static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001000 { 6, NULL }
1001};
1002
1003/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001004static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001007 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001008 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001009 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001011 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1012 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1014 { } /* end */
1015};
1016
1017
1018/*
1019 * Z710V model
1020 *
1021 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001022 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1023 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001024 */
1025
1026static hda_nid_t alc880_z71v_dac_nids[1] = {
1027 0x02
1028};
1029#define ALC880_Z71V_HP_DAC 0x03
1030
1031/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001032static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001033 { 2, NULL }
1034};
1035
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001036static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001039 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001040 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1045 { } /* end */
1046};
1047
1048
1049/* FIXME! */
1050/*
1051 * ALC880 F1734 model
1052 *
1053 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1054 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1055 */
1056
1057static hda_nid_t alc880_f1734_dac_nids[1] = {
1058 0x03
1059};
1060#define ALC880_F1734_HP_DAC 0x02
1061
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001062static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001063 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001064 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001065 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001066 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001071 { } /* end */
1072};
1073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074
1075/* FIXME! */
1076/*
1077 * ALC880 ASUS model
1078 *
1079 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1080 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1081 * Mic = 0x18, Line = 0x1a
1082 */
1083
1084#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1085#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1086
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001087static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001090 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001091 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001092 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1093 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001094 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1095 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001102 {
1103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1104 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001105 .info = alc_ch_mode_info,
1106 .get = alc_ch_mode_get,
1107 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001108 },
1109 { } /* end */
1110};
1111
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001112/* FIXME! */
1113/*
1114 * ALC880 ASUS W1V model
1115 *
1116 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1117 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1118 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1119 */
1120
1121/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001122static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001123 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1124 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001125 { } /* end */
1126};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001127
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001128/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001129static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001130 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1131 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1132 { } /* end */
1133};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134
Kailang Yangdf694da2005-12-05 19:42:22 +01001135/* TCL S700 */
1136static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1141 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1144 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1146 {
1147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1148 /* The multiple "Capture Source" controls confuse alsamixer
1149 * So call somewhat different..
1150 * FIXME: the controls appear in the "playback" view!
1151 */
1152 /* .name = "Capture Source", */
1153 .name = "Input Source",
1154 .count = 1,
1155 .info = alc_mux_enum_info,
1156 .get = alc_mux_enum_get,
1157 .put = alc_mux_enum_put,
1158 },
1159 { } /* end */
1160};
1161
Kailang Yangccc656c2006-10-17 12:32:26 +02001162/* Uniwill */
1163static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1164 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1165 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1166 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1167 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1168 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1169 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1170 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1171 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1178 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1179 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1180 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1181 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1182 {
1183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1184 .name = "Channel Mode",
1185 .info = alc_ch_mode_info,
1186 .get = alc_ch_mode_get,
1187 .put = alc_ch_mode_put,
1188 },
1189 { } /* end */
1190};
1191
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001192static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1194 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1195 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1196 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1200 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1201 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1202 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1203 { } /* end */
1204};
1205
Kailang Yangccc656c2006-10-17 12:32:26 +02001206static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1207 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1208 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1209 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1210 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1213 { } /* end */
1214};
1215
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001217 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 */
1219static int alc_build_controls(struct hda_codec *codec)
1220{
1221 struct alc_spec *spec = codec->spec;
1222 int err;
1223 int i;
1224
1225 for (i = 0; i < spec->num_mixers; i++) {
1226 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1227 if (err < 0)
1228 return err;
1229 }
1230
1231 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001232 err = snd_hda_create_spdif_out_ctls(codec,
1233 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 if (err < 0)
1235 return err;
1236 }
1237 if (spec->dig_in_nid) {
1238 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1239 if (err < 0)
1240 return err;
1241 }
1242 return 0;
1243}
1244
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246/*
1247 * initialize the codec volumes, etc
1248 */
1249
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001250/*
1251 * generic initialization of ADC, input mixers and output mixers
1252 */
1253static struct hda_verb alc880_volume_init_verbs[] = {
1254 /*
1255 * Unmute ADC0-2 and set the default input to mic-in
1256 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001257 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001259 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001261 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1265 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001266 * Note: PASD motherboards uses the Line In 2 as the input for front
1267 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001269 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001276 /*
1277 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 /* set vol=0 to output mixers */
1280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1284 /* set up input amps for analog loopback */
1285 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001286 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001292 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294
1295 { }
1296};
1297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298/*
1299 * 3-stack pin configuration:
1300 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1301 */
1302static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1303 /*
1304 * preset connection lists of input pins
1305 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1306 */
1307 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1308 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1309 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1310
1311 /*
1312 * Set pin mode and muting
1313 */
1314 /* set front pin widgets 0x14 for output */
1315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1317 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1320 /* Mic2 (as headphone out) for HP output */
1321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1323 /* Line In pin widget for input */
1324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1326 /* Line2 (as front mic) pin widget for input and vref at 80% */
1327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1328 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1329 /* CD pin widget for input */
1330 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1331
1332 { }
1333};
1334
1335/*
1336 * 5-stack pin configuration:
1337 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1338 * line-in/side = 0x1a, f-mic = 0x1b
1339 */
1340static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1341 /*
1342 * preset connection lists of input pins
1343 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1344 */
1345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1346 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1347
1348 /*
1349 * Set pin mode and muting
1350 */
1351 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001356 /* unmute pins for output (no gain on this amp) */
1357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001364 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1365 /* Mic2 (as headphone out) for HP output */
1366 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001368 /* Line In pin widget for input */
1369 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1371 /* Line2 (as front mic) pin widget for input and vref at 80% */
1372 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1373 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1374 /* CD pin widget for input */
1375 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376
1377 { }
1378};
1379
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001380/*
1381 * W810 pin configuration:
1382 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1383 */
1384static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 /* hphone/speaker input selector: front DAC */
1386 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1387
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394
1395 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001396 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 { }
1399};
1400
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401/*
1402 * Z71V pin configuration:
1403 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1404 */
1405static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001410
Takashi Iwai16ded522005-06-10 19:58:24 +02001411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001414 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001415
1416 { }
1417};
1418
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001419/*
1420 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001421 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1422 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423 */
1424static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1425 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1426
Takashi Iwai16ded522005-06-10 19:58:24 +02001427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001432 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001434 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1435
Takashi Iwai16ded522005-06-10 19:58:24 +02001436 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001437 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001443 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001444 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1445
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001446 { }
1447};
Takashi Iwai16ded522005-06-10 19:58:24 +02001448
Kailang Yangccc656c2006-10-17 12:32:26 +02001449/*
1450 * Uniwill pin configuration:
1451 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1452 * line = 0x1a
1453 */
1454static struct hda_verb alc880_uniwill_init_verbs[] = {
1455 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1456
1457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1461 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1462 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1464 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1471
1472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1478 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1479 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481
1482 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1483 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1484
1485 { }
1486};
1487
1488/*
1489* Uniwill P53
1490* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1491 */
1492static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1494
1495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507
1508 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1514
1515 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1516 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1517
1518 { }
1519};
1520
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001521static struct hda_verb alc880_beep_init_verbs[] = {
1522 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1523 { }
1524};
1525
Kailang Yangccc656c2006-10-17 12:32:26 +02001526/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001527static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001528{
1529 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001530 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001531
1532 present = snd_hda_codec_read(codec, 0x14, 0,
1533 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001534 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001535 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001536 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001537 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001538 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001539 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001540 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001541 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001542 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001543}
1544
1545/* auto-toggle front mic */
1546static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1547{
1548 unsigned int present;
1549 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001550
1551 present = snd_hda_codec_read(codec, 0x18, 0,
1552 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001553 bits = present ? 0x80 : 0;
1554 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1555 0x80, bits);
1556 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1557 0x80, bits);
1558}
1559
1560static void alc880_uniwill_automute(struct hda_codec *codec)
1561{
1562 alc880_uniwill_hp_automute(codec);
1563 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001564}
1565
1566static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1567 unsigned int res)
1568{
1569 /* Looks like the unsol event is incompatible with the standard
1570 * definition. 4bit tag is placed at 28 bit!
1571 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001572 switch (res >> 28) {
1573 case ALC880_HP_EVENT:
1574 alc880_uniwill_hp_automute(codec);
1575 break;
1576 case ALC880_MIC_EVENT:
1577 alc880_uniwill_mic_automute(codec);
1578 break;
1579 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001580}
1581
1582static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1583{
1584 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001585 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001586
1587 present = snd_hda_codec_read(codec, 0x14, 0,
1588 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001589 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001590 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001591 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001592 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001593 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001594}
1595
1596static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1597{
1598 unsigned int present;
1599
1600 present = snd_hda_codec_read(codec, 0x21, 0,
1601 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1602
1603 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1604 0x7f, present);
1605 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1606 0x7f, present);
1607
1608 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1609 0x7f, present);
1610 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1611 0x7f, present);
1612
1613}
1614static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1615 unsigned int res)
1616{
1617 /* Looks like the unsol event is incompatible with the standard
1618 * definition. 4bit tag is placed at 28 bit!
1619 */
1620 if ((res >> 28) == ALC880_HP_EVENT)
1621 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001622 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001623 alc880_uniwill_p53_dcvol_automute(codec);
1624}
1625
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001626/* FIXME! */
1627/*
1628 * F1734 pin configuration:
1629 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1630 */
1631static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1632 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1633 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1634 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1635 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1636
1637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641
1642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001651
1652 { }
1653};
1654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655/* FIXME! */
1656/*
1657 * ASUS pin configuration:
1658 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1659 */
1660static struct hda_verb alc880_pin_asus_init_verbs[] = {
1661 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1662 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1663 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1664 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1665
1666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1674
1675 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1681 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1683 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1684
1685 { }
1686};
1687
1688/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001689#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1690#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691
Kailang Yangdf694da2005-12-05 19:42:22 +01001692/* Clevo m520g init */
1693static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1694 /* headphone output */
1695 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1696 /* line-out */
1697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1699 /* Line-in */
1700 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1702 /* CD */
1703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1704 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 /* Mic1 (rear panel) */
1706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708 /* Mic2 (front panel) */
1709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 /* headphone */
1712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1714 /* change to EAPD mode */
1715 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1716 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1717
1718 { }
1719};
1720
1721static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001722 /* change to EAPD mode */
1723 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1724 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1725
Kailang Yangdf694da2005-12-05 19:42:22 +01001726 /* Headphone output */
1727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1728 /* Front output*/
1729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1730 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1731
1732 /* Line In pin widget for input */
1733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1734 /* CD pin widget for input */
1735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1736 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1738
1739 /* change to EAPD mode */
1740 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1741 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1742
1743 { }
1744};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745
1746/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001747 * LG m1 express dual
1748 *
1749 * Pin assignment:
1750 * Rear Line-In/Out (blue): 0x14
1751 * Build-in Mic-In: 0x15
1752 * Speaker-out: 0x17
1753 * HP-Out (green): 0x1b
1754 * Mic-In/Out (red): 0x19
1755 * SPDIF-Out: 0x1e
1756 */
1757
1758/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1759static hda_nid_t alc880_lg_dac_nids[3] = {
1760 0x05, 0x02, 0x03
1761};
1762
1763/* seems analog CD is not working */
1764static struct hda_input_mux alc880_lg_capture_source = {
1765 .num_items = 3,
1766 .items = {
1767 { "Mic", 0x1 },
1768 { "Line", 0x5 },
1769 { "Internal Mic", 0x6 },
1770 },
1771};
1772
1773/* 2,4,6 channel modes */
1774static struct hda_verb alc880_lg_ch2_init[] = {
1775 /* set line-in and mic-in to input */
1776 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1777 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1778 { }
1779};
1780
1781static struct hda_verb alc880_lg_ch4_init[] = {
1782 /* set line-in to out and mic-in to input */
1783 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1784 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1785 { }
1786};
1787
1788static struct hda_verb alc880_lg_ch6_init[] = {
1789 /* set line-in and mic-in to output */
1790 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1791 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1792 { }
1793};
1794
1795static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1796 { 2, alc880_lg_ch2_init },
1797 { 4, alc880_lg_ch4_init },
1798 { 6, alc880_lg_ch6_init },
1799};
1800
1801static struct snd_kcontrol_new alc880_lg_mixer[] = {
1802 /* FIXME: it's not really "master" but front channels */
1803 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1804 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1805 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1806 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1807 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1808 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1809 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1810 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1815 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1816 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1817 {
1818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1819 .name = "Channel Mode",
1820 .info = alc_ch_mode_info,
1821 .get = alc_ch_mode_get,
1822 .put = alc_ch_mode_put,
1823 },
1824 { } /* end */
1825};
1826
1827static struct hda_verb alc880_lg_init_verbs[] = {
1828 /* set capture source to mic-in */
1829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1832 /* mute all amp mixer inputs */
1833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1836 /* line-in to input */
1837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 /* built-in mic */
1840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1842 /* speaker-out */
1843 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 /* mic-in to input */
1846 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1847 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1849 /* HP-out */
1850 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1851 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1853 /* jack sense */
1854 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1855 { }
1856};
1857
1858/* toggle speaker-output according to the hp-jack state */
1859static void alc880_lg_automute(struct hda_codec *codec)
1860{
1861 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001862 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001863
1864 present = snd_hda_codec_read(codec, 0x1b, 0,
1865 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001866 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001867 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001868 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001869 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001870 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001871}
1872
1873static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1874{
1875 /* Looks like the unsol event is incompatible with the standard
1876 * definition. 4bit tag is placed at 28 bit!
1877 */
1878 if ((res >> 28) == 0x01)
1879 alc880_lg_automute(codec);
1880}
1881
1882/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001883 * LG LW20
1884 *
1885 * Pin assignment:
1886 * Speaker-out: 0x14
1887 * Mic-In: 0x18
1888 * Built-in Mic-In: 0x19 (?)
1889 * HP-Out: 0x1b
1890 * SPDIF-Out: 0x1e
1891 */
1892
1893/* seems analog CD is not working */
1894static struct hda_input_mux alc880_lg_lw_capture_source = {
1895 .num_items = 2,
1896 .items = {
1897 { "Mic", 0x0 },
1898 { "Internal Mic", 0x1 },
1899 },
1900};
1901
1902static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1903 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1904 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1907 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1908 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1909 { } /* end */
1910};
1911
1912static struct hda_verb alc880_lg_lw_init_verbs[] = {
1913 /* set capture source to mic-in */
1914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1915 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1918 /* speaker-out */
1919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 /* HP-out */
1922 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1923 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 /* mic-in to input */
1926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1928 /* built-in mic */
1929 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1930 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1931 /* jack sense */
1932 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1933 { }
1934};
1935
1936/* toggle speaker-output according to the hp-jack state */
1937static void alc880_lg_lw_automute(struct hda_codec *codec)
1938{
1939 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001940 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001941
1942 present = snd_hda_codec_read(codec, 0x1b, 0,
1943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001944 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001945 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001946 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001947 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001948 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001949}
1950
1951static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1952{
1953 /* Looks like the unsol event is incompatible with the standard
1954 * definition. 4bit tag is placed at 28 bit!
1955 */
1956 if ((res >> 28) == 0x01)
1957 alc880_lg_lw_automute(codec);
1958}
1959
1960/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001961 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001962 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001963
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964static int alc_init(struct hda_codec *codec)
1965{
1966 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001967 unsigned int i;
1968
1969 for (i = 0; i < spec->num_init_verbs; i++)
1970 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001971
1972 if (spec->init_hook)
1973 spec->init_hook(codec);
1974
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975 return 0;
1976}
1977
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001978static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1979{
1980 struct alc_spec *spec = codec->spec;
1981
1982 if (spec->unsol_event)
1983 spec->unsol_event(codec, res);
1984}
1985
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986#ifdef CONFIG_PM
1987/*
1988 * resume
1989 */
1990static int alc_resume(struct hda_codec *codec)
1991{
1992 struct alc_spec *spec = codec->spec;
1993 int i;
1994
1995 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001996 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 if (spec->multiout.dig_out_nid)
1999 snd_hda_resume_spdif_out(codec);
2000 if (spec->dig_in_nid)
2001 snd_hda_resume_spdif_in(codec);
2002
2003 return 0;
2004}
2005#endif
2006
2007/*
2008 * Analog playback callbacks
2009 */
2010static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2011 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002012 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013{
2014 struct alc_spec *spec = codec->spec;
2015 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2016}
2017
2018static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2019 struct hda_codec *codec,
2020 unsigned int stream_tag,
2021 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002022 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023{
2024 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002025 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2026 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027}
2028
2029static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2030 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002031 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032{
2033 struct alc_spec *spec = codec->spec;
2034 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2035}
2036
2037/*
2038 * Digital out
2039 */
2040static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2041 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002042 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043{
2044 struct alc_spec *spec = codec->spec;
2045 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2046}
2047
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002048static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2049 struct hda_codec *codec,
2050 unsigned int stream_tag,
2051 unsigned int format,
2052 struct snd_pcm_substream *substream)
2053{
2054 struct alc_spec *spec = codec->spec;
2055 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2056 stream_tag, format, substream);
2057}
2058
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2060 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002061 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062{
2063 struct alc_spec *spec = codec->spec;
2064 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2065}
2066
2067/*
2068 * Analog capture
2069 */
2070static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2071 struct hda_codec *codec,
2072 unsigned int stream_tag,
2073 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002074 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075{
2076 struct alc_spec *spec = codec->spec;
2077
2078 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2079 stream_tag, 0, format);
2080 return 0;
2081}
2082
2083static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2084 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002085 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086{
2087 struct alc_spec *spec = codec->spec;
2088
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002089 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2090 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091 return 0;
2092}
2093
2094
2095/*
2096 */
2097static struct hda_pcm_stream alc880_pcm_analog_playback = {
2098 .substreams = 1,
2099 .channels_min = 2,
2100 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 .ops = {
2103 .open = alc880_playback_pcm_open,
2104 .prepare = alc880_playback_pcm_prepare,
2105 .cleanup = alc880_playback_pcm_cleanup
2106 },
2107};
2108
2109static struct hda_pcm_stream alc880_pcm_analog_capture = {
2110 .substreams = 2,
2111 .channels_min = 2,
2112 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002113 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 .ops = {
2115 .prepare = alc880_capture_pcm_prepare,
2116 .cleanup = alc880_capture_pcm_cleanup
2117 },
2118};
2119
2120static struct hda_pcm_stream alc880_pcm_digital_playback = {
2121 .substreams = 1,
2122 .channels_min = 2,
2123 .channels_max = 2,
2124 /* NID is set in alc_build_pcms */
2125 .ops = {
2126 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002127 .close = alc880_dig_playback_pcm_close,
2128 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 },
2130};
2131
2132static struct hda_pcm_stream alc880_pcm_digital_capture = {
2133 .substreams = 1,
2134 .channels_min = 2,
2135 .channels_max = 2,
2136 /* NID is set in alc_build_pcms */
2137};
2138
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002139/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2140static struct hda_pcm_stream alc_pcm_null_playback = {
2141 .substreams = 0,
2142 .channels_min = 0,
2143 .channels_max = 0,
2144};
2145
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146static int alc_build_pcms(struct hda_codec *codec)
2147{
2148 struct alc_spec *spec = codec->spec;
2149 struct hda_pcm *info = spec->pcm_rec;
2150 int i;
2151
2152 codec->num_pcms = 1;
2153 codec->pcm_info = info;
2154
2155 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002156 if (spec->stream_analog_playback) {
2157 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2158 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2159 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2160 }
2161 if (spec->stream_analog_capture) {
2162 snd_assert(spec->adc_nids, return -EINVAL);
2163 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2164 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166
Takashi Iwai4a471b72005-12-07 13:56:29 +01002167 if (spec->channel_mode) {
2168 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2169 for (i = 0; i < spec->num_channel_mode; i++) {
2170 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2171 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2172 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 }
2174 }
2175
Takashi Iwaie08a0072006-09-07 17:52:14 +02002176 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002178 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002179 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002181 if (spec->multiout.dig_out_nid &&
2182 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2184 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2185 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002186 if (spec->dig_in_nid &&
2187 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2189 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2190 }
2191 }
2192
Takashi Iwaie08a0072006-09-07 17:52:14 +02002193 /* If the use of more than one ADC is requested for the current
2194 * model, configure a second analog capture-only PCM.
2195 */
2196 /* Additional Analaog capture for index #2 */
2197 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2198 spec->adc_nids) {
2199 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002200 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002201 info->name = spec->stream_name_analog;
2202 /* No playback stream for second PCM */
2203 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2205 if (spec->stream_analog_capture) {
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2208 }
2209 }
2210
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 return 0;
2212}
2213
2214static void alc_free(struct hda_codec *codec)
2215{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002216 struct alc_spec *spec = codec->spec;
2217 unsigned int i;
2218
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002219 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220 return;
2221
2222 if (spec->kctl_alloc) {
2223 for (i = 0; i < spec->num_kctl_used; i++)
2224 kfree(spec->kctl_alloc[i].name);
2225 kfree(spec->kctl_alloc);
2226 }
2227 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228}
2229
2230/*
2231 */
2232static struct hda_codec_ops alc_patch_ops = {
2233 .build_controls = alc_build_controls,
2234 .build_pcms = alc_build_pcms,
2235 .init = alc_init,
2236 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002237 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238#ifdef CONFIG_PM
2239 .resume = alc_resume,
2240#endif
2241};
2242
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002243
2244/*
2245 * Test configuration for debugging
2246 *
2247 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2248 * enum controls.
2249 */
2250#ifdef CONFIG_SND_DEBUG
2251static hda_nid_t alc880_test_dac_nids[4] = {
2252 0x02, 0x03, 0x04, 0x05
2253};
2254
2255static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002256 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002257 .items = {
2258 { "In-1", 0x0 },
2259 { "In-2", 0x1 },
2260 { "In-3", 0x2 },
2261 { "In-4", 0x3 },
2262 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002263 { "Front", 0x5 },
2264 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002265 },
2266};
2267
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002268static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002269 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002270 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002271 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002272 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002273};
2274
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002275static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2276 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002277{
2278 static char *texts[] = {
2279 "N/A", "Line Out", "HP Out",
2280 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2281 };
2282 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2283 uinfo->count = 1;
2284 uinfo->value.enumerated.items = 8;
2285 if (uinfo->value.enumerated.item >= 8)
2286 uinfo->value.enumerated.item = 7;
2287 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2288 return 0;
2289}
2290
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002291static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2292 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002293{
2294 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2295 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2296 unsigned int pin_ctl, item = 0;
2297
2298 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2299 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2300 if (pin_ctl & AC_PINCTL_OUT_EN) {
2301 if (pin_ctl & AC_PINCTL_HP_EN)
2302 item = 2;
2303 else
2304 item = 1;
2305 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2306 switch (pin_ctl & AC_PINCTL_VREFEN) {
2307 case AC_PINCTL_VREF_HIZ: item = 3; break;
2308 case AC_PINCTL_VREF_50: item = 4; break;
2309 case AC_PINCTL_VREF_GRD: item = 5; break;
2310 case AC_PINCTL_VREF_80: item = 6; break;
2311 case AC_PINCTL_VREF_100: item = 7; break;
2312 }
2313 }
2314 ucontrol->value.enumerated.item[0] = item;
2315 return 0;
2316}
2317
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002318static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2319 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002320{
2321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2322 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2323 static unsigned int ctls[] = {
2324 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2325 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2330 };
2331 unsigned int old_ctl, new_ctl;
2332
2333 old_ctl = snd_hda_codec_read(codec, nid, 0,
2334 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2335 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2336 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002337 snd_hda_codec_write(codec, nid, 0,
2338 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002339 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002340 (ucontrol->value.enumerated.item[0] >= 3 ?
2341 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002342 return 1;
2343 }
2344 return 0;
2345}
2346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002347static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2348 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002349{
2350 static char *texts[] = {
2351 "Front", "Surround", "CLFE", "Side"
2352 };
2353 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2354 uinfo->count = 1;
2355 uinfo->value.enumerated.items = 4;
2356 if (uinfo->value.enumerated.item >= 4)
2357 uinfo->value.enumerated.item = 3;
2358 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2359 return 0;
2360}
2361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002362static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2363 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002364{
2365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2366 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2367 unsigned int sel;
2368
2369 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2370 ucontrol->value.enumerated.item[0] = sel & 3;
2371 return 0;
2372}
2373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002374static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2375 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002376{
2377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2379 unsigned int sel;
2380
2381 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2382 if (ucontrol->value.enumerated.item[0] != sel) {
2383 sel = ucontrol->value.enumerated.item[0] & 3;
2384 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2385 return 1;
2386 }
2387 return 0;
2388}
2389
2390#define PIN_CTL_TEST(xname,nid) { \
2391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2392 .name = xname, \
2393 .info = alc_test_pin_ctl_info, \
2394 .get = alc_test_pin_ctl_get, \
2395 .put = alc_test_pin_ctl_put, \
2396 .private_value = nid \
2397 }
2398
2399#define PIN_SRC_TEST(xname,nid) { \
2400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2401 .name = xname, \
2402 .info = alc_test_pin_src_info, \
2403 .get = alc_test_pin_src_get, \
2404 .put = alc_test_pin_src_put, \
2405 .private_value = nid \
2406 }
2407
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002408static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2410 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2411 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2412 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2414 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2415 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2416 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002417 PIN_CTL_TEST("Front Pin Mode", 0x14),
2418 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2419 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2420 PIN_CTL_TEST("Side Pin Mode", 0x17),
2421 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2422 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2423 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2424 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2425 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2426 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2427 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2428 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2429 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2430 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2431 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2432 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2433 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2434 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2435 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2436 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2437 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2438 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002439 {
2440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2441 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002442 .info = alc_ch_mode_info,
2443 .get = alc_ch_mode_get,
2444 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002445 },
2446 { } /* end */
2447};
2448
2449static struct hda_verb alc880_test_init_verbs[] = {
2450 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2457 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002459 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2463 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002464 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002469 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002474 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002480 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002485 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002487 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002489 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002492 /* Analog input/passthru */
2493 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002498 { }
2499};
2500#endif
2501
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502/*
2503 */
2504
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002505static const char *alc880_models[ALC880_MODEL_LAST] = {
2506 [ALC880_3ST] = "3stack",
2507 [ALC880_TCL_S700] = "tcl",
2508 [ALC880_3ST_DIG] = "3stack-digout",
2509 [ALC880_CLEVO] = "clevo",
2510 [ALC880_5ST] = "5stack",
2511 [ALC880_5ST_DIG] = "5stack-digout",
2512 [ALC880_W810] = "w810",
2513 [ALC880_Z71V] = "z71v",
2514 [ALC880_6ST] = "6stack",
2515 [ALC880_6ST_DIG] = "6stack-digout",
2516 [ALC880_ASUS] = "asus",
2517 [ALC880_ASUS_W1V] = "asus-w1v",
2518 [ALC880_ASUS_DIG] = "asus-dig",
2519 [ALC880_ASUS_DIG2] = "asus-dig2",
2520 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002521 [ALC880_UNIWILL_P53] = "uniwill-p53",
2522 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002523 [ALC880_F1734] = "F1734",
2524 [ALC880_LG] = "lg",
2525 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002526#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002527 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002528#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002529 [ALC880_AUTO] = "auto",
2530};
2531
2532static struct snd_pci_quirk alc880_cfg_tbl[] = {
2533 /* Broken BIOS configuration */
2534 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2535 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2536
2537 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2538 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002539 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002540 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2541 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2542 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2543 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2544 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2545 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2546
2547 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2548 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2549
2550 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2551 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2552 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2553 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2554 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2555 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2556 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2557 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2558 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2559 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002560 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002561 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2562 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2563 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2564 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2565
2566 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2567 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2568 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2569 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2570 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2571 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2572 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2573 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2574 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2575 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2576 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2577 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2578 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2579 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2580 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2582 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2584
2585 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2586 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2587 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2588 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2589
2590 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2591 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2592 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002593 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002594
2595 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2596 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2597 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2598 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2599
2600 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2601 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2602 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2603 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2604 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2605 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2606 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2607 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2608 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2609 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2610 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 {}
2613};
2614
Takashi Iwai16ded522005-06-10 19:58:24 +02002615/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002616 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002617 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002618static struct alc_config_preset alc880_presets[] = {
2619 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002620 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002621 .init_verbs = { alc880_volume_init_verbs,
2622 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002623 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002624 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2626 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002627 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002628 .input_mux = &alc880_capture_source,
2629 },
2630 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002632 .init_verbs = { alc880_volume_init_verbs,
2633 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002634 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002635 .dac_nids = alc880_dac_nids,
2636 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002637 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2638 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002639 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002640 .input_mux = &alc880_capture_source,
2641 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002642 [ALC880_TCL_S700] = {
2643 .mixers = { alc880_tcl_s700_mixer },
2644 .init_verbs = { alc880_volume_init_verbs,
2645 alc880_pin_tcl_S700_init_verbs,
2646 alc880_gpio2_init_verbs },
2647 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2648 .dac_nids = alc880_dac_nids,
2649 .hp_nid = 0x03,
2650 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2651 .channel_mode = alc880_2_jack_modes,
2652 .input_mux = &alc880_capture_source,
2653 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002655 .mixers = { alc880_three_stack_mixer,
2656 alc880_five_stack_mixer},
2657 .init_verbs = { alc880_volume_init_verbs,
2658 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2660 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2662 .channel_mode = alc880_fivestack_modes,
2663 .input_mux = &alc880_capture_source,
2664 },
2665 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002666 .mixers = { alc880_three_stack_mixer,
2667 alc880_five_stack_mixer },
2668 .init_verbs = { alc880_volume_init_verbs,
2669 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2671 .dac_nids = alc880_dac_nids,
2672 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2674 .channel_mode = alc880_fivestack_modes,
2675 .input_mux = &alc880_capture_source,
2676 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002677 [ALC880_6ST] = {
2678 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002679 .init_verbs = { alc880_volume_init_verbs,
2680 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002681 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2682 .dac_nids = alc880_6st_dac_nids,
2683 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2684 .channel_mode = alc880_sixstack_modes,
2685 .input_mux = &alc880_6stack_capture_source,
2686 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002688 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002689 .init_verbs = { alc880_volume_init_verbs,
2690 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2692 .dac_nids = alc880_6st_dac_nids,
2693 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2695 .channel_mode = alc880_sixstack_modes,
2696 .input_mux = &alc880_6stack_capture_source,
2697 },
2698 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002700 .init_verbs = { alc880_volume_init_verbs,
2701 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002702 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2704 .dac_nids = alc880_w810_dac_nids,
2705 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002706 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2707 .channel_mode = alc880_w810_modes,
2708 .input_mux = &alc880_capture_source,
2709 },
2710 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002712 .init_verbs = { alc880_volume_init_verbs,
2713 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002714 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2715 .dac_nids = alc880_z71v_dac_nids,
2716 .dig_out_nid = ALC880_DIGOUT_NID,
2717 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2719 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002720 .input_mux = &alc880_capture_source,
2721 },
2722 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002724 .init_verbs = { alc880_volume_init_verbs,
2725 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002726 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2727 .dac_nids = alc880_f1734_dac_nids,
2728 .hp_nid = 0x02,
2729 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2730 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002731 .input_mux = &alc880_capture_source,
2732 },
2733 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002737 alc880_gpio1_init_verbs },
2738 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2739 .dac_nids = alc880_asus_dac_nids,
2740 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2741 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002742 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002743 .input_mux = &alc880_capture_source,
2744 },
2745 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002749 alc880_gpio1_init_verbs },
2750 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2751 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002752 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2754 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002755 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002756 .input_mux = &alc880_capture_source,
2757 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002758 [ALC880_ASUS_DIG2] = {
2759 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002760 .init_verbs = { alc880_volume_init_verbs,
2761 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002762 alc880_gpio2_init_verbs }, /* use GPIO2 */
2763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2764 .dac_nids = alc880_asus_dac_nids,
2765 .dig_out_nid = ALC880_DIGOUT_NID,
2766 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2767 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002768 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002769 .input_mux = &alc880_capture_source,
2770 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002773 .init_verbs = { alc880_volume_init_verbs,
2774 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775 alc880_gpio1_init_verbs },
2776 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2777 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002778 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2780 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002781 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002782 .input_mux = &alc880_capture_source,
2783 },
2784 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002785 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002786 .init_verbs = { alc880_volume_init_verbs,
2787 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2789 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002790 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2792 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002793 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 .input_mux = &alc880_capture_source,
2795 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002796 [ALC880_UNIWILL] = {
2797 .mixers = { alc880_uniwill_mixer },
2798 .init_verbs = { alc880_volume_init_verbs,
2799 alc880_uniwill_init_verbs },
2800 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2801 .dac_nids = alc880_asus_dac_nids,
2802 .dig_out_nid = ALC880_DIGOUT_NID,
2803 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2804 .channel_mode = alc880_threestack_modes,
2805 .need_dac_fix = 1,
2806 .input_mux = &alc880_capture_source,
2807 .unsol_event = alc880_uniwill_unsol_event,
2808 .init_hook = alc880_uniwill_automute,
2809 },
2810 [ALC880_UNIWILL_P53] = {
2811 .mixers = { alc880_uniwill_p53_mixer },
2812 .init_verbs = { alc880_volume_init_verbs,
2813 alc880_uniwill_p53_init_verbs },
2814 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2815 .dac_nids = alc880_asus_dac_nids,
2816 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002817 .channel_mode = alc880_threestack_modes,
2818 .input_mux = &alc880_capture_source,
2819 .unsol_event = alc880_uniwill_p53_unsol_event,
2820 .init_hook = alc880_uniwill_p53_hp_automute,
2821 },
2822 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002823 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002824 alc880_pcbeep_mixer, },
2825 .init_verbs = { alc880_volume_init_verbs,
2826 alc880_uniwill_p53_init_verbs,
2827 alc880_beep_init_verbs },
2828 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2829 .dac_nids = alc880_dac_nids,
2830 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2831 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002832 .input_mux = &alc880_capture_source,
2833 .unsol_event = alc880_uniwill_p53_unsol_event,
2834 .init_hook = alc880_uniwill_p53_hp_automute,
2835 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002836 [ALC880_CLEVO] = {
2837 .mixers = { alc880_three_stack_mixer },
2838 .init_verbs = { alc880_volume_init_verbs,
2839 alc880_pin_clevo_init_verbs },
2840 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2841 .dac_nids = alc880_dac_nids,
2842 .hp_nid = 0x03,
2843 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2844 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002845 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002846 .input_mux = &alc880_capture_source,
2847 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002848 [ALC880_LG] = {
2849 .mixers = { alc880_lg_mixer },
2850 .init_verbs = { alc880_volume_init_verbs,
2851 alc880_lg_init_verbs },
2852 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2853 .dac_nids = alc880_lg_dac_nids,
2854 .dig_out_nid = ALC880_DIGOUT_NID,
2855 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2856 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002857 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002858 .input_mux = &alc880_lg_capture_source,
2859 .unsol_event = alc880_lg_unsol_event,
2860 .init_hook = alc880_lg_automute,
2861 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002862 [ALC880_LG_LW] = {
2863 .mixers = { alc880_lg_lw_mixer },
2864 .init_verbs = { alc880_volume_init_verbs,
2865 alc880_lg_lw_init_verbs },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002866 .num_dacs = 1,
Takashi Iwaid6815182006-03-23 16:06:23 +01002867 .dac_nids = alc880_dac_nids,
2868 .dig_out_nid = ALC880_DIGOUT_NID,
2869 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2870 .channel_mode = alc880_2_jack_modes,
2871 .input_mux = &alc880_lg_lw_capture_source,
2872 .unsol_event = alc880_lg_lw_unsol_event,
2873 .init_hook = alc880_lg_lw_automute,
2874 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002875#ifdef CONFIG_SND_DEBUG
2876 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877 .mixers = { alc880_test_mixer },
2878 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002879 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2880 .dac_nids = alc880_test_dac_nids,
2881 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002882 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2883 .channel_mode = alc880_test_modes,
2884 .input_mux = &alc880_test_capture_source,
2885 },
2886#endif
2887};
2888
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002889/*
2890 * Automatic parse of I/O pins from the BIOS configuration
2891 */
2892
2893#define NUM_CONTROL_ALLOC 32
2894#define NUM_VERB_ALLOC 32
2895
2896enum {
2897 ALC_CTL_WIDGET_VOL,
2898 ALC_CTL_WIDGET_MUTE,
2899 ALC_CTL_BIND_MUTE,
2900};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002901static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2903 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002904 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002905};
2906
2907/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002908static int add_control(struct alc_spec *spec, int type, const char *name,
2909 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002910{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002911 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002912
2913 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2914 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2915
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002916 /* array + terminator */
2917 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2918 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002919 return -ENOMEM;
2920 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002921 memcpy(knew, spec->kctl_alloc,
2922 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002923 kfree(spec->kctl_alloc);
2924 }
2925 spec->kctl_alloc = knew;
2926 spec->num_kctl_alloc = num;
2927 }
2928
2929 knew = &spec->kctl_alloc[spec->num_kctl_used];
2930 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002931 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002932 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002933 return -ENOMEM;
2934 knew->private_value = val;
2935 spec->num_kctl_used++;
2936 return 0;
2937}
2938
2939#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2940#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2941#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2942#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2943#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2944#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2945#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2946#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2947#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2948#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2949#define ALC880_PIN_CD_NID 0x1c
2950
2951/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002952static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2953 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954{
2955 hda_nid_t nid;
2956 int assigned[4];
2957 int i, j;
2958
2959 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002960 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961
2962 /* check the pins hardwired to audio widget */
2963 for (i = 0; i < cfg->line_outs; i++) {
2964 nid = cfg->line_out_pins[i];
2965 if (alc880_is_fixed_pin(nid)) {
2966 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002967 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 assigned[idx] = 1;
2969 }
2970 }
2971 /* left pins can be connect to any audio widget */
2972 for (i = 0; i < cfg->line_outs; i++) {
2973 nid = cfg->line_out_pins[i];
2974 if (alc880_is_fixed_pin(nid))
2975 continue;
2976 /* search for an empty channel */
2977 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002978 if (!assigned[j]) {
2979 spec->multiout.dac_nids[i] =
2980 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981 assigned[j] = 1;
2982 break;
2983 }
2984 }
2985 }
2986 spec->multiout.num_dacs = cfg->line_outs;
2987 return 0;
2988}
2989
2990/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002991static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2992 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002993{
2994 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002995 static const char *chname[4] = {
2996 "Front", "Surround", NULL /*CLFE*/, "Side"
2997 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 hda_nid_t nid;
2999 int i, err;
3000
3001 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003002 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003 continue;
3004 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3005 if (i == 2) {
3006 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003007 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3008 "Center Playback Volume",
3009 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3010 HDA_OUTPUT));
3011 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003012 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003013 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3014 "LFE Playback Volume",
3015 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3016 HDA_OUTPUT));
3017 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003018 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003019 err = add_control(spec, ALC_CTL_BIND_MUTE,
3020 "Center Playback Switch",
3021 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3022 HDA_INPUT));
3023 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003025 err = add_control(spec, ALC_CTL_BIND_MUTE,
3026 "LFE Playback Switch",
3027 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3028 HDA_INPUT));
3029 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003030 return err;
3031 } else {
3032 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003033 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3034 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3035 HDA_OUTPUT));
3036 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003037 return err;
3038 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003039 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3040 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3041 HDA_INPUT));
3042 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003043 return err;
3044 }
3045 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 return 0;
3047}
3048
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003049/* add playback controls for speaker and HP outputs */
3050static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3051 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052{
3053 hda_nid_t nid;
3054 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003055 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003056
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003057 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003058 return 0;
3059
3060 if (alc880_is_fixed_pin(pin)) {
3061 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003062 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003063 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003065 else
3066 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 /* control HP volume/switch on the output mixer amp */
3068 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003069 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003070 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3071 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3072 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003074 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003075 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3076 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3077 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003078 return err;
3079 } else if (alc880_is_multi_pin(pin)) {
3080 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003082 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003083 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3084 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3085 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 return err;
3087 }
3088 return 0;
3089}
3090
3091/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003092static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3093 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003094 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095{
3096 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003097 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098
3099 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003100 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3101 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3102 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003103 return err;
3104 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003105 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3106 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3107 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 return err;
3109 return 0;
3110}
3111
3112/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003113static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3114 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118
3119 for (i = 0; i < AUTO_PIN_LAST; i++) {
3120 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003121 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003122 err = new_analog_input(spec, cfg->input_pins[i],
3123 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003124 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125 if (err < 0)
3126 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003127 imux->items[imux->num_items].label =
3128 auto_pin_cfg_labels[i];
3129 imux->items[imux->num_items].index =
3130 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 imux->num_items++;
3132 }
3133 }
3134 return 0;
3135}
3136
Kailang Yangdf694da2005-12-05 19:42:22 +01003137static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3138 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 int dac_idx)
3140{
3141 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003142 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3143 pin_type);
3144 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3145 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 /* need the manual connection? */
3147 if (alc880_is_multi_pin(nid)) {
3148 struct alc_spec *spec = codec->spec;
3149 int idx = alc880_multi_pin_idx(nid);
3150 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3151 AC_VERB_SET_CONNECT_SEL,
3152 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3153 }
3154}
3155
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003156static int get_pin_type(int line_out_type)
3157{
3158 if (line_out_type == AUTO_PIN_HP_OUT)
3159 return PIN_HP;
3160 else
3161 return PIN_OUT;
3162}
3163
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164static void alc880_auto_init_multi_out(struct hda_codec *codec)
3165{
3166 struct alc_spec *spec = codec->spec;
3167 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003168
3169 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003170 for (i = 0; i < spec->autocfg.line_outs; i++) {
3171 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003172 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3173 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 }
3175}
3176
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003177static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003178{
3179 struct alc_spec *spec = codec->spec;
3180 hda_nid_t pin;
3181
Takashi Iwai82bc9552006-03-21 11:24:42 +01003182 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003183 if (pin) /* connect to front */
3184 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003185 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 if (pin) /* connect to front */
3187 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3188}
3189
3190static void alc880_auto_init_analog_input(struct hda_codec *codec)
3191{
3192 struct alc_spec *spec = codec->spec;
3193 int i;
3194
3195 for (i = 0; i < AUTO_PIN_LAST; i++) {
3196 hda_nid_t nid = spec->autocfg.input_pins[i];
3197 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003198 snd_hda_codec_write(codec, nid, 0,
3199 AC_VERB_SET_PIN_WIDGET_CONTROL,
3200 i <= AUTO_PIN_FRONT_MIC ?
3201 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003203 snd_hda_codec_write(codec, nid, 0,
3204 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205 AMP_OUT_MUTE);
3206 }
3207 }
3208}
3209
3210/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003211/* return 1 if successful, 0 if the proper config is not found,
3212 * or a negative error code
3213 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003214static int alc880_parse_auto_config(struct hda_codec *codec)
3215{
3216 struct alc_spec *spec = codec->spec;
3217 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003218 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003220 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3221 alc880_ignore);
3222 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003227 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3228 if (err < 0)
3229 return err;
3230 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3231 if (err < 0)
3232 return err;
3233 err = alc880_auto_create_extra_out(spec,
3234 spec->autocfg.speaker_pins[0],
3235 "Speaker");
3236 if (err < 0)
3237 return err;
3238 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3239 "Headphone");
3240 if (err < 0)
3241 return err;
3242 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3243 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 return err;
3245
3246 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3247
3248 if (spec->autocfg.dig_out_pin)
3249 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3250 if (spec->autocfg.dig_in_pin)
3251 spec->dig_in_nid = ALC880_DIGIN_NID;
3252
3253 if (spec->kctl_alloc)
3254 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3255
3256 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3257
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003258 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 spec->input_mux = &spec->private_imux;
3260
3261 return 1;
3262}
3263
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003264/* additional initialization for auto-configuration model */
3265static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003268 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270}
3271
3272/*
3273 * OK, here we have finally the patch for ALC880
3274 */
3275
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276static int patch_alc880(struct hda_codec *codec)
3277{
3278 struct alc_spec *spec;
3279 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003280 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003281
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003282 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003283 if (spec == NULL)
3284 return -ENOMEM;
3285
3286 codec->spec = spec;
3287
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003288 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3289 alc880_models,
3290 alc880_cfg_tbl);
3291 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003292 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3293 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003295 }
3296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297 if (board_config == ALC880_AUTO) {
3298 /* automatic parse from the BIOS config */
3299 err = alc880_parse_auto_config(codec);
3300 if (err < 0) {
3301 alc_free(codec);
3302 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003303 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003304 printk(KERN_INFO
3305 "hda_codec: Cannot set up configuration "
3306 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003307 board_config = ALC880_3ST;
3308 }
3309 }
3310
Kailang Yangdf694da2005-12-05 19:42:22 +01003311 if (board_config != ALC880_AUTO)
3312 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313
3314 spec->stream_name_analog = "ALC880 Analog";
3315 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3316 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3317
3318 spec->stream_name_digital = "ALC880 Digital";
3319 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3320 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3321
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003322 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003323 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003324 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003325 /* get type */
3326 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 if (wcap != AC_WID_AUD_IN) {
3328 spec->adc_nids = alc880_adc_nids_alt;
3329 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003330 spec->mixers[spec->num_mixers] =
3331 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003332 spec->num_mixers++;
3333 } else {
3334 spec->adc_nids = alc880_adc_nids;
3335 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3336 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3337 spec->num_mixers++;
3338 }
3339 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003340
3341 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003342 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003343 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003344
3345 return 0;
3346}
3347
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348
Linus Torvalds1da177e2005-04-16 15:20:36 -07003349/*
3350 * ALC260 support
3351 */
3352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353static hda_nid_t alc260_dac_nids[1] = {
3354 /* front */
3355 0x02,
3356};
3357
3358static hda_nid_t alc260_adc_nids[1] = {
3359 /* ADC0 */
3360 0x04,
3361};
3362
Kailang Yangdf694da2005-12-05 19:42:22 +01003363static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 /* ADC1 */
3365 0x05,
3366};
3367
Kailang Yangdf694da2005-12-05 19:42:22 +01003368static hda_nid_t alc260_hp_adc_nids[2] = {
3369 /* ADC1, 0 */
3370 0x05, 0x04
3371};
3372
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003373/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3374 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3375 */
3376static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003377 /* ADC0, ADC1 */
3378 0x04, 0x05
3379};
3380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381#define ALC260_DIGOUT_NID 0x03
3382#define ALC260_DIGIN_NID 0x06
3383
3384static struct hda_input_mux alc260_capture_source = {
3385 .num_items = 4,
3386 .items = {
3387 { "Mic", 0x0 },
3388 { "Front Mic", 0x1 },
3389 { "Line", 0x2 },
3390 { "CD", 0x4 },
3391 },
3392};
3393
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003394/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003395 * headphone jack and the internal CD lines since these are the only pins at
3396 * which audio can appear. For flexibility, also allow the option of
3397 * recording the mixer output on the second ADC (ADC0 doesn't have a
3398 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003399 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003400static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3401 {
3402 .num_items = 3,
3403 .items = {
3404 { "Mic/Line", 0x0 },
3405 { "CD", 0x4 },
3406 { "Headphone", 0x2 },
3407 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003408 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003409 {
3410 .num_items = 4,
3411 .items = {
3412 { "Mic/Line", 0x0 },
3413 { "CD", 0x4 },
3414 { "Headphone", 0x2 },
3415 { "Mixer", 0x5 },
3416 },
3417 },
3418
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003419};
3420
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003421/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3422 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003423 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003424static struct hda_input_mux alc260_acer_capture_sources[2] = {
3425 {
3426 .num_items = 4,
3427 .items = {
3428 { "Mic", 0x0 },
3429 { "Line", 0x2 },
3430 { "CD", 0x4 },
3431 { "Headphone", 0x5 },
3432 },
3433 },
3434 {
3435 .num_items = 5,
3436 .items = {
3437 { "Mic", 0x0 },
3438 { "Line", 0x2 },
3439 { "CD", 0x4 },
3440 { "Headphone", 0x6 },
3441 { "Mixer", 0x5 },
3442 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003443 },
3444};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445/*
3446 * This is just place-holder, so there's something for alc_build_pcms to look
3447 * at when it calculates the maximum number of channels. ALC260 has no mixer
3448 * element which allows changing the channel mode, so the verb list is
3449 * never used.
3450 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003451static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003452 { 2, NULL },
3453};
3454
Kailang Yangdf694da2005-12-05 19:42:22 +01003455
3456/* Mixer combinations
3457 *
3458 * basic: base_output + input + pc_beep + capture
3459 * HP: base_output + input + capture_alt
3460 * HP_3013: hp_3013 + input + capture
3461 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003462 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003463 */
3464
3465static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003466 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003467 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003468 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3469 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3470 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3471 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3472 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003473};
Kailang Yangdf694da2005-12-05 19:42:22 +01003474
3475static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003476 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3477 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3478 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3479 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3481 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3482 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 { } /* end */
3485};
3486
Kailang Yangdf694da2005-12-05 19:42:22 +01003487static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3488 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3489 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3490 { } /* end */
3491};
3492
3493static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3494 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3495 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3497 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3500 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3501 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003502 { } /* end */
3503};
3504
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003505/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3506 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3507 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003508static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003509 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003510 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003511 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003512 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3513 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3514 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3515 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003516 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003517 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3518 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3519 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003520 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003521 { } /* end */
3522};
3523
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003524/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3525 * versions of the ALC260 don't act on requests to enable mic bias from NID
3526 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3527 * datasheet doesn't mention this restriction. At this stage it's not clear
3528 * whether this behaviour is intentional or is a hardware bug in chip
3529 * revisions available in early 2006. Therefore for now allow the
3530 * "Headphone Jack Mode" control to span all choices, but if it turns out
3531 * that the lack of mic bias for this NID is intentional we could change the
3532 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3533 *
3534 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3535 * don't appear to make the mic bias available from the "line" jack, even
3536 * though the NID used for this jack (0x14) can supply it. The theory is
3537 * that perhaps Acer have included blocking capacitors between the ALC260
3538 * and the output jack. If this turns out to be the case for all such
3539 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3540 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003541 *
3542 * The C20x Tablet series have a mono internal speaker which is controlled
3543 * via the chip's Mono sum widget and pin complex, so include the necessary
3544 * controls for such models. On models without a "mono speaker" the control
3545 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003546 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003547static struct snd_kcontrol_new alc260_acer_mixer[] = {
3548 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3549 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003550 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003551 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3552 HDA_OUTPUT),
3553 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3554 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003555 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3556 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3558 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3559 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3560 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3561 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3562 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3563 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3564 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3565 { } /* end */
3566};
3567
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003568/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3569 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3570 */
3571static struct snd_kcontrol_new alc260_will_mixer[] = {
3572 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3573 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3575 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3576 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3577 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3578 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3579 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3580 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3581 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3582 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3583 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3584 { } /* end */
3585};
3586
3587/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3588 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3589 */
3590static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3591 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3592 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3594 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3595 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3596 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3597 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
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 { } /* end */
3602};
3603
Kailang Yangdf694da2005-12-05 19:42:22 +01003604/* capture mixer elements */
3605static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003606 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3607 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003608 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3609 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003610 {
3611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003612 /* The multiple "Capture Source" controls confuse alsamixer
3613 * So call somewhat different..
3614 * FIXME: the controls appear in the "playback" view!
3615 */
3616 /* .name = "Capture Source", */
3617 .name = "Input Source",
3618 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003619 .info = alc_mux_enum_info,
3620 .get = alc_mux_enum_get,
3621 .put = alc_mux_enum_put,
3622 },
3623 { } /* end */
3624};
3625
Kailang Yangdf694da2005-12-05 19:42:22 +01003626static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3627 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3629 {
3630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3631 /* The multiple "Capture Source" controls confuse alsamixer
3632 * So call somewhat different..
3633 * FIXME: the controls appear in the "playback" view!
3634 */
3635 /* .name = "Capture Source", */
3636 .name = "Input Source",
3637 .count = 1,
3638 .info = alc_mux_enum_info,
3639 .get = alc_mux_enum_get,
3640 .put = alc_mux_enum_put,
3641 },
3642 { } /* end */
3643};
3644
3645/*
3646 * initialization verbs
3647 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003648static struct hda_verb alc260_init_verbs[] = {
3649 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003651 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003653 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003654 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003655 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003656 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003657 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003659 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003660 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003661 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003662 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003663 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003664 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003665 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003666 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3667 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003668 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003669 /* set connection select to line in (default select for this ADC) */
3670 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 /* mute capture amp left and right */
3672 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3673 /* set connection select to line in (default select for this ADC) */
3674 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003675 /* set vol=0 Line-Out mixer amp left and right */
3676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3677 /* unmute pin widget amp left and right (no gain on this amp) */
3678 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3679 /* set vol=0 HP mixer amp left and right */
3680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3681 /* unmute pin widget amp left and right (no gain on this amp) */
3682 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3683 /* set vol=0 Mono mixer amp left and right */
3684 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3685 /* unmute pin widget amp left and right (no gain on this amp) */
3686 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3687 /* unmute LINE-2 out pin */
3688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003689 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3690 * Line In 2 = 0x03
3691 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003694 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003696 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003698 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003699 /* mute Front out path */
3700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3702 /* mute Headphone out path */
3703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3705 /* mute Mono out path */
3706 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 { }
3709};
3710
Takashi Iwai474167d2006-05-17 17:17:43 +02003711#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003712static struct hda_verb alc260_hp_init_verbs[] = {
3713 /* Headphone and output */
3714 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3715 /* mono output */
3716 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3717 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3718 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3719 /* Mic2 (front panel) pin widget for input and vref at 80% */
3720 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3721 /* Line In pin widget for input */
3722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3723 /* Line-2 pin widget for output */
3724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3725 /* CD pin widget for input */
3726 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3727 /* unmute amp left and right */
3728 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3729 /* set connection select to line in (default select for this ADC) */
3730 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3731 /* unmute Line-Out mixer amp left and right (volume = 0) */
3732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3733 /* mute pin widget amp left and right (no gain on this amp) */
3734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3735 /* unmute HP mixer amp left and right (volume = 0) */
3736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3737 /* mute pin widget amp left and right (no gain on this amp) */
3738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003739 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3740 * Line In 2 = 0x03
3741 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003742 /* unmute CD */
3743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3744 /* unmute Line In */
3745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3746 /* unmute Mic */
3747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3748 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3749 /* Unmute Front out path */
3750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3752 /* Unmute Headphone out path */
3753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3755 /* Unmute Mono out path */
3756 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3757 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3758 { }
3759};
Takashi Iwai474167d2006-05-17 17:17:43 +02003760#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003761
3762static struct hda_verb alc260_hp_3013_init_verbs[] = {
3763 /* Line out and output */
3764 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3765 /* mono output */
3766 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3767 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3768 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3769 /* Mic2 (front panel) pin widget for input and vref at 80% */
3770 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3771 /* Line In pin widget for input */
3772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3773 /* Headphone pin widget for output */
3774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3775 /* CD pin widget for input */
3776 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3777 /* unmute amp left and right */
3778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3779 /* set connection select to line in (default select for this ADC) */
3780 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3781 /* unmute Line-Out mixer amp left and right (volume = 0) */
3782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3783 /* mute pin widget amp left and right (no gain on this amp) */
3784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3785 /* unmute HP mixer amp left and right (volume = 0) */
3786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3787 /* mute pin widget amp left and right (no gain on this amp) */
3788 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003789 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3790 * Line In 2 = 0x03
3791 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003792 /* unmute CD */
3793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3794 /* unmute Line In */
3795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3796 /* unmute Mic */
3797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3798 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3799 /* Unmute Front out path */
3800 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3802 /* Unmute Headphone out path */
3803 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3805 /* Unmute Mono out path */
3806 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 { }
3809};
3810
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003811/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003812 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3813 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003814 */
3815static struct hda_verb alc260_fujitsu_init_verbs[] = {
3816 /* Disable all GPIOs */
3817 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3818 /* Internal speaker is connected to headphone pin */
3819 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3820 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003822 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3824 /* Ensure all other unused pins are disabled and muted. */
3825 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3826 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003827 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003828 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003829 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003830 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003833
Jonathan Woithef7ace402006-02-28 11:46:14 +01003834 /* Disable digital (SPDIF) pins */
3835 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3836 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003837
Jonathan Woithef7ace402006-02-28 11:46:14 +01003838 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3839 * when acting as an output.
3840 */
3841 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3842
3843 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3850 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003853
Jonathan Woithef7ace402006-02-28 11:46:14 +01003854 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3855 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 /* Unmute Line1 pin widget output buffer since it starts as an output.
3857 * If the pin mode is changed by the user the pin mode control will
3858 * take care of enabling the pin's input/output buffers as needed.
3859 * Therefore there's no need to enable the input buffer at this
3860 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003861 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003863 /* Unmute input buffer of pin widget used for Line-in (no equiv
3864 * mixer ctrl)
3865 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003866 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003867
Jonathan Woithef7ace402006-02-28 11:46:14 +01003868 /* Mute capture amp left and right */
3869 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3870 /* Set ADC connection select to match default mixer setting - line
3871 * in (on mic1 pin)
3872 */
3873 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003874
Jonathan Woithef7ace402006-02-28 11:46:14 +01003875 /* Do the same for the second ADC: mute capture input amp and
3876 * set ADC connection to line in (on mic1 pin)
3877 */
3878 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3879 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003880
Jonathan Woithef7ace402006-02-28 11:46:14 +01003881 /* Mute all inputs to mixer widget (even unconnected ones) */
3882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003890
3891 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003892};
3893
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003894/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3895 * similar laptops (adapted from Fujitsu init verbs).
3896 */
3897static struct hda_verb alc260_acer_init_verbs[] = {
3898 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3899 * the headphone jack. Turn this on and rely on the standard mute
3900 * methods whenever the user wants to turn these outputs off.
3901 */
3902 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3903 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3904 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3905 /* Internal speaker/Headphone jack is connected to Line-out pin */
3906 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3907 /* Internal microphone/Mic jack is connected to Mic1 pin */
3908 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3909 /* Line In jack is connected to Line1 pin */
3910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003911 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3912 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003913 /* Ensure all other unused pins are disabled and muted. */
3914 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3915 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003916 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3917 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3920 /* Disable digital (SPDIF) pins */
3921 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3922 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3923
3924 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3925 * bus when acting as outputs.
3926 */
3927 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3928 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3929
3930 /* Start with output sum widgets muted and their output gains at min */
3931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3934 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3935 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3937 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3938 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3939 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3940
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003941 /* Unmute Line-out pin widget amp left and right
3942 * (no equiv mixer ctrl)
3943 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003945 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3946 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003947 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3948 * inputs. If the pin mode is changed by the user the pin mode control
3949 * will take care of enabling the pin's input/output buffers as needed.
3950 * Therefore there's no need to enable the input buffer at this
3951 * stage.
3952 */
3953 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3955
3956 /* Mute capture amp left and right */
3957 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3958 /* Set ADC connection select to match default mixer setting - mic
3959 * (on mic1 pin)
3960 */
3961 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3962
3963 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003964 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003965 */
3966 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003967 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003968
3969 /* Mute all inputs to mixer widget (even unconnected ones) */
3970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3978
3979 { }
3980};
3981
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003982static struct hda_verb alc260_will_verbs[] = {
3983 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3984 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3985 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3986 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3987 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3988 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3989 {}
3990};
3991
3992static struct hda_verb alc260_replacer_672v_verbs[] = {
3993 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3994 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3995 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3996
3997 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3998 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3999 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4000
4001 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4002 {}
4003};
4004
4005/* toggle speaker-output according to the hp-jack state */
4006static void alc260_replacer_672v_automute(struct hda_codec *codec)
4007{
4008 unsigned int present;
4009
4010 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4011 present = snd_hda_codec_read(codec, 0x0f, 0,
4012 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4013 if (present) {
4014 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4015 snd_hda_codec_write(codec, 0x0f, 0,
4016 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4017 } else {
4018 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4019 snd_hda_codec_write(codec, 0x0f, 0,
4020 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4021 }
4022}
4023
4024static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4025 unsigned int res)
4026{
4027 if ((res >> 26) == ALC880_HP_EVENT)
4028 alc260_replacer_672v_automute(codec);
4029}
4030
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004031/* Test configuration for debugging, modelled after the ALC880 test
4032 * configuration.
4033 */
4034#ifdef CONFIG_SND_DEBUG
4035static hda_nid_t alc260_test_dac_nids[1] = {
4036 0x02,
4037};
4038static hda_nid_t alc260_test_adc_nids[2] = {
4039 0x04, 0x05,
4040};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004041/* For testing the ALC260, each input MUX needs its own definition since
4042 * the signal assignments are different. This assumes that the first ADC
4043 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004044 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004045static struct hda_input_mux alc260_test_capture_sources[2] = {
4046 {
4047 .num_items = 7,
4048 .items = {
4049 { "MIC1 pin", 0x0 },
4050 { "MIC2 pin", 0x1 },
4051 { "LINE1 pin", 0x2 },
4052 { "LINE2 pin", 0x3 },
4053 { "CD pin", 0x4 },
4054 { "LINE-OUT pin", 0x5 },
4055 { "HP-OUT pin", 0x6 },
4056 },
4057 },
4058 {
4059 .num_items = 8,
4060 .items = {
4061 { "MIC1 pin", 0x0 },
4062 { "MIC2 pin", 0x1 },
4063 { "LINE1 pin", 0x2 },
4064 { "LINE2 pin", 0x3 },
4065 { "CD pin", 0x4 },
4066 { "Mixer", 0x5 },
4067 { "LINE-OUT pin", 0x6 },
4068 { "HP-OUT pin", 0x7 },
4069 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004070 },
4071};
4072static struct snd_kcontrol_new alc260_test_mixer[] = {
4073 /* Output driver widgets */
4074 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4075 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4076 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4077 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4078 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4079 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4080
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004081 /* Modes for retasking pin widgets
4082 * Note: the ALC260 doesn't seem to act on requests to enable mic
4083 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4084 * mention this restriction. At this stage it's not clear whether
4085 * this behaviour is intentional or is a hardware bug in chip
4086 * revisions available at least up until early 2006. Therefore for
4087 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4088 * choices, but if it turns out that the lack of mic bias for these
4089 * NIDs is intentional we could change their modes from
4090 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4091 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004092 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4093 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4094 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4095 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4096 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4097 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4098
4099 /* Loopback mixer controls */
4100 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4101 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4102 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4103 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4104 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4105 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4106 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4107 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4108 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4109 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4110 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4111 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4112 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4113 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4114 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4115 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004116
4117 /* Controls for GPIO pins, assuming they are configured as outputs */
4118 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4119 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4120 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4121 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4122
Jonathan Woithe92621f12006-02-28 11:47:47 +01004123 /* Switches to allow the digital IO pins to be enabled. The datasheet
4124 * is ambigious as to which NID is which; testing on laptops which
4125 * make this output available should provide clarification.
4126 */
4127 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4128 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4129
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004130 { } /* end */
4131};
4132static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004133 /* Enable all GPIOs as outputs with an initial value of 0 */
4134 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4135 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4136 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4137
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004138 /* Enable retasking pins as output, initially without power amp */
4139 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4140 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4143 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4144 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4145
Jonathan Woithe92621f12006-02-28 11:47:47 +01004146 /* Disable digital (SPDIF) pins initially, but users can enable
4147 * them via a mixer switch. In the case of SPDIF-out, this initverb
4148 * payload also sets the generation to 0, output to be in "consumer"
4149 * PCM format, copyright asserted, no pre-emphasis and no validity
4150 * control.
4151 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004152 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4153 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4154
Jonathan Woithef7ace402006-02-28 11:46:14 +01004155 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004156 * OUT1 sum bus when acting as an output.
4157 */
4158 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4159 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4160 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4161 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4162
4163 /* Start with output sum widgets muted and their output gains at min */
4164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4170 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4171 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4173
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004174 /* Unmute retasking pin widget output buffers since the default
4175 * state appears to be output. As the pin mode is changed by the
4176 * user the pin mode control will take care of enabling the pin's
4177 * input/output buffers as needed.
4178 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4180 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4183 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4184 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4185 /* Also unmute the mono-out pin widget */
4186 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4187
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004188 /* Mute capture amp left and right */
4189 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004190 /* Set ADC connection select to match default mixer setting (mic1
4191 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004192 */
4193 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4194
4195 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004196 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004197 */
4198 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4199 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4200
4201 /* Mute all inputs to mixer widget (even unconnected ones) */
4202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4210
4211 { }
4212};
4213#endif
4214
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215static struct hda_pcm_stream alc260_pcm_analog_playback = {
4216 .substreams = 1,
4217 .channels_min = 2,
4218 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219};
4220
4221static struct hda_pcm_stream alc260_pcm_analog_capture = {
4222 .substreams = 1,
4223 .channels_min = 2,
4224 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004225};
4226
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004227#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4228#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4229
Kailang Yangdf694da2005-12-05 19:42:22 +01004230/*
4231 * for BIOS auto-configuration
4232 */
4233
4234static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4235 const char *pfx)
4236{
4237 hda_nid_t nid_vol;
4238 unsigned long vol_val, sw_val;
4239 char name[32];
4240 int err;
4241
4242 if (nid >= 0x0f && nid < 0x11) {
4243 nid_vol = nid - 0x7;
4244 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4245 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4246 } else if (nid == 0x11) {
4247 nid_vol = nid - 0x7;
4248 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4249 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4250 } else if (nid >= 0x12 && nid <= 0x15) {
4251 nid_vol = 0x08;
4252 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4253 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4254 } else
4255 return 0; /* N/A */
4256
4257 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004258 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4259 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004260 return err;
4261 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004262 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4263 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004264 return err;
4265 return 1;
4266}
4267
4268/* add playback controls from the parsed DAC table */
4269static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4270 const struct auto_pin_cfg *cfg)
4271{
4272 hda_nid_t nid;
4273 int err;
4274
4275 spec->multiout.num_dacs = 1;
4276 spec->multiout.dac_nids = spec->private_dac_nids;
4277 spec->multiout.dac_nids[0] = 0x02;
4278
4279 nid = cfg->line_out_pins[0];
4280 if (nid) {
4281 err = alc260_add_playback_controls(spec, nid, "Front");
4282 if (err < 0)
4283 return err;
4284 }
4285
Takashi Iwai82bc9552006-03-21 11:24:42 +01004286 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 if (nid) {
4288 err = alc260_add_playback_controls(spec, nid, "Speaker");
4289 if (err < 0)
4290 return err;
4291 }
4292
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004293 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004294 if (nid) {
4295 err = alc260_add_playback_controls(spec, nid, "Headphone");
4296 if (err < 0)
4297 return err;
4298 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004299 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004300}
4301
4302/* create playback/capture controls for input pins */
4303static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4304 const struct auto_pin_cfg *cfg)
4305{
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 struct hda_input_mux *imux = &spec->private_imux;
4307 int i, err, idx;
4308
4309 for (i = 0; i < AUTO_PIN_LAST; i++) {
4310 if (cfg->input_pins[i] >= 0x12) {
4311 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004312 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004313 auto_pin_cfg_labels[i], idx,
4314 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004315 if (err < 0)
4316 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317 imux->items[imux->num_items].label =
4318 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004319 imux->items[imux->num_items].index = idx;
4320 imux->num_items++;
4321 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004322 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004323 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004324 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004325 auto_pin_cfg_labels[i], idx,
4326 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004327 if (err < 0)
4328 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004329 imux->items[imux->num_items].label =
4330 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004331 imux->items[imux->num_items].index = idx;
4332 imux->num_items++;
4333 }
4334 }
4335 return 0;
4336}
4337
4338static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4339 hda_nid_t nid, int pin_type,
4340 int sel_idx)
4341{
4342 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004343 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4344 pin_type);
4345 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4346 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004347 /* need the manual connection? */
4348 if (nid >= 0x12) {
4349 int idx = nid - 0x12;
4350 snd_hda_codec_write(codec, idx + 0x0b, 0,
4351 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004352 }
4353}
4354
4355static void alc260_auto_init_multi_out(struct hda_codec *codec)
4356{
4357 struct alc_spec *spec = codec->spec;
4358 hda_nid_t nid;
4359
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004360 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004361 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004362 if (nid) {
4363 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4364 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4365 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004366
Takashi Iwai82bc9552006-03-21 11:24:42 +01004367 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004368 if (nid)
4369 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4370
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004371 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004372 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004373 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004374}
Kailang Yangdf694da2005-12-05 19:42:22 +01004375
4376#define ALC260_PIN_CD_NID 0x16
4377static void alc260_auto_init_analog_input(struct hda_codec *codec)
4378{
4379 struct alc_spec *spec = codec->spec;
4380 int i;
4381
4382 for (i = 0; i < AUTO_PIN_LAST; i++) {
4383 hda_nid_t nid = spec->autocfg.input_pins[i];
4384 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 snd_hda_codec_write(codec, nid, 0,
4386 AC_VERB_SET_PIN_WIDGET_CONTROL,
4387 i <= AUTO_PIN_FRONT_MIC ?
4388 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004389 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 snd_hda_codec_write(codec, nid, 0,
4391 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004392 AMP_OUT_MUTE);
4393 }
4394 }
4395}
4396
4397/*
4398 * generic initialization of ADC, input mixers and output mixers
4399 */
4400static struct hda_verb alc260_volume_init_verbs[] = {
4401 /*
4402 * Unmute ADC0-1 and set the default input to mic-in
4403 */
4404 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4405 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4406 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4407 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4408
4409 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4410 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004411 * Note: PASD motherboards uses the Line In 2 as the input for
4412 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004413 */
4414 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4420
4421 /*
4422 * Set up output mixers (0x08 - 0x0a)
4423 */
4424 /* set vol=0 to output mixers */
4425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4428 /* set up input amps for analog loopback */
4429 /* Amp Indices: DAC = 0, mixer = 1 */
4430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4432 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4434 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4435 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4436
4437 { }
4438};
4439
4440static int alc260_parse_auto_config(struct hda_codec *codec)
4441{
4442 struct alc_spec *spec = codec->spec;
4443 unsigned int wcap;
4444 int err;
4445 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4448 alc260_ignore);
4449 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004450 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4452 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004453 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004454 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004455 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004456 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4457 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004458 return err;
4459
4460 spec->multiout.max_channels = 2;
4461
4462 if (spec->autocfg.dig_out_pin)
4463 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4464 if (spec->kctl_alloc)
4465 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4466
4467 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4468
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004469 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 spec->input_mux = &spec->private_imux;
4471
4472 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004473 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004474 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4475 if (wcap != AC_WID_AUD_IN) {
4476 spec->adc_nids = alc260_adc_nids_alt;
4477 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4478 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004479 } else {
4480 spec->adc_nids = alc260_adc_nids;
4481 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4482 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004483 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004484 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004485
4486 return 1;
4487}
4488
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004489/* additional initialization for auto-configuration model */
4490static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004491{
Kailang Yangdf694da2005-12-05 19:42:22 +01004492 alc260_auto_init_multi_out(codec);
4493 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004494}
4495
4496/*
4497 * ALC260 configurations
4498 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004499static const char *alc260_models[ALC260_MODEL_LAST] = {
4500 [ALC260_BASIC] = "basic",
4501 [ALC260_HP] = "hp",
4502 [ALC260_HP_3013] = "hp-3013",
4503 [ALC260_FUJITSU_S702X] = "fujitsu",
4504 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004505 [ALC260_WILL] = "will",
4506 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004507#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004508 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004509#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004510 [ALC260_AUTO] = "auto",
4511};
4512
4513static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004514 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004515 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004516 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004517 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004518 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4519 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4520 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4521 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4522 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4523 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4524 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4525 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4526 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4527 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4528 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4529 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004530 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4531 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004532 {}
4533};
4534
Kailang Yangdf694da2005-12-05 19:42:22 +01004535static struct alc_config_preset alc260_presets[] = {
4536 [ALC260_BASIC] = {
4537 .mixers = { alc260_base_output_mixer,
4538 alc260_input_mixer,
4539 alc260_pc_beep_mixer,
4540 alc260_capture_mixer },
4541 .init_verbs = { alc260_init_verbs },
4542 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4543 .dac_nids = alc260_dac_nids,
4544 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4545 .adc_nids = alc260_adc_nids,
4546 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4547 .channel_mode = alc260_modes,
4548 .input_mux = &alc260_capture_source,
4549 },
4550 [ALC260_HP] = {
4551 .mixers = { alc260_base_output_mixer,
4552 alc260_input_mixer,
4553 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004554 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004555 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4556 .dac_nids = alc260_dac_nids,
4557 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4558 .adc_nids = alc260_hp_adc_nids,
4559 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4560 .channel_mode = alc260_modes,
4561 .input_mux = &alc260_capture_source,
4562 },
4563 [ALC260_HP_3013] = {
4564 .mixers = { alc260_hp_3013_mixer,
4565 alc260_input_mixer,
4566 alc260_capture_alt_mixer },
4567 .init_verbs = { alc260_hp_3013_init_verbs },
4568 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4569 .dac_nids = alc260_dac_nids,
4570 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4571 .adc_nids = alc260_hp_adc_nids,
4572 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4573 .channel_mode = alc260_modes,
4574 .input_mux = &alc260_capture_source,
4575 },
4576 [ALC260_FUJITSU_S702X] = {
4577 .mixers = { alc260_fujitsu_mixer,
4578 alc260_capture_mixer },
4579 .init_verbs = { alc260_fujitsu_init_verbs },
4580 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4581 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004582 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4583 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004584 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4585 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004586 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4587 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004588 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004589 [ALC260_ACER] = {
4590 .mixers = { alc260_acer_mixer,
4591 alc260_capture_mixer },
4592 .init_verbs = { alc260_acer_init_verbs },
4593 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4594 .dac_nids = alc260_dac_nids,
4595 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4596 .adc_nids = alc260_dual_adc_nids,
4597 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4598 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004599 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4600 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004601 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004602 [ALC260_WILL] = {
4603 .mixers = { alc260_will_mixer,
4604 alc260_capture_mixer },
4605 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4606 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4607 .dac_nids = alc260_dac_nids,
4608 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4609 .adc_nids = alc260_adc_nids,
4610 .dig_out_nid = ALC260_DIGOUT_NID,
4611 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4612 .channel_mode = alc260_modes,
4613 .input_mux = &alc260_capture_source,
4614 },
4615 [ALC260_REPLACER_672V] = {
4616 .mixers = { alc260_replacer_672v_mixer,
4617 alc260_capture_mixer },
4618 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4619 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4620 .dac_nids = alc260_dac_nids,
4621 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4622 .adc_nids = alc260_adc_nids,
4623 .dig_out_nid = ALC260_DIGOUT_NID,
4624 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4625 .channel_mode = alc260_modes,
4626 .input_mux = &alc260_capture_source,
4627 .unsol_event = alc260_replacer_672v_unsol_event,
4628 .init_hook = alc260_replacer_672v_automute,
4629 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004630#ifdef CONFIG_SND_DEBUG
4631 [ALC260_TEST] = {
4632 .mixers = { alc260_test_mixer,
4633 alc260_capture_mixer },
4634 .init_verbs = { alc260_test_init_verbs },
4635 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4636 .dac_nids = alc260_test_dac_nids,
4637 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4638 .adc_nids = alc260_test_adc_nids,
4639 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4640 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004641 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4642 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004643 },
4644#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004645};
4646
Linus Torvalds1da177e2005-04-16 15:20:36 -07004647static int patch_alc260(struct hda_codec *codec)
4648{
4649 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004650 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004651
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004652 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004653 if (spec == NULL)
4654 return -ENOMEM;
4655
4656 codec->spec = spec;
4657
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004658 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4659 alc260_models,
4660 alc260_cfg_tbl);
4661 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004662 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4663 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004664 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004665 }
4666
Kailang Yangdf694da2005-12-05 19:42:22 +01004667 if (board_config == ALC260_AUTO) {
4668 /* automatic parse from the BIOS config */
4669 err = alc260_parse_auto_config(codec);
4670 if (err < 0) {
4671 alc_free(codec);
4672 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004673 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004674 printk(KERN_INFO
4675 "hda_codec: Cannot set up configuration "
4676 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004677 board_config = ALC260_BASIC;
4678 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004680
Kailang Yangdf694da2005-12-05 19:42:22 +01004681 if (board_config != ALC260_AUTO)
4682 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004683
4684 spec->stream_name_analog = "ALC260 Analog";
4685 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4686 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4687
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004688 spec->stream_name_digital = "ALC260 Digital";
4689 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4690 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4691
Linus Torvalds1da177e2005-04-16 15:20:36 -07004692 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004693 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004694 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004695
4696 return 0;
4697}
4698
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699
Linus Torvalds1da177e2005-04-16 15:20:36 -07004700/*
4701 * ALC882 support
4702 *
4703 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4704 * configuration. Each pin widget can choose any input DACs and a mixer.
4705 * Each ADC is connected from a mixer of all inputs. This makes possible
4706 * 6-channel independent captures.
4707 *
4708 * In addition, an independent DAC for the multi-playback (not used in this
4709 * driver yet).
4710 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004711#define ALC882_DIGOUT_NID 0x06
4712#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004713
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004714static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004715 { 8, NULL }
4716};
4717
4718static hda_nid_t alc882_dac_nids[4] = {
4719 /* front, rear, clfe, rear_surr */
4720 0x02, 0x03, 0x04, 0x05
4721};
4722
Kailang Yangdf694da2005-12-05 19:42:22 +01004723/* identical with ALC880 */
4724#define alc882_adc_nids alc880_adc_nids
4725#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004726
4727/* input MUX */
4728/* FIXME: should be a matrix-type input source selection */
4729
4730static struct hda_input_mux alc882_capture_source = {
4731 .num_items = 4,
4732 .items = {
4733 { "Mic", 0x0 },
4734 { "Front Mic", 0x1 },
4735 { "Line", 0x2 },
4736 { "CD", 0x4 },
4737 },
4738};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004739#define alc882_mux_enum_info alc_mux_enum_info
4740#define alc882_mux_enum_get alc_mux_enum_get
4741
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4743 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004744{
4745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4746 struct alc_spec *spec = codec->spec;
4747 const struct hda_input_mux *imux = spec->input_mux;
4748 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4749 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4750 hda_nid_t nid = capture_mixers[adc_idx];
4751 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4752 unsigned int i, idx;
4753
4754 idx = ucontrol->value.enumerated.item[0];
4755 if (idx >= imux->num_items)
4756 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004758 return 0;
4759 for (i = 0; i < imux->num_items; i++) {
4760 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4761 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4762 v | (imux->items[i].index << 8));
4763 }
4764 *cur_val = idx;
4765 return 1;
4766}
4767
Kailang Yangdf694da2005-12-05 19:42:22 +01004768/*
Kailang Yang272a5272007-05-14 11:00:38 +02004769 * 2ch mode
4770 */
4771static struct hda_verb alc882_3ST_ch2_init[] = {
4772 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4773 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4774 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4775 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4776 { } /* end */
4777};
4778
4779/*
4780 * 6ch mode
4781 */
4782static struct hda_verb alc882_3ST_ch6_init[] = {
4783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4785 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4786 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4787 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4788 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4789 { } /* end */
4790};
4791
4792static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4793 { 2, alc882_3ST_ch2_init },
4794 { 6, alc882_3ST_ch6_init },
4795};
4796
4797/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004798 * 6ch mode
4799 */
4800static struct hda_verb alc882_sixstack_ch6_init[] = {
4801 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4802 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4803 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4804 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4805 { } /* end */
4806};
4807
4808/*
4809 * 8ch mode
4810 */
4811static struct hda_verb alc882_sixstack_ch8_init[] = {
4812 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4813 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4814 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4815 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4816 { } /* end */
4817};
4818
4819static struct hda_channel_mode alc882_sixstack_modes[2] = {
4820 { 6, alc882_sixstack_ch6_init },
4821 { 8, alc882_sixstack_ch8_init },
4822};
4823
Linus Torvalds1da177e2005-04-16 15:20:36 -07004824/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4825 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4826 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004827static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004830 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004831 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004832 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4833 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004834 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4835 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004836 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004837 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004838 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4841 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4842 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004844 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4846 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004847 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004848 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4849 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4850 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004851 { } /* end */
4852};
4853
Kailang Yangbdd148a2007-05-08 15:19:08 +02004854static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4855 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4856 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4859 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4860 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4864 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4865 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4866 { } /* end */
4867};
4868
Kailang Yang272a5272007-05-14 11:00:38 +02004869static struct snd_kcontrol_new alc882_targa_mixer[] = {
4870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4871 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4872 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4879 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4880 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4881 { } /* end */
4882};
4883
4884/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4885 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4886 */
4887static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4889 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4896 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4897 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, 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 { } /* end */
4901};
4902
Kailang Yangdf694da2005-12-05 19:42:22 +01004903static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4904 {
4905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4906 .name = "Channel Mode",
4907 .info = alc_ch_mode_info,
4908 .get = alc_ch_mode_get,
4909 .put = alc_ch_mode_put,
4910 },
4911 { } /* end */
4912};
4913
Linus Torvalds1da177e2005-04-16 15:20:36 -07004914static struct hda_verb alc882_init_verbs[] = {
4915 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004919 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004927 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004931
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004935 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004940 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004943 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004944 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004947 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4951 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004952 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004953 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4954 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4957 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004961 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004962 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004963
4964 /* FIXME: use matrix-type input source selection */
4965 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4966 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004971 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004976 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4981 /* ADC1: mute amp left and right */
4982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004983 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004984 /* ADC2: mute amp left and right */
4985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004986 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004987 /* ADC3: mute amp left and right */
4988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004989 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004990
4991 { }
4992};
4993
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004994static struct hda_verb alc882_eapd_verbs[] = {
4995 /* change to EAPD mode */
4996 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004997 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004998 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004999};
5000
Tobin Davis9102cd12006-12-15 10:02:12 +01005001/* Mac Pro test */
5002static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5006 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5007 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5008 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5009 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5010 { } /* end */
5011};
5012
5013static struct hda_verb alc882_macpro_init_verbs[] = {
5014 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5018 /* Front Pin: output 0 (0x0c) */
5019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5022 /* Front Mic pin: input vref at 80% */
5023 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5025 /* Speaker: output */
5026 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5027 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5028 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5029 /* Headphone output (output 0 - 0x0c) */
5030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5031 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5032 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5033
5034 /* FIXME: use matrix-type input source selection */
5035 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5036 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5037 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5041 /* Input mixer2 */
5042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5046 /* Input mixer3 */
5047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5051 /* ADC1: mute amp left and right */
5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5053 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5054 /* ADC2: mute amp left and right */
5055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5057 /* ADC3: mute amp left and right */
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5059 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5060
5061 { }
5062};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005063
Kailang Yang272a5272007-05-14 11:00:38 +02005064static struct hda_verb alc882_targa_verbs[] = {
5065 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5067
5068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5070
5071 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5072 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5074
5075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5076 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5077 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5078 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5079 { } /* end */
5080};
5081
5082/* toggle speaker-output according to the hp-jack state */
5083static void alc882_targa_automute(struct hda_codec *codec)
5084{
5085 unsigned int present;
5086
5087 present = snd_hda_codec_read(codec, 0x14, 0,
5088 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5089 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5090 0x80, present ? 0x80 : 0);
5091 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5092 0x80, present ? 0x80 : 0);
5093 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5094}
5095
5096static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5097{
5098 /* Looks like the unsol event is incompatible with the standard
5099 * definition. 4bit tag is placed at 26 bit!
5100 */
5101 if (((res >> 26) == ALC880_HP_EVENT)) {
5102 alc882_targa_automute(codec);
5103 }
5104}
5105
5106static struct hda_verb alc882_asus_a7j_verbs[] = {
5107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5109
5110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5113
5114 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5116 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5117
5118 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5119 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5120 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5121 { } /* end */
5122};
5123
Tobin Davis9102cd12006-12-15 10:02:12 +01005124static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5125{
5126 unsigned int gpiostate, gpiomask, gpiodir;
5127
5128 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5129 AC_VERB_GET_GPIO_DATA, 0);
5130
5131 if (!muted)
5132 gpiostate |= (1 << pin);
5133 else
5134 gpiostate &= ~(1 << pin);
5135
5136 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5137 AC_VERB_GET_GPIO_MASK, 0);
5138 gpiomask |= (1 << pin);
5139
5140 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5141 AC_VERB_GET_GPIO_DIRECTION, 0);
5142 gpiodir |= (1 << pin);
5143
5144
5145 snd_hda_codec_write(codec, codec->afg, 0,
5146 AC_VERB_SET_GPIO_MASK, gpiomask);
5147 snd_hda_codec_write(codec, codec->afg, 0,
5148 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5149
5150 msleep(1);
5151
5152 snd_hda_codec_write(codec, codec->afg, 0,
5153 AC_VERB_SET_GPIO_DATA, gpiostate);
5154}
5155
Kailang Yangdf694da2005-12-05 19:42:22 +01005156/*
5157 * generic initialization of ADC, input mixers and output mixers
5158 */
5159static struct hda_verb alc882_auto_init_verbs[] = {
5160 /*
5161 * Unmute ADC0-2 and set the default input to mic-in
5162 */
5163 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5165 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5167 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5169
5170 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5171 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005172 * Note: PASD motherboards uses the Line In 2 as the input for
5173 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005174 */
5175 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5181
5182 /*
5183 * Set up output mixers (0x0c - 0x0f)
5184 */
5185 /* set vol=0 to output mixers */
5186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5188 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5190 /* set up input amps for analog loopback */
5191 /* Amp Indices: DAC = 0, mixer = 1 */
5192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5193 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5199 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5200 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5201 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5202
5203 /* FIXME: use matrix-type input source selection */
5204 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5205 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5210 /* Input mixer2 */
5211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5215 /* Input mixer3 */
5216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5220
5221 { }
5222};
5223
5224/* capture mixer elements */
5225static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5226 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5227 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5228 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5229 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5230 {
5231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5232 /* The multiple "Capture Source" controls confuse alsamixer
5233 * So call somewhat different..
5234 * FIXME: the controls appear in the "playback" view!
5235 */
5236 /* .name = "Capture Source", */
5237 .name = "Input Source",
5238 .count = 2,
5239 .info = alc882_mux_enum_info,
5240 .get = alc882_mux_enum_get,
5241 .put = alc882_mux_enum_put,
5242 },
5243 { } /* end */
5244};
5245
5246static struct snd_kcontrol_new alc882_capture_mixer[] = {
5247 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5251 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5252 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5253 {
5254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5255 /* The multiple "Capture Source" controls confuse alsamixer
5256 * So call somewhat different..
5257 * FIXME: the controls appear in the "playback" view!
5258 */
5259 /* .name = "Capture Source", */
5260 .name = "Input Source",
5261 .count = 3,
5262 .info = alc882_mux_enum_info,
5263 .get = alc882_mux_enum_get,
5264 .put = alc882_mux_enum_put,
5265 },
5266 { } /* end */
5267};
5268
5269/* pcm configuration: identiacal with ALC880 */
5270#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5271#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5272#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5273#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5274
5275/*
5276 * configuration and preset
5277 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005278static const char *alc882_models[ALC882_MODEL_LAST] = {
5279 [ALC882_3ST_DIG] = "3stack-dig",
5280 [ALC882_6ST_DIG] = "6stack-dig",
5281 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005282 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005283 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005284 [ALC882_AUTO] = "auto",
5285};
5286
5287static struct snd_pci_quirk alc882_cfg_tbl[] = {
5288 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5289 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5290 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005291 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005292 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005293 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005294 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005295 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005296 {}
5297};
5298
5299static struct alc_config_preset alc882_presets[] = {
5300 [ALC882_3ST_DIG] = {
5301 .mixers = { alc882_base_mixer },
5302 .init_verbs = { alc882_init_verbs },
5303 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5304 .dac_nids = alc882_dac_nids,
5305 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 .dig_in_nid = ALC882_DIGIN_NID,
5307 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5308 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005309 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005310 .input_mux = &alc882_capture_source,
5311 },
5312 [ALC882_6ST_DIG] = {
5313 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5314 .init_verbs = { alc882_init_verbs },
5315 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5316 .dac_nids = alc882_dac_nids,
5317 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005318 .dig_in_nid = ALC882_DIGIN_NID,
5319 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5320 .channel_mode = alc882_sixstack_modes,
5321 .input_mux = &alc882_capture_source,
5322 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005323 [ALC882_ARIMA] = {
5324 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5325 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5326 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5327 .dac_nids = alc882_dac_nids,
5328 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5329 .channel_mode = alc882_sixstack_modes,
5330 .input_mux = &alc882_capture_source,
5331 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005332 [ALC882_W2JC] = {
5333 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5334 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5335 alc880_gpio1_init_verbs },
5336 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5337 .dac_nids = alc882_dac_nids,
5338 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5339 .channel_mode = alc880_threestack_modes,
5340 .need_dac_fix = 1,
5341 .input_mux = &alc882_capture_source,
5342 .dig_out_nid = ALC882_DIGOUT_NID,
5343 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005344 [ALC885_MACPRO] = {
5345 .mixers = { alc882_macpro_mixer },
5346 .init_verbs = { alc882_macpro_init_verbs },
5347 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5348 .dac_nids = alc882_dac_nids,
5349 .dig_out_nid = ALC882_DIGOUT_NID,
5350 .dig_in_nid = ALC882_DIGIN_NID,
5351 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5352 .channel_mode = alc882_ch_modes,
5353 .input_mux = &alc882_capture_source,
5354 },
Kailang Yang272a5272007-05-14 11:00:38 +02005355 [ALC882_TARGA] = {
5356 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5357 alc882_capture_mixer },
5358 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5359 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5360 .dac_nids = alc882_dac_nids,
5361 .dig_out_nid = ALC882_DIGOUT_NID,
5362 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5363 .adc_nids = alc882_adc_nids,
5364 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5365 .channel_mode = alc882_3ST_6ch_modes,
5366 .need_dac_fix = 1,
5367 .input_mux = &alc882_capture_source,
5368 .unsol_event = alc882_targa_unsol_event,
5369 .init_hook = alc882_targa_automute,
5370 },
5371 [ALC882_ASUS_A7J] = {
5372 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5373 alc882_capture_mixer },
5374 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5375 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5376 .dac_nids = alc882_dac_nids,
5377 .dig_out_nid = ALC882_DIGOUT_NID,
5378 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5379 .adc_nids = alc882_adc_nids,
5380 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5381 .channel_mode = alc882_3ST_6ch_modes,
5382 .need_dac_fix = 1,
5383 .input_mux = &alc882_capture_source,
5384 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005385};
5386
5387
5388/*
5389 * BIOS auto configuration
5390 */
5391static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5392 hda_nid_t nid, int pin_type,
5393 int dac_idx)
5394{
5395 /* set as output */
5396 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005397 int idx;
5398
Kailang Yangdf694da2005-12-05 19:42:22 +01005399 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5400 idx = 4;
5401 else
5402 idx = spec->multiout.dac_nids[dac_idx] - 2;
5403
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005404 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5405 pin_type);
5406 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5407 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005408 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5409
5410}
5411
5412static void alc882_auto_init_multi_out(struct hda_codec *codec)
5413{
5414 struct alc_spec *spec = codec->spec;
5415 int i;
5416
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005417 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005418 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005419 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005420 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005421 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005422 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005423 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005424 }
5425}
5426
5427static void alc882_auto_init_hp_out(struct hda_codec *codec)
5428{
5429 struct alc_spec *spec = codec->spec;
5430 hda_nid_t pin;
5431
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005432 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005433 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005434 /* use dac 0 */
5435 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005436}
5437
5438#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5439#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5440
5441static void alc882_auto_init_analog_input(struct hda_codec *codec)
5442{
5443 struct alc_spec *spec = codec->spec;
5444 int i;
5445
5446 for (i = 0; i < AUTO_PIN_LAST; i++) {
5447 hda_nid_t nid = spec->autocfg.input_pins[i];
5448 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005449 snd_hda_codec_write(codec, nid, 0,
5450 AC_VERB_SET_PIN_WIDGET_CONTROL,
5451 i <= AUTO_PIN_FRONT_MIC ?
5452 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005453 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005454 snd_hda_codec_write(codec, nid, 0,
5455 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005456 AMP_OUT_MUTE);
5457 }
5458 }
5459}
5460
5461/* almost identical with ALC880 parser... */
5462static int alc882_parse_auto_config(struct hda_codec *codec)
5463{
5464 struct alc_spec *spec = codec->spec;
5465 int err = alc880_parse_auto_config(codec);
5466
5467 if (err < 0)
5468 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005469 else if (err > 0)
5470 /* hack - override the init verbs */
5471 spec->init_verbs[0] = alc882_auto_init_verbs;
5472 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005473}
5474
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005475/* additional initialization for auto-configuration model */
5476static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005477{
Kailang Yangdf694da2005-12-05 19:42:22 +01005478 alc882_auto_init_multi_out(codec);
5479 alc882_auto_init_hp_out(codec);
5480 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005481}
5482
Linus Torvalds1da177e2005-04-16 15:20:36 -07005483static int patch_alc882(struct hda_codec *codec)
5484{
5485 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005486 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005487
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005488 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005489 if (spec == NULL)
5490 return -ENOMEM;
5491
Linus Torvalds1da177e2005-04-16 15:20:36 -07005492 codec->spec = spec;
5493
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005494 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5495 alc882_models,
5496 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005497
Kailang Yangdf694da2005-12-05 19:42:22 +01005498 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005499 /* Pick up systems that don't supply PCI SSID */
5500 switch (codec->subsystem_id) {
5501 case 0x106b0c00: /* Mac Pro */
5502 board_config = ALC885_MACPRO;
5503 break;
5504 default:
5505 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5506 "trying auto-probe from BIOS...\n");
5507 board_config = ALC882_AUTO;
5508 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005509 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005510
Kailang Yangdf694da2005-12-05 19:42:22 +01005511 if (board_config == ALC882_AUTO) {
5512 /* automatic parse from the BIOS config */
5513 err = alc882_parse_auto_config(codec);
5514 if (err < 0) {
5515 alc_free(codec);
5516 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005517 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005518 printk(KERN_INFO
5519 "hda_codec: Cannot set up configuration "
5520 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005521 board_config = ALC882_3ST_DIG;
5522 }
5523 }
5524
5525 if (board_config != ALC882_AUTO)
5526 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527
Tobin Davis9102cd12006-12-15 10:02:12 +01005528 if (board_config == ALC885_MACPRO) {
5529 alc882_gpio_mute(codec, 0, 0);
5530 alc882_gpio_mute(codec, 1, 0);
5531 }
5532
Linus Torvalds1da177e2005-04-16 15:20:36 -07005533 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5535 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005536
5537 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005538 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5539 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005540
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005541 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005542 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005543 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005544 /* get type */
5545 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005546 if (wcap != AC_WID_AUD_IN) {
5547 spec->adc_nids = alc882_adc_nids_alt;
5548 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005549 spec->mixers[spec->num_mixers] =
5550 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005551 spec->num_mixers++;
5552 } else {
5553 spec->adc_nids = alc882_adc_nids;
5554 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5555 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5556 spec->num_mixers++;
5557 }
5558 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005559
5560 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005561 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005562 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005563
5564 return 0;
5565}
5566
5567/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005568 * ALC883 support
5569 *
5570 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5571 * configuration. Each pin widget can choose any input DACs and a mixer.
5572 * Each ADC is connected from a mixer of all inputs. This makes possible
5573 * 6-channel independent captures.
5574 *
5575 * In addition, an independent DAC for the multi-playback (not used in this
5576 * driver yet).
5577 */
5578#define ALC883_DIGOUT_NID 0x06
5579#define ALC883_DIGIN_NID 0x0a
5580
5581static hda_nid_t alc883_dac_nids[4] = {
5582 /* front, rear, clfe, rear_surr */
5583 0x02, 0x04, 0x03, 0x05
5584};
5585
5586static hda_nid_t alc883_adc_nids[2] = {
5587 /* ADC1-2 */
5588 0x08, 0x09,
5589};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005590
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005591/* input MUX */
5592/* FIXME: should be a matrix-type input source selection */
5593
5594static struct hda_input_mux alc883_capture_source = {
5595 .num_items = 4,
5596 .items = {
5597 { "Mic", 0x0 },
5598 { "Front Mic", 0x1 },
5599 { "Line", 0x2 },
5600 { "CD", 0x4 },
5601 },
5602};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005603
5604static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5605 .num_items = 2,
5606 .items = {
5607 { "Mic", 0x1 },
5608 { "Line", 0x2 },
5609 },
5610};
5611
Kailang Yang272a5272007-05-14 11:00:38 +02005612static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5613 .num_items = 4,
5614 .items = {
5615 { "Mic", 0x0 },
5616 { "iMic", 0x1 },
5617 { "Line", 0x2 },
5618 { "CD", 0x4 },
5619 },
5620};
5621
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005622#define alc883_mux_enum_info alc_mux_enum_info
5623#define alc883_mux_enum_get alc_mux_enum_get
5624
5625static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5626 struct snd_ctl_elem_value *ucontrol)
5627{
5628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5629 struct alc_spec *spec = codec->spec;
5630 const struct hda_input_mux *imux = spec->input_mux;
5631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5632 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5633 hda_nid_t nid = capture_mixers[adc_idx];
5634 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5635 unsigned int i, idx;
5636
5637 idx = ucontrol->value.enumerated.item[0];
5638 if (idx >= imux->num_items)
5639 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005640 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005641 return 0;
5642 for (i = 0; i < imux->num_items; i++) {
5643 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5644 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5645 v | (imux->items[i].index << 8));
5646 }
5647 *cur_val = idx;
5648 return 1;
5649}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005650
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005651/*
5652 * 2ch mode
5653 */
5654static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5655 { 2, NULL }
5656};
5657
5658/*
5659 * 2ch mode
5660 */
5661static struct hda_verb alc883_3ST_ch2_init[] = {
5662 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5663 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5664 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5665 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5666 { } /* end */
5667};
5668
5669/*
5670 * 6ch mode
5671 */
5672static struct hda_verb alc883_3ST_ch6_init[] = {
5673 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5674 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5675 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5676 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5677 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5678 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5679 { } /* end */
5680};
5681
5682static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5683 { 2, alc883_3ST_ch2_init },
5684 { 6, alc883_3ST_ch6_init },
5685};
5686
5687/*
5688 * 6ch mode
5689 */
5690static struct hda_verb alc883_sixstack_ch6_init[] = {
5691 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5692 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5694 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5695 { } /* end */
5696};
5697
5698/*
5699 * 8ch mode
5700 */
5701static struct hda_verb alc883_sixstack_ch8_init[] = {
5702 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5703 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5705 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5706 { } /* end */
5707};
5708
5709static struct hda_channel_mode alc883_sixstack_modes[2] = {
5710 { 6, alc883_sixstack_ch6_init },
5711 { 8, alc883_sixstack_ch8_init },
5712};
5713
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005714static struct hda_verb alc883_medion_eapd_verbs[] = {
5715 /* eanable EAPD on medion laptop */
5716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5717 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5718 { }
5719};
5720
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005721/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5722 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5723 */
5724
5725static struct snd_kcontrol_new alc883_base_mixer[] = {
5726 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5728 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5729 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5730 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5731 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5732 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5733 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5734 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5735 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5737 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5738 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005742 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5744 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005745 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5747 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5748 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5749 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5750 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5751 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5752 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5753 {
5754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5755 /* .name = "Capture Source", */
5756 .name = "Input Source",
5757 .count = 2,
5758 .info = alc883_mux_enum_info,
5759 .get = alc883_mux_enum_get,
5760 .put = alc883_mux_enum_put,
5761 },
5762 { } /* end */
5763};
5764
5765static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5772 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005777 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5779 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5780 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5781 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5782 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5783 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5784 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5785 {
5786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5787 /* .name = "Capture Source", */
5788 .name = "Input Source",
5789 .count = 2,
5790 .info = alc883_mux_enum_info,
5791 .get = alc883_mux_enum_get,
5792 .put = alc883_mux_enum_put,
5793 },
5794 { } /* end */
5795};
5796
5797static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5799 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5800 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5801 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5802 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5803 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5804 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5805 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005815 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5817 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5818 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5819 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5820 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5821 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5822 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5823 {
5824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5825 /* .name = "Capture Source", */
5826 .name = "Input Source",
5827 .count = 2,
5828 .info = alc883_mux_enum_info,
5829 .get = alc883_mux_enum_get,
5830 .put = alc883_mux_enum_put,
5831 },
5832 { } /* end */
5833};
5834
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005835static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5837 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5838 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5839 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5840 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5841 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5842 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5843 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005850 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005853 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5855 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5856 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5857 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5858 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5859
5860 {
5861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5862 /* .name = "Capture Source", */
5863 .name = "Input Source",
5864 .count = 1,
5865 .info = alc883_mux_enum_info,
5866 .get = alc883_mux_enum_get,
5867 .put = alc883_mux_enum_put,
5868 },
5869 { } /* end */
5870};
5871
Kailang Yangccc656c2006-10-17 12:32:26 +02005872static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5875 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5891 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5892 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5893 {
5894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5895 /* .name = "Capture Source", */
5896 .name = "Input Source",
5897 .count = 2,
5898 .info = alc883_mux_enum_info,
5899 .get = alc883_mux_enum_get,
5900 .put = alc883_mux_enum_put,
5901 },
5902 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005903};
Kailang Yangccc656c2006-10-17 12:32:26 +02005904
5905static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5907 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5908 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005912 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5914 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5915 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5916 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5917 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5918 {
5919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5920 /* .name = "Capture Source", */
5921 .name = "Input Source",
5922 .count = 2,
5923 .info = alc883_mux_enum_info,
5924 .get = alc883_mux_enum_get,
5925 .put = alc883_mux_enum_put,
5926 },
5927 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005928};
Kailang Yangccc656c2006-10-17 12:32:26 +02005929
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005930static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5931 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5932 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5933 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5934 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5939 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5940 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5941 {
5942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5943 /* .name = "Capture Source", */
5944 .name = "Input Source",
5945 .count = 1,
5946 .info = alc883_mux_enum_info,
5947 .get = alc883_mux_enum_get,
5948 .put = alc883_mux_enum_put,
5949 },
5950 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005951};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005952
Kailang Yang272a5272007-05-14 11:00:38 +02005953static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5954 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5955 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5962 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5963 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5964 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5965 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5966 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5967 {
5968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5969 /* .name = "Capture Source", */
5970 .name = "Input Source",
5971 .count = 2,
5972 .info = alc883_mux_enum_info,
5973 .get = alc883_mux_enum_get,
5974 .put = alc883_mux_enum_put,
5975 },
5976 { } /* end */
5977};
5978
5979static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
5980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5989 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5990 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5991 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5992 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5993 {
5994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5995 /* .name = "Capture Source", */
5996 .name = "Input Source",
5997 .count = 2,
5998 .info = alc883_mux_enum_info,
5999 .get = alc883_mux_enum_get,
6000 .put = alc883_mux_enum_put,
6001 },
6002 { } /* end */
6003};
6004
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006005static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6006 {
6007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6008 .name = "Channel Mode",
6009 .info = alc_ch_mode_info,
6010 .get = alc_ch_mode_get,
6011 .put = alc_ch_mode_put,
6012 },
6013 { } /* end */
6014};
6015
6016static struct hda_verb alc883_init_verbs[] = {
6017 /* ADC1: mute amp left and right */
6018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6020 /* ADC2: mute amp left and right */
6021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6022 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6023 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6027 /* Rear mixer */
6028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6031 /* CLFE mixer */
6032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6035 /* Side mixer */
6036 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6037 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6039
6040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6045
6046 /* Front Pin: output 0 (0x0c) */
6047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6049 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6050 /* Rear Pin: output 1 (0x0d) */
6051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6053 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6054 /* CLFE Pin: output 2 (0x0e) */
6055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6057 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6058 /* Side Pin: output 3 (0x0f) */
6059 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6060 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6061 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6062 /* Mic (rear) pin: input vref at 80% */
6063 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6064 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6065 /* Front Mic pin: input vref at 80% */
6066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6067 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6068 /* Line In pin: input */
6069 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6071 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6073 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6075 /* CD pin widget for input */
6076 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6077
6078 /* FIXME: use matrix-type input source selection */
6079 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6080 /* Input mixer2 */
6081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6085 /* Input mixer3 */
6086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6090 { }
6091};
6092
Kailang Yangccc656c2006-10-17 12:32:26 +02006093static struct hda_verb alc883_tagra_verbs[] = {
6094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6096
6097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6099
6100 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6101 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6103
6104 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006105 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6106 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6107 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006108
6109 { } /* end */
6110};
6111
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006112static struct hda_verb alc883_lenovo_101e_verbs[] = {
6113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6114 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6115 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6116 { } /* end */
6117};
6118
Kailang Yang272a5272007-05-14 11:00:38 +02006119static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6120 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6122 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6124 { } /* end */
6125};
6126
6127static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6131 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6132 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6133 { } /* end */
6134};
6135
6136/* toggle front-jack and RCA according to the hp-jack state */
6137static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6138{
6139 unsigned int present;
6140
6141 present = snd_hda_codec_read(codec, 0x1b, 0,
6142 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6143 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6144 0x80, present ? 0x80 : 0);
6145 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6146 0x80, present ? 0x80 : 0);
6147 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6148 0x80, present ? 0x80 : 0);
6149 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6150 0x80, present ? 0x80 : 0);
6151
6152}
6153
6154/* toggle RCA according to the front-jack state */
6155static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6156{
6157 unsigned int present;
6158
6159 present = snd_hda_codec_read(codec, 0x14, 0,
6160 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6161 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6162 0x80, present ? 0x80 : 0);
6163 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6164 0x80, present ? 0x80 : 0);
6165
6166}
6167static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6168 unsigned int res)
6169{
6170 if ((res >> 26) == ALC880_HP_EVENT)
6171 alc888_lenovo_ms7195_front_automute(codec);
6172 if ((res >> 26) == ALC880_FRONT_EVENT)
6173 alc888_lenovo_ms7195_rca_automute(codec);
6174}
6175
6176static struct hda_verb alc883_medion_md2_verbs[] = {
6177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6179
6180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6181
6182 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6183 { } /* end */
6184};
6185
6186/* toggle speaker-output according to the hp-jack state */
6187static void alc883_medion_md2_automute(struct hda_codec *codec)
6188{
6189 unsigned int present;
6190
6191 present = snd_hda_codec_read(codec, 0x14, 0,
6192 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6193 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6194 0x80, present ? 0x80 : 0);
6195 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6196 0x80, present ? 0x80 : 0);
6197}
6198
6199static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6200 unsigned int res)
6201{
6202 if ((res >> 26) == ALC880_HP_EVENT)
6203 alc883_medion_md2_automute(codec);
6204}
6205
Kailang Yangccc656c2006-10-17 12:32:26 +02006206/* toggle speaker-output according to the hp-jack state */
6207static void alc883_tagra_automute(struct hda_codec *codec)
6208{
6209 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006210 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006211
6212 present = snd_hda_codec_read(codec, 0x14, 0,
6213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006214 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006215 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006216 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006217 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006218 0x80, bits);
6219 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6220 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006221}
6222
6223static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6224{
6225 if ((res >> 26) == ALC880_HP_EVENT)
6226 alc883_tagra_automute(codec);
6227}
6228
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006229static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6230{
6231 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006232 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006233
6234 present = snd_hda_codec_read(codec, 0x14, 0,
6235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006236 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006237 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006238 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006239 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006240 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006241}
6242
6243static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6244{
6245 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006246 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006247
6248 present = snd_hda_codec_read(codec, 0x1b, 0,
6249 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006250 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006251 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006252 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006253 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006254 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006255 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006256 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006257 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006258 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006259}
6260
6261static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6262 unsigned int res)
6263{
6264 if ((res >> 26) == ALC880_HP_EVENT)
6265 alc883_lenovo_101e_all_automute(codec);
6266 if ((res >> 26) == ALC880_FRONT_EVENT)
6267 alc883_lenovo_101e_ispeaker_automute(codec);
6268}
6269
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006270/*
6271 * generic initialization of ADC, input mixers and output mixers
6272 */
6273static struct hda_verb alc883_auto_init_verbs[] = {
6274 /*
6275 * Unmute ADC0-2 and set the default input to mic-in
6276 */
6277 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6281
6282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6283 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006284 * Note: PASD motherboards uses the Line In 2 as the input for
6285 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006286 */
6287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6293
6294 /*
6295 * Set up output mixers (0x0c - 0x0f)
6296 */
6297 /* set vol=0 to output mixers */
6298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 /* set up input amps for analog loopback */
6303 /* Amp Indices: DAC = 0, mixer = 1 */
6304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6312 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6314
6315 /* FIXME: use matrix-type input source selection */
6316 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6317 /* Input mixer1 */
6318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006321 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6323 /* Input mixer2 */
6324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006327 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6329
6330 { }
6331};
6332
6333/* capture mixer elements */
6334static struct snd_kcontrol_new alc883_capture_mixer[] = {
6335 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6336 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6337 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6338 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6339 {
6340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6341 /* The multiple "Capture Source" controls confuse alsamixer
6342 * So call somewhat different..
6343 * FIXME: the controls appear in the "playback" view!
6344 */
6345 /* .name = "Capture Source", */
6346 .name = "Input Source",
6347 .count = 2,
6348 .info = alc882_mux_enum_info,
6349 .get = alc882_mux_enum_get,
6350 .put = alc882_mux_enum_put,
6351 },
6352 { } /* end */
6353};
6354
6355/* pcm configuration: identiacal with ALC880 */
6356#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6357#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6358#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6359#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6360
6361/*
6362 * configuration and preset
6363 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006364static const char *alc883_models[ALC883_MODEL_LAST] = {
6365 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6366 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6367 [ALC883_3ST_6ch] = "3stack-6ch",
6368 [ALC883_6ST_DIG] = "6stack-dig",
6369 [ALC883_TARGA_DIG] = "targa-dig",
6370 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006371 [ALC883_ACER] = "acer",
6372 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006373 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006374 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006375 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006376 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6377 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006378 [ALC883_AUTO] = "auto",
6379};
6380
6381static struct snd_pci_quirk alc883_cfg_tbl[] = {
6382 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006383 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006384 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6385 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6386 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006387 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006388 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6389 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006390 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006391 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006392 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006393 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006394 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006395 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6396 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6397 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6398 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6399 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6400 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6401 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6402 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6403 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6404 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006405 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006406 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6407 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6408 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006409 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6410 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6411 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6412 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006413 {}
6414};
6415
6416static struct alc_config_preset alc883_presets[] = {
6417 [ALC883_3ST_2ch_DIG] = {
6418 .mixers = { alc883_3ST_2ch_mixer },
6419 .init_verbs = { alc883_init_verbs },
6420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6421 .dac_nids = alc883_dac_nids,
6422 .dig_out_nid = ALC883_DIGOUT_NID,
6423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6424 .adc_nids = alc883_adc_nids,
6425 .dig_in_nid = ALC883_DIGIN_NID,
6426 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6427 .channel_mode = alc883_3ST_2ch_modes,
6428 .input_mux = &alc883_capture_source,
6429 },
6430 [ALC883_3ST_6ch_DIG] = {
6431 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6432 .init_verbs = { alc883_init_verbs },
6433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6434 .dac_nids = alc883_dac_nids,
6435 .dig_out_nid = ALC883_DIGOUT_NID,
6436 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6437 .adc_nids = alc883_adc_nids,
6438 .dig_in_nid = ALC883_DIGIN_NID,
6439 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6440 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006441 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006442 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006443 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006444 [ALC883_3ST_6ch] = {
6445 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6446 .init_verbs = { alc883_init_verbs },
6447 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6448 .dac_nids = alc883_dac_nids,
6449 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6450 .adc_nids = alc883_adc_nids,
6451 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6452 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006453 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006454 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006455 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006456 [ALC883_6ST_DIG] = {
6457 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6458 .init_verbs = { alc883_init_verbs },
6459 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6460 .dac_nids = alc883_dac_nids,
6461 .dig_out_nid = ALC883_DIGOUT_NID,
6462 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6463 .adc_nids = alc883_adc_nids,
6464 .dig_in_nid = ALC883_DIGIN_NID,
6465 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6466 .channel_mode = alc883_sixstack_modes,
6467 .input_mux = &alc883_capture_source,
6468 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006469 [ALC883_TARGA_DIG] = {
6470 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6471 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6473 .dac_nids = alc883_dac_nids,
6474 .dig_out_nid = ALC883_DIGOUT_NID,
6475 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6476 .adc_nids = alc883_adc_nids,
6477 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6478 .channel_mode = alc883_3ST_6ch_modes,
6479 .need_dac_fix = 1,
6480 .input_mux = &alc883_capture_source,
6481 .unsol_event = alc883_tagra_unsol_event,
6482 .init_hook = alc883_tagra_automute,
6483 },
6484 [ALC883_TARGA_2ch_DIG] = {
6485 .mixers = { alc883_tagra_2ch_mixer},
6486 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6488 .dac_nids = alc883_dac_nids,
6489 .dig_out_nid = ALC883_DIGOUT_NID,
6490 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6491 .adc_nids = alc883_adc_nids,
6492 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6493 .channel_mode = alc883_3ST_2ch_modes,
6494 .input_mux = &alc883_capture_source,
6495 .unsol_event = alc883_tagra_unsol_event,
6496 .init_hook = alc883_tagra_automute,
6497 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02006498 [ALC883_ACER] = {
6499 .mixers = { alc883_base_mixer,
6500 alc883_chmode_mixer },
6501 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6502 * and the headphone jack. Turn this on and rely on the
6503 * standard mute methods whenever the user wants to turn
6504 * these outputs off.
6505 */
6506 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6507 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6508 .dac_nids = alc883_dac_nids,
6509 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6510 .adc_nids = alc883_adc_nids,
6511 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6512 .channel_mode = alc883_3ST_2ch_modes,
6513 .input_mux = &alc883_capture_source,
6514 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006515 [ALC883_MEDION] = {
6516 .mixers = { alc883_fivestack_mixer,
6517 alc883_chmode_mixer },
6518 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006519 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006520 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6521 .dac_nids = alc883_dac_nids,
6522 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6523 .adc_nids = alc883_adc_nids,
6524 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6525 .channel_mode = alc883_sixstack_modes,
6526 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006527 },
Kailang Yang272a5272007-05-14 11:00:38 +02006528 [ALC883_MEDION_MD2] = {
6529 .mixers = { alc883_medion_md2_mixer},
6530 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6532 .dac_nids = alc883_dac_nids,
6533 .dig_out_nid = ALC883_DIGOUT_NID,
6534 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6535 .adc_nids = alc883_adc_nids,
6536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6537 .channel_mode = alc883_3ST_2ch_modes,
6538 .input_mux = &alc883_capture_source,
6539 .unsol_event = alc883_medion_md2_unsol_event,
6540 .init_hook = alc883_medion_md2_automute,
6541 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006542 [ALC883_LAPTOP_EAPD] = {
6543 .mixers = { alc883_base_mixer,
6544 alc883_chmode_mixer },
6545 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6547 .dac_nids = alc883_dac_nids,
6548 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6549 .adc_nids = alc883_adc_nids,
6550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6551 .channel_mode = alc883_3ST_2ch_modes,
6552 .input_mux = &alc883_capture_source,
6553 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006554 [ALC883_LENOVO_101E_2ch] = {
6555 .mixers = { alc883_lenovo_101e_2ch_mixer},
6556 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6557 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6558 .dac_nids = alc883_dac_nids,
6559 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6560 .adc_nids = alc883_adc_nids,
6561 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6562 .channel_mode = alc883_3ST_2ch_modes,
6563 .input_mux = &alc883_lenovo_101e_capture_source,
6564 .unsol_event = alc883_lenovo_101e_unsol_event,
6565 .init_hook = alc883_lenovo_101e_all_automute,
6566 },
Kailang Yang272a5272007-05-14 11:00:38 +02006567 [ALC883_LENOVO_NB0763] = {
6568 .mixers = { alc883_lenovo_nb0763_mixer },
6569 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6570 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6571 .dac_nids = alc883_dac_nids,
6572 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6573 .adc_nids = alc883_adc_nids,
6574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6575 .channel_mode = alc883_3ST_2ch_modes,
6576 .need_dac_fix = 1,
6577 .input_mux = &alc883_lenovo_nb0763_capture_source,
6578 .unsol_event = alc883_medion_md2_unsol_event,
6579 .init_hook = alc883_medion_md2_automute,
6580 },
6581 [ALC888_LENOVO_MS7195_DIG] = {
6582 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6583 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6584 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6585 .dac_nids = alc883_dac_nids,
6586 .dig_out_nid = ALC883_DIGOUT_NID,
6587 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6588 .adc_nids = alc883_adc_nids,
6589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6590 .channel_mode = alc883_3ST_6ch_modes,
6591 .need_dac_fix = 1,
6592 .input_mux = &alc883_capture_source,
6593 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6594 .init_hook = alc888_lenovo_ms7195_front_automute,
6595 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006596};
6597
6598
6599/*
6600 * BIOS auto configuration
6601 */
6602static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6603 hda_nid_t nid, int pin_type,
6604 int dac_idx)
6605{
6606 /* set as output */
6607 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006608 int idx;
6609
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006610 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6611 idx = 4;
6612 else
6613 idx = spec->multiout.dac_nids[dac_idx] - 2;
6614
6615 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6616 pin_type);
6617 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6618 AMP_OUT_UNMUTE);
6619 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6620
6621}
6622
6623static void alc883_auto_init_multi_out(struct hda_codec *codec)
6624{
6625 struct alc_spec *spec = codec->spec;
6626 int i;
6627
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006628 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006629 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006630 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006631 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006632 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006633 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006634 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 }
6636}
6637
6638static void alc883_auto_init_hp_out(struct hda_codec *codec)
6639{
6640 struct alc_spec *spec = codec->spec;
6641 hda_nid_t pin;
6642
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006643 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006644 if (pin) /* connect to front */
6645 /* use dac 0 */
6646 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6647}
6648
6649#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6650#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6651
6652static void alc883_auto_init_analog_input(struct hda_codec *codec)
6653{
6654 struct alc_spec *spec = codec->spec;
6655 int i;
6656
6657 for (i = 0; i < AUTO_PIN_LAST; i++) {
6658 hda_nid_t nid = spec->autocfg.input_pins[i];
6659 if (alc883_is_input_pin(nid)) {
6660 snd_hda_codec_write(codec, nid, 0,
6661 AC_VERB_SET_PIN_WIDGET_CONTROL,
6662 (i <= AUTO_PIN_FRONT_MIC ?
6663 PIN_VREF80 : PIN_IN));
6664 if (nid != ALC883_PIN_CD_NID)
6665 snd_hda_codec_write(codec, nid, 0,
6666 AC_VERB_SET_AMP_GAIN_MUTE,
6667 AMP_OUT_MUTE);
6668 }
6669 }
6670}
6671
6672/* almost identical with ALC880 parser... */
6673static int alc883_parse_auto_config(struct hda_codec *codec)
6674{
6675 struct alc_spec *spec = codec->spec;
6676 int err = alc880_parse_auto_config(codec);
6677
6678 if (err < 0)
6679 return err;
6680 else if (err > 0)
6681 /* hack - override the init verbs */
6682 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006683 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6684 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006685 return err;
6686}
6687
6688/* additional initialization for auto-configuration model */
6689static void alc883_auto_init(struct hda_codec *codec)
6690{
6691 alc883_auto_init_multi_out(codec);
6692 alc883_auto_init_hp_out(codec);
6693 alc883_auto_init_analog_input(codec);
6694}
6695
6696static int patch_alc883(struct hda_codec *codec)
6697{
6698 struct alc_spec *spec;
6699 int err, board_config;
6700
6701 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6702 if (spec == NULL)
6703 return -ENOMEM;
6704
6705 codec->spec = spec;
6706
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006707 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6708 alc883_models,
6709 alc883_cfg_tbl);
6710 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006711 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6712 "trying auto-probe from BIOS...\n");
6713 board_config = ALC883_AUTO;
6714 }
6715
6716 if (board_config == ALC883_AUTO) {
6717 /* automatic parse from the BIOS config */
6718 err = alc883_parse_auto_config(codec);
6719 if (err < 0) {
6720 alc_free(codec);
6721 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006722 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006723 printk(KERN_INFO
6724 "hda_codec: Cannot set up configuration "
6725 "from BIOS. Using base mode...\n");
6726 board_config = ALC883_3ST_2ch_DIG;
6727 }
6728 }
6729
6730 if (board_config != ALC883_AUTO)
6731 setup_preset(spec, &alc883_presets[board_config]);
6732
6733 spec->stream_name_analog = "ALC883 Analog";
6734 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6735 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6736
6737 spec->stream_name_digital = "ALC883 Digital";
6738 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6739 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6740
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006741 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006742 spec->adc_nids = alc883_adc_nids;
6743 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6744 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006745
6746 codec->patch_ops = alc_patch_ops;
6747 if (board_config == ALC883_AUTO)
6748 spec->init_hook = alc883_auto_init;
6749
6750 return 0;
6751}
6752
6753/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006754 * ALC262 support
6755 */
6756
6757#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6758#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6759
6760#define alc262_dac_nids alc260_dac_nids
6761#define alc262_adc_nids alc882_adc_nids
6762#define alc262_adc_nids_alt alc882_adc_nids_alt
6763
6764#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006765#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006766
6767static struct snd_kcontrol_new alc262_base_mixer[] = {
6768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6769 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006780 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6781 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6784 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006786 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006787};
6788
Kailang Yangccc656c2006-10-17 12:32:26 +02006789static struct snd_kcontrol_new alc262_hippo1_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 Yangccc656c2006-10-17 12:32:26 +02006799 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 Yangccc656c2006-10-17 12:32:26 +02006802 /* 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", 0x1b, 0x0, HDA_OUTPUT),
6806 { } /* end */
6807};
6808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006809static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6811 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6814 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6815
6816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006821 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6826 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6827 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6828 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6829 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6830 { } /* end */
6831};
6832
Kailang Yangcd7509a2007-01-26 18:33:17 +01006833static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6835 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6838 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6839 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006842 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006843 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6844 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6847 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6848 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6849 { } /* end */
6850};
6851
6852static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6853 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6854 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006855 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006856 { } /* end */
6857};
6858
Kailang Yang272a5272007-05-14 11:00:38 +02006859static struct snd_kcontrol_new alc262_sony_mixer[] = {
6860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6864 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6865 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6866 { } /* end */
6867};
6868
6869
6870
Kailang Yangdf694da2005-12-05 19:42:22 +01006871#define alc262_capture_mixer alc882_capture_mixer
6872#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6873
6874/*
6875 * generic initialization of ADC, input mixers and output mixers
6876 */
6877static struct hda_verb alc262_init_verbs[] = {
6878 /*
6879 * Unmute ADC0-2 and set the default input to mic-in
6880 */
6881 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6883 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6885 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6886 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6887
6888 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6889 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006890 * Note: PASD motherboards uses the Line In 2 as the input for
6891 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006892 */
6893 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6899
6900 /*
6901 * Set up output mixers (0x0c - 0x0e)
6902 */
6903 /* set vol=0 to output mixers */
6904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6907 /* set up input amps for analog loopback */
6908 /* Amp Indices: DAC = 0, mixer = 1 */
6909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6911 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6912 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6913 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6914 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6915
6916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6919 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6920 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6921 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6922
6923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6925 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6928
6929 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6930 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6931
6932 /* FIXME: use matrix-type input source selection */
6933 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6934 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6938 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6939 /* Input mixer2 */
6940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6944 /* Input mixer3 */
6945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01006949
6950 { }
6951};
6952
Kailang Yangccc656c2006-10-17 12:32:26 +02006953static struct hda_verb alc262_hippo_unsol_verbs[] = {
6954 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6956 {}
6957};
6958
6959static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6963
6964 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6966 {}
6967};
6968
Kailang Yang272a5272007-05-14 11:00:38 +02006969static struct hda_verb alc262_sony_unsol_verbs[] = {
6970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6972 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6973
6974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6976};
6977
Kailang Yangccc656c2006-10-17 12:32:26 +02006978/* mute/unmute internal speaker according to the hp jack and mute state */
6979static void alc262_hippo_automute(struct hda_codec *codec, int force)
6980{
6981 struct alc_spec *spec = codec->spec;
6982 unsigned int mute;
6983
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006984 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02006985 unsigned int present;
6986 /* need to execute and sync at first */
6987 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6988 present = snd_hda_codec_read(codec, 0x15, 0,
6989 AC_VERB_GET_PIN_SENSE, 0);
6990 spec->jack_present = (present & 0x80000000) != 0;
6991 spec->sense_updated = 1;
6992 }
6993 if (spec->jack_present) {
6994 /* mute internal speaker */
6995 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6996 0x80, 0x80);
6997 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6998 0x80, 0x80);
6999 } else {
7000 /* unmute internal speaker if necessary */
7001 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7002 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7003 0x80, mute & 0x80);
7004 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7005 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7006 0x80, mute & 0x80);
7007 }
7008}
7009
7010/* unsolicited event for HP jack sensing */
7011static void alc262_hippo_unsol_event(struct hda_codec *codec,
7012 unsigned int res)
7013{
7014 if ((res >> 26) != ALC880_HP_EVENT)
7015 return;
7016 alc262_hippo_automute(codec, 1);
7017}
7018
7019static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7020{
7021 struct alc_spec *spec = codec->spec;
7022 unsigned int mute;
7023
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007024 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007025 unsigned int present;
7026 /* need to execute and sync at first */
7027 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7028 present = snd_hda_codec_read(codec, 0x1b, 0,
7029 AC_VERB_GET_PIN_SENSE, 0);
7030 spec->jack_present = (present & 0x80000000) != 0;
7031 spec->sense_updated = 1;
7032 }
7033 if (spec->jack_present) {
7034 /* mute internal speaker */
7035 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7036 0x80, 0x80);
7037 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7038 0x80, 0x80);
7039 } else {
7040 /* unmute internal speaker if necessary */
7041 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7042 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7043 0x80, mute & 0x80);
7044 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7045 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7046 0x80, mute & 0x80);
7047 }
7048}
7049
7050/* unsolicited event for HP jack sensing */
7051static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7052 unsigned int res)
7053{
7054 if ((res >> 26) != ALC880_HP_EVENT)
7055 return;
7056 alc262_hippo1_automute(codec, 1);
7057}
7058
Takashi Iwai834be882006-03-01 14:16:17 +01007059/*
7060 * fujitsu model
7061 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7062 */
7063
7064#define ALC_HP_EVENT 0x37
7065
7066static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7069 {}
7070};
7071
7072static struct hda_input_mux alc262_fujitsu_capture_source = {
7073 .num_items = 2,
7074 .items = {
7075 { "Mic", 0x0 },
7076 { "CD", 0x4 },
7077 },
7078};
7079
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007080static struct hda_input_mux alc262_HP_capture_source = {
7081 .num_items = 5,
7082 .items = {
7083 { "Mic", 0x0 },
7084 { "Front Mic", 0x3 },
7085 { "Line", 0x2 },
7086 { "CD", 0x4 },
7087 { "AUX IN", 0x6 },
7088 },
7089};
7090
Takashi Iwai834be882006-03-01 14:16:17 +01007091/* mute/unmute internal speaker according to the hp jack and mute state */
7092static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7093{
7094 struct alc_spec *spec = codec->spec;
7095 unsigned int mute;
7096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007097 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007098 unsigned int present;
7099 /* need to execute and sync at first */
7100 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7101 present = snd_hda_codec_read(codec, 0x14, 0,
7102 AC_VERB_GET_PIN_SENSE, 0);
7103 spec->jack_present = (present & 0x80000000) != 0;
7104 spec->sense_updated = 1;
7105 }
7106 if (spec->jack_present) {
7107 /* mute internal speaker */
7108 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7109 0x80, 0x80);
7110 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7111 0x80, 0x80);
7112 } else {
7113 /* unmute internal speaker if necessary */
7114 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7115 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7116 0x80, mute & 0x80);
7117 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7118 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7119 0x80, mute & 0x80);
7120 }
7121}
7122
7123/* unsolicited event for HP jack sensing */
7124static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7125 unsigned int res)
7126{
7127 if ((res >> 26) != ALC_HP_EVENT)
7128 return;
7129 alc262_fujitsu_automute(codec, 1);
7130}
7131
7132/* bind volumes of both NID 0x0c and 0x0d */
7133static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7134 struct snd_ctl_elem_value *ucontrol)
7135{
7136 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7137 long *valp = ucontrol->value.integer.value;
7138 int change;
7139
7140 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7141 0x7f, valp[0] & 0x7f);
7142 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7143 0x7f, valp[1] & 0x7f);
7144 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7145 0x7f, valp[0] & 0x7f);
7146 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7147 0x7f, valp[1] & 0x7f);
7148 return change;
7149}
7150
7151/* bind hp and internal speaker mute (with plug check) */
7152static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7153 struct snd_ctl_elem_value *ucontrol)
7154{
7155 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7156 long *valp = ucontrol->value.integer.value;
7157 int change;
7158
7159 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7160 0x80, valp[0] ? 0 : 0x80);
7161 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7162 0x80, valp[1] ? 0 : 0x80);
7163 if (change || codec->in_resume)
7164 alc262_fujitsu_automute(codec, codec->in_resume);
7165 return change;
7166}
7167
7168static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7169 {
7170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7171 .name = "Master Playback Volume",
7172 .info = snd_hda_mixer_amp_volume_info,
7173 .get = snd_hda_mixer_amp_volume_get,
7174 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007175 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007176 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7177 },
7178 {
7179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7180 .name = "Master Playback Switch",
7181 .info = snd_hda_mixer_amp_switch_info,
7182 .get = snd_hda_mixer_amp_switch_get,
7183 .put = alc262_fujitsu_master_sw_put,
7184 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7185 },
7186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7191 { } /* end */
7192};
7193
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007194/* additional init verbs for Benq laptops */
7195static struct hda_verb alc262_EAPD_verbs[] = {
7196 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7197 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7198 {}
7199};
7200
Kailang Yangdf694da2005-12-05 19:42:22 +01007201/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007202static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7203 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007204{
7205 hda_nid_t nid;
7206 int err;
7207
7208 spec->multiout.num_dacs = 1; /* only use one dac */
7209 spec->multiout.dac_nids = spec->private_dac_nids;
7210 spec->multiout.dac_nids[0] = 2;
7211
7212 nid = cfg->line_out_pins[0];
7213 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007214 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7215 "Front Playback Volume",
7216 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7217 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007219 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7220 "Front Playback Switch",
7221 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7222 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007223 return err;
7224 }
7225
Takashi Iwai82bc9552006-03-21 11:24:42 +01007226 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007227 if (nid) {
7228 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007229 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7230 "Speaker Playback Volume",
7231 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7232 HDA_OUTPUT));
7233 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007234 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007235 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7236 "Speaker Playback Switch",
7237 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7238 HDA_OUTPUT));
7239 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 return err;
7241 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007242 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7243 "Speaker Playback Switch",
7244 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7245 HDA_OUTPUT));
7246 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007247 return err;
7248 }
7249 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007250 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007251 if (nid) {
7252 /* spec->multiout.hp_nid = 2; */
7253 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007254 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7255 "Headphone Playback Volume",
7256 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7257 HDA_OUTPUT));
7258 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007259 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007260 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7261 "Headphone Playback Switch",
7262 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7263 HDA_OUTPUT));
7264 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007265 return err;
7266 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007267 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7268 "Headphone Playback Switch",
7269 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7270 HDA_OUTPUT));
7271 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007272 return err;
7273 }
7274 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007275 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007276}
7277
7278/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007279#define alc262_auto_create_analog_input_ctls \
7280 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007281
7282/*
7283 * generic initialization of ADC, input mixers and output mixers
7284 */
7285static struct hda_verb alc262_volume_init_verbs[] = {
7286 /*
7287 * Unmute ADC0-2 and set the default input to mic-in
7288 */
7289 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7291 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7293 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7295
7296 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7297 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007298 * Note: PASD motherboards uses the Line In 2 as the input for
7299 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007300 */
7301 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7307
7308 /*
7309 * Set up output mixers (0x0c - 0x0f)
7310 */
7311 /* set vol=0 to output mixers */
7312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7315
7316 /* set up input amps for analog loopback */
7317 /* Amp Indices: DAC = 0, mixer = 1 */
7318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7324
7325 /* FIXME: use matrix-type input source selection */
7326 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7327 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7332 /* Input mixer2 */
7333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7337 /* Input mixer3 */
7338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7342
7343 { }
7344};
7345
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007346static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7347 /*
7348 * Unmute ADC0-2 and set the default input to mic-in
7349 */
7350 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7352 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7354 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7356
7357 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7358 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007359 * Note: PASD motherboards uses the Line In 2 as the input for
7360 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007361 */
7362 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7370
7371 /*
7372 * Set up output mixers (0x0c - 0x0e)
7373 */
7374 /* set vol=0 to output mixers */
7375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378
7379 /* set up input amps for analog loopback */
7380 /* Amp Indices: DAC = 0, mixer = 1 */
7381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387
7388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7391
7392 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7394
7395 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7397
7398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7400 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7401 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7402 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7403
7404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7405 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7406 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7408 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7409 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7410
7411
7412 /* FIXME: use matrix-type input source selection */
7413 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7414 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7419 /* Input mixer2 */
7420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7424 /* Input mixer3 */
7425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7429
7430 { }
7431};
7432
Kailang Yangcd7509a2007-01-26 18:33:17 +01007433static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7434 /*
7435 * Unmute ADC0-2 and set the default input to mic-in
7436 */
7437 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7439 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7441 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7443
7444 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7445 * mixer widget
7446 * Note: PASD motherboards uses the Line In 2 as the input for front
7447 * panel mic (mic 2)
7448 */
7449 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7458 /*
7459 * Set up output mixers (0x0c - 0x0e)
7460 */
7461 /* set vol=0 to output mixers */
7462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7465
7466 /* set up input amps for analog loopback */
7467 /* Amp Indices: DAC = 0, mixer = 1 */
7468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7474
7475
7476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7479 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7483
7484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7486
7487 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7489
7490 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7491 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7494 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7495 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7496
7497 /* FIXME: use matrix-type input source selection */
7498 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7499 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7505 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7507 /* Input mixer2 */
7508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7513 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7515 /* Input mixer3 */
7516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7521 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7523
7524 { }
7525};
7526
Kailang Yangdf694da2005-12-05 19:42:22 +01007527/* pcm configuration: identiacal with ALC880 */
7528#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7529#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7530#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7531#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7532
7533/*
7534 * BIOS auto configuration
7535 */
7536static int alc262_parse_auto_config(struct hda_codec *codec)
7537{
7538 struct alc_spec *spec = codec->spec;
7539 int err;
7540 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7541
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007542 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7543 alc262_ignore);
7544 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007546 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007547 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007548 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7549 if (err < 0)
7550 return err;
7551 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7552 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007553 return err;
7554
7555 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7556
7557 if (spec->autocfg.dig_out_pin)
7558 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7559 if (spec->autocfg.dig_in_pin)
7560 spec->dig_in_nid = ALC262_DIGIN_NID;
7561
7562 if (spec->kctl_alloc)
7563 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7564
7565 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007566 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007567 spec->input_mux = &spec->private_imux;
7568
7569 return 1;
7570}
7571
7572#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7573#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7574#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7575
7576
7577/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007578static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007579{
Kailang Yangdf694da2005-12-05 19:42:22 +01007580 alc262_auto_init_multi_out(codec);
7581 alc262_auto_init_hp_out(codec);
7582 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007583}
7584
7585/*
7586 * configuration and preset
7587 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007588static const char *alc262_models[ALC262_MODEL_LAST] = {
7589 [ALC262_BASIC] = "basic",
7590 [ALC262_HIPPO] = "hippo",
7591 [ALC262_HIPPO_1] = "hippo_1",
7592 [ALC262_FUJITSU] = "fujitsu",
7593 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007594 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007595 [ALC262_BENQ_ED8] = "benq",
Kailang Yang272a5272007-05-14 11:00:38 +02007596 [ALC262_BENQ_ED8] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007597 [ALC262_AUTO] = "auto",
7598};
7599
7600static struct snd_pci_quirk alc262_cfg_tbl[] = {
7601 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7602 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7603 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007604 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7605 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007606 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007607 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007608 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007609 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007610 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7611 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7612 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7613 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7614 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7615 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7616 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7617 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007618 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7619 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7620 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7621 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang272a5272007-05-14 11:00:38 +02007622 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7623 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7624 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007625 {}
7626};
7627
7628static struct alc_config_preset alc262_presets[] = {
7629 [ALC262_BASIC] = {
7630 .mixers = { alc262_base_mixer },
7631 .init_verbs = { alc262_init_verbs },
7632 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7633 .dac_nids = alc262_dac_nids,
7634 .hp_nid = 0x03,
7635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7636 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007637 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007638 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007639 [ALC262_HIPPO] = {
7640 .mixers = { alc262_base_mixer },
7641 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7642 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7643 .dac_nids = alc262_dac_nids,
7644 .hp_nid = 0x03,
7645 .dig_out_nid = ALC262_DIGOUT_NID,
7646 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7647 .channel_mode = alc262_modes,
7648 .input_mux = &alc262_capture_source,
7649 .unsol_event = alc262_hippo_unsol_event,
7650 },
7651 [ALC262_HIPPO_1] = {
7652 .mixers = { alc262_hippo1_mixer },
7653 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7654 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7655 .dac_nids = alc262_dac_nids,
7656 .hp_nid = 0x02,
7657 .dig_out_nid = ALC262_DIGOUT_NID,
7658 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7659 .channel_mode = alc262_modes,
7660 .input_mux = &alc262_capture_source,
7661 .unsol_event = alc262_hippo1_unsol_event,
7662 },
Takashi Iwai834be882006-03-01 14:16:17 +01007663 [ALC262_FUJITSU] = {
7664 .mixers = { alc262_fujitsu_mixer },
7665 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7666 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7667 .dac_nids = alc262_dac_nids,
7668 .hp_nid = 0x03,
7669 .dig_out_nid = ALC262_DIGOUT_NID,
7670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7671 .channel_mode = alc262_modes,
7672 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007673 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007674 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007675 [ALC262_HP_BPC] = {
7676 .mixers = { alc262_HP_BPC_mixer },
7677 .init_verbs = { alc262_HP_BPC_init_verbs },
7678 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7679 .dac_nids = alc262_dac_nids,
7680 .hp_nid = 0x03,
7681 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7682 .channel_mode = alc262_modes,
7683 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007684 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007685 [ALC262_HP_BPC_D7000_WF] = {
7686 .mixers = { alc262_HP_BPC_WildWest_mixer },
7687 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7688 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7689 .dac_nids = alc262_dac_nids,
7690 .hp_nid = 0x03,
7691 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7692 .channel_mode = alc262_modes,
7693 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007694 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007695 [ALC262_HP_BPC_D7000_WL] = {
7696 .mixers = { alc262_HP_BPC_WildWest_mixer,
7697 alc262_HP_BPC_WildWest_option_mixer },
7698 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7699 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7700 .dac_nids = alc262_dac_nids,
7701 .hp_nid = 0x03,
7702 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7703 .channel_mode = alc262_modes,
7704 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007705 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007706 [ALC262_BENQ_ED8] = {
7707 .mixers = { alc262_base_mixer },
7708 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7709 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7710 .dac_nids = alc262_dac_nids,
7711 .hp_nid = 0x03,
7712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7713 .channel_mode = alc262_modes,
7714 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007715 },
Kailang Yang272a5272007-05-14 11:00:38 +02007716 [ALC262_SONY_ASSAMD] = {
7717 .mixers = { alc262_sony_mixer },
7718 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7719 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7720 .dac_nids = alc262_dac_nids,
7721 .hp_nid = 0x02,
7722 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7723 .channel_mode = alc262_modes,
7724 .input_mux = &alc262_capture_source,
7725 .unsol_event = alc262_hippo_unsol_event,
7726 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007727};
7728
7729static int patch_alc262(struct hda_codec *codec)
7730{
7731 struct alc_spec *spec;
7732 int board_config;
7733 int err;
7734
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007735 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007736 if (spec == NULL)
7737 return -ENOMEM;
7738
7739 codec->spec = spec;
7740#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007741 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7742 * under-run
7743 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007744 {
7745 int tmp;
7746 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7747 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7748 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7749 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7750 }
7751#endif
7752
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007753 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7754 alc262_models,
7755 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007756
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007757 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007758 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7759 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007760 board_config = ALC262_AUTO;
7761 }
7762
7763 if (board_config == ALC262_AUTO) {
7764 /* automatic parse from the BIOS config */
7765 err = alc262_parse_auto_config(codec);
7766 if (err < 0) {
7767 alc_free(codec);
7768 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007769 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007770 printk(KERN_INFO
7771 "hda_codec: Cannot set up configuration "
7772 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007773 board_config = ALC262_BASIC;
7774 }
7775 }
7776
7777 if (board_config != ALC262_AUTO)
7778 setup_preset(spec, &alc262_presets[board_config]);
7779
7780 spec->stream_name_analog = "ALC262 Analog";
7781 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7782 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7783
7784 spec->stream_name_digital = "ALC262 Digital";
7785 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7786 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7787
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007788 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007789 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007790 unsigned int wcap = get_wcaps(codec, 0x07);
7791
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007792 /* get type */
7793 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007794 if (wcap != AC_WID_AUD_IN) {
7795 spec->adc_nids = alc262_adc_nids_alt;
7796 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007797 spec->mixers[spec->num_mixers] =
7798 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007799 spec->num_mixers++;
7800 } else {
7801 spec->adc_nids = alc262_adc_nids;
7802 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7803 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7804 spec->num_mixers++;
7805 }
7806 }
7807
7808 codec->patch_ops = alc_patch_ops;
7809 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007810 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01007811
Kailang Yangdf694da2005-12-05 19:42:22 +01007812 return 0;
7813}
7814
Kailang Yangdf694da2005-12-05 19:42:22 +01007815/*
Kailang Yanga361d842007-06-05 12:30:55 +02007816 * ALC268 channel source setting (2 channel)
7817 */
7818#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7819#define alc268_modes alc260_modes
7820
7821static hda_nid_t alc268_dac_nids[2] = {
7822 /* front, hp */
7823 0x02, 0x03
7824};
7825
7826static hda_nid_t alc268_adc_nids[2] = {
7827 /* ADC0-1 */
7828 0x08, 0x07
7829};
7830
7831static hda_nid_t alc268_adc_nids_alt[1] = {
7832 /* ADC0 */
7833 0x08
7834};
7835
7836static struct snd_kcontrol_new alc268_base_mixer[] = {
7837 /* output mixer control */
7838 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7839 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7842 { }
7843};
7844
7845/*
7846 * generic initialization of ADC, input mixers and output mixers
7847 */
7848static struct hda_verb alc268_base_init_verbs[] = {
7849 /* Unmute DAC0-1 and set vol = 0 */
7850 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7851 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7852 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7853 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7854 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7856
7857 /*
7858 * Set up output mixers (0x0c - 0x0e)
7859 */
7860 /* set vol=0 to output mixers */
7861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7864 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7865
7866 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7867 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7868
7869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7871 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7872 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7873 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7875 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7876 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7877
7878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7881 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7884 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7885 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7886
7887 /* FIXME: use matrix-type input source selection */
7888 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
7889 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7890 /* Input mixer2 */
7891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7895
7896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7900 { }
7901};
7902
7903/*
7904 * generic initialization of ADC, input mixers and output mixers
7905 */
7906static struct hda_verb alc268_volume_init_verbs[] = {
7907 /* set output DAC */
7908 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7912
7913 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7914 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7917 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7918
7919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7923 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7924
7925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7926 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7929
7930 /* set PCBEEP vol = 0 */
7931 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
7932
7933 { }
7934};
7935
7936#define alc268_mux_enum_info alc_mux_enum_info
7937#define alc268_mux_enum_get alc_mux_enum_get
7938
7939static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
7940 struct snd_ctl_elem_value *ucontrol)
7941{
7942 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7943 struct alc_spec *spec = codec->spec;
7944 const struct hda_input_mux *imux = spec->input_mux;
7945 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7946 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
7947 hda_nid_t nid = capture_mixers[adc_idx];
7948 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7949 unsigned int i, idx;
7950
7951 idx = ucontrol->value.enumerated.item[0];
7952 if (idx >= imux->num_items)
7953 idx = imux->num_items - 1;
7954 if (*cur_val == idx && !codec->in_resume)
7955 return 0;
7956 for (i = 0; i < imux->num_items; i++) {
7957 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
7958 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7959 v | (imux->items[i].index << 8));
7960 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
7961 idx );
7962 }
7963 *cur_val = idx;
7964 return 1;
7965}
7966
7967static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
7968 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7969 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7970 {
7971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7972 /* The multiple "Capture Source" controls confuse alsamixer
7973 * So call somewhat different..
7974 * FIXME: the controls appear in the "playback" view!
7975 */
7976 /* .name = "Capture Source", */
7977 .name = "Input Source",
7978 .count = 1,
7979 .info = alc268_mux_enum_info,
7980 .get = alc268_mux_enum_get,
7981 .put = alc268_mux_enum_put,
7982 },
7983 { } /* end */
7984};
7985
7986static struct snd_kcontrol_new alc268_capture_mixer[] = {
7987 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
7990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
7991 {
7992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7993 /* The multiple "Capture Source" controls confuse alsamixer
7994 * So call somewhat different..
7995 * FIXME: the controls appear in the "playback" view!
7996 */
7997 /* .name = "Capture Source", */
7998 .name = "Input Source",
7999 .count = 2,
8000 .info = alc268_mux_enum_info,
8001 .get = alc268_mux_enum_get,
8002 .put = alc268_mux_enum_put,
8003 },
8004 { } /* end */
8005};
8006
8007static struct hda_input_mux alc268_capture_source = {
8008 .num_items = 4,
8009 .items = {
8010 { "Mic", 0x0 },
8011 { "Front Mic", 0x1 },
8012 { "Line", 0x2 },
8013 { "CD", 0x3 },
8014 },
8015};
8016
8017/* create input playback/capture controls for the given pin */
8018static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8019 const char *ctlname, int idx)
8020{
8021 char name[32];
8022 int err;
8023
8024 sprintf(name, "%s Playback Volume", ctlname);
8025 if (nid == 0x14) {
8026 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8027 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8028 HDA_OUTPUT));
8029 if (err < 0)
8030 return err;
8031 } else if (nid == 0x15) {
8032 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8033 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8034 HDA_OUTPUT));
8035 if (err < 0)
8036 return err;
8037 } else
8038 return -1;
8039 sprintf(name, "%s Playback Switch", ctlname);
8040 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8041 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8042 if (err < 0)
8043 return err;
8044 return 0;
8045}
8046
8047/* add playback controls from the parsed DAC table */
8048static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8049 const struct auto_pin_cfg *cfg)
8050{
8051 hda_nid_t nid;
8052 int err;
8053
8054 spec->multiout.num_dacs = 2; /* only use one dac */
8055 spec->multiout.dac_nids = spec->private_dac_nids;
8056 spec->multiout.dac_nids[0] = 2;
8057 spec->multiout.dac_nids[1] = 3;
8058
8059 nid = cfg->line_out_pins[0];
8060 if (nid)
8061 alc268_new_analog_output(spec, nid, "Front", 0);
8062
8063 nid = cfg->speaker_pins[0];
8064 if (nid == 0x1d) {
8065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8066 "Speaker Playback Volume",
8067 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8068 if (err < 0)
8069 return err;
8070 }
8071 nid = cfg->hp_pins[0];
8072 if (nid)
8073 alc268_new_analog_output(spec, nid, "Headphone", 0);
8074
8075 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8076 if (nid == 0x16) {
8077 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8078 "Mono Playback Switch",
8079 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8080 if (err < 0)
8081 return err;
8082 }
8083 return 0;
8084}
8085
8086/* create playback/capture controls for input pins */
8087static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8088 const struct auto_pin_cfg *cfg)
8089{
8090 struct hda_input_mux *imux = &spec->private_imux;
8091 int i, idx1;
8092
8093 for (i = 0; i < AUTO_PIN_LAST; i++) {
8094 switch(cfg->input_pins[i]) {
8095 case 0x18:
8096 idx1 = 0; /* Mic 1 */
8097 break;
8098 case 0x19:
8099 idx1 = 1; /* Mic 2 */
8100 break;
8101 case 0x1a:
8102 idx1 = 2; /* Line In */
8103 break;
8104 case 0x1c:
8105 idx1 = 3; /* CD */
8106 break;
8107 default:
8108 continue;
8109 }
8110 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8111 imux->items[imux->num_items].index = idx1;
8112 imux->num_items++;
8113 }
8114 return 0;
8115}
8116
8117static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8118{
8119 struct alc_spec *spec = codec->spec;
8120 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8121 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8122 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8123 unsigned int dac_vol1, dac_vol2;
8124
8125 if (speaker_nid) {
8126 snd_hda_codec_write(codec, speaker_nid, 0,
8127 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8128 snd_hda_codec_write(codec, 0x0f, 0,
8129 AC_VERB_SET_AMP_GAIN_MUTE,
8130 AMP_IN_UNMUTE(1));
8131 snd_hda_codec_write(codec, 0x10, 0,
8132 AC_VERB_SET_AMP_GAIN_MUTE,
8133 AMP_IN_UNMUTE(1));
8134 } else {
8135 snd_hda_codec_write(codec, 0x0f, 0,
8136 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8137 snd_hda_codec_write(codec, 0x10, 0,
8138 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8139 }
8140
8141 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8142 if (line_nid == 0x14)
8143 dac_vol2 = AMP_OUT_ZERO;
8144 else if (line_nid == 0x15)
8145 dac_vol1 = AMP_OUT_ZERO;
8146 if (hp_nid == 0x14)
8147 dac_vol2 = AMP_OUT_ZERO;
8148 else if (hp_nid == 0x15)
8149 dac_vol1 = AMP_OUT_ZERO;
8150 if (line_nid != 0x16 || hp_nid != 0x16 ||
8151 spec->autocfg.line_out_pins[1] != 0x16 ||
8152 spec->autocfg.line_out_pins[2] != 0x16)
8153 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8154
8155 snd_hda_codec_write(codec, 0x02, 0,
8156 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8157 snd_hda_codec_write(codec, 0x03, 0,
8158 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8159}
8160
8161/* pcm configuration: identiacal with ALC880 */
8162#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8163#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8164#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8165
8166/*
8167 * BIOS auto configuration
8168 */
8169static int alc268_parse_auto_config(struct hda_codec *codec)
8170{
8171 struct alc_spec *spec = codec->spec;
8172 int err;
8173 static hda_nid_t alc268_ignore[] = { 0 };
8174
8175 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8176 alc268_ignore);
8177 if (err < 0)
8178 return err;
8179 if (!spec->autocfg.line_outs)
8180 return 0; /* can't find valid BIOS pin config */
8181
8182 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8183 if (err < 0)
8184 return err;
8185 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8186 if (err < 0)
8187 return err;
8188
8189 spec->multiout.max_channels = 2;
8190
8191 /* digital only support output */
8192 if (spec->autocfg.dig_out_pin)
8193 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8194
8195 if (spec->kctl_alloc)
8196 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8197
8198 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8199 spec->num_mux_defs = 1;
8200 spec->input_mux = &spec->private_imux;
8201
8202 return 1;
8203}
8204
8205#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8206#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8207#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8208
8209/* init callback for auto-configuration model -- overriding the default init */
8210static void alc268_auto_init(struct hda_codec *codec)
8211{
8212 alc268_auto_init_multi_out(codec);
8213 alc268_auto_init_hp_out(codec);
8214 alc268_auto_init_mono_speaker_out(codec);
8215 alc268_auto_init_analog_input(codec);
8216}
8217
8218/*
8219 * configuration and preset
8220 */
8221static const char *alc268_models[ALC268_MODEL_LAST] = {
8222 [ALC268_3ST] = "3stack",
8223 [ALC268_AUTO] = "auto",
8224};
8225
8226static struct snd_pci_quirk alc268_cfg_tbl[] = {
8227 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8228 {}
8229};
8230
8231static struct alc_config_preset alc268_presets[] = {
8232 [ALC268_3ST] = {
8233 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8234 .init_verbs = { alc268_base_init_verbs },
8235 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8236 .dac_nids = alc268_dac_nids,
8237 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8238 .adc_nids = alc268_adc_nids_alt,
8239 .hp_nid = 0x03,
8240 .dig_out_nid = ALC268_DIGOUT_NID,
8241 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8242 .channel_mode = alc268_modes,
8243 .input_mux = &alc268_capture_source,
8244 },
8245};
8246
8247static int patch_alc268(struct hda_codec *codec)
8248{
8249 struct alc_spec *spec;
8250 int board_config;
8251 int err;
8252
8253 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8254 if (spec == NULL)
8255 return -ENOMEM;
8256
8257 codec->spec = spec;
8258
8259 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8260 alc268_models,
8261 alc268_cfg_tbl);
8262
8263 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8264 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8265 "trying auto-probe from BIOS...\n");
8266 board_config = ALC268_AUTO;
8267 }
8268
8269 if (board_config == ALC268_AUTO) {
8270 /* automatic parse from the BIOS config */
8271 err = alc268_parse_auto_config(codec);
8272 if (err < 0) {
8273 alc_free(codec);
8274 return err;
8275 } else if (!err) {
8276 printk(KERN_INFO
8277 "hda_codec: Cannot set up configuration "
8278 "from BIOS. Using base mode...\n");
8279 board_config = ALC268_3ST;
8280 }
8281 }
8282
8283 if (board_config != ALC268_AUTO)
8284 setup_preset(spec, &alc268_presets[board_config]);
8285
8286 spec->stream_name_analog = "ALC268 Analog";
8287 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8288 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8289
8290 spec->stream_name_digital = "ALC268 Digital";
8291 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8292
8293 if (board_config == ALC268_AUTO) {
8294 if (!spec->adc_nids && spec->input_mux) {
8295 /* check whether NID 0x07 is valid */
8296 unsigned int wcap = get_wcaps(codec, 0x07);
8297
8298 /* get type */
8299 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8300 if (wcap != AC_WID_AUD_IN) {
8301 spec->adc_nids = alc268_adc_nids_alt;
8302 spec->num_adc_nids =
8303 ARRAY_SIZE(alc268_adc_nids_alt);
8304 spec->mixers[spec->num_mixers] =
8305 alc268_capture_alt_mixer;
8306 spec->num_mixers++;
8307 } else {
8308 spec->adc_nids = alc268_adc_nids;
8309 spec->num_adc_nids =
8310 ARRAY_SIZE(alc268_adc_nids);
8311 spec->mixers[spec->num_mixers] =
8312 alc268_capture_mixer;
8313 spec->num_mixers++;
8314 }
8315 }
8316 }
8317 codec->patch_ops = alc_patch_ops;
8318 if (board_config == ALC268_AUTO)
8319 spec->init_hook = alc268_auto_init;
8320
8321 return 0;
8322}
8323
8324/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008325 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8326 */
8327
8328/*
8329 * set the path ways for 2 channel output
8330 * need to set the codec line out and mic 1 pin widgets to inputs
8331 */
8332static struct hda_verb alc861_threestack_ch2_init[] = {
8333 /* set pin widget 1Ah (line in) for input */
8334 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008335 /* set pin widget 18h (mic1/2) for input, for mic also enable
8336 * the vref
8337 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008338 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8339
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008340 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8341#if 0
8342 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8344#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008345 { } /* end */
8346};
8347/*
8348 * 6ch mode
8349 * need to set the codec line out and mic 1 pin widgets to outputs
8350 */
8351static struct hda_verb alc861_threestack_ch6_init[] = {
8352 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8353 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8354 /* set pin widget 18h (mic1) for output (CLFE)*/
8355 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8356
8357 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008358 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008359
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008360 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8361#if 0
8362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8364#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008365 { } /* end */
8366};
8367
8368static struct hda_channel_mode alc861_threestack_modes[2] = {
8369 { 2, alc861_threestack_ch2_init },
8370 { 6, alc861_threestack_ch6_init },
8371};
Takashi Iwai22309c32006-08-09 16:57:28 +02008372/* Set mic1 as input and unmute the mixer */
8373static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8374 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8375 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8376 { } /* end */
8377};
8378/* Set mic1 as output and mute mixer */
8379static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8380 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8381 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8382 { } /* end */
8383};
8384
8385static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8386 { 2, alc861_uniwill_m31_ch2_init },
8387 { 4, alc861_uniwill_m31_ch4_init },
8388};
Kailang Yangdf694da2005-12-05 19:42:22 +01008389
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008390/* Set mic1 and line-in as input and unmute the mixer */
8391static struct hda_verb alc861_asus_ch2_init[] = {
8392 /* set pin widget 1Ah (line in) for input */
8393 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008394 /* set pin widget 18h (mic1/2) for input, for mic also enable
8395 * the vref
8396 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008397 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8398
8399 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8400#if 0
8401 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8402 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8403#endif
8404 { } /* end */
8405};
8406/* Set mic1 nad line-in as output and mute mixer */
8407static struct hda_verb alc861_asus_ch6_init[] = {
8408 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8409 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8410 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8411 /* set pin widget 18h (mic1) for output (CLFE)*/
8412 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8413 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8414 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8415 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8416
8417 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8418#if 0
8419 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8420 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8421#endif
8422 { } /* end */
8423};
8424
8425static struct hda_channel_mode alc861_asus_modes[2] = {
8426 { 2, alc861_asus_ch2_init },
8427 { 6, alc861_asus_ch6_init },
8428};
8429
Kailang Yangdf694da2005-12-05 19:42:22 +01008430/* patch-ALC861 */
8431
8432static struct snd_kcontrol_new alc861_base_mixer[] = {
8433 /* output mixer control */
8434 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8435 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8436 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8439
8440 /*Input mixer control */
8441 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8442 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8443 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8444 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8445 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8446 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8448 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008451
Kailang Yangdf694da2005-12-05 19:42:22 +01008452 /* Capture mixer control */
8453 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8454 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8455 {
8456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8457 .name = "Capture Source",
8458 .count = 1,
8459 .info = alc_mux_enum_info,
8460 .get = alc_mux_enum_get,
8461 .put = alc_mux_enum_put,
8462 },
8463 { } /* end */
8464};
8465
8466static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8467 /* output mixer control */
8468 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8469 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8470 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8471 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8472 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8473
8474 /* Input mixer control */
8475 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8476 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8477 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8478 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8479 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8480 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8482 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008485
Kailang Yangdf694da2005-12-05 19:42:22 +01008486 /* Capture mixer control */
8487 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8488 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8489 {
8490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8491 .name = "Capture Source",
8492 .count = 1,
8493 .info = alc_mux_enum_info,
8494 .get = alc_mux_enum_get,
8495 .put = alc_mux_enum_put,
8496 },
8497 {
8498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8499 .name = "Channel Mode",
8500 .info = alc_ch_mode_info,
8501 .get = alc_ch_mode_get,
8502 .put = alc_ch_mode_put,
8503 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8504 },
8505 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008506};
8507
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008508static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008509 /* output mixer control */
8510 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8512 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8513
8514 /*Capture mixer control */
8515 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8516 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8517 {
8518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8519 .name = "Capture Source",
8520 .count = 1,
8521 .info = alc_mux_enum_info,
8522 .get = alc_mux_enum_get,
8523 .put = alc_mux_enum_put,
8524 },
8525
8526 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008527};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008528
Takashi Iwai22309c32006-08-09 16:57:28 +02008529static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8530 /* output mixer control */
8531 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8532 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8533 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8534 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8535 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8536
8537 /* Input mixer control */
8538 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8539 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8540 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8541 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8542 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8543 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8545 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008548
Takashi Iwai22309c32006-08-09 16:57:28 +02008549 /* Capture mixer control */
8550 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8551 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8552 {
8553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8554 .name = "Capture Source",
8555 .count = 1,
8556 .info = alc_mux_enum_info,
8557 .get = alc_mux_enum_get,
8558 .put = alc_mux_enum_put,
8559 },
8560 {
8561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8562 .name = "Channel Mode",
8563 .info = alc_ch_mode_info,
8564 .get = alc_ch_mode_get,
8565 .put = alc_ch_mode_put,
8566 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8567 },
8568 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008569};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008570
8571static struct snd_kcontrol_new alc861_asus_mixer[] = {
8572 /* output mixer control */
8573 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8574 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8577 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8578
8579 /* Input mixer control */
8580 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8581 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8582 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8583 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8584 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8585 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8587 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8588 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8590
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008591 /* Capture mixer control */
8592 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8593 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8594 {
8595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8596 .name = "Capture Source",
8597 .count = 1,
8598 .info = alc_mux_enum_info,
8599 .get = alc_mux_enum_get,
8600 .put = alc_mux_enum_put,
8601 },
8602 {
8603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8604 .name = "Channel Mode",
8605 .info = alc_ch_mode_info,
8606 .get = alc_ch_mode_get,
8607 .put = alc_ch_mode_put,
8608 .private_value = ARRAY_SIZE(alc861_asus_modes),
8609 },
8610 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008611};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008612
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008613/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008614static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008615 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8616 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8617 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8618 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8619 { }
8620};
8621
Kailang Yangdf694da2005-12-05 19:42:22 +01008622/*
8623 * generic initialization of ADC, input mixers and output mixers
8624 */
8625static struct hda_verb alc861_base_init_verbs[] = {
8626 /*
8627 * Unmute ADC0 and set the default input to mic-in
8628 */
8629 /* port-A for surround (rear panel) */
8630 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8631 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8632 /* port-B for mic-in (rear panel) with vref */
8633 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8634 /* port-C for line-in (rear panel) */
8635 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8636 /* port-D for Front */
8637 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8638 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8639 /* port-E for HP out (front panel) */
8640 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8641 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008642 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008643 /* port-F for mic-in (front panel) with vref */
8644 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8645 /* port-G for CLFE (rear panel) */
8646 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8647 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8648 /* port-H for side (rear panel) */
8649 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8650 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8651 /* CD-in */
8652 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8653 /* route front mic to ADC1*/
8654 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8656
8657 /* Unmute DAC0~3 & spdif out*/
8658 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8659 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8660 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8661 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8663
8664 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8665 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8666 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8667 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8668 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8669
8670 /* Unmute Stereo Mixer 15 */
8671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008675
8676 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8678 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008684 /* hp used DAC 3 (Front) */
8685 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8687
8688 { }
8689};
8690
8691static struct hda_verb alc861_threestack_init_verbs[] = {
8692 /*
8693 * Unmute ADC0 and set the default input to mic-in
8694 */
8695 /* port-A for surround (rear panel) */
8696 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8697 /* port-B for mic-in (rear panel) with vref */
8698 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8699 /* port-C for line-in (rear panel) */
8700 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8701 /* port-D for Front */
8702 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8703 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8704 /* port-E for HP out (front panel) */
8705 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8706 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008707 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008708 /* port-F for mic-in (front panel) with vref */
8709 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8710 /* port-G for CLFE (rear panel) */
8711 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8712 /* port-H for side (rear panel) */
8713 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8714 /* CD-in */
8715 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8716 /* route front mic to ADC1*/
8717 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8718 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8719 /* Unmute DAC0~3 & spdif out*/
8720 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8722 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8723 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8725
8726 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8727 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8728 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8729 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8730 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8731
8732 /* Unmute Stereo Mixer 15 */
8733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008737
8738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008746 /* hp used DAC 3 (Front) */
8747 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8749 { }
8750};
Takashi Iwai22309c32006-08-09 16:57:28 +02008751
8752static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8753 /*
8754 * Unmute ADC0 and set the default input to mic-in
8755 */
8756 /* port-A for surround (rear panel) */
8757 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8758 /* port-B for mic-in (rear panel) with vref */
8759 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8760 /* port-C for line-in (rear panel) */
8761 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8762 /* port-D for Front */
8763 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8764 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8765 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008766 /* this has to be set to VREF80 */
8767 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008768 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008769 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008770 /* port-F for mic-in (front panel) with vref */
8771 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8772 /* port-G for CLFE (rear panel) */
8773 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8774 /* port-H for side (rear panel) */
8775 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8776 /* CD-in */
8777 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8778 /* route front mic to ADC1*/
8779 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8781 /* Unmute DAC0~3 & spdif out*/
8782 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8783 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8784 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8785 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8787
8788 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8789 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8790 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8791 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8792 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8793
8794 /* Unmute Stereo Mixer 15 */
8795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008799
8800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8801 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8802 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8804 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8806 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008808 /* hp used DAC 3 (Front) */
8809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02008810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8811 { }
8812};
8813
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008814static struct hda_verb alc861_asus_init_verbs[] = {
8815 /*
8816 * Unmute ADC0 and set the default input to mic-in
8817 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008818 /* port-A for surround (rear panel)
8819 * according to codec#0 this is the HP jack
8820 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008821 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8822 /* route front PCM to HP */
8823 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8824 /* port-B for mic-in (rear panel) with vref */
8825 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8826 /* port-C for line-in (rear panel) */
8827 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8828 /* port-D for Front */
8829 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8830 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8831 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008832 /* this has to be set to VREF80 */
8833 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008834 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008835 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008836 /* port-F for mic-in (front panel) with vref */
8837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8838 /* port-G for CLFE (rear panel) */
8839 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8840 /* port-H for side (rear panel) */
8841 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8842 /* CD-in */
8843 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8844 /* route front mic to ADC1*/
8845 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8847 /* Unmute DAC0~3 & spdif out*/
8848 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8849 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8850 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8851 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8853 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8854 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8855 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8856 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8857 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8858
8859 /* Unmute Stereo Mixer 15 */
8860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008864
8865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8867 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8872 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008873 /* hp used DAC 3 (Front) */
8874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8876 { }
8877};
8878
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008879/* additional init verbs for ASUS laptops */
8880static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8881 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8882 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8883 { }
8884};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008885
Kailang Yangdf694da2005-12-05 19:42:22 +01008886/*
8887 * generic initialization of ADC, input mixers and output mixers
8888 */
8889static struct hda_verb alc861_auto_init_verbs[] = {
8890 /*
8891 * Unmute ADC0 and set the default input to mic-in
8892 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008893 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01008894 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8895
8896 /* Unmute DAC0~3 & spdif out*/
8897 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8898 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8899 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8900 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8902
8903 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8904 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8905 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8906 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8908
8909 /* Unmute Stereo Mixer 15 */
8910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8914
8915 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8921 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8923
8924 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008928 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008930 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008932
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008933 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008934
8935 { }
8936};
8937
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008938static struct hda_verb alc861_toshiba_init_verbs[] = {
8939 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008940
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008941 { }
8942};
8943
8944/* toggle speaker-output according to the hp-jack state */
8945static void alc861_toshiba_automute(struct hda_codec *codec)
8946{
8947 unsigned int present;
8948
8949 present = snd_hda_codec_read(codec, 0x0f, 0,
8950 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8951 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8952 0x80, present ? 0x80 : 0);
8953 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8954 0x80, present ? 0x80 : 0);
8955 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8956 0x80, present ? 0 : 0x80);
8957 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8958 0x80, present ? 0 : 0x80);
8959}
8960
8961static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8962 unsigned int res)
8963{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008964 if ((res >> 26) == ALC880_HP_EVENT)
8965 alc861_toshiba_automute(codec);
8966}
8967
Kailang Yangdf694da2005-12-05 19:42:22 +01008968/* pcm configuration: identiacal with ALC880 */
8969#define alc861_pcm_analog_playback alc880_pcm_analog_playback
8970#define alc861_pcm_analog_capture alc880_pcm_analog_capture
8971#define alc861_pcm_digital_playback alc880_pcm_digital_playback
8972#define alc861_pcm_digital_capture alc880_pcm_digital_capture
8973
8974
8975#define ALC861_DIGOUT_NID 0x07
8976
8977static struct hda_channel_mode alc861_8ch_modes[1] = {
8978 { 8, NULL }
8979};
8980
8981static hda_nid_t alc861_dac_nids[4] = {
8982 /* front, surround, clfe, side */
8983 0x03, 0x06, 0x05, 0x04
8984};
8985
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008986static hda_nid_t alc660_dac_nids[3] = {
8987 /* front, clfe, surround */
8988 0x03, 0x05, 0x06
8989};
8990
Kailang Yangdf694da2005-12-05 19:42:22 +01008991static hda_nid_t alc861_adc_nids[1] = {
8992 /* ADC0-2 */
8993 0x08,
8994};
8995
8996static struct hda_input_mux alc861_capture_source = {
8997 .num_items = 5,
8998 .items = {
8999 { "Mic", 0x0 },
9000 { "Front Mic", 0x3 },
9001 { "Line", 0x1 },
9002 { "CD", 0x4 },
9003 { "Mixer", 0x5 },
9004 },
9005};
9006
9007/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009008static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9009 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009010{
9011 int i;
9012 hda_nid_t nid;
9013
9014 spec->multiout.dac_nids = spec->private_dac_nids;
9015 for (i = 0; i < cfg->line_outs; i++) {
9016 nid = cfg->line_out_pins[i];
9017 if (nid) {
9018 if (i >= ARRAY_SIZE(alc861_dac_nids))
9019 continue;
9020 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9021 }
9022 }
9023 spec->multiout.num_dacs = cfg->line_outs;
9024 return 0;
9025}
9026
9027/* add playback controls from the parsed DAC table */
9028static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9029 const struct auto_pin_cfg *cfg)
9030{
9031 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009032 static const char *chname[4] = {
9033 "Front", "Surround", NULL /*CLFE*/, "Side"
9034 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009035 hda_nid_t nid;
9036 int i, idx, err;
9037
9038 for (i = 0; i < cfg->line_outs; i++) {
9039 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009040 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009041 continue;
9042 if (nid == 0x05) {
9043 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009044 err = add_control(spec, ALC_CTL_BIND_MUTE,
9045 "Center Playback Switch",
9046 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9047 HDA_OUTPUT));
9048 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009049 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009050 err = add_control(spec, ALC_CTL_BIND_MUTE,
9051 "LFE Playback Switch",
9052 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9053 HDA_OUTPUT));
9054 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009055 return err;
9056 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009057 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9058 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009059 if (nid == alc861_dac_nids[idx])
9060 break;
9061 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009062 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9063 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9064 HDA_OUTPUT));
9065 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009066 return err;
9067 }
9068 }
9069 return 0;
9070}
9071
9072static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9073{
9074 int err;
9075 hda_nid_t nid;
9076
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009077 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009078 return 0;
9079
9080 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9081 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009082 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9083 "Headphone Playback Switch",
9084 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009086 return err;
9087 spec->multiout.hp_nid = nid;
9088 }
9089 return 0;
9090}
9091
9092/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009093static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9094 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009095{
Kailang Yangdf694da2005-12-05 19:42:22 +01009096 struct hda_input_mux *imux = &spec->private_imux;
9097 int i, err, idx, idx1;
9098
9099 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009100 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009101 case 0x0c:
9102 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009103 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009104 break;
9105 case 0x0f:
9106 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009107 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009108 break;
9109 case 0x0d:
9110 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009111 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009112 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009113 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009114 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009115 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009116 break;
9117 case 0x11:
9118 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009119 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009120 break;
9121 default:
9122 continue;
9123 }
9124
Takashi Iwai4a471b72005-12-07 13:56:29 +01009125 err = new_analog_input(spec, cfg->input_pins[i],
9126 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009127 if (err < 0)
9128 return err;
9129
Takashi Iwai4a471b72005-12-07 13:56:29 +01009130 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009131 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009132 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009133 }
9134 return 0;
9135}
9136
9137static struct snd_kcontrol_new alc861_capture_mixer[] = {
9138 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9139 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9140
9141 {
9142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9143 /* The multiple "Capture Source" controls confuse alsamixer
9144 * So call somewhat different..
9145 *FIXME: the controls appear in the "playback" view!
9146 */
9147 /* .name = "Capture Source", */
9148 .name = "Input Source",
9149 .count = 1,
9150 .info = alc_mux_enum_info,
9151 .get = alc_mux_enum_get,
9152 .put = alc_mux_enum_put,
9153 },
9154 { } /* end */
9155};
9156
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009157static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9158 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009159 int pin_type, int dac_idx)
9160{
9161 /* set as output */
9162
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9164 pin_type);
9165 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9166 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009167
9168}
9169
9170static void alc861_auto_init_multi_out(struct hda_codec *codec)
9171{
9172 struct alc_spec *spec = codec->spec;
9173 int i;
9174
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009175 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009176 for (i = 0; i < spec->autocfg.line_outs; i++) {
9177 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009178 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009179 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009180 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009181 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009182 }
9183}
9184
9185static void alc861_auto_init_hp_out(struct hda_codec *codec)
9186{
9187 struct alc_spec *spec = codec->spec;
9188 hda_nid_t pin;
9189
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009190 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009191 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009192 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9193 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009194}
9195
9196static void alc861_auto_init_analog_input(struct hda_codec *codec)
9197{
9198 struct alc_spec *spec = codec->spec;
9199 int i;
9200
9201 for (i = 0; i < AUTO_PIN_LAST; i++) {
9202 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009203 if (nid >= 0x0c && nid <= 0x11) {
9204 snd_hda_codec_write(codec, nid, 0,
9205 AC_VERB_SET_PIN_WIDGET_CONTROL,
9206 i <= AUTO_PIN_FRONT_MIC ?
9207 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009208 }
9209 }
9210}
9211
9212/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009213/* return 1 if successful, 0 if the proper config is not found,
9214 * or a negative error code
9215 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009216static int alc861_parse_auto_config(struct hda_codec *codec)
9217{
9218 struct alc_spec *spec = codec->spec;
9219 int err;
9220 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9221
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009222 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9223 alc861_ignore);
9224 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009225 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009226 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009227 return 0; /* can't find valid BIOS pin config */
9228
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009229 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9230 if (err < 0)
9231 return err;
9232 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9233 if (err < 0)
9234 return err;
9235 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9236 if (err < 0)
9237 return err;
9238 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9239 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009240 return err;
9241
9242 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9243
9244 if (spec->autocfg.dig_out_pin)
9245 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9246
9247 if (spec->kctl_alloc)
9248 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9249
9250 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9251
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009252 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009253 spec->input_mux = &spec->private_imux;
9254
9255 spec->adc_nids = alc861_adc_nids;
9256 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9257 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9258 spec->num_mixers++;
9259
9260 return 1;
9261}
9262
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009263/* additional initialization for auto-configuration model */
9264static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009265{
Kailang Yangdf694da2005-12-05 19:42:22 +01009266 alc861_auto_init_multi_out(codec);
9267 alc861_auto_init_hp_out(codec);
9268 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009269}
9270
9271
9272/*
9273 * configuration and preset
9274 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009275static const char *alc861_models[ALC861_MODEL_LAST] = {
9276 [ALC861_3ST] = "3stack",
9277 [ALC660_3ST] = "3stack-660",
9278 [ALC861_3ST_DIG] = "3stack-dig",
9279 [ALC861_6ST_DIG] = "6stack-dig",
9280 [ALC861_UNIWILL_M31] = "uniwill-m31",
9281 [ALC861_TOSHIBA] = "toshiba",
9282 [ALC861_ASUS] = "asus",
9283 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9284 [ALC861_AUTO] = "auto",
9285};
9286
9287static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009288 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009289 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9290 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009291 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009292 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Tobin Davisad5e7732007-01-08 10:57:32 +01009293 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009294 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9295 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009296 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009297 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009298 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009299 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009300 {}
9301};
9302
9303static struct alc_config_preset alc861_presets[] = {
9304 [ALC861_3ST] = {
9305 .mixers = { alc861_3ST_mixer },
9306 .init_verbs = { alc861_threestack_init_verbs },
9307 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9308 .dac_nids = alc861_dac_nids,
9309 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9310 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009311 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009312 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9313 .adc_nids = alc861_adc_nids,
9314 .input_mux = &alc861_capture_source,
9315 },
9316 [ALC861_3ST_DIG] = {
9317 .mixers = { alc861_base_mixer },
9318 .init_verbs = { alc861_threestack_init_verbs },
9319 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9320 .dac_nids = alc861_dac_nids,
9321 .dig_out_nid = ALC861_DIGOUT_NID,
9322 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9323 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009324 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009325 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9326 .adc_nids = alc861_adc_nids,
9327 .input_mux = &alc861_capture_source,
9328 },
9329 [ALC861_6ST_DIG] = {
9330 .mixers = { alc861_base_mixer },
9331 .init_verbs = { alc861_base_init_verbs },
9332 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9333 .dac_nids = alc861_dac_nids,
9334 .dig_out_nid = ALC861_DIGOUT_NID,
9335 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9336 .channel_mode = alc861_8ch_modes,
9337 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9338 .adc_nids = alc861_adc_nids,
9339 .input_mux = &alc861_capture_source,
9340 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009341 [ALC660_3ST] = {
9342 .mixers = { alc861_3ST_mixer },
9343 .init_verbs = { alc861_threestack_init_verbs },
9344 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9345 .dac_nids = alc660_dac_nids,
9346 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9347 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009348 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009349 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9350 .adc_nids = alc861_adc_nids,
9351 .input_mux = &alc861_capture_source,
9352 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009353 [ALC861_UNIWILL_M31] = {
9354 .mixers = { alc861_uniwill_m31_mixer },
9355 .init_verbs = { alc861_uniwill_m31_init_verbs },
9356 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9357 .dac_nids = alc861_dac_nids,
9358 .dig_out_nid = ALC861_DIGOUT_NID,
9359 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9360 .channel_mode = alc861_uniwill_m31_modes,
9361 .need_dac_fix = 1,
9362 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9363 .adc_nids = alc861_adc_nids,
9364 .input_mux = &alc861_capture_source,
9365 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009366 [ALC861_TOSHIBA] = {
9367 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009368 .init_verbs = { alc861_base_init_verbs,
9369 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009370 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9371 .dac_nids = alc861_dac_nids,
9372 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9373 .channel_mode = alc883_3ST_2ch_modes,
9374 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9375 .adc_nids = alc861_adc_nids,
9376 .input_mux = &alc861_capture_source,
9377 .unsol_event = alc861_toshiba_unsol_event,
9378 .init_hook = alc861_toshiba_automute,
9379 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009380 [ALC861_ASUS] = {
9381 .mixers = { alc861_asus_mixer },
9382 .init_verbs = { alc861_asus_init_verbs },
9383 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9384 .dac_nids = alc861_dac_nids,
9385 .dig_out_nid = ALC861_DIGOUT_NID,
9386 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9387 .channel_mode = alc861_asus_modes,
9388 .need_dac_fix = 1,
9389 .hp_nid = 0x06,
9390 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9391 .adc_nids = alc861_adc_nids,
9392 .input_mux = &alc861_capture_source,
9393 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009394 [ALC861_ASUS_LAPTOP] = {
9395 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9396 .init_verbs = { alc861_asus_init_verbs,
9397 alc861_asus_laptop_init_verbs },
9398 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9399 .dac_nids = alc861_dac_nids,
9400 .dig_out_nid = ALC861_DIGOUT_NID,
9401 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9402 .channel_mode = alc883_3ST_2ch_modes,
9403 .need_dac_fix = 1,
9404 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9405 .adc_nids = alc861_adc_nids,
9406 .input_mux = &alc861_capture_source,
9407 },
9408};
Kailang Yangdf694da2005-12-05 19:42:22 +01009409
9410
9411static int patch_alc861(struct hda_codec *codec)
9412{
9413 struct alc_spec *spec;
9414 int board_config;
9415 int err;
9416
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009417 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009418 if (spec == NULL)
9419 return -ENOMEM;
9420
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009421 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009422
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009423 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9424 alc861_models,
9425 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009426
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009427 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009428 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9429 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009430 board_config = ALC861_AUTO;
9431 }
9432
9433 if (board_config == ALC861_AUTO) {
9434 /* automatic parse from the BIOS config */
9435 err = alc861_parse_auto_config(codec);
9436 if (err < 0) {
9437 alc_free(codec);
9438 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009439 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009440 printk(KERN_INFO
9441 "hda_codec: Cannot set up configuration "
9442 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 board_config = ALC861_3ST_DIG;
9444 }
9445 }
9446
9447 if (board_config != ALC861_AUTO)
9448 setup_preset(spec, &alc861_presets[board_config]);
9449
9450 spec->stream_name_analog = "ALC861 Analog";
9451 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9452 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9453
9454 spec->stream_name_digital = "ALC861 Digital";
9455 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9456 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9457
9458 codec->patch_ops = alc_patch_ops;
9459 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009460 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009461
9462 return 0;
9463}
9464
9465/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009466 * ALC861-VD support
9467 *
9468 * Based on ALC882
9469 *
9470 * In addition, an independent DAC
9471 */
9472#define ALC861VD_DIGOUT_NID 0x06
9473
9474static hda_nid_t alc861vd_dac_nids[4] = {
9475 /* front, surr, clfe, side surr */
9476 0x02, 0x03, 0x04, 0x05
9477};
9478
9479/* dac_nids for ALC660vd are in a different order - according to
9480 * Realtek's driver.
9481 * This should probably tesult in a different mixer for 6stack models
9482 * of ALC660vd codecs, but for now there is only 3stack mixer
9483 * - and it is the same as in 861vd.
9484 * adc_nids in ALC660vd are (is) the same as in 861vd
9485 */
9486static hda_nid_t alc660vd_dac_nids[3] = {
9487 /* front, rear, clfe, rear_surr */
9488 0x02, 0x04, 0x03
9489};
9490
9491static hda_nid_t alc861vd_adc_nids[1] = {
9492 /* ADC0 */
9493 0x09,
9494};
9495
9496/* input MUX */
9497/* FIXME: should be a matrix-type input source selection */
9498static struct hda_input_mux alc861vd_capture_source = {
9499 .num_items = 4,
9500 .items = {
9501 { "Mic", 0x0 },
9502 { "Front Mic", 0x1 },
9503 { "Line", 0x2 },
9504 { "CD", 0x4 },
9505 },
9506};
9507
Kailang Yang272a5272007-05-14 11:00:38 +02009508static struct hda_input_mux alc861vd_dallas_capture_source = {
9509 .num_items = 3,
9510 .items = {
9511 { "Front Mic", 0x0 },
9512 { "ATAPI Mic", 0x1 },
9513 { "Line In", 0x5 },
9514 },
9515};
9516
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009517#define alc861vd_mux_enum_info alc_mux_enum_info
9518#define alc861vd_mux_enum_get alc_mux_enum_get
9519
9520static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9521 struct snd_ctl_elem_value *ucontrol)
9522{
9523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9524 struct alc_spec *spec = codec->spec;
9525 const struct hda_input_mux *imux = spec->input_mux;
9526 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9527 static hda_nid_t capture_mixers[1] = { 0x22 };
9528 hda_nid_t nid = capture_mixers[adc_idx];
9529 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9530 unsigned int i, idx;
9531
9532 idx = ucontrol->value.enumerated.item[0];
9533 if (idx >= imux->num_items)
9534 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009535 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009536 return 0;
9537 for (i = 0; i < imux->num_items; i++) {
9538 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9540 v | (imux->items[i].index << 8));
9541 }
9542 *cur_val = idx;
9543 return 1;
9544}
9545
9546/*
9547 * 2ch mode
9548 */
9549static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9550 { 2, NULL }
9551};
9552
9553/*
9554 * 6ch mode
9555 */
9556static struct hda_verb alc861vd_6stack_ch6_init[] = {
9557 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9558 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9559 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9560 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9561 { } /* end */
9562};
9563
9564/*
9565 * 8ch mode
9566 */
9567static struct hda_verb alc861vd_6stack_ch8_init[] = {
9568 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9569 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9570 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9571 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9572 { } /* end */
9573};
9574
9575static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9576 { 6, alc861vd_6stack_ch6_init },
9577 { 8, alc861vd_6stack_ch8_init },
9578};
9579
9580static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9581 {
9582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9583 .name = "Channel Mode",
9584 .info = alc_ch_mode_info,
9585 .get = alc_ch_mode_get,
9586 .put = alc_ch_mode_put,
9587 },
9588 { } /* end */
9589};
9590
9591static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9592 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9593 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9594
9595 {
9596 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9597 /* The multiple "Capture Source" controls confuse alsamixer
9598 * So call somewhat different..
9599 *FIXME: the controls appear in the "playback" view!
9600 */
9601 /* .name = "Capture Source", */
9602 .name = "Input Source",
9603 .count = 1,
9604 .info = alc861vd_mux_enum_info,
9605 .get = alc861vd_mux_enum_get,
9606 .put = alc861vd_mux_enum_put,
9607 },
9608 { } /* end */
9609};
9610
9611/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9612 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9613 */
9614static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9615 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9616 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9617
9618 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9619 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9620
9621 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9622 HDA_OUTPUT),
9623 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9624 HDA_OUTPUT),
9625 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9626 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9627
9628 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9629 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9630
9631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9632
9633 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9636
9637 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9640
9641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9643
9644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9646
9647 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9648 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9649
9650 { } /* end */
9651};
9652
9653static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9654 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9655 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9656
9657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9658
9659 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9662
9663 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9664 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9665 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9666
9667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9668 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9669
9670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9672
9673 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9674 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9675
9676 { } /* end */
9677};
9678
Kailang Yangbdd148a2007-05-08 15:19:08 +02009679static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9680 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9681 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9682 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9683
9684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9685
9686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9689
9690 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9691 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9692 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9693
9694 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9695 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9696
9697 { } /* end */
9698};
9699
Kailang Yang272a5272007-05-14 11:00:38 +02009700/* Pin assignment: Front=0x14, HP = 0x15,
9701 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9702 */
9703static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9704 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9705 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9707 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9708 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9711 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9712 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9713 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9714 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9715 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9716 {
9717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9718 /* .name = "Capture Source", */
9719 .name = "Input Source",
9720 .count = 1,
9721 .info = alc882_mux_enum_info,
9722 .get = alc882_mux_enum_get,
9723 .put = alc882_mux_enum_put,
9724 },
9725 { } /* end */
9726};
9727
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009728/*
9729 * generic initialization of ADC, input mixers and output mixers
9730 */
9731static struct hda_verb alc861vd_volume_init_verbs[] = {
9732 /*
9733 * Unmute ADC0 and set the default input to mic-in
9734 */
9735 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9737
9738 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9739 * the analog-loopback mixer widget
9740 */
9741 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9747
9748 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009753
9754 /*
9755 * Set up output mixers (0x02 - 0x05)
9756 */
9757 /* set vol=0 to output mixers */
9758 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9759 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9760 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9761 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9762
9763 /* set up input amps for analog loopback */
9764 /* Amp Indices: DAC = 0, mixer = 1 */
9765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9771 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9773
9774 { }
9775};
9776
9777/*
9778 * 3-stack pin configuration:
9779 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9780 */
9781static struct hda_verb alc861vd_3stack_init_verbs[] = {
9782 /*
9783 * Set pin mode and muting
9784 */
9785 /* set front pin widgets 0x14 for output */
9786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9788 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9789
9790 /* Mic (rear) pin: input vref at 80% */
9791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9793 /* Front Mic pin: input vref at 80% */
9794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9796 /* Line In pin: input */
9797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9799 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9801 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9802 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9803 /* CD pin widget for input */
9804 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9805
9806 { }
9807};
9808
9809/*
9810 * 6-stack pin configuration:
9811 */
9812static struct hda_verb alc861vd_6stack_init_verbs[] = {
9813 /*
9814 * Set pin mode and muting
9815 */
9816 /* set front pin widgets 0x14 for output */
9817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9819 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9820
9821 /* Rear Pin: output 1 (0x0d) */
9822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9825 /* CLFE Pin: output 2 (0x0e) */
9826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9828 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9829 /* Side Pin: output 3 (0x0f) */
9830 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9831 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9832 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9833
9834 /* Mic (rear) pin: input vref at 80% */
9835 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9837 /* Front Mic pin: input vref at 80% */
9838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9840 /* Line In pin: input */
9841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9843 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9846 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9847 /* CD pin widget for input */
9848 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9849
9850 { }
9851};
9852
Kailang Yangbdd148a2007-05-08 15:19:08 +02009853static struct hda_verb alc861vd_eapd_verbs[] = {
9854 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9855 { }
9856};
9857
9858static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9862 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9863 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9864 {}
9865};
9866
9867/* toggle speaker-output according to the hp-jack state */
9868static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9869{
9870 unsigned int present;
9871 unsigned char bits;
9872
9873 present = snd_hda_codec_read(codec, 0x1b, 0,
9874 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9875 bits = present ? 0x80 : 0;
9876 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9877 0x80, bits);
9878 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9879 0x80, bits);
9880}
9881
9882static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9883{
9884 unsigned int present;
9885 unsigned char bits;
9886
9887 present = snd_hda_codec_read(codec, 0x18, 0,
9888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9889 bits = present ? 0x80 : 0;
9890 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9891 0x80, bits);
9892 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9893 0x80, bits);
9894}
9895
9896static void alc861vd_lenovo_automute(struct hda_codec *codec)
9897{
9898 alc861vd_lenovo_hp_automute(codec);
9899 alc861vd_lenovo_mic_automute(codec);
9900}
9901
9902static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9903 unsigned int res)
9904{
9905 switch (res >> 26) {
9906 case ALC880_HP_EVENT:
9907 alc861vd_lenovo_hp_automute(codec);
9908 break;
9909 case ALC880_MIC_EVENT:
9910 alc861vd_lenovo_mic_automute(codec);
9911 break;
9912 }
9913}
9914
Kailang Yang272a5272007-05-14 11:00:38 +02009915static struct hda_verb alc861vd_dallas_verbs[] = {
9916 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9917 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9918 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9919 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9920
9921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9929
9930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9936 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9938
9939 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9940 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9943 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9946 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9947
9948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9952
9953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9954 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9956
9957 { } /* end */
9958};
9959
9960/* toggle speaker-output according to the hp-jack state */
9961static void alc861vd_dallas_automute(struct hda_codec *codec)
9962{
9963 unsigned int present;
9964
9965 present = snd_hda_codec_read(codec, 0x15, 0,
9966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9967 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9968 0x80, present ? 0x80 : 0);
9969 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9970 0x80, present ? 0x80 : 0);
9971}
9972
9973static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9974{
9975 if ((res >> 26) == ALC880_HP_EVENT)
9976 alc861vd_dallas_automute(codec);
9977}
9978
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009979/* pcm configuration: identiacal with ALC880 */
9980#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
9981#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
9982#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
9983#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
9984
9985/*
9986 * configuration and preset
9987 */
9988static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
9989 [ALC660VD_3ST] = "3stack-660",
9990 [ALC861VD_3ST] = "3stack",
9991 [ALC861VD_3ST_DIG] = "3stack-digout",
9992 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +02009993 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +02009994 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009995 [ALC861VD_AUTO] = "auto",
9996};
9997
9998static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +01009999 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010000 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Daniel Drake36c3b4e2007-05-21 12:27:57 +020010001 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010002 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10003 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10004
Kailang Yang272a5272007-05-14 11:00:38 +020010005 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10006 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010007 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10008 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010009 {}
10010};
10011
10012static struct alc_config_preset alc861vd_presets[] = {
10013 [ALC660VD_3ST] = {
10014 .mixers = { alc861vd_3st_mixer },
10015 .init_verbs = { alc861vd_volume_init_verbs,
10016 alc861vd_3stack_init_verbs },
10017 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10018 .dac_nids = alc660vd_dac_nids,
10019 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10020 .adc_nids = alc861vd_adc_nids,
10021 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10022 .channel_mode = alc861vd_3stack_2ch_modes,
10023 .input_mux = &alc861vd_capture_source,
10024 },
10025 [ALC861VD_3ST] = {
10026 .mixers = { alc861vd_3st_mixer },
10027 .init_verbs = { alc861vd_volume_init_verbs,
10028 alc861vd_3stack_init_verbs },
10029 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10030 .dac_nids = alc861vd_dac_nids,
10031 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10032 .channel_mode = alc861vd_3stack_2ch_modes,
10033 .input_mux = &alc861vd_capture_source,
10034 },
10035 [ALC861VD_3ST_DIG] = {
10036 .mixers = { alc861vd_3st_mixer },
10037 .init_verbs = { alc861vd_volume_init_verbs,
10038 alc861vd_3stack_init_verbs },
10039 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10040 .dac_nids = alc861vd_dac_nids,
10041 .dig_out_nid = ALC861VD_DIGOUT_NID,
10042 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10043 .channel_mode = alc861vd_3stack_2ch_modes,
10044 .input_mux = &alc861vd_capture_source,
10045 },
10046 [ALC861VD_6ST_DIG] = {
10047 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10048 .init_verbs = { alc861vd_volume_init_verbs,
10049 alc861vd_6stack_init_verbs },
10050 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10051 .dac_nids = alc861vd_dac_nids,
10052 .dig_out_nid = ALC861VD_DIGOUT_NID,
10053 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10054 .channel_mode = alc861vd_6stack_modes,
10055 .input_mux = &alc861vd_capture_source,
10056 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010057 [ALC861VD_LENOVO] = {
10058 .mixers = { alc861vd_lenovo_mixer },
10059 .init_verbs = { alc861vd_volume_init_verbs,
10060 alc861vd_3stack_init_verbs,
10061 alc861vd_eapd_verbs,
10062 alc861vd_lenovo_unsol_verbs },
10063 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10064 .dac_nids = alc660vd_dac_nids,
10065 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10066 .adc_nids = alc861vd_adc_nids,
10067 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10068 .channel_mode = alc861vd_3stack_2ch_modes,
10069 .input_mux = &alc861vd_capture_source,
10070 .unsol_event = alc861vd_lenovo_unsol_event,
10071 .init_hook = alc861vd_lenovo_automute,
10072 },
Kailang Yang272a5272007-05-14 11:00:38 +020010073 [ALC861VD_DALLAS] = {
10074 .mixers = { alc861vd_dallas_mixer },
10075 .init_verbs = { alc861vd_dallas_verbs },
10076 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10077 .dac_nids = alc861vd_dac_nids,
10078 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10079 .adc_nids = alc861vd_adc_nids,
10080 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10081 .channel_mode = alc861vd_3stack_2ch_modes,
10082 .input_mux = &alc861vd_dallas_capture_source,
10083 .unsol_event = alc861vd_dallas_unsol_event,
10084 .init_hook = alc861vd_dallas_automute,
10085 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010086};
10087
10088/*
10089 * BIOS auto configuration
10090 */
10091static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10092 hda_nid_t nid, int pin_type, int dac_idx)
10093{
10094 /* set as output */
10095 snd_hda_codec_write(codec, nid, 0,
10096 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10097 snd_hda_codec_write(codec, nid, 0,
10098 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10099}
10100
10101static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10102{
10103 struct alc_spec *spec = codec->spec;
10104 int i;
10105
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010106 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010107 for (i = 0; i <= HDA_SIDE; i++) {
10108 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010109 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010110 if (nid)
10111 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010112 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010113 }
10114}
10115
10116
10117static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10118{
10119 struct alc_spec *spec = codec->spec;
10120 hda_nid_t pin;
10121
10122 pin = spec->autocfg.hp_pins[0];
10123 if (pin) /* connect to front and use dac 0 */
10124 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10125}
10126
10127#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10128#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10129
10130static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10131{
10132 struct alc_spec *spec = codec->spec;
10133 int i;
10134
10135 for (i = 0; i < AUTO_PIN_LAST; i++) {
10136 hda_nid_t nid = spec->autocfg.input_pins[i];
10137 if (alc861vd_is_input_pin(nid)) {
10138 snd_hda_codec_write(codec, nid, 0,
10139 AC_VERB_SET_PIN_WIDGET_CONTROL,
10140 i <= AUTO_PIN_FRONT_MIC ?
10141 PIN_VREF80 : PIN_IN);
10142 if (nid != ALC861VD_PIN_CD_NID)
10143 snd_hda_codec_write(codec, nid, 0,
10144 AC_VERB_SET_AMP_GAIN_MUTE,
10145 AMP_OUT_MUTE);
10146 }
10147 }
10148}
10149
10150#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10151#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10152
10153/* add playback controls from the parsed DAC table */
10154/* Based on ALC880 version. But ALC861VD has separate,
10155 * different NIDs for mute/unmute switch and volume control */
10156static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10157 const struct auto_pin_cfg *cfg)
10158{
10159 char name[32];
10160 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10161 hda_nid_t nid_v, nid_s;
10162 int i, err;
10163
10164 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010165 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010166 continue;
10167 nid_v = alc861vd_idx_to_mixer_vol(
10168 alc880_dac_to_idx(
10169 spec->multiout.dac_nids[i]));
10170 nid_s = alc861vd_idx_to_mixer_switch(
10171 alc880_dac_to_idx(
10172 spec->multiout.dac_nids[i]));
10173
10174 if (i == 2) {
10175 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010176 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10177 "Center Playback Volume",
10178 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10179 HDA_OUTPUT));
10180 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010181 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010182 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10183 "LFE Playback Volume",
10184 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10185 HDA_OUTPUT));
10186 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010187 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010188 err = add_control(spec, ALC_CTL_BIND_MUTE,
10189 "Center Playback Switch",
10190 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10191 HDA_INPUT));
10192 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010193 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010194 err = add_control(spec, ALC_CTL_BIND_MUTE,
10195 "LFE Playback Switch",
10196 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10197 HDA_INPUT));
10198 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010199 return err;
10200 } else {
10201 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010202 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10203 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10204 HDA_OUTPUT));
10205 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010206 return err;
10207 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010208 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010209 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010210 HDA_INPUT));
10211 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010212 return err;
10213 }
10214 }
10215 return 0;
10216}
10217
10218/* add playback controls for speaker and HP outputs */
10219/* Based on ALC880 version. But ALC861VD has separate,
10220 * different NIDs for mute/unmute switch and volume control */
10221static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10222 hda_nid_t pin, const char *pfx)
10223{
10224 hda_nid_t nid_v, nid_s;
10225 int err;
10226 char name[32];
10227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010228 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010229 return 0;
10230
10231 if (alc880_is_fixed_pin(pin)) {
10232 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10233 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010234 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010235 spec->multiout.hp_nid = nid_v;
10236 else
10237 spec->multiout.extra_out_nid[0] = nid_v;
10238 /* control HP volume/switch on the output mixer amp */
10239 nid_v = alc861vd_idx_to_mixer_vol(
10240 alc880_fixed_pin_idx(pin));
10241 nid_s = alc861vd_idx_to_mixer_switch(
10242 alc880_fixed_pin_idx(pin));
10243
10244 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010245 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10246 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10247 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010248 return err;
10249 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010250 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10251 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10252 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010253 return err;
10254 } else if (alc880_is_multi_pin(pin)) {
10255 /* set manual connection */
10256 /* we have only a switch on HP-out PIN */
10257 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010258 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10259 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10260 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010261 return err;
10262 }
10263 return 0;
10264}
10265
10266/* parse the BIOS configuration and set up the alc_spec
10267 * return 1 if successful, 0 if the proper config is not found,
10268 * or a negative error code
10269 * Based on ALC880 version - had to change it to override
10270 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10271static int alc861vd_parse_auto_config(struct hda_codec *codec)
10272{
10273 struct alc_spec *spec = codec->spec;
10274 int err;
10275 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010277 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10278 alc861vd_ignore);
10279 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010280 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010281 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010282 return 0; /* can't find valid BIOS pin config */
10283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010284 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10285 if (err < 0)
10286 return err;
10287 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10288 if (err < 0)
10289 return err;
10290 err = alc861vd_auto_create_extra_out(spec,
10291 spec->autocfg.speaker_pins[0],
10292 "Speaker");
10293 if (err < 0)
10294 return err;
10295 err = alc861vd_auto_create_extra_out(spec,
10296 spec->autocfg.hp_pins[0],
10297 "Headphone");
10298 if (err < 0)
10299 return err;
10300 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10301 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010302 return err;
10303
10304 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10305
10306 if (spec->autocfg.dig_out_pin)
10307 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10308
10309 if (spec->kctl_alloc)
10310 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10311
10312 spec->init_verbs[spec->num_init_verbs++]
10313 = alc861vd_volume_init_verbs;
10314
10315 spec->num_mux_defs = 1;
10316 spec->input_mux = &spec->private_imux;
10317
10318 return 1;
10319}
10320
10321/* additional initialization for auto-configuration model */
10322static void alc861vd_auto_init(struct hda_codec *codec)
10323{
10324 alc861vd_auto_init_multi_out(codec);
10325 alc861vd_auto_init_hp_out(codec);
10326 alc861vd_auto_init_analog_input(codec);
10327}
10328
10329static int patch_alc861vd(struct hda_codec *codec)
10330{
10331 struct alc_spec *spec;
10332 int err, board_config;
10333
10334 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10335 if (spec == NULL)
10336 return -ENOMEM;
10337
10338 codec->spec = spec;
10339
10340 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10341 alc861vd_models,
10342 alc861vd_cfg_tbl);
10343
10344 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10345 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10346 "ALC861VD, trying auto-probe from BIOS...\n");
10347 board_config = ALC861VD_AUTO;
10348 }
10349
10350 if (board_config == ALC861VD_AUTO) {
10351 /* automatic parse from the BIOS config */
10352 err = alc861vd_parse_auto_config(codec);
10353 if (err < 0) {
10354 alc_free(codec);
10355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010356 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010357 printk(KERN_INFO
10358 "hda_codec: Cannot set up configuration "
10359 "from BIOS. Using base mode...\n");
10360 board_config = ALC861VD_3ST;
10361 }
10362 }
10363
10364 if (board_config != ALC861VD_AUTO)
10365 setup_preset(spec, &alc861vd_presets[board_config]);
10366
10367 spec->stream_name_analog = "ALC861VD Analog";
10368 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10369 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10370
10371 spec->stream_name_digital = "ALC861VD Digital";
10372 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10373 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10374
10375 spec->adc_nids = alc861vd_adc_nids;
10376 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10377
10378 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10379 spec->num_mixers++;
10380
10381 codec->patch_ops = alc_patch_ops;
10382
10383 if (board_config == ALC861VD_AUTO)
10384 spec->init_hook = alc861vd_auto_init;
10385
10386 return 0;
10387}
10388
10389/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010390 * ALC662 support
10391 *
10392 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10393 * configuration. Each pin widget can choose any input DACs and a mixer.
10394 * Each ADC is connected from a mixer of all inputs. This makes possible
10395 * 6-channel independent captures.
10396 *
10397 * In addition, an independent DAC for the multi-playback (not used in this
10398 * driver yet).
10399 */
10400#define ALC662_DIGOUT_NID 0x06
10401#define ALC662_DIGIN_NID 0x0a
10402
10403static hda_nid_t alc662_dac_nids[4] = {
10404 /* front, rear, clfe, rear_surr */
10405 0x02, 0x03, 0x04
10406};
10407
10408static hda_nid_t alc662_adc_nids[1] = {
10409 /* ADC1-2 */
10410 0x09,
10411};
10412/* input MUX */
10413/* FIXME: should be a matrix-type input source selection */
10414
10415static struct hda_input_mux alc662_capture_source = {
10416 .num_items = 4,
10417 .items = {
10418 { "Mic", 0x0 },
10419 { "Front Mic", 0x1 },
10420 { "Line", 0x2 },
10421 { "CD", 0x4 },
10422 },
10423};
10424
10425static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10426 .num_items = 2,
10427 .items = {
10428 { "Mic", 0x1 },
10429 { "Line", 0x2 },
10430 },
10431};
10432#define alc662_mux_enum_info alc_mux_enum_info
10433#define alc662_mux_enum_get alc_mux_enum_get
10434
10435static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10436 struct snd_ctl_elem_value *ucontrol)
10437{
10438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10439 struct alc_spec *spec = codec->spec;
10440 const struct hda_input_mux *imux = spec->input_mux;
10441 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10442 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10443 hda_nid_t nid = capture_mixers[adc_idx];
10444 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10445 unsigned int i, idx;
10446
10447 idx = ucontrol->value.enumerated.item[0];
10448 if (idx >= imux->num_items)
10449 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010450 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010451 return 0;
10452 for (i = 0; i < imux->num_items; i++) {
10453 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10454 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10455 v | (imux->items[i].index << 8));
10456 }
10457 *cur_val = idx;
10458 return 1;
10459}
10460/*
10461 * 2ch mode
10462 */
10463static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10464 { 2, NULL }
10465};
10466
10467/*
10468 * 2ch mode
10469 */
10470static struct hda_verb alc662_3ST_ch2_init[] = {
10471 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10472 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10475 { } /* end */
10476};
10477
10478/*
10479 * 6ch mode
10480 */
10481static struct hda_verb alc662_3ST_ch6_init[] = {
10482 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10483 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10484 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10485 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10486 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10487 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10488 { } /* end */
10489};
10490
10491static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10492 { 2, alc662_3ST_ch2_init },
10493 { 6, alc662_3ST_ch6_init },
10494};
10495
10496/*
10497 * 2ch mode
10498 */
10499static struct hda_verb alc662_sixstack_ch6_init[] = {
10500 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10501 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10502 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10503 { } /* end */
10504};
10505
10506/*
10507 * 6ch mode
10508 */
10509static struct hda_verb alc662_sixstack_ch8_init[] = {
10510 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10511 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10512 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10513 { } /* end */
10514};
10515
10516static struct hda_channel_mode alc662_5stack_modes[2] = {
10517 { 2, alc662_sixstack_ch6_init },
10518 { 6, alc662_sixstack_ch8_init },
10519};
10520
10521/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10522 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10523 */
10524
10525static struct snd_kcontrol_new alc662_base_mixer[] = {
10526 /* output mixer control */
10527 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10528 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10529 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10530 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10531 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10532 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10533 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10534 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10536
10537 /*Input mixer control */
10538 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10539 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10540 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10541 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10542 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10543 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10545 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10546
10547 /* Capture mixer control */
10548 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10549 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10550 {
10551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10552 .name = "Capture Source",
10553 .count = 1,
10554 .info = alc_mux_enum_info,
10555 .get = alc_mux_enum_get,
10556 .put = alc_mux_enum_put,
10557 },
10558 { } /* end */
10559};
10560
10561static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10562 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10563 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10566 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10567 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10568 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10571 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10573 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10574 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10575 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10576 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10577 {
10578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10579 /* .name = "Capture Source", */
10580 .name = "Input Source",
10581 .count = 1,
10582 .info = alc662_mux_enum_info,
10583 .get = alc662_mux_enum_get,
10584 .put = alc662_mux_enum_put,
10585 },
10586 { } /* end */
10587};
10588
10589static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10590 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10591 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10592 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10593 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10594 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10595 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10596 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10597 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10605 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10607 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10608 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10609 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10610 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10611 {
10612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10613 /* .name = "Capture Source", */
10614 .name = "Input Source",
10615 .count = 1,
10616 .info = alc662_mux_enum_info,
10617 .get = alc662_mux_enum_get,
10618 .put = alc662_mux_enum_put,
10619 },
10620 { } /* end */
10621};
10622
10623static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10624 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10625 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10626 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10627 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10633 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10634 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10635 {
10636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10637 /* .name = "Capture Source", */
10638 .name = "Input Source",
10639 .count = 1,
10640 .info = alc662_mux_enum_info,
10641 .get = alc662_mux_enum_get,
10642 .put = alc662_mux_enum_put,
10643 },
10644 { } /* end */
10645};
10646
10647static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10648 {
10649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10650 .name = "Channel Mode",
10651 .info = alc_ch_mode_info,
10652 .get = alc_ch_mode_get,
10653 .put = alc_ch_mode_put,
10654 },
10655 { } /* end */
10656};
10657
10658static struct hda_verb alc662_init_verbs[] = {
10659 /* ADC: mute amp left and right */
10660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10661 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10662 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10663
10664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10669
10670 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10671 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10672 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10675 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10676
10677 /* Front Pin: output 0 (0x0c) */
10678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10680
10681 /* Rear Pin: output 1 (0x0d) */
10682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10684
10685 /* CLFE Pin: output 2 (0x0e) */
10686 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10687 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10688
10689 /* Mic (rear) pin: input vref at 80% */
10690 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10692 /* Front Mic pin: input vref at 80% */
10693 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10694 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10695 /* Line In pin: input */
10696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10698 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10699 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10700 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10701 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10702 /* CD pin widget for input */
10703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10704
10705 /* FIXME: use matrix-type input source selection */
10706 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10707 /* Input mixer */
10708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10712 { }
10713};
10714
10715static struct hda_verb alc662_sue_init_verbs[] = {
10716 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10717 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10718 {}
10719};
10720
10721/*
10722 * generic initialization of ADC, input mixers and output mixers
10723 */
10724static struct hda_verb alc662_auto_init_verbs[] = {
10725 /*
10726 * Unmute ADC and set the default input to mic-in
10727 */
10728 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10730
10731 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10732 * mixer widget
10733 * Note: PASD motherboards uses the Line In 2 as the input for front
10734 * panel mic (mic 2)
10735 */
10736 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10742
10743 /*
10744 * Set up output mixers (0x0c - 0x0f)
10745 */
10746 /* set vol=0 to output mixers */
10747 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10748 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10749 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10750
10751 /* set up input amps for analog loopback */
10752 /* Amp Indices: DAC = 0, mixer = 1 */
10753 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10754 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10755 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10759
10760
10761 /* FIXME: use matrix-type input source selection */
10762 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10763 /* Input mixer */
10764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10767 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10769
10770 { }
10771};
10772
10773/* capture mixer elements */
10774static struct snd_kcontrol_new alc662_capture_mixer[] = {
10775 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10776 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10777 {
10778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10779 /* The multiple "Capture Source" controls confuse alsamixer
10780 * So call somewhat different..
10781 * FIXME: the controls appear in the "playback" view!
10782 */
10783 /* .name = "Capture Source", */
10784 .name = "Input Source",
10785 .count = 1,
10786 .info = alc882_mux_enum_info,
10787 .get = alc882_mux_enum_get,
10788 .put = alc882_mux_enum_put,
10789 },
10790 { } /* end */
10791};
10792
10793static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10794{
10795 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010796 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010797
10798 present = snd_hda_codec_read(codec, 0x14, 0,
10799 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010800 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010801 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010802 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010803 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010804 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010805}
10806
10807static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10808{
10809 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010810 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010811
10812 present = snd_hda_codec_read(codec, 0x1b, 0,
10813 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010814 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010815 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010816 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010817 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010819 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010820 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010821 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010822 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010823}
10824
10825static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10826 unsigned int res)
10827{
10828 if ((res >> 26) == ALC880_HP_EVENT)
10829 alc662_lenovo_101e_all_automute(codec);
10830 if ((res >> 26) == ALC880_FRONT_EVENT)
10831 alc662_lenovo_101e_ispeaker_automute(codec);
10832}
10833
10834
10835/* pcm configuration: identiacal with ALC880 */
10836#define alc662_pcm_analog_playback alc880_pcm_analog_playback
10837#define alc662_pcm_analog_capture alc880_pcm_analog_capture
10838#define alc662_pcm_digital_playback alc880_pcm_digital_playback
10839#define alc662_pcm_digital_capture alc880_pcm_digital_capture
10840
10841/*
10842 * configuration and preset
10843 */
10844static const char *alc662_models[ALC662_MODEL_LAST] = {
10845 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10846 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10847 [ALC662_3ST_6ch] = "3stack-6ch",
10848 [ALC662_5ST_DIG] = "6stack-dig",
10849 [ALC662_LENOVO_101E] = "lenovo-101e",
10850 [ALC662_AUTO] = "auto",
10851};
10852
10853static struct snd_pci_quirk alc662_cfg_tbl[] = {
10854 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10855 {}
10856};
10857
10858static struct alc_config_preset alc662_presets[] = {
10859 [ALC662_3ST_2ch_DIG] = {
10860 .mixers = { alc662_3ST_2ch_mixer },
10861 .init_verbs = { alc662_init_verbs },
10862 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10863 .dac_nids = alc662_dac_nids,
10864 .dig_out_nid = ALC662_DIGOUT_NID,
10865 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10866 .adc_nids = alc662_adc_nids,
10867 .dig_in_nid = ALC662_DIGIN_NID,
10868 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10869 .channel_mode = alc662_3ST_2ch_modes,
10870 .input_mux = &alc662_capture_source,
10871 },
10872 [ALC662_3ST_6ch_DIG] = {
10873 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10874 .init_verbs = { alc662_init_verbs },
10875 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10876 .dac_nids = alc662_dac_nids,
10877 .dig_out_nid = ALC662_DIGOUT_NID,
10878 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10879 .adc_nids = alc662_adc_nids,
10880 .dig_in_nid = ALC662_DIGIN_NID,
10881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10882 .channel_mode = alc662_3ST_6ch_modes,
10883 .need_dac_fix = 1,
10884 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010885 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010886 [ALC662_3ST_6ch] = {
10887 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10888 .init_verbs = { alc662_init_verbs },
10889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10890 .dac_nids = alc662_dac_nids,
10891 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10892 .adc_nids = alc662_adc_nids,
10893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10894 .channel_mode = alc662_3ST_6ch_modes,
10895 .need_dac_fix = 1,
10896 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010897 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010898 [ALC662_5ST_DIG] = {
10899 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10900 .init_verbs = { alc662_init_verbs },
10901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10902 .dac_nids = alc662_dac_nids,
10903 .dig_out_nid = ALC662_DIGOUT_NID,
10904 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10905 .adc_nids = alc662_adc_nids,
10906 .dig_in_nid = ALC662_DIGIN_NID,
10907 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10908 .channel_mode = alc662_5stack_modes,
10909 .input_mux = &alc662_capture_source,
10910 },
10911 [ALC662_LENOVO_101E] = {
10912 .mixers = { alc662_lenovo_101e_mixer },
10913 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10914 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10915 .dac_nids = alc662_dac_nids,
10916 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10917 .adc_nids = alc662_adc_nids,
10918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10919 .channel_mode = alc662_3ST_2ch_modes,
10920 .input_mux = &alc662_lenovo_101e_capture_source,
10921 .unsol_event = alc662_lenovo_101e_unsol_event,
10922 .init_hook = alc662_lenovo_101e_all_automute,
10923 },
10924
10925};
10926
10927
10928/*
10929 * BIOS auto configuration
10930 */
10931
10932/* add playback controls from the parsed DAC table */
10933static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10934 const struct auto_pin_cfg *cfg)
10935{
10936 char name[32];
10937 static const char *chname[4] = {
10938 "Front", "Surround", NULL /*CLFE*/, "Side"
10939 };
10940 hda_nid_t nid;
10941 int i, err;
10942
10943 for (i = 0; i < cfg->line_outs; i++) {
10944 if (!spec->multiout.dac_nids[i])
10945 continue;
10946 nid = alc880_idx_to_dac(i);
10947 if (i == 2) {
10948 /* Center/LFE */
10949 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10950 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010951 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10952 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010953 if (err < 0)
10954 return err;
10955 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10956 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010957 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10958 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010959 if (err < 0)
10960 return err;
10961 err = add_control(spec, ALC_CTL_BIND_MUTE,
10962 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010963 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
10964 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010965 if (err < 0)
10966 return err;
10967 err = add_control(spec, ALC_CTL_BIND_MUTE,
10968 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010969 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
10970 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010971 if (err < 0)
10972 return err;
10973 } else {
10974 sprintf(name, "%s Playback Volume", chname[i]);
10975 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010976 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10977 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010978 if (err < 0)
10979 return err;
10980 sprintf(name, "%s Playback Switch", chname[i]);
10981 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010982 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
10983 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010984 if (err < 0)
10985 return err;
10986 }
10987 }
10988 return 0;
10989}
10990
10991/* add playback controls for speaker and HP outputs */
10992static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
10993 const char *pfx)
10994{
10995 hda_nid_t nid;
10996 int err;
10997 char name[32];
10998
10999 if (!pin)
11000 return 0;
11001
11002 if (alc880_is_fixed_pin(pin)) {
11003 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11004 /* printk("DAC nid=%x\n",nid); */
11005 /* specify the DAC as the extra output */
11006 if (!spec->multiout.hp_nid)
11007 spec->multiout.hp_nid = nid;
11008 else
11009 spec->multiout.extra_out_nid[0] = nid;
11010 /* control HP volume/switch on the output mixer amp */
11011 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11012 sprintf(name, "%s Playback Volume", pfx);
11013 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11014 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11015 if (err < 0)
11016 return err;
11017 sprintf(name, "%s Playback Switch", pfx);
11018 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11019 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11020 if (err < 0)
11021 return err;
11022 } else if (alc880_is_multi_pin(pin)) {
11023 /* set manual connection */
11024 /* we have only a switch on HP-out PIN */
11025 sprintf(name, "%s Playback Switch", pfx);
11026 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11027 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11028 if (err < 0)
11029 return err;
11030 }
11031 return 0;
11032}
11033
11034/* create playback/capture controls for input pins */
11035static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11036 const struct auto_pin_cfg *cfg)
11037{
11038 struct hda_input_mux *imux = &spec->private_imux;
11039 int i, err, idx;
11040
11041 for (i = 0; i < AUTO_PIN_LAST; i++) {
11042 if (alc880_is_input_pin(cfg->input_pins[i])) {
11043 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11044 err = new_analog_input(spec, cfg->input_pins[i],
11045 auto_pin_cfg_labels[i],
11046 idx, 0x0b);
11047 if (err < 0)
11048 return err;
11049 imux->items[imux->num_items].label =
11050 auto_pin_cfg_labels[i];
11051 imux->items[imux->num_items].index =
11052 alc880_input_pin_idx(cfg->input_pins[i]);
11053 imux->num_items++;
11054 }
11055 }
11056 return 0;
11057}
11058
11059static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11060 hda_nid_t nid, int pin_type,
11061 int dac_idx)
11062{
11063 /* set as output */
11064 snd_hda_codec_write(codec, nid, 0,
11065 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11066 snd_hda_codec_write(codec, nid, 0,
11067 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11068 /* need the manual connection? */
11069 if (alc880_is_multi_pin(nid)) {
11070 struct alc_spec *spec = codec->spec;
11071 int idx = alc880_multi_pin_idx(nid);
11072 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11073 AC_VERB_SET_CONNECT_SEL,
11074 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11075 }
11076}
11077
11078static void alc662_auto_init_multi_out(struct hda_codec *codec)
11079{
11080 struct alc_spec *spec = codec->spec;
11081 int i;
11082
11083 for (i = 0; i <= HDA_SIDE; i++) {
11084 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011085 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011086 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011087 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011088 i);
11089 }
11090}
11091
11092static void alc662_auto_init_hp_out(struct hda_codec *codec)
11093{
11094 struct alc_spec *spec = codec->spec;
11095 hda_nid_t pin;
11096
11097 pin = spec->autocfg.hp_pins[0];
11098 if (pin) /* connect to front */
11099 /* use dac 0 */
11100 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11101}
11102
11103#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11104#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11105
11106static void alc662_auto_init_analog_input(struct hda_codec *codec)
11107{
11108 struct alc_spec *spec = codec->spec;
11109 int i;
11110
11111 for (i = 0; i < AUTO_PIN_LAST; i++) {
11112 hda_nid_t nid = spec->autocfg.input_pins[i];
11113 if (alc662_is_input_pin(nid)) {
11114 snd_hda_codec_write(codec, nid, 0,
11115 AC_VERB_SET_PIN_WIDGET_CONTROL,
11116 (i <= AUTO_PIN_FRONT_MIC ?
11117 PIN_VREF80 : PIN_IN));
11118 if (nid != ALC662_PIN_CD_NID)
11119 snd_hda_codec_write(codec, nid, 0,
11120 AC_VERB_SET_AMP_GAIN_MUTE,
11121 AMP_OUT_MUTE);
11122 }
11123 }
11124}
11125
11126static int alc662_parse_auto_config(struct hda_codec *codec)
11127{
11128 struct alc_spec *spec = codec->spec;
11129 int err;
11130 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11131
11132 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11133 alc662_ignore);
11134 if (err < 0)
11135 return err;
11136 if (!spec->autocfg.line_outs)
11137 return 0; /* can't find valid BIOS pin config */
11138
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011139 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11140 if (err < 0)
11141 return err;
11142 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11143 if (err < 0)
11144 return err;
11145 err = alc662_auto_create_extra_out(spec,
11146 spec->autocfg.speaker_pins[0],
11147 "Speaker");
11148 if (err < 0)
11149 return err;
11150 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11151 "Headphone");
11152 if (err < 0)
11153 return err;
11154 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11155 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011156 return err;
11157
11158 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11159
11160 if (spec->autocfg.dig_out_pin)
11161 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11162
11163 if (spec->kctl_alloc)
11164 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11165
11166 spec->num_mux_defs = 1;
11167 spec->input_mux = &spec->private_imux;
11168
11169 if (err < 0)
11170 return err;
11171 else if (err > 0)
11172 /* hack - override the init verbs */
11173 spec->init_verbs[0] = alc662_auto_init_verbs;
11174 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11175 spec->num_mixers++;
11176 return err;
11177}
11178
11179/* additional initialization for auto-configuration model */
11180static void alc662_auto_init(struct hda_codec *codec)
11181{
11182 alc662_auto_init_multi_out(codec);
11183 alc662_auto_init_hp_out(codec);
11184 alc662_auto_init_analog_input(codec);
11185}
11186
11187static int patch_alc662(struct hda_codec *codec)
11188{
11189 struct alc_spec *spec;
11190 int err, board_config;
11191
11192 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11193 if (!spec)
11194 return -ENOMEM;
11195
11196 codec->spec = spec;
11197
11198 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11199 alc662_models,
11200 alc662_cfg_tbl);
11201 if (board_config < 0) {
11202 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11203 "trying auto-probe from BIOS...\n");
11204 board_config = ALC662_AUTO;
11205 }
11206
11207 if (board_config == ALC662_AUTO) {
11208 /* automatic parse from the BIOS config */
11209 err = alc662_parse_auto_config(codec);
11210 if (err < 0) {
11211 alc_free(codec);
11212 return err;
11213 } else if (err) {
11214 printk(KERN_INFO
11215 "hda_codec: Cannot set up configuration "
11216 "from BIOS. Using base mode...\n");
11217 board_config = ALC662_3ST_2ch_DIG;
11218 }
11219 }
11220
11221 if (board_config != ALC662_AUTO)
11222 setup_preset(spec, &alc662_presets[board_config]);
11223
11224 spec->stream_name_analog = "ALC662 Analog";
11225 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11226 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11227
11228 spec->stream_name_digital = "ALC662 Digital";
11229 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11230 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11231
11232 if (!spec->adc_nids && spec->input_mux) {
11233 spec->adc_nids = alc662_adc_nids;
11234 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11235 }
11236
11237 codec->patch_ops = alc_patch_ops;
11238 if (board_config == ALC662_AUTO)
11239 spec->init_hook = alc662_auto_init;
11240
11241 return 0;
11242}
11243
11244/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011245 * patch entries
11246 */
11247struct hda_codec_preset snd_hda_preset_realtek[] = {
11248 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011249 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011250 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011251 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011252 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011253 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11254 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11255 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011256 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11257 .patch = patch_alc883 },
11258 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11259 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011260 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011261 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011262 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011264 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011265 {} /* terminator */
11266};