blob: b47934f87f8c73c5e04561c9288adf12c804716f [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 Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200105 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200106 ALC268_ACER,
Kailang Yanga361d842007-06-05 12:30:55 +0200107 ALC268_AUTO,
108 ALC268_MODEL_LAST /* last tag */
109};
110
Kailang Yangdf694da2005-12-05 19:42:22 +0100111/* ALC861 models */
112enum {
113 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200114 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100115 ALC861_3ST_DIG,
116 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200117 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200118 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200119 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100120 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100121 ALC861_AUTO,
122 ALC861_MODEL_LAST,
123};
124
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100125/* ALC861-VD models */
126enum {
127 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200128 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100129 ALC861VD_3ST,
130 ALC861VD_3ST_DIG,
131 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200132 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200133 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200134 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100135 ALC861VD_AUTO,
136 ALC861VD_MODEL_LAST,
137};
138
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200139/* ALC662 models */
140enum {
141 ALC662_3ST_2ch_DIG,
142 ALC662_3ST_6ch_DIG,
143 ALC662_3ST_6ch,
144 ALC662_5ST_DIG,
145 ALC662_LENOVO_101E,
146 ALC662_AUTO,
147 ALC662_MODEL_LAST,
148};
149
Kailang Yangdf694da2005-12-05 19:42:22 +0100150/* ALC882 models */
151enum {
152 ALC882_3ST_DIG,
153 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200154 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200155 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_TARGA,
157 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100158 ALC885_MACPRO,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200159 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200160 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100161 ALC882_MODEL_LAST,
162};
163
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200164/* ALC883 models */
165enum {
166 ALC883_3ST_2ch_DIG,
167 ALC883_3ST_6ch_DIG,
168 ALC883_3ST_6ch,
169 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200170 ALC883_TARGA_DIG,
171 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200172 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200173 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200174 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200175 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100176 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200177 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200178 ALC883_LENOVO_NB0763,
179 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200180 ALC888_6ST_HP,
181 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200182 ALC883_AUTO,
183 ALC883_MODEL_LAST,
184};
185
Kailang Yangdf694da2005-12-05 19:42:22 +0100186/* for GPIO Poll */
187#define GPIO_MASK 0x03
188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189struct alc_spec {
190 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100191 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 unsigned int num_mixers;
193
Kailang Yangdf694da2005-12-05 19:42:22 +0100194 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200195 * don't forget NULL
196 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200197 */
198 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Takashi Iwai16ded522005-06-10 19:58:24 +0200200 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 struct hda_pcm_stream *stream_analog_playback;
202 struct hda_pcm_stream *stream_analog_capture;
203
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200204 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 struct hda_pcm_stream *stream_digital_playback;
206 struct hda_pcm_stream *stream_digital_capture;
207
208 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200209 struct hda_multi_out multiout; /* playback set-up
210 * max_channels, dacs must be set
211 * dig_out_nid and hp_nid are optional
212 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214 /* capture */
215 unsigned int num_adc_nids;
216 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200217 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200220 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 const struct hda_input_mux *input_mux;
222 unsigned int cur_mux[3];
223
224 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100225 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200227 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100230 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200231
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200232 /* dynamic controls, init_verbs and input_mux */
233 struct auto_pin_cfg autocfg;
234 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100235 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200236 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100237 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100238
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100239 /* hooks */
240 void (*init_hook)(struct hda_codec *codec);
241 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
242
Takashi Iwai834be882006-03-01 14:16:17 +0100243 /* for pin sensing */
244 unsigned int sense_updated: 1;
245 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200246
247#ifdef CONFIG_SND_HDA_POWER_SAVE
248 struct hda_loopback_check loopback;
249#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100250};
251
252/*
253 * configuration template - to be copied to the spec instance
254 */
255struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256 struct snd_kcontrol_new *mixers[5]; /* should be identical size
257 * with spec
258 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100259 const struct hda_verb *init_verbs[5];
260 unsigned int num_dacs;
261 hda_nid_t *dac_nids;
262 hda_nid_t dig_out_nid; /* optional */
263 hda_nid_t hp_nid; /* optional */
264 unsigned int num_adc_nids;
265 hda_nid_t *adc_nids;
266 hda_nid_t dig_in_nid;
267 unsigned int num_channel_mode;
268 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200269 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200270 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100271 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100272 void (*unsol_event)(struct hda_codec *, unsigned int);
273 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200274#ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_amp_list *loopbacks;
276#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277};
278
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280/*
281 * input MUX handling
282 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200283static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285{
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200288 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
289 if (mux_idx >= spec->num_mux_defs)
290 mux_idx = 0;
291 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292}
293
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200294static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
300
301 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
302 return 0;
303}
304
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200305static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct alc_spec *spec = codec->spec;
310 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200311 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
312 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200313 spec->adc_nids[adc_idx],
314 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
316
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200317
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318/*
319 * channel mode setting
320 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200321static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100326 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
327 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100335 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200336 spec->num_channel_mode,
337 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200340static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342{
343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
344 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200345 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
346 spec->num_channel_mode,
347 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200348 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200349 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
350 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351}
352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100354 * Control the mode of pin widget settings via the mixer. "pc" is used
355 * instead of "%" to avoid consequences of accidently treating the % as
356 * being part of a format specifier. Maximum allowed length of a value is
357 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100358 *
359 * Note: some retasking pin complexes seem to ignore requests for input
360 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
361 * are requested. Therefore order this list so that this behaviour will not
362 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
364 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200365 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100366static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100367 "Mic 50pc bias", "Mic 80pc bias",
368 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369};
370static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100371 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372};
373/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374 * in the pin being assumed to be exclusively an input or an output pin. In
375 * addition, "input" pins may or may not process the mic bias option
376 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
377 * accept requests for bias as of chip versions up to March 2006) and/or
378 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100379 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380#define ALC_PIN_DIR_IN 0x00
381#define ALC_PIN_DIR_OUT 0x01
382#define ALC_PIN_DIR_INOUT 0x02
383#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
384#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100385
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200386/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100387 * For each direction the minimum and maximum values are given.
388 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100390 { 0, 2 }, /* ALC_PIN_DIR_IN */
391 { 3, 4 }, /* ALC_PIN_DIR_OUT */
392 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200393 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
394 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100395};
396#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
397#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
398#define alc_pin_mode_n_items(_dir) \
399 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
400
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200401static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200403{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404 unsigned int item_num = uinfo->value.enumerated.item;
405 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
406
407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
410
411 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
412 item_num = alc_pin_mode_min(dir);
413 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200414 return 0;
415}
416
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200419{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200424 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200425 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
426 AC_VERB_GET_PIN_WIDGET_CONTROL,
427 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200428
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429 /* Find enumerated value for current pinctl setting */
430 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200431 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 return 0;
435}
436
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200437static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
438 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439{
440 signed int change;
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 hda_nid_t nid = kcontrol->private_value & 0xffff;
443 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
444 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
446 AC_VERB_GET_PIN_WIDGET_CONTROL,
447 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200449 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100450 val = alc_pin_mode_min(dir);
451
452 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100453 if (change) {
454 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200455 snd_hda_codec_write_cache(codec, nid, 0,
456 AC_VERB_SET_PIN_WIDGET_CONTROL,
457 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100458
459 /* Also enable the retasking pin's input/output as required
460 * for the requested pin mode. Enum values of 2 or less are
461 * input modes.
462 *
463 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200464 * reduces noise slightly (particularly on input) so we'll
465 * do it. However, having both input and output buffers
466 * enabled simultaneously doesn't seem to be problematic if
467 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100468 */
469 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200470 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
471 HDA_AMP_MUTE, HDA_AMP_MUTE);
472 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
473 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100474 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200475 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
476 HDA_AMP_MUTE, HDA_AMP_MUTE);
477 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
478 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100479 }
480 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200481 return change;
482}
483
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200485 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100486 .info = alc_pin_mode_info, \
487 .get = alc_pin_mode_get, \
488 .put = alc_pin_mode_put, \
489 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100490
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100491/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
492 * together using a mask with more than one bit set. This control is
493 * currently used only by the ALC260 test model. At this stage they are not
494 * needed for any "production" models.
495 */
496#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200497#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200498
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100501{
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 hda_nid_t nid = kcontrol->private_value & 0xffff;
504 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
505 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200506 unsigned int val = snd_hda_codec_read(codec, nid, 0,
507 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100508
509 *valp = (val & mask) != 0;
510 return 0;
511}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200512static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
513 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100514{
515 signed int change;
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 hda_nid_t nid = kcontrol->private_value & 0xffff;
518 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
519 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
521 AC_VERB_GET_GPIO_DATA,
522 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100523
524 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
526 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100527 gpio_data &= ~mask;
528 else
529 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200530 snd_hda_codec_write_cache(codec, nid, 0,
531 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100532
533 return change;
534}
535#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
536 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
537 .info = alc_gpio_data_info, \
538 .get = alc_gpio_data_get, \
539 .put = alc_gpio_data_put, \
540 .private_value = nid | (mask<<16) }
541#endif /* CONFIG_SND_DEBUG */
542
Jonathan Woithe92621f12006-02-28 11:47:47 +0100543/* A switch control to allow the enabling of the digital IO pins on the
544 * ALC260. This is incredibly simplistic; the intention of this control is
545 * to provide something in the test model allowing digital outputs to be
546 * identified if present. If models are found which can utilise these
547 * outputs a more complete mixer control can be devised for those models if
548 * necessary.
549 */
550#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200551#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200552
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100555{
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
558 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
559 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560 unsigned int val = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100562
563 *valp = (val & mask) != 0;
564 return 0;
565}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100568{
569 signed int change;
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 hda_nid_t nid = kcontrol->private_value & 0xffff;
572 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
573 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
575 AC_VERB_GET_DIGI_CONVERT,
576 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100577
578 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100580 if (val==0)
581 ctrl_data &= ~mask;
582 else
583 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200584 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
585 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100586
587 return change;
588}
589#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
590 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
591 .info = alc_spdif_ctrl_info, \
592 .get = alc_spdif_ctrl_get, \
593 .put = alc_spdif_ctrl_put, \
594 .private_value = nid | (mask<<16) }
595#endif /* CONFIG_SND_DEBUG */
596
Kailang Yangdf694da2005-12-05 19:42:22 +0100597/*
598 * set up from the preset table
599 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200600static void setup_preset(struct alc_spec *spec,
601 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100602{
603 int i;
604
605 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
606 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
608 i++)
609 spec->init_verbs[spec->num_init_verbs++] =
610 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100611
612 spec->channel_mode = preset->channel_mode;
613 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200614 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100615
616 spec->multiout.max_channels = spec->channel_mode[0].channels;
617
618 spec->multiout.num_dacs = preset->num_dacs;
619 spec->multiout.dac_nids = preset->dac_nids;
620 spec->multiout.dig_out_nid = preset->dig_out_nid;
621 spec->multiout.hp_nid = preset->hp_nid;
622
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200623 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200624 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200625 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100626 spec->input_mux = preset->input_mux;
627
628 spec->num_adc_nids = preset->num_adc_nids;
629 spec->adc_nids = preset->adc_nids;
630 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100631
632 spec->unsol_event = preset->unsol_event;
633 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200634#ifdef CONFIG_SND_HDA_POWER_SAVE
635 spec->loopback.amplist = preset->loopbacks;
636#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100637}
638
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200639/* Enable GPIO mask and set output */
640static struct hda_verb alc_gpio1_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
644 { }
645};
646
647static struct hda_verb alc_gpio2_init_verbs[] = {
648 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
650 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
651 { }
652};
653
Kailang Yangbdd148a2007-05-08 15:19:08 +0200654static struct hda_verb alc_gpio3_init_verbs[] = {
655 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
657 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
658 { }
659};
660
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200661/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
662 * 31 ~ 16 : Manufacture ID
663 * 15 ~ 8 : SKU ID
664 * 7 ~ 0 : Assembly ID
665 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
666 */
667static void alc_subsystem_id(struct hda_codec *codec,
668 unsigned int porta, unsigned int porte,
669 unsigned int portd)
670{
671 unsigned int ass, tmp;
672
673 ass = codec->subsystem_id;
674 if (!(ass & 1))
675 return;
676
677 /* Override */
678 tmp = (ass & 0x38) >> 3; /* external Amp control */
679 switch (tmp) {
680 case 1:
681 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
682 break;
683 case 3:
684 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
685 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200686 case 7:
687 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
688 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200689 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200690 switch (codec->vendor_id) {
691 case 0x10ec0862:
692 case 0x10ec0660:
693 case 0x10ec0662:
694 case 0x10ec0267:
695 case 0x10ec0268:
696 snd_hda_codec_write(codec, 0x14, 0,
697 AC_VERB_SET_EAPD_BTLENABLE, 2);
698 snd_hda_codec_write(codec, 0x15, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 return;
701 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200702 case 6:
703 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
704 hda_nid_t port = 0;
705 tmp = (ass & 0x1800) >> 11;
706 switch (tmp) {
707 case 0: port = porta; break;
708 case 1: port = porte; break;
709 case 2: port = portd; break;
710 }
711 if (port)
712 snd_hda_codec_write(codec, port, 0,
713 AC_VERB_SET_EAPD_BTLENABLE,
714 2);
715 }
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
717 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
718 (tmp == 5 ? 0x3040 : 0x3050));
719 break;
720 }
721}
722
Takashi Iwai41e41f12005-06-08 14:48:49 +0200723/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200724 * Fix-up pin default configurations
725 */
726
727struct alc_pincfg {
728 hda_nid_t nid;
729 u32 val;
730};
731
732static void alc_fix_pincfg(struct hda_codec *codec,
733 const struct snd_pci_quirk *quirk,
734 const struct alc_pincfg **pinfix)
735{
736 const struct alc_pincfg *cfg;
737
738 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
739 if (!quirk)
740 return;
741
742 cfg = pinfix[quirk->value];
743 for (; cfg->nid; cfg++) {
744 int i;
745 u32 val = cfg->val;
746 for (i = 0; i < 4; i++) {
747 snd_hda_codec_write(codec, cfg->nid, 0,
748 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
749 val & 0xff);
750 val >>= 8;
751 }
752 }
753}
754
755/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200756 * ALC880 3-stack model
757 *
758 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200759 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
760 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 */
762
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200763static hda_nid_t alc880_dac_nids[4] = {
764 /* front, rear, clfe, rear_surr */
765 0x02, 0x05, 0x04, 0x03
766};
767
768static hda_nid_t alc880_adc_nids[3] = {
769 /* ADC0-2 */
770 0x07, 0x08, 0x09,
771};
772
773/* The datasheet says the node 0x07 is connected from inputs,
774 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100775 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200777static hda_nid_t alc880_adc_nids_alt[2] = {
778 /* ADC1-2 */
779 0x08, 0x09,
780};
781
782#define ALC880_DIGOUT_NID 0x06
783#define ALC880_DIGIN_NID 0x0a
784
785static struct hda_input_mux alc880_capture_source = {
786 .num_items = 4,
787 .items = {
788 { "Mic", 0x0 },
789 { "Front Mic", 0x3 },
790 { "Line", 0x2 },
791 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200793};
794
795/* channel source setting (2/6 channel selection for 3-stack) */
796/* 2ch mode */
797static struct hda_verb alc880_threestack_ch2_init[] = {
798 /* set line-in to input, mute it */
799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
801 /* set mic-in to input vref 80%, mute it */
802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 { } /* end */
805};
806
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200807/* 6ch mode */
808static struct hda_verb alc880_threestack_ch6_init[] = {
809 /* set line-in to output, unmute it */
810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
812 /* set mic-in to output, unmute it */
813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
815 { } /* end */
816};
817
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100818static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200819 { 2, alc880_threestack_ch2_init },
820 { 6, alc880_threestack_ch6_init },
821};
822
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100823static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100825 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100827 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
838 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
840 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
841 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200843 {
844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
845 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100846 .info = alc_ch_mode_info,
847 .get = alc_ch_mode_get,
848 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200849 },
850 { } /* end */
851};
852
853/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100854static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200855 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
856 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
861 {
862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
863 /* The multiple "Capture Source" controls confuse alsamixer
864 * So call somewhat different..
865 * FIXME: the controls appear in the "playback" view!
866 */
867 /* .name = "Capture Source", */
868 .name = "Input Source",
869 .count = 3,
870 .info = alc_mux_enum_info,
871 .get = alc_mux_enum_get,
872 .put = alc_mux_enum_put,
873 },
874 { } /* end */
875};
876
877/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100878static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
881 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
882 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 {
884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
885 /* The multiple "Capture Source" controls confuse alsamixer
886 * So call somewhat different..
887 * FIXME: the controls appear in the "playback" view!
888 */
889 /* .name = "Capture Source", */
890 .name = "Input Source",
891 .count = 2,
892 .info = alc_mux_enum_info,
893 .get = alc_mux_enum_get,
894 .put = alc_mux_enum_put,
895 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 { } /* end */
897};
898
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200899
900
901/*
902 * ALC880 5-stack model
903 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200904 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
905 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200906 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
907 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
908 */
909
910/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100911static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200912 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100913 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 { } /* end */
915};
916
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200917/* channel source setting (6/8 channel selection for 5-stack) */
918/* 6ch mode */
919static struct hda_verb alc880_fivestack_ch6_init[] = {
920 /* set line-in to input, mute it */
921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200923 { } /* end */
924};
925
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200926/* 8ch mode */
927static struct hda_verb alc880_fivestack_ch8_init[] = {
928 /* set line-in to output, unmute it */
929 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
930 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
931 { } /* end */
932};
933
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100934static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200935 { 6, alc880_fivestack_ch6_init },
936 { 8, alc880_fivestack_ch8_init },
937};
938
939
940/*
941 * ALC880 6-stack model
942 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200943 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
944 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200945 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
946 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
947 */
948
949static hda_nid_t alc880_6st_dac_nids[4] = {
950 /* front, rear, clfe, rear_surr */
951 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200952};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200953
954static struct hda_input_mux alc880_6stack_capture_source = {
955 .num_items = 4,
956 .items = {
957 { "Mic", 0x0 },
958 { "Front Mic", 0x1 },
959 { "Line", 0x2 },
960 { "CD", 0x4 },
961 },
962};
963
964/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100965static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200966 { 8, NULL },
967};
968
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100969static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200970 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200972 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100973 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200974 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
975 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100976 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
977 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200978 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100979 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200990 {
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
992 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100993 .info = alc_ch_mode_info,
994 .get = alc_ch_mode_get,
995 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200996 },
997 { } /* end */
998};
999
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001000
1001/*
1002 * ALC880 W810 model
1003 *
1004 * W810 has rear IO for:
1005 * Front (DAC 02)
1006 * Surround (DAC 03)
1007 * Center/LFE (DAC 04)
1008 * Digital out (06)
1009 *
1010 * The system also has a pair of internal speakers, and a headphone jack.
1011 * These are both connected to Line2 on the codec, hence to DAC 02.
1012 *
1013 * There is a variable resistor to control the speaker or headphone
1014 * volume. This is a hardware-only device without a software API.
1015 *
1016 * Plugging headphones in will disable the internal speakers. This is
1017 * implemented in hardware, not via the driver using jack sense. In
1018 * a similar fashion, plugging into the rear socket marked "front" will
1019 * disable both the speakers and headphones.
1020 *
1021 * For input, there's a microphone jack, and an "audio in" jack.
1022 * These may not do anything useful with this driver yet, because I
1023 * haven't setup any initialization verbs for these yet...
1024 */
1025
1026static hda_nid_t alc880_w810_dac_nids[3] = {
1027 /* front, rear/surround, clfe */
1028 0x02, 0x03, 0x04
1029};
1030
1031/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001032static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001033 { 6, NULL }
1034};
1035
1036/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001037static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001041 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1047 { } /* end */
1048};
1049
1050
1051/*
1052 * Z710V model
1053 *
1054 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001055 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1056 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001057 */
1058
1059static hda_nid_t alc880_z71v_dac_nids[1] = {
1060 0x02
1061};
1062#define ALC880_Z71V_HP_DAC 0x03
1063
1064/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001065static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001066 { 2, NULL }
1067};
1068
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001069static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001073 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1078 { } /* end */
1079};
1080
1081
1082/* FIXME! */
1083/*
1084 * ALC880 F1734 model
1085 *
1086 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1087 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1088 */
1089
1090static hda_nid_t alc880_f1734_dac_nids[1] = {
1091 0x03
1092};
1093#define ALC880_F1734_HP_DAC 0x02
1094
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001095static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001096 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001097 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001098 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001099 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001104 { } /* end */
1105};
1106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001107
1108/* FIXME! */
1109/*
1110 * ALC880 ASUS model
1111 *
1112 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1113 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1114 * Mic = 0x18, Line = 0x1a
1115 */
1116
1117#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1118#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1119
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001120static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001122 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001123 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001124 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001125 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001135 {
1136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1137 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001138 .info = alc_ch_mode_info,
1139 .get = alc_ch_mode_get,
1140 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001141 },
1142 { } /* end */
1143};
1144
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001145/* FIXME! */
1146/*
1147 * ALC880 ASUS W1V model
1148 *
1149 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1150 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1151 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1152 */
1153
1154/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001155static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001156 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1157 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001158 { } /* end */
1159};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001160
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001161/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001162static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001163 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1164 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1165 { } /* end */
1166};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001167
Kailang Yangdf694da2005-12-05 19:42:22 +01001168/* TCL S700 */
1169static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1171 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1179 {
1180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1181 /* The multiple "Capture Source" controls confuse alsamixer
1182 * So call somewhat different..
1183 * FIXME: the controls appear in the "playback" view!
1184 */
1185 /* .name = "Capture Source", */
1186 .name = "Input Source",
1187 .count = 1,
1188 .info = alc_mux_enum_info,
1189 .get = alc_mux_enum_get,
1190 .put = alc_mux_enum_put,
1191 },
1192 { } /* end */
1193};
1194
Kailang Yangccc656c2006-10-17 12:32:26 +02001195/* Uniwill */
1196static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1197 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1198 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1213 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1214 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1215 {
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 .name = "Channel Mode",
1218 .info = alc_ch_mode_info,
1219 .get = alc_ch_mode_get,
1220 .put = alc_ch_mode_put,
1221 },
1222 { } /* end */
1223};
1224
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001225static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1233 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1235 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1236 { } /* end */
1237};
1238
Kailang Yangccc656c2006-10-17 12:32:26 +02001239static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1240 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1241 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1242 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1243 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1246 { } /* end */
1247};
1248
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001250 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 */
1252static int alc_build_controls(struct hda_codec *codec)
1253{
1254 struct alc_spec *spec = codec->spec;
1255 int err;
1256 int i;
1257
1258 for (i = 0; i < spec->num_mixers; i++) {
1259 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1260 if (err < 0)
1261 return err;
1262 }
1263
1264 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001265 err = snd_hda_create_spdif_out_ctls(codec,
1266 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 if (err < 0)
1268 return err;
1269 }
1270 if (spec->dig_in_nid) {
1271 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1272 if (err < 0)
1273 return err;
1274 }
1275 return 0;
1276}
1277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279/*
1280 * initialize the codec volumes, etc
1281 */
1282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283/*
1284 * generic initialization of ADC, input mixers and output mixers
1285 */
1286static struct hda_verb alc880_volume_init_verbs[] = {
1287 /*
1288 * Unmute ADC0-2 and set the default input to mic-in
1289 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1298 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001299 * Note: PASD motherboards uses the Line In 2 as the input for front
1300 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001302 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001311 /*
1312 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001314 /* set vol=0 to output mixers */
1315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 /* set up input amps for analog loopback */
1320 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329
1330 { }
1331};
1332
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001333/*
1334 * 3-stack pin configuration:
1335 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1336 */
1337static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1338 /*
1339 * preset connection lists of input pins
1340 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1341 */
1342 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1343 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1344 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1345
1346 /*
1347 * Set pin mode and muting
1348 */
1349 /* set front pin widgets 0x14 for output */
1350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1355 /* Mic2 (as headphone out) for HP output */
1356 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 /* Line In pin widget for input */
1359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1361 /* Line2 (as front mic) pin widget for input and vref at 80% */
1362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* CD pin widget for input */
1365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1366
1367 { }
1368};
1369
1370/*
1371 * 5-stack pin configuration:
1372 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1373 * line-in/side = 0x1a, f-mic = 0x1b
1374 */
1375static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1376 /*
1377 * preset connection lists of input pins
1378 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1379 */
1380 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1381 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1382
1383 /*
1384 * Set pin mode and muting
1385 */
1386 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001391 /* unmute pins for output (no gain on this amp) */
1392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001398 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1400 /* Mic2 (as headphone out) for HP output */
1401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001403 /* Line In pin widget for input */
1404 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1406 /* Line2 (as front mic) pin widget for input and vref at 80% */
1407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1408 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1409 /* CD pin widget for input */
1410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411
1412 { }
1413};
1414
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001415/*
1416 * W810 pin configuration:
1417 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1418 */
1419static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 /* hphone/speaker input selector: front DAC */
1421 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429
1430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001431 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 { }
1434};
1435
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001436/*
1437 * Z71V pin configuration:
1438 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1439 */
1440static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001445
Takashi Iwai16ded522005-06-10 19:58:24 +02001446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001449 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001450
1451 { }
1452};
1453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454/*
1455 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001456 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1457 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458 */
1459static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1460 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1461
Takashi Iwai16ded522005-06-10 19:58:24 +02001462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470
Takashi Iwai16ded522005-06-10 19:58:24 +02001471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001481 { }
1482};
Takashi Iwai16ded522005-06-10 19:58:24 +02001483
Kailang Yangccc656c2006-10-17 12:32:26 +02001484/*
1485 * Uniwill pin configuration:
1486 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1487 * line = 0x1a
1488 */
1489static struct hda_verb alc880_uniwill_init_verbs[] = {
1490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1491
1492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506
1507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1514 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1516
1517 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1518 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1519
1520 { }
1521};
1522
1523/*
1524* Uniwill P53
1525* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1526 */
1527static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1528 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1529
1530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542
1543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549
1550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1551 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1552
1553 { }
1554};
1555
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001556static struct hda_verb alc880_beep_init_verbs[] = {
1557 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1558 { }
1559};
1560
Kailang Yangccc656c2006-10-17 12:32:26 +02001561/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001562static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001563{
1564 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001565 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001566
1567 present = snd_hda_codec_read(codec, 0x14, 0,
1568 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001569 bits = present ? HDA_AMP_MUTE : 0;
1570 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1571 HDA_AMP_MUTE, bits);
1572 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1573 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001574}
1575
1576/* auto-toggle front mic */
1577static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1578{
1579 unsigned int present;
1580 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001581
1582 present = snd_hda_codec_read(codec, 0x18, 0,
1583 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001584 bits = present ? HDA_AMP_MUTE : 0;
1585 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001586}
1587
1588static void alc880_uniwill_automute(struct hda_codec *codec)
1589{
1590 alc880_uniwill_hp_automute(codec);
1591 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001592}
1593
1594static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1595 unsigned int res)
1596{
1597 /* Looks like the unsol event is incompatible with the standard
1598 * definition. 4bit tag is placed at 28 bit!
1599 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001600 switch (res >> 28) {
1601 case ALC880_HP_EVENT:
1602 alc880_uniwill_hp_automute(codec);
1603 break;
1604 case ALC880_MIC_EVENT:
1605 alc880_uniwill_mic_automute(codec);
1606 break;
1607 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001608}
1609
1610static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1611{
1612 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001613 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001614
1615 present = snd_hda_codec_read(codec, 0x14, 0,
1616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001617 bits = present ? HDA_AMP_MUTE : 0;
1618 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001619}
1620
1621static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1622{
1623 unsigned int present;
1624
1625 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001626 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1627 present &= HDA_AMP_VOLMASK;
1628 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1629 HDA_AMP_VOLMASK, present);
1630 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1631 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001632}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001633
Kailang Yangccc656c2006-10-17 12:32:26 +02001634static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1635 unsigned int res)
1636{
1637 /* Looks like the unsol event is incompatible with the standard
1638 * definition. 4bit tag is placed at 28 bit!
1639 */
1640 if ((res >> 28) == ALC880_HP_EVENT)
1641 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001642 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001643 alc880_uniwill_p53_dcvol_automute(codec);
1644}
1645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646/* FIXME! */
1647/*
1648 * F1734 pin configuration:
1649 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1650 */
1651static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1652 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1653 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1654 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1656
1657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661
1662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001671
1672 { }
1673};
1674
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675/* FIXME! */
1676/*
1677 * ASUS pin configuration:
1678 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1679 */
1680static struct hda_verb alc880_pin_asus_init_verbs[] = {
1681 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1682 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1683 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1685
1686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694
1695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1704
1705 { }
1706};
1707
1708/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001709#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1710#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711
Kailang Yangdf694da2005-12-05 19:42:22 +01001712/* Clevo m520g init */
1713static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1714 /* headphone output */
1715 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1716 /* line-out */
1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1719 /* Line-in */
1720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 /* CD */
1723 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 /* Mic1 (rear panel) */
1726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1728 /* Mic2 (front panel) */
1729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 /* headphone */
1732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 /* change to EAPD mode */
1735 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1736 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1737
1738 { }
1739};
1740
1741static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001742 /* change to EAPD mode */
1743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1744 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1745
Kailang Yangdf694da2005-12-05 19:42:22 +01001746 /* Headphone output */
1747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1748 /* Front output*/
1749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1750 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1751
1752 /* Line In pin widget for input */
1753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1754 /* CD pin widget for input */
1755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1758
1759 /* change to EAPD mode */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1762
1763 { }
1764};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765
1766/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001767 * LG m1 express dual
1768 *
1769 * Pin assignment:
1770 * Rear Line-In/Out (blue): 0x14
1771 * Build-in Mic-In: 0x15
1772 * Speaker-out: 0x17
1773 * HP-Out (green): 0x1b
1774 * Mic-In/Out (red): 0x19
1775 * SPDIF-Out: 0x1e
1776 */
1777
1778/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1779static hda_nid_t alc880_lg_dac_nids[3] = {
1780 0x05, 0x02, 0x03
1781};
1782
1783/* seems analog CD is not working */
1784static struct hda_input_mux alc880_lg_capture_source = {
1785 .num_items = 3,
1786 .items = {
1787 { "Mic", 0x1 },
1788 { "Line", 0x5 },
1789 { "Internal Mic", 0x6 },
1790 },
1791};
1792
1793/* 2,4,6 channel modes */
1794static struct hda_verb alc880_lg_ch2_init[] = {
1795 /* set line-in and mic-in to input */
1796 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1797 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1798 { }
1799};
1800
1801static struct hda_verb alc880_lg_ch4_init[] = {
1802 /* set line-in to out and mic-in to input */
1803 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1804 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1805 { }
1806};
1807
1808static struct hda_verb alc880_lg_ch6_init[] = {
1809 /* set line-in and mic-in to output */
1810 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1811 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1812 { }
1813};
1814
1815static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1816 { 2, alc880_lg_ch2_init },
1817 { 4, alc880_lg_ch4_init },
1818 { 6, alc880_lg_ch6_init },
1819};
1820
1821static struct snd_kcontrol_new alc880_lg_mixer[] = {
1822 /* FIXME: it's not really "master" but front channels */
1823 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1824 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1836 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1837 {
1838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1839 .name = "Channel Mode",
1840 .info = alc_ch_mode_info,
1841 .get = alc_ch_mode_get,
1842 .put = alc_ch_mode_put,
1843 },
1844 { } /* end */
1845};
1846
1847static struct hda_verb alc880_lg_init_verbs[] = {
1848 /* set capture source to mic-in */
1849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1851 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 /* mute all amp mixer inputs */
1853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001856 /* line-in to input */
1857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1859 /* built-in mic */
1860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 /* speaker-out */
1863 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 /* mic-in to input */
1866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1869 /* HP-out */
1870 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1872 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1873 /* jack sense */
1874 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1875 { }
1876};
1877
1878/* toggle speaker-output according to the hp-jack state */
1879static void alc880_lg_automute(struct hda_codec *codec)
1880{
1881 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001882 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001883
1884 present = snd_hda_codec_read(codec, 0x1b, 0,
1885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001886 bits = present ? HDA_AMP_MUTE : 0;
1887 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1888 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001889}
1890
1891static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1892{
1893 /* Looks like the unsol event is incompatible with the standard
1894 * definition. 4bit tag is placed at 28 bit!
1895 */
1896 if ((res >> 28) == 0x01)
1897 alc880_lg_automute(codec);
1898}
1899
1900/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001901 * LG LW20
1902 *
1903 * Pin assignment:
1904 * Speaker-out: 0x14
1905 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001906 * Built-in Mic-In: 0x19
1907 * Line-In: 0x1b
1908 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001909 * SPDIF-Out: 0x1e
1910 */
1911
Takashi Iwaid6815182006-03-23 16:06:23 +01001912static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001913 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001914 .items = {
1915 { "Mic", 0x0 },
1916 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001917 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001918 },
1919};
1920
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001921#define alc880_lg_lw_modes alc880_threestack_modes
1922
Takashi Iwaid6815182006-03-23 16:06:23 +01001923static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1927 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1928 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1931 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1937 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001938 {
1939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1940 .name = "Channel Mode",
1941 .info = alc_ch_mode_info,
1942 .get = alc_ch_mode_get,
1943 .put = alc_ch_mode_put,
1944 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001945 { } /* end */
1946};
1947
1948static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1950 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1951 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1952
Takashi Iwaid6815182006-03-23 16:06:23 +01001953 /* set capture source to mic-in */
1954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01001958 /* speaker-out */
1959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1961 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 /* mic-in to input */
1965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1967 /* built-in mic */
1968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 /* jack sense */
1971 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1972 { }
1973};
1974
1975/* toggle speaker-output according to the hp-jack state */
1976static void alc880_lg_lw_automute(struct hda_codec *codec)
1977{
1978 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001979 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001980
1981 present = snd_hda_codec_read(codec, 0x1b, 0,
1982 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001983 bits = present ? HDA_AMP_MUTE : 0;
1984 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1985 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001986}
1987
1988static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1989{
1990 /* Looks like the unsol event is incompatible with the standard
1991 * definition. 4bit tag is placed at 28 bit!
1992 */
1993 if ((res >> 28) == 0x01)
1994 alc880_lg_lw_automute(codec);
1995}
1996
Takashi Iwaicb53c622007-08-10 17:21:45 +02001997#ifdef CONFIG_SND_HDA_POWER_SAVE
1998static struct hda_amp_list alc880_loopbacks[] = {
1999 { 0x0b, HDA_INPUT, 0 },
2000 { 0x0b, HDA_INPUT, 1 },
2001 { 0x0b, HDA_INPUT, 2 },
2002 { 0x0b, HDA_INPUT, 3 },
2003 { 0x0b, HDA_INPUT, 4 },
2004 { } /* end */
2005};
2006
2007static struct hda_amp_list alc880_lg_loopbacks[] = {
2008 { 0x0b, HDA_INPUT, 1 },
2009 { 0x0b, HDA_INPUT, 6 },
2010 { 0x0b, HDA_INPUT, 7 },
2011 { } /* end */
2012};
2013#endif
2014
Takashi Iwaid6815182006-03-23 16:06:23 +01002015/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002016 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002018
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019static int alc_init(struct hda_codec *codec)
2020{
2021 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002022 unsigned int i;
2023
2024 for (i = 0; i < spec->num_init_verbs; i++)
2025 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002026
2027 if (spec->init_hook)
2028 spec->init_hook(codec);
2029
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030 return 0;
2031}
2032
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002033static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2034{
2035 struct alc_spec *spec = codec->spec;
2036
2037 if (spec->unsol_event)
2038 spec->unsol_event(codec, res);
2039}
2040
Takashi Iwaicb53c622007-08-10 17:21:45 +02002041#ifdef CONFIG_SND_HDA_POWER_SAVE
2042static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2043{
2044 struct alc_spec *spec = codec->spec;
2045 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2046}
2047#endif
2048
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049/*
2050 * Analog playback callbacks
2051 */
2052static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055{
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2058}
2059
2060static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
2062 unsigned int stream_tag,
2063 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002064 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065{
2066 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2068 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069}
2070
2071static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002073 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074{
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2077}
2078
2079/*
2080 * Digital out
2081 */
2082static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2083 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002084 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085{
2086 struct alc_spec *spec = codec->spec;
2087 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2088}
2089
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002090static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2091 struct hda_codec *codec,
2092 unsigned int stream_tag,
2093 unsigned int format,
2094 struct snd_pcm_substream *substream)
2095{
2096 struct alc_spec *spec = codec->spec;
2097 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2098 stream_tag, format, substream);
2099}
2100
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2102 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002103 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104{
2105 struct alc_spec *spec = codec->spec;
2106 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2107}
2108
2109/*
2110 * Analog capture
2111 */
2112static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2113 struct hda_codec *codec,
2114 unsigned int stream_tag,
2115 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002116 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117{
2118 struct alc_spec *spec = codec->spec;
2119
2120 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2121 stream_tag, 0, format);
2122 return 0;
2123}
2124
2125static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2126 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002127 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128{
2129 struct alc_spec *spec = codec->spec;
2130
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002131 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2132 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133 return 0;
2134}
2135
2136
2137/*
2138 */
2139static struct hda_pcm_stream alc880_pcm_analog_playback = {
2140 .substreams = 1,
2141 .channels_min = 2,
2142 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002143 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 .ops = {
2145 .open = alc880_playback_pcm_open,
2146 .prepare = alc880_playback_pcm_prepare,
2147 .cleanup = alc880_playback_pcm_cleanup
2148 },
2149};
2150
2151static struct hda_pcm_stream alc880_pcm_analog_capture = {
2152 .substreams = 2,
2153 .channels_min = 2,
2154 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 .ops = {
2157 .prepare = alc880_capture_pcm_prepare,
2158 .cleanup = alc880_capture_pcm_cleanup
2159 },
2160};
2161
2162static struct hda_pcm_stream alc880_pcm_digital_playback = {
2163 .substreams = 1,
2164 .channels_min = 2,
2165 .channels_max = 2,
2166 /* NID is set in alc_build_pcms */
2167 .ops = {
2168 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002169 .close = alc880_dig_playback_pcm_close,
2170 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 },
2172};
2173
2174static struct hda_pcm_stream alc880_pcm_digital_capture = {
2175 .substreams = 1,
2176 .channels_min = 2,
2177 .channels_max = 2,
2178 /* NID is set in alc_build_pcms */
2179};
2180
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002181/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2182static struct hda_pcm_stream alc_pcm_null_playback = {
2183 .substreams = 0,
2184 .channels_min = 0,
2185 .channels_max = 0,
2186};
2187
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188static int alc_build_pcms(struct hda_codec *codec)
2189{
2190 struct alc_spec *spec = codec->spec;
2191 struct hda_pcm *info = spec->pcm_rec;
2192 int i;
2193
2194 codec->num_pcms = 1;
2195 codec->pcm_info = info;
2196
2197 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002198 if (spec->stream_analog_playback) {
2199 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2200 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2201 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2202 }
2203 if (spec->stream_analog_capture) {
2204 snd_assert(spec->adc_nids, return -EINVAL);
2205 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2207 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208
Takashi Iwai4a471b72005-12-07 13:56:29 +01002209 if (spec->channel_mode) {
2210 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2211 for (i = 0; i < spec->num_channel_mode; i++) {
2212 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2214 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 }
2216 }
2217
Takashi Iwaie08a0072006-09-07 17:52:14 +02002218 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002220 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002221 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002223 if (spec->multiout.dig_out_nid &&
2224 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2227 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002228 if (spec->dig_in_nid &&
2229 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2231 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2232 }
2233 }
2234
Takashi Iwaie08a0072006-09-07 17:52:14 +02002235 /* If the use of more than one ADC is requested for the current
2236 * model, configure a second analog capture-only PCM.
2237 */
2238 /* Additional Analaog capture for index #2 */
2239 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2240 spec->adc_nids) {
2241 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002242 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002243 info->name = spec->stream_name_analog;
2244 /* No playback stream for second PCM */
2245 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2247 if (spec->stream_analog_capture) {
2248 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2249 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2250 }
2251 }
2252
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 return 0;
2254}
2255
2256static void alc_free(struct hda_codec *codec)
2257{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258 struct alc_spec *spec = codec->spec;
2259 unsigned int i;
2260
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002261 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002262 return;
2263
2264 if (spec->kctl_alloc) {
2265 for (i = 0; i < spec->num_kctl_used; i++)
2266 kfree(spec->kctl_alloc[i].name);
2267 kfree(spec->kctl_alloc);
2268 }
2269 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270}
2271
2272/*
2273 */
2274static struct hda_codec_ops alc_patch_ops = {
2275 .build_controls = alc_build_controls,
2276 .build_pcms = alc_build_pcms,
2277 .init = alc_init,
2278 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002279 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002280#ifdef CONFIG_SND_HDA_POWER_SAVE
2281 .check_power_status = alc_check_power_status,
2282#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283};
2284
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002285
2286/*
2287 * Test configuration for debugging
2288 *
2289 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2290 * enum controls.
2291 */
2292#ifdef CONFIG_SND_DEBUG
2293static hda_nid_t alc880_test_dac_nids[4] = {
2294 0x02, 0x03, 0x04, 0x05
2295};
2296
2297static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002298 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002299 .items = {
2300 { "In-1", 0x0 },
2301 { "In-2", 0x1 },
2302 { "In-3", 0x2 },
2303 { "In-4", 0x3 },
2304 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002305 { "Front", 0x5 },
2306 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002307 },
2308};
2309
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002310static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002311 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002312 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002313 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002314 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002315};
2316
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002317static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2318 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002319{
2320 static char *texts[] = {
2321 "N/A", "Line Out", "HP Out",
2322 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2323 };
2324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2325 uinfo->count = 1;
2326 uinfo->value.enumerated.items = 8;
2327 if (uinfo->value.enumerated.item >= 8)
2328 uinfo->value.enumerated.item = 7;
2329 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2330 return 0;
2331}
2332
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002333static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002335{
2336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2337 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2338 unsigned int pin_ctl, item = 0;
2339
2340 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2341 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2342 if (pin_ctl & AC_PINCTL_OUT_EN) {
2343 if (pin_ctl & AC_PINCTL_HP_EN)
2344 item = 2;
2345 else
2346 item = 1;
2347 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2348 switch (pin_ctl & AC_PINCTL_VREFEN) {
2349 case AC_PINCTL_VREF_HIZ: item = 3; break;
2350 case AC_PINCTL_VREF_50: item = 4; break;
2351 case AC_PINCTL_VREF_GRD: item = 5; break;
2352 case AC_PINCTL_VREF_80: item = 6; break;
2353 case AC_PINCTL_VREF_100: item = 7; break;
2354 }
2355 }
2356 ucontrol->value.enumerated.item[0] = item;
2357 return 0;
2358}
2359
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002360static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002362{
2363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2364 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2365 static unsigned int ctls[] = {
2366 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2367 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2368 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2372 };
2373 unsigned int old_ctl, new_ctl;
2374
2375 old_ctl = snd_hda_codec_read(codec, nid, 0,
2376 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2377 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2378 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002379 int val;
2380 snd_hda_codec_write_cache(codec, nid, 0,
2381 AC_VERB_SET_PIN_WIDGET_CONTROL,
2382 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002383 val = ucontrol->value.enumerated.item[0] >= 3 ?
2384 HDA_AMP_MUTE : 0;
2385 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2386 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002387 return 1;
2388 }
2389 return 0;
2390}
2391
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002392static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2393 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002394{
2395 static char *texts[] = {
2396 "Front", "Surround", "CLFE", "Side"
2397 };
2398 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2399 uinfo->count = 1;
2400 uinfo->value.enumerated.items = 4;
2401 if (uinfo->value.enumerated.item >= 4)
2402 uinfo->value.enumerated.item = 3;
2403 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2404 return 0;
2405}
2406
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002407static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2408 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002409{
2410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2411 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2412 unsigned int sel;
2413
2414 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2415 ucontrol->value.enumerated.item[0] = sel & 3;
2416 return 0;
2417}
2418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002419static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2420 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002421{
2422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2424 unsigned int sel;
2425
2426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2427 if (ucontrol->value.enumerated.item[0] != sel) {
2428 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002429 snd_hda_codec_write_cache(codec, nid, 0,
2430 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002431 return 1;
2432 }
2433 return 0;
2434}
2435
2436#define PIN_CTL_TEST(xname,nid) { \
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2438 .name = xname, \
2439 .info = alc_test_pin_ctl_info, \
2440 .get = alc_test_pin_ctl_get, \
2441 .put = alc_test_pin_ctl_put, \
2442 .private_value = nid \
2443 }
2444
2445#define PIN_SRC_TEST(xname,nid) { \
2446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2447 .name = xname, \
2448 .info = alc_test_pin_src_info, \
2449 .get = alc_test_pin_src_get, \
2450 .put = alc_test_pin_src_put, \
2451 .private_value = nid \
2452 }
2453
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002454static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002455 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2457 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2458 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002459 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2460 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2461 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2462 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002463 PIN_CTL_TEST("Front Pin Mode", 0x14),
2464 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2465 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2466 PIN_CTL_TEST("Side Pin Mode", 0x17),
2467 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2468 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2469 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2470 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2471 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2472 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2473 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2474 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2475 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2476 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2477 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2479 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2480 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2481 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2482 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002485 {
2486 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2487 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002488 .info = alc_ch_mode_info,
2489 .get = alc_ch_mode_get,
2490 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002491 },
2492 { } /* end */
2493};
2494
2495static struct hda_verb alc880_test_init_verbs[] = {
2496 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002505 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002510 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002515 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002516 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002520 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2525 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002526 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002531 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002537 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 /* Analog input/passthru */
2539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002544 { }
2545};
2546#endif
2547
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548/*
2549 */
2550
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002551static const char *alc880_models[ALC880_MODEL_LAST] = {
2552 [ALC880_3ST] = "3stack",
2553 [ALC880_TCL_S700] = "tcl",
2554 [ALC880_3ST_DIG] = "3stack-digout",
2555 [ALC880_CLEVO] = "clevo",
2556 [ALC880_5ST] = "5stack",
2557 [ALC880_5ST_DIG] = "5stack-digout",
2558 [ALC880_W810] = "w810",
2559 [ALC880_Z71V] = "z71v",
2560 [ALC880_6ST] = "6stack",
2561 [ALC880_6ST_DIG] = "6stack-digout",
2562 [ALC880_ASUS] = "asus",
2563 [ALC880_ASUS_W1V] = "asus-w1v",
2564 [ALC880_ASUS_DIG] = "asus-dig",
2565 [ALC880_ASUS_DIG2] = "asus-dig2",
2566 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002567 [ALC880_UNIWILL_P53] = "uniwill-p53",
2568 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002569 [ALC880_F1734] = "F1734",
2570 [ALC880_LG] = "lg",
2571 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002572#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002573 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002574#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002575 [ALC880_AUTO] = "auto",
2576};
2577
2578static struct snd_pci_quirk alc880_cfg_tbl[] = {
2579 /* Broken BIOS configuration */
2580 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2582
2583 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2584 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002585 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002586 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2587 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2588 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2589 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2592
2593 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2594 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2595
2596 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2597 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2598 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2599 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2600 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2603 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2604 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002606 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002607 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2609 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2610 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2611
2612 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2613 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2614 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2615 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2616 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2617 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2618 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2619 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2620 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2621 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2622 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2623 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2624 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2630
2631 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2632 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2633 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2635
2636 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2637 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2638 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002639 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002640
2641 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2642 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2643 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2644 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2645
2646 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2647 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2648 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002657
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 {}
2659};
2660
Takashi Iwai16ded522005-06-10 19:58:24 +02002661/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002662 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002664static struct alc_config_preset alc880_presets[] = {
2665 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002667 .init_verbs = { alc880_volume_init_verbs,
2668 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2672 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002673 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 .input_mux = &alc880_capture_source,
2675 },
2676 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002678 .init_verbs = { alc880_volume_init_verbs,
2679 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 .dac_nids = alc880_dac_nids,
2682 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2684 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002685 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 .input_mux = &alc880_capture_source,
2687 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002688 [ALC880_TCL_S700] = {
2689 .mixers = { alc880_tcl_s700_mixer },
2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_tcl_S700_init_verbs,
2692 alc880_gpio2_init_verbs },
2693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2694 .dac_nids = alc880_dac_nids,
2695 .hp_nid = 0x03,
2696 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2697 .channel_mode = alc880_2_jack_modes,
2698 .input_mux = &alc880_capture_source,
2699 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002700 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002701 .mixers = { alc880_three_stack_mixer,
2702 alc880_five_stack_mixer},
2703 .init_verbs = { alc880_volume_init_verbs,
2704 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2706 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002707 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2708 .channel_mode = alc880_fivestack_modes,
2709 .input_mux = &alc880_capture_source,
2710 },
2711 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002712 .mixers = { alc880_three_stack_mixer,
2713 alc880_five_stack_mixer },
2714 .init_verbs = { alc880_volume_init_verbs,
2715 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2717 .dac_nids = alc880_dac_nids,
2718 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2720 .channel_mode = alc880_fivestack_modes,
2721 .input_mux = &alc880_capture_source,
2722 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002723 [ALC880_6ST] = {
2724 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002725 .init_verbs = { alc880_volume_init_verbs,
2726 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002727 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2728 .dac_nids = alc880_6st_dac_nids,
2729 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2730 .channel_mode = alc880_sixstack_modes,
2731 .input_mux = &alc880_6stack_capture_source,
2732 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002737 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2738 .dac_nids = alc880_6st_dac_nids,
2739 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2741 .channel_mode = alc880_sixstack_modes,
2742 .input_mux = &alc880_6stack_capture_source,
2743 },
2744 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002746 .init_verbs = { alc880_volume_init_verbs,
2747 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002748 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002749 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2750 .dac_nids = alc880_w810_dac_nids,
2751 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002752 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2753 .channel_mode = alc880_w810_modes,
2754 .input_mux = &alc880_capture_source,
2755 },
2756 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002760 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2761 .dac_nids = alc880_z71v_dac_nids,
2762 .dig_out_nid = ALC880_DIGOUT_NID,
2763 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002764 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2765 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002766 .input_mux = &alc880_capture_source,
2767 },
2768 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002769 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2773 .dac_nids = alc880_f1734_dac_nids,
2774 .hp_nid = 0x02,
2775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2776 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 .input_mux = &alc880_capture_source,
2778 },
2779 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002781 .init_verbs = { alc880_volume_init_verbs,
2782 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783 alc880_gpio1_init_verbs },
2784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2785 .dac_nids = alc880_asus_dac_nids,
2786 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2787 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002788 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002789 .input_mux = &alc880_capture_source,
2790 },
2791 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 alc880_gpio1_init_verbs },
2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2797 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2800 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002801 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002802 .input_mux = &alc880_capture_source,
2803 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002804 [ALC880_ASUS_DIG2] = {
2805 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002806 .init_verbs = { alc880_volume_init_verbs,
2807 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002808 alc880_gpio2_init_verbs }, /* use GPIO2 */
2809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2810 .dac_nids = alc880_asus_dac_nids,
2811 .dig_out_nid = ALC880_DIGOUT_NID,
2812 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2813 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002814 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002815 .input_mux = &alc880_capture_source,
2816 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002817 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002819 .init_verbs = { alc880_volume_init_verbs,
2820 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002821 alc880_gpio1_init_verbs },
2822 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2823 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002824 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002825 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2826 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002827 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002828 .input_mux = &alc880_capture_source,
2829 },
2830 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002831 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002832 .init_verbs = { alc880_volume_init_verbs,
2833 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2835 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002836 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2838 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002839 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002840 .input_mux = &alc880_capture_source,
2841 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002842 [ALC880_UNIWILL] = {
2843 .mixers = { alc880_uniwill_mixer },
2844 .init_verbs = { alc880_volume_init_verbs,
2845 alc880_uniwill_init_verbs },
2846 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2847 .dac_nids = alc880_asus_dac_nids,
2848 .dig_out_nid = ALC880_DIGOUT_NID,
2849 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2850 .channel_mode = alc880_threestack_modes,
2851 .need_dac_fix = 1,
2852 .input_mux = &alc880_capture_source,
2853 .unsol_event = alc880_uniwill_unsol_event,
2854 .init_hook = alc880_uniwill_automute,
2855 },
2856 [ALC880_UNIWILL_P53] = {
2857 .mixers = { alc880_uniwill_p53_mixer },
2858 .init_verbs = { alc880_volume_init_verbs,
2859 alc880_uniwill_p53_init_verbs },
2860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2861 .dac_nids = alc880_asus_dac_nids,
2862 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002863 .channel_mode = alc880_threestack_modes,
2864 .input_mux = &alc880_capture_source,
2865 .unsol_event = alc880_uniwill_p53_unsol_event,
2866 .init_hook = alc880_uniwill_p53_hp_automute,
2867 },
2868 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002869 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002870 alc880_pcbeep_mixer, },
2871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_uniwill_p53_init_verbs,
2873 alc880_beep_init_verbs },
2874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2875 .dac_nids = alc880_dac_nids,
2876 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2877 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002878 .input_mux = &alc880_capture_source,
2879 .unsol_event = alc880_uniwill_p53_unsol_event,
2880 .init_hook = alc880_uniwill_p53_hp_automute,
2881 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002882 [ALC880_CLEVO] = {
2883 .mixers = { alc880_three_stack_mixer },
2884 .init_verbs = { alc880_volume_init_verbs,
2885 alc880_pin_clevo_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2887 .dac_nids = alc880_dac_nids,
2888 .hp_nid = 0x03,
2889 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2890 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002891 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002892 .input_mux = &alc880_capture_source,
2893 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002894 [ALC880_LG] = {
2895 .mixers = { alc880_lg_mixer },
2896 .init_verbs = { alc880_volume_init_verbs,
2897 alc880_lg_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2899 .dac_nids = alc880_lg_dac_nids,
2900 .dig_out_nid = ALC880_DIGOUT_NID,
2901 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2902 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002903 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002904 .input_mux = &alc880_lg_capture_source,
2905 .unsol_event = alc880_lg_unsol_event,
2906 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002907#ifdef CONFIG_SND_HDA_POWER_SAVE
2908 .loopbacks = alc880_lg_loopbacks,
2909#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002910 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002911 [ALC880_LG_LW] = {
2912 .mixers = { alc880_lg_lw_mixer },
2913 .init_verbs = { alc880_volume_init_verbs,
2914 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002915 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002916 .dac_nids = alc880_dac_nids,
2917 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002918 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2919 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002920 .input_mux = &alc880_lg_lw_capture_source,
2921 .unsol_event = alc880_lg_lw_unsol_event,
2922 .init_hook = alc880_lg_lw_automute,
2923 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002924#ifdef CONFIG_SND_DEBUG
2925 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926 .mixers = { alc880_test_mixer },
2927 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002928 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2929 .dac_nids = alc880_test_dac_nids,
2930 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002931 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2932 .channel_mode = alc880_test_modes,
2933 .input_mux = &alc880_test_capture_source,
2934 },
2935#endif
2936};
2937
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002938/*
2939 * Automatic parse of I/O pins from the BIOS configuration
2940 */
2941
2942#define NUM_CONTROL_ALLOC 32
2943#define NUM_VERB_ALLOC 32
2944
2945enum {
2946 ALC_CTL_WIDGET_VOL,
2947 ALC_CTL_WIDGET_MUTE,
2948 ALC_CTL_BIND_MUTE,
2949};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002950static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002951 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2952 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002953 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954};
2955
2956/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002957static int add_control(struct alc_spec *spec, int type, const char *name,
2958 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002959{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002960 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961
2962 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2963 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2964
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002965 /* array + terminator */
2966 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2967 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 return -ENOMEM;
2969 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002970 memcpy(knew, spec->kctl_alloc,
2971 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 kfree(spec->kctl_alloc);
2973 }
2974 spec->kctl_alloc = knew;
2975 spec->num_kctl_alloc = num;
2976 }
2977
2978 knew = &spec->kctl_alloc[spec->num_kctl_used];
2979 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002980 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002981 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002982 return -ENOMEM;
2983 knew->private_value = val;
2984 spec->num_kctl_used++;
2985 return 0;
2986}
2987
2988#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2989#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2990#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2991#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2992#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2993#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2994#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2995#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2996#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2997#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2998#define ALC880_PIN_CD_NID 0x1c
2999
3000/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003001static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3002 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003{
3004 hda_nid_t nid;
3005 int assigned[4];
3006 int i, j;
3007
3008 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003009 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003010
3011 /* check the pins hardwired to audio widget */
3012 for (i = 0; i < cfg->line_outs; i++) {
3013 nid = cfg->line_out_pins[i];
3014 if (alc880_is_fixed_pin(nid)) {
3015 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003016 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017 assigned[idx] = 1;
3018 }
3019 }
3020 /* left pins can be connect to any audio widget */
3021 for (i = 0; i < cfg->line_outs; i++) {
3022 nid = cfg->line_out_pins[i];
3023 if (alc880_is_fixed_pin(nid))
3024 continue;
3025 /* search for an empty channel */
3026 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003027 if (!assigned[j]) {
3028 spec->multiout.dac_nids[i] =
3029 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003030 assigned[j] = 1;
3031 break;
3032 }
3033 }
3034 }
3035 spec->multiout.num_dacs = cfg->line_outs;
3036 return 0;
3037}
3038
3039/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003040static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3041 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042{
3043 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003044 static const char *chname[4] = {
3045 "Front", "Surround", NULL /*CLFE*/, "Side"
3046 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 hda_nid_t nid;
3048 int i, err;
3049
3050 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003051 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052 continue;
3053 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3054 if (i == 2) {
3055 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003056 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3057 "Center Playback Volume",
3058 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3059 HDA_OUTPUT));
3060 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003062 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3063 "LFE Playback Volume",
3064 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3065 HDA_OUTPUT));
3066 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003068 err = add_control(spec, ALC_CTL_BIND_MUTE,
3069 "Center Playback Switch",
3070 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3071 HDA_INPUT));
3072 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003074 err = add_control(spec, ALC_CTL_BIND_MUTE,
3075 "LFE Playback Switch",
3076 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3077 HDA_INPUT));
3078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 return err;
3080 } else {
3081 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003082 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3083 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3084 HDA_OUTPUT));
3085 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 return err;
3087 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003088 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3089 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3090 HDA_INPUT));
3091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003092 return err;
3093 }
3094 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 return 0;
3096}
3097
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003098/* add playback controls for speaker and HP outputs */
3099static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3100 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101{
3102 hda_nid_t nid;
3103 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003104 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003106 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 return 0;
3108
3109 if (alc880_is_fixed_pin(pin)) {
3110 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003111 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003112 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003113 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003114 else
3115 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 /* control HP volume/switch on the output mixer amp */
3117 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003118 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003119 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3120 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003123 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003124 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3125 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3126 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 return err;
3128 } else if (alc880_is_multi_pin(pin)) {
3129 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003131 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003132 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3133 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3134 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003135 return err;
3136 }
3137 return 0;
3138}
3139
3140/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003141static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3142 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003143 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144{
3145 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003146 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003147
3148 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003149 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3150 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3151 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003152 return err;
3153 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003154 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3155 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3156 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003157 return err;
3158 return 0;
3159}
3160
3161/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003162static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3163 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003166 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167
3168 for (i = 0; i < AUTO_PIN_LAST; i++) {
3169 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003170 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003171 err = new_analog_input(spec, cfg->input_pins[i],
3172 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003173 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 if (err < 0)
3175 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003176 imux->items[imux->num_items].label =
3177 auto_pin_cfg_labels[i];
3178 imux->items[imux->num_items].index =
3179 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003180 imux->num_items++;
3181 }
3182 }
3183 return 0;
3184}
3185
Kailang Yangdf694da2005-12-05 19:42:22 +01003186static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3187 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188 int dac_idx)
3189{
3190 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3192 pin_type);
3193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3194 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 /* need the manual connection? */
3196 if (alc880_is_multi_pin(nid)) {
3197 struct alc_spec *spec = codec->spec;
3198 int idx = alc880_multi_pin_idx(nid);
3199 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3200 AC_VERB_SET_CONNECT_SEL,
3201 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3202 }
3203}
3204
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003205static int get_pin_type(int line_out_type)
3206{
3207 if (line_out_type == AUTO_PIN_HP_OUT)
3208 return PIN_HP;
3209 else
3210 return PIN_OUT;
3211}
3212
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213static void alc880_auto_init_multi_out(struct hda_codec *codec)
3214{
3215 struct alc_spec *spec = codec->spec;
3216 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003217
3218 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 for (i = 0; i < spec->autocfg.line_outs; i++) {
3220 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003221 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3222 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 }
3224}
3225
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003226static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227{
3228 struct alc_spec *spec = codec->spec;
3229 hda_nid_t pin;
3230
Takashi Iwai82bc9552006-03-21 11:24:42 +01003231 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003232 if (pin) /* connect to front */
3233 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003234 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 if (pin) /* connect to front */
3236 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3237}
3238
3239static void alc880_auto_init_analog_input(struct hda_codec *codec)
3240{
3241 struct alc_spec *spec = codec->spec;
3242 int i;
3243
3244 for (i = 0; i < AUTO_PIN_LAST; i++) {
3245 hda_nid_t nid = spec->autocfg.input_pins[i];
3246 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003247 snd_hda_codec_write(codec, nid, 0,
3248 AC_VERB_SET_PIN_WIDGET_CONTROL,
3249 i <= AUTO_PIN_FRONT_MIC ?
3250 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003252 snd_hda_codec_write(codec, nid, 0,
3253 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 AMP_OUT_MUTE);
3255 }
3256 }
3257}
3258
3259/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003260/* return 1 if successful, 0 if the proper config is not found,
3261 * or a negative error code
3262 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263static int alc880_parse_auto_config(struct hda_codec *codec)
3264{
3265 struct alc_spec *spec = codec->spec;
3266 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003267 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003269 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3270 alc880_ignore);
3271 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003276 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3277 if (err < 0)
3278 return err;
3279 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3280 if (err < 0)
3281 return err;
3282 err = alc880_auto_create_extra_out(spec,
3283 spec->autocfg.speaker_pins[0],
3284 "Speaker");
3285 if (err < 0)
3286 return err;
3287 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3288 "Headphone");
3289 if (err < 0)
3290 return err;
3291 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3292 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 return err;
3294
3295 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3296
3297 if (spec->autocfg.dig_out_pin)
3298 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3299 if (spec->autocfg.dig_in_pin)
3300 spec->dig_in_nid = ALC880_DIGIN_NID;
3301
3302 if (spec->kctl_alloc)
3303 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3304
3305 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3306
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003307 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003308 spec->input_mux = &spec->private_imux;
3309
3310 return 1;
3311}
3312
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003313/* additional initialization for auto-configuration model */
3314static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003317 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003319}
3320
3321/*
3322 * OK, here we have finally the patch for ALC880
3323 */
3324
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325static int patch_alc880(struct hda_codec *codec)
3326{
3327 struct alc_spec *spec;
3328 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003329 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003330
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003331 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003332 if (spec == NULL)
3333 return -ENOMEM;
3334
3335 codec->spec = spec;
3336
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003337 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3338 alc880_models,
3339 alc880_cfg_tbl);
3340 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003341 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3342 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003344 }
3345
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346 if (board_config == ALC880_AUTO) {
3347 /* automatic parse from the BIOS config */
3348 err = alc880_parse_auto_config(codec);
3349 if (err < 0) {
3350 alc_free(codec);
3351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003352 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003353 printk(KERN_INFO
3354 "hda_codec: Cannot set up configuration "
3355 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356 board_config = ALC880_3ST;
3357 }
3358 }
3359
Kailang Yangdf694da2005-12-05 19:42:22 +01003360 if (board_config != ALC880_AUTO)
3361 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362
3363 spec->stream_name_analog = "ALC880 Analog";
3364 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3365 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3366
3367 spec->stream_name_digital = "ALC880 Digital";
3368 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3369 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3370
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003371 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003372 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003373 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003374 /* get type */
3375 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 if (wcap != AC_WID_AUD_IN) {
3377 spec->adc_nids = alc880_adc_nids_alt;
3378 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003379 spec->mixers[spec->num_mixers] =
3380 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381 spec->num_mixers++;
3382 } else {
3383 spec->adc_nids = alc880_adc_nids;
3384 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3385 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3386 spec->num_mixers++;
3387 }
3388 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389
3390 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003392 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003393#ifdef CONFIG_SND_HDA_POWER_SAVE
3394 if (!spec->loopback.amplist)
3395 spec->loopback.amplist = alc880_loopbacks;
3396#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003397
3398 return 0;
3399}
3400
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003401
Linus Torvalds1da177e2005-04-16 15:20:36 -07003402/*
3403 * ALC260 support
3404 */
3405
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406static hda_nid_t alc260_dac_nids[1] = {
3407 /* front */
3408 0x02,
3409};
3410
3411static hda_nid_t alc260_adc_nids[1] = {
3412 /* ADC0 */
3413 0x04,
3414};
3415
Kailang Yangdf694da2005-12-05 19:42:22 +01003416static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 /* ADC1 */
3418 0x05,
3419};
3420
Kailang Yangdf694da2005-12-05 19:42:22 +01003421static hda_nid_t alc260_hp_adc_nids[2] = {
3422 /* ADC1, 0 */
3423 0x05, 0x04
3424};
3425
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003426/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3427 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3428 */
3429static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003430 /* ADC0, ADC1 */
3431 0x04, 0x05
3432};
3433
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434#define ALC260_DIGOUT_NID 0x03
3435#define ALC260_DIGIN_NID 0x06
3436
3437static struct hda_input_mux alc260_capture_source = {
3438 .num_items = 4,
3439 .items = {
3440 { "Mic", 0x0 },
3441 { "Front Mic", 0x1 },
3442 { "Line", 0x2 },
3443 { "CD", 0x4 },
3444 },
3445};
3446
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003447/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003448 * headphone jack and the internal CD lines since these are the only pins at
3449 * which audio can appear. For flexibility, also allow the option of
3450 * recording the mixer output on the second ADC (ADC0 doesn't have a
3451 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003452 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003453static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3454 {
3455 .num_items = 3,
3456 .items = {
3457 { "Mic/Line", 0x0 },
3458 { "CD", 0x4 },
3459 { "Headphone", 0x2 },
3460 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003461 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003462 {
3463 .num_items = 4,
3464 .items = {
3465 { "Mic/Line", 0x0 },
3466 { "CD", 0x4 },
3467 { "Headphone", 0x2 },
3468 { "Mixer", 0x5 },
3469 },
3470 },
3471
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003472};
3473
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003474/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3475 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003476 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003477static struct hda_input_mux alc260_acer_capture_sources[2] = {
3478 {
3479 .num_items = 4,
3480 .items = {
3481 { "Mic", 0x0 },
3482 { "Line", 0x2 },
3483 { "CD", 0x4 },
3484 { "Headphone", 0x5 },
3485 },
3486 },
3487 {
3488 .num_items = 5,
3489 .items = {
3490 { "Mic", 0x0 },
3491 { "Line", 0x2 },
3492 { "CD", 0x4 },
3493 { "Headphone", 0x6 },
3494 { "Mixer", 0x5 },
3495 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003496 },
3497};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003498/*
3499 * This is just place-holder, so there's something for alc_build_pcms to look
3500 * at when it calculates the maximum number of channels. ALC260 has no mixer
3501 * element which allows changing the channel mode, so the verb list is
3502 * never used.
3503 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003504static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 { 2, NULL },
3506};
3507
Kailang Yangdf694da2005-12-05 19:42:22 +01003508
3509/* Mixer combinations
3510 *
3511 * basic: base_output + input + pc_beep + capture
3512 * HP: base_output + input + capture_alt
3513 * HP_3013: hp_3013 + input + capture
3514 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003515 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003516 */
3517
3518static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003519 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003520 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3522 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3523 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3525 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003526};
Kailang Yangdf694da2005-12-05 19:42:22 +01003527
3528static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003529 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3530 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3531 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3532 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3534 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003537 { } /* end */
3538};
3539
Kailang Yangdf694da2005-12-05 19:42:22 +01003540static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3541 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3542 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3543 { } /* end */
3544};
3545
3546static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3547 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3548 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3549 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3550 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003555 { } /* end */
3556};
3557
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003558/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3559 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3560 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003561static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003563 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003564 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003565 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3566 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3568 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003569 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003570 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3571 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003573 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003574 { } /* end */
3575};
3576
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003577/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3578 * versions of the ALC260 don't act on requests to enable mic bias from NID
3579 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3580 * datasheet doesn't mention this restriction. At this stage it's not clear
3581 * whether this behaviour is intentional or is a hardware bug in chip
3582 * revisions available in early 2006. Therefore for now allow the
3583 * "Headphone Jack Mode" control to span all choices, but if it turns out
3584 * that the lack of mic bias for this NID is intentional we could change the
3585 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3586 *
3587 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3588 * don't appear to make the mic bias available from the "line" jack, even
3589 * though the NID used for this jack (0x14) can supply it. The theory is
3590 * that perhaps Acer have included blocking capacitors between the ALC260
3591 * and the output jack. If this turns out to be the case for all such
3592 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3593 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003594 *
3595 * The C20x Tablet series have a mono internal speaker which is controlled
3596 * via the chip's Mono sum widget and pin complex, so include the necessary
3597 * controls for such models. On models without a "mono speaker" the control
3598 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003599 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003600static struct snd_kcontrol_new alc260_acer_mixer[] = {
3601 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3602 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003603 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003604 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3605 HDA_OUTPUT),
3606 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3607 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003608 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3609 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3611 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3612 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3613 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3614 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3615 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3616 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3617 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3618 { } /* end */
3619};
3620
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003621/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3622 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3623 */
3624static struct snd_kcontrol_new alc260_will_mixer[] = {
3625 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3626 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3629 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3630 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3631 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3632 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3633 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3634 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3636 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3637 { } /* end */
3638};
3639
3640/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3641 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3642 */
3643static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3644 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3645 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3647 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3648 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3649 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3650 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3652 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3653 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3654 { } /* end */
3655};
3656
Kailang Yangdf694da2005-12-05 19:42:22 +01003657/* capture mixer elements */
3658static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003659 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3660 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003661 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3662 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003663 {
3664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003665 /* The multiple "Capture Source" controls confuse alsamixer
3666 * So call somewhat different..
3667 * FIXME: the controls appear in the "playback" view!
3668 */
3669 /* .name = "Capture Source", */
3670 .name = "Input Source",
3671 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003672 .info = alc_mux_enum_info,
3673 .get = alc_mux_enum_get,
3674 .put = alc_mux_enum_put,
3675 },
3676 { } /* end */
3677};
3678
Kailang Yangdf694da2005-12-05 19:42:22 +01003679static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3680 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3682 {
3683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3684 /* The multiple "Capture Source" controls confuse alsamixer
3685 * So call somewhat different..
3686 * FIXME: the controls appear in the "playback" view!
3687 */
3688 /* .name = "Capture Source", */
3689 .name = "Input Source",
3690 .count = 1,
3691 .info = alc_mux_enum_info,
3692 .get = alc_mux_enum_get,
3693 .put = alc_mux_enum_put,
3694 },
3695 { } /* end */
3696};
3697
3698/*
3699 * initialization verbs
3700 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701static struct hda_verb alc260_init_verbs[] = {
3702 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003704 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003713 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3720 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003722 /* set connection select to line in (default select for this ADC) */
3723 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003724 /* mute capture amp left and right */
3725 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3726 /* set connection select to line in (default select for this ADC) */
3727 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003728 /* set vol=0 Line-Out mixer amp left and right */
3729 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3730 /* unmute pin widget amp left and right (no gain on this amp) */
3731 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3732 /* set vol=0 HP mixer amp left and right */
3733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3734 /* unmute pin widget amp left and right (no gain on this amp) */
3735 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* set vol=0 Mono mixer amp left and right */
3737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3738 /* unmute pin widget amp left and right (no gain on this amp) */
3739 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* unmute LINE-2 out pin */
3741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003742 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3743 * Line In 2 = 0x03
3744 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003745 /* mute analog inputs */
3746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003751 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003752 /* mute Front out path */
3753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3755 /* mute Headphone out path */
3756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3758 /* mute Mono out path */
3759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003761 { }
3762};
3763
Takashi Iwai474167d2006-05-17 17:17:43 +02003764#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003765static struct hda_verb alc260_hp_init_verbs[] = {
3766 /* Headphone and output */
3767 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3768 /* mono output */
3769 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3770 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3771 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3772 /* Mic2 (front panel) pin widget for input and vref at 80% */
3773 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3774 /* Line In pin widget for input */
3775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3776 /* Line-2 pin widget for output */
3777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3778 /* CD pin widget for input */
3779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3780 /* unmute amp left and right */
3781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3782 /* set connection select to line in (default select for this ADC) */
3783 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3784 /* unmute Line-Out mixer amp left and right (volume = 0) */
3785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3786 /* mute pin widget amp left and right (no gain on this amp) */
3787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3788 /* unmute HP mixer amp left and right (volume = 0) */
3789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3790 /* mute pin widget amp left and right (no gain on this amp) */
3791 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003792 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3793 * Line In 2 = 0x03
3794 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003795 /* mute analog inputs */
3796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003801 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3802 /* Unmute Front out path */
3803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3805 /* Unmute Headphone out path */
3806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 /* Unmute Mono out path */
3809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3811 { }
3812};
Takashi Iwai474167d2006-05-17 17:17:43 +02003813#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003814
3815static struct hda_verb alc260_hp_3013_init_verbs[] = {
3816 /* Line out and output */
3817 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3818 /* mono output */
3819 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3820 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3821 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3822 /* Mic2 (front panel) pin widget for input and vref at 80% */
3823 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3824 /* Line In pin widget for input */
3825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3826 /* Headphone pin widget for output */
3827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3828 /* CD pin widget for input */
3829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3830 /* unmute amp left and right */
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3832 /* set connection select to line in (default select for this ADC) */
3833 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3834 /* unmute Line-Out mixer amp left and right (volume = 0) */
3835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3836 /* mute pin widget amp left and right (no gain on this amp) */
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3838 /* unmute HP mixer amp left and right (volume = 0) */
3839 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3840 /* mute pin widget amp left and right (no gain on this amp) */
3841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3843 * Line In 2 = 0x03
3844 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003845 /* mute analog inputs */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3852 /* Unmute Front out path */
3853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3855 /* Unmute Headphone out path */
3856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3858 /* Unmute Mono out path */
3859 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3861 { }
3862};
3863
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003864/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003865 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3866 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003867 */
3868static struct hda_verb alc260_fujitsu_init_verbs[] = {
3869 /* Disable all GPIOs */
3870 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3871 /* Internal speaker is connected to headphone pin */
3872 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3873 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003875 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3877 /* Ensure all other unused pins are disabled and muted. */
3878 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3879 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003880 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003881 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003882 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003883 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003886
Jonathan Woithef7ace402006-02-28 11:46:14 +01003887 /* Disable digital (SPDIF) pins */
3888 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3889 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003890
Jonathan Woithef7ace402006-02-28 11:46:14 +01003891 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3892 * when acting as an output.
3893 */
3894 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3895
3896 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003906
Jonathan Woithef7ace402006-02-28 11:46:14 +01003907 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3908 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3909 /* Unmute Line1 pin widget output buffer since it starts as an output.
3910 * If the pin mode is changed by the user the pin mode control will
3911 * take care of enabling the pin's input/output buffers as needed.
3912 * Therefore there's no need to enable the input buffer at this
3913 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003914 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003916 /* Unmute input buffer of pin widget used for Line-in (no equiv
3917 * mixer ctrl)
3918 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003919 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003920
Jonathan Woithef7ace402006-02-28 11:46:14 +01003921 /* Mute capture amp left and right */
3922 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3923 /* Set ADC connection select to match default mixer setting - line
3924 * in (on mic1 pin)
3925 */
3926 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003927
Jonathan Woithef7ace402006-02-28 11:46:14 +01003928 /* Do the same for the second ADC: mute capture input amp and
3929 * set ADC connection to line in (on mic1 pin)
3930 */
3931 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3932 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003933
Jonathan Woithef7ace402006-02-28 11:46:14 +01003934 /* Mute all inputs to mixer widget (even unconnected ones) */
3935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003943
3944 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003945};
3946
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003947/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3948 * similar laptops (adapted from Fujitsu init verbs).
3949 */
3950static struct hda_verb alc260_acer_init_verbs[] = {
3951 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3952 * the headphone jack. Turn this on and rely on the standard mute
3953 * methods whenever the user wants to turn these outputs off.
3954 */
3955 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3957 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3958 /* Internal speaker/Headphone jack is connected to Line-out pin */
3959 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3960 /* Internal microphone/Mic jack is connected to Mic1 pin */
3961 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3962 /* Line In jack is connected to Line1 pin */
3963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003964 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3965 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003966 /* Ensure all other unused pins are disabled and muted. */
3967 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3968 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003969 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3970 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3973 /* Disable digital (SPDIF) pins */
3974 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3975 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3976
3977 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3978 * bus when acting as outputs.
3979 */
3980 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3981 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3982
3983 /* Start with output sum widgets muted and their output gains at min */
3984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3993
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003994 /* Unmute Line-out pin widget amp left and right
3995 * (no equiv mixer ctrl)
3996 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003998 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3999 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004000 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4001 * inputs. If the pin mode is changed by the user the pin mode control
4002 * will take care of enabling the pin's input/output buffers as needed.
4003 * Therefore there's no need to enable the input buffer at this
4004 * stage.
4005 */
4006 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4008
4009 /* Mute capture amp left and right */
4010 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4011 /* Set ADC connection select to match default mixer setting - mic
4012 * (on mic1 pin)
4013 */
4014 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4015
4016 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004017 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004018 */
4019 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004020 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004021
4022 /* Mute all inputs to mixer widget (even unconnected ones) */
4023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4031
4032 { }
4033};
4034
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004035static struct hda_verb alc260_will_verbs[] = {
4036 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4037 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4038 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4039 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4040 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4041 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4042 {}
4043};
4044
4045static struct hda_verb alc260_replacer_672v_verbs[] = {
4046 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4047 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4048 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4049
4050 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4051 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4052 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4053
4054 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4055 {}
4056};
4057
4058/* toggle speaker-output according to the hp-jack state */
4059static void alc260_replacer_672v_automute(struct hda_codec *codec)
4060{
4061 unsigned int present;
4062
4063 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4064 present = snd_hda_codec_read(codec, 0x0f, 0,
4065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4066 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004067 snd_hda_codec_write_cache(codec, 0x01, 0,
4068 AC_VERB_SET_GPIO_DATA, 1);
4069 snd_hda_codec_write_cache(codec, 0x0f, 0,
4070 AC_VERB_SET_PIN_WIDGET_CONTROL,
4071 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004072 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004073 snd_hda_codec_write_cache(codec, 0x01, 0,
4074 AC_VERB_SET_GPIO_DATA, 0);
4075 snd_hda_codec_write_cache(codec, 0x0f, 0,
4076 AC_VERB_SET_PIN_WIDGET_CONTROL,
4077 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004078 }
4079}
4080
4081static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4082 unsigned int res)
4083{
4084 if ((res >> 26) == ALC880_HP_EVENT)
4085 alc260_replacer_672v_automute(codec);
4086}
4087
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004088/* Test configuration for debugging, modelled after the ALC880 test
4089 * configuration.
4090 */
4091#ifdef CONFIG_SND_DEBUG
4092static hda_nid_t alc260_test_dac_nids[1] = {
4093 0x02,
4094};
4095static hda_nid_t alc260_test_adc_nids[2] = {
4096 0x04, 0x05,
4097};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004098/* For testing the ALC260, each input MUX needs its own definition since
4099 * the signal assignments are different. This assumes that the first ADC
4100 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004101 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004102static struct hda_input_mux alc260_test_capture_sources[2] = {
4103 {
4104 .num_items = 7,
4105 .items = {
4106 { "MIC1 pin", 0x0 },
4107 { "MIC2 pin", 0x1 },
4108 { "LINE1 pin", 0x2 },
4109 { "LINE2 pin", 0x3 },
4110 { "CD pin", 0x4 },
4111 { "LINE-OUT pin", 0x5 },
4112 { "HP-OUT pin", 0x6 },
4113 },
4114 },
4115 {
4116 .num_items = 8,
4117 .items = {
4118 { "MIC1 pin", 0x0 },
4119 { "MIC2 pin", 0x1 },
4120 { "LINE1 pin", 0x2 },
4121 { "LINE2 pin", 0x3 },
4122 { "CD pin", 0x4 },
4123 { "Mixer", 0x5 },
4124 { "LINE-OUT pin", 0x6 },
4125 { "HP-OUT pin", 0x7 },
4126 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004127 },
4128};
4129static struct snd_kcontrol_new alc260_test_mixer[] = {
4130 /* Output driver widgets */
4131 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4132 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4133 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4134 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4135 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4137
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004138 /* Modes for retasking pin widgets
4139 * Note: the ALC260 doesn't seem to act on requests to enable mic
4140 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4141 * mention this restriction. At this stage it's not clear whether
4142 * this behaviour is intentional or is a hardware bug in chip
4143 * revisions available at least up until early 2006. Therefore for
4144 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4145 * choices, but if it turns out that the lack of mic bias for these
4146 * NIDs is intentional we could change their modes from
4147 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4148 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004149 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4150 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4155
4156 /* Loopback mixer controls */
4157 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4158 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4159 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4160 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4161 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4162 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4164 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4165 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4166 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4167 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4168 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4169 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4170 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4171 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4172 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004173
4174 /* Controls for GPIO pins, assuming they are configured as outputs */
4175 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4179
Jonathan Woithe92621f12006-02-28 11:47:47 +01004180 /* Switches to allow the digital IO pins to be enabled. The datasheet
4181 * is ambigious as to which NID is which; testing on laptops which
4182 * make this output available should provide clarification.
4183 */
4184 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4185 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4186
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004187 { } /* end */
4188};
4189static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004190 /* Enable all GPIOs as outputs with an initial value of 0 */
4191 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4192 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4193 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4194
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004195 /* Enable retasking pins as output, initially without power amp */
4196 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4197 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202
Jonathan Woithe92621f12006-02-28 11:47:47 +01004203 /* Disable digital (SPDIF) pins initially, but users can enable
4204 * them via a mixer switch. In the case of SPDIF-out, this initverb
4205 * payload also sets the generation to 0, output to be in "consumer"
4206 * PCM format, copyright asserted, no pre-emphasis and no validity
4207 * control.
4208 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004209 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4210 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4211
Jonathan Woithef7ace402006-02-28 11:46:14 +01004212 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004213 * OUT1 sum bus when acting as an output.
4214 */
4215 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4216 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4219
4220 /* Start with output sum widgets muted and their output gains at min */
4221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4230
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004231 /* Unmute retasking pin widget output buffers since the default
4232 * state appears to be output. As the pin mode is changed by the
4233 * user the pin mode control will take care of enabling the pin's
4234 * input/output buffers as needed.
4235 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004236 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 /* Also unmute the mono-out pin widget */
4243 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004245 /* Mute capture amp left and right */
4246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004247 /* Set ADC connection select to match default mixer setting (mic1
4248 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004249 */
4250 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4251
4252 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004253 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004254 */
4255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4257
4258 /* Mute all inputs to mixer widget (even unconnected ones) */
4259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4267
4268 { }
4269};
4270#endif
4271
Linus Torvalds1da177e2005-04-16 15:20:36 -07004272static struct hda_pcm_stream alc260_pcm_analog_playback = {
4273 .substreams = 1,
4274 .channels_min = 2,
4275 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004276};
4277
4278static struct hda_pcm_stream alc260_pcm_analog_capture = {
4279 .substreams = 1,
4280 .channels_min = 2,
4281 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004282};
4283
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004284#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4285#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4286
Kailang Yangdf694da2005-12-05 19:42:22 +01004287/*
4288 * for BIOS auto-configuration
4289 */
4290
4291static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4292 const char *pfx)
4293{
4294 hda_nid_t nid_vol;
4295 unsigned long vol_val, sw_val;
4296 char name[32];
4297 int err;
4298
4299 if (nid >= 0x0f && nid < 0x11) {
4300 nid_vol = nid - 0x7;
4301 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4302 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4303 } else if (nid == 0x11) {
4304 nid_vol = nid - 0x7;
4305 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4306 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4307 } else if (nid >= 0x12 && nid <= 0x15) {
4308 nid_vol = 0x08;
4309 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4310 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4311 } else
4312 return 0; /* N/A */
4313
4314 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4316 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004317 return err;
4318 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004319 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4320 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004321 return err;
4322 return 1;
4323}
4324
4325/* add playback controls from the parsed DAC table */
4326static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4327 const struct auto_pin_cfg *cfg)
4328{
4329 hda_nid_t nid;
4330 int err;
4331
4332 spec->multiout.num_dacs = 1;
4333 spec->multiout.dac_nids = spec->private_dac_nids;
4334 spec->multiout.dac_nids[0] = 0x02;
4335
4336 nid = cfg->line_out_pins[0];
4337 if (nid) {
4338 err = alc260_add_playback_controls(spec, nid, "Front");
4339 if (err < 0)
4340 return err;
4341 }
4342
Takashi Iwai82bc9552006-03-21 11:24:42 +01004343 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004344 if (nid) {
4345 err = alc260_add_playback_controls(spec, nid, "Speaker");
4346 if (err < 0)
4347 return err;
4348 }
4349
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004350 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004351 if (nid) {
4352 err = alc260_add_playback_controls(spec, nid, "Headphone");
4353 if (err < 0)
4354 return err;
4355 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004356 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004357}
4358
4359/* create playback/capture controls for input pins */
4360static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4361 const struct auto_pin_cfg *cfg)
4362{
Kailang Yangdf694da2005-12-05 19:42:22 +01004363 struct hda_input_mux *imux = &spec->private_imux;
4364 int i, err, idx;
4365
4366 for (i = 0; i < AUTO_PIN_LAST; i++) {
4367 if (cfg->input_pins[i] >= 0x12) {
4368 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004369 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004370 auto_pin_cfg_labels[i], idx,
4371 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004372 if (err < 0)
4373 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004374 imux->items[imux->num_items].label =
4375 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004376 imux->items[imux->num_items].index = idx;
4377 imux->num_items++;
4378 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004379 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004380 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004381 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004382 auto_pin_cfg_labels[i], idx,
4383 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004384 if (err < 0)
4385 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 imux->items[imux->num_items].label =
4387 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004388 imux->items[imux->num_items].index = idx;
4389 imux->num_items++;
4390 }
4391 }
4392 return 0;
4393}
4394
4395static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4396 hda_nid_t nid, int pin_type,
4397 int sel_idx)
4398{
4399 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004400 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4401 pin_type);
4402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4403 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004404 /* need the manual connection? */
4405 if (nid >= 0x12) {
4406 int idx = nid - 0x12;
4407 snd_hda_codec_write(codec, idx + 0x0b, 0,
4408 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004409 }
4410}
4411
4412static void alc260_auto_init_multi_out(struct hda_codec *codec)
4413{
4414 struct alc_spec *spec = codec->spec;
4415 hda_nid_t nid;
4416
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004417 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004418 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004419 if (nid) {
4420 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4421 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4422 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004423
Takashi Iwai82bc9552006-03-21 11:24:42 +01004424 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004425 if (nid)
4426 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4427
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004428 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004429 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004430 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004431}
Kailang Yangdf694da2005-12-05 19:42:22 +01004432
4433#define ALC260_PIN_CD_NID 0x16
4434static void alc260_auto_init_analog_input(struct hda_codec *codec)
4435{
4436 struct alc_spec *spec = codec->spec;
4437 int i;
4438
4439 for (i = 0; i < AUTO_PIN_LAST; i++) {
4440 hda_nid_t nid = spec->autocfg.input_pins[i];
4441 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004442 snd_hda_codec_write(codec, nid, 0,
4443 AC_VERB_SET_PIN_WIDGET_CONTROL,
4444 i <= AUTO_PIN_FRONT_MIC ?
4445 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004446 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 snd_hda_codec_write(codec, nid, 0,
4448 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004449 AMP_OUT_MUTE);
4450 }
4451 }
4452}
4453
4454/*
4455 * generic initialization of ADC, input mixers and output mixers
4456 */
4457static struct hda_verb alc260_volume_init_verbs[] = {
4458 /*
4459 * Unmute ADC0-1 and set the default input to mic-in
4460 */
4461 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4462 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4463 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4464 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4465
4466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4467 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004468 * Note: PASD motherboards uses the Line In 2 as the input for
4469 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 */
4471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004472 /* mute analog inputs */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004478
4479 /*
4480 * Set up output mixers (0x08 - 0x0a)
4481 */
4482 /* set vol=0 to output mixers */
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 /* set up input amps for analog loopback */
4487 /* Amp Indices: DAC = 0, mixer = 1 */
4488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494
4495 { }
4496};
4497
4498static int alc260_parse_auto_config(struct hda_codec *codec)
4499{
4500 struct alc_spec *spec = codec->spec;
4501 unsigned int wcap;
4502 int err;
4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4504
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4506 alc260_ignore);
4507 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004508 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4510 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004511 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004512 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004513 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4515 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004516 return err;
4517
4518 spec->multiout.max_channels = 2;
4519
4520 if (spec->autocfg.dig_out_pin)
4521 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4522 if (spec->kctl_alloc)
4523 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4524
4525 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4526
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004527 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004528 spec->input_mux = &spec->private_imux;
4529
4530 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004531 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4533 if (wcap != AC_WID_AUD_IN) {
4534 spec->adc_nids = alc260_adc_nids_alt;
4535 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4536 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004537 } else {
4538 spec->adc_nids = alc260_adc_nids;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4540 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004541 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004542 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004543
4544 return 1;
4545}
4546
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004547/* additional initialization for auto-configuration model */
4548static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004549{
Kailang Yangdf694da2005-12-05 19:42:22 +01004550 alc260_auto_init_multi_out(codec);
4551 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004552}
4553
Takashi Iwaicb53c622007-08-10 17:21:45 +02004554#ifdef CONFIG_SND_HDA_POWER_SAVE
4555static struct hda_amp_list alc260_loopbacks[] = {
4556 { 0x07, HDA_INPUT, 0 },
4557 { 0x07, HDA_INPUT, 1 },
4558 { 0x07, HDA_INPUT, 2 },
4559 { 0x07, HDA_INPUT, 3 },
4560 { 0x07, HDA_INPUT, 4 },
4561 { } /* end */
4562};
4563#endif
4564
Kailang Yangdf694da2005-12-05 19:42:22 +01004565/*
4566 * ALC260 configurations
4567 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004568static const char *alc260_models[ALC260_MODEL_LAST] = {
4569 [ALC260_BASIC] = "basic",
4570 [ALC260_HP] = "hp",
4571 [ALC260_HP_3013] = "hp-3013",
4572 [ALC260_FUJITSU_S702X] = "fujitsu",
4573 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004574 [ALC260_WILL] = "will",
4575 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004576#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004577 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004578#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 [ALC260_AUTO] = "auto",
4580};
4581
4582static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004583 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004584 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004585 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004586 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004587 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4588 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4589 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4591 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4592 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4593 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4594 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4595 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4596 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4597 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4598 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4600 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004601 {}
4602};
4603
Kailang Yangdf694da2005-12-05 19:42:22 +01004604static struct alc_config_preset alc260_presets[] = {
4605 [ALC260_BASIC] = {
4606 .mixers = { alc260_base_output_mixer,
4607 alc260_input_mixer,
4608 alc260_pc_beep_mixer,
4609 alc260_capture_mixer },
4610 .init_verbs = { alc260_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4612 .dac_nids = alc260_dac_nids,
4613 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4614 .adc_nids = alc260_adc_nids,
4615 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4616 .channel_mode = alc260_modes,
4617 .input_mux = &alc260_capture_source,
4618 },
4619 [ALC260_HP] = {
4620 .mixers = { alc260_base_output_mixer,
4621 alc260_input_mixer,
4622 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004623 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004624 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4625 .dac_nids = alc260_dac_nids,
4626 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4627 .adc_nids = alc260_hp_adc_nids,
4628 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4629 .channel_mode = alc260_modes,
4630 .input_mux = &alc260_capture_source,
4631 },
4632 [ALC260_HP_3013] = {
4633 .mixers = { alc260_hp_3013_mixer,
4634 alc260_input_mixer,
4635 alc260_capture_alt_mixer },
4636 .init_verbs = { alc260_hp_3013_init_verbs },
4637 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4638 .dac_nids = alc260_dac_nids,
4639 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4640 .adc_nids = alc260_hp_adc_nids,
4641 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4642 .channel_mode = alc260_modes,
4643 .input_mux = &alc260_capture_source,
4644 },
4645 [ALC260_FUJITSU_S702X] = {
4646 .mixers = { alc260_fujitsu_mixer,
4647 alc260_capture_mixer },
4648 .init_verbs = { alc260_fujitsu_init_verbs },
4649 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4650 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004651 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4652 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004653 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4654 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004655 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4656 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004658 [ALC260_ACER] = {
4659 .mixers = { alc260_acer_mixer,
4660 alc260_capture_mixer },
4661 .init_verbs = { alc260_acer_init_verbs },
4662 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4663 .dac_nids = alc260_dac_nids,
4664 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4665 .adc_nids = alc260_dual_adc_nids,
4666 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4667 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004668 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4669 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004670 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004671 [ALC260_WILL] = {
4672 .mixers = { alc260_will_mixer,
4673 alc260_capture_mixer },
4674 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4675 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4676 .dac_nids = alc260_dac_nids,
4677 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4678 .adc_nids = alc260_adc_nids,
4679 .dig_out_nid = ALC260_DIGOUT_NID,
4680 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4681 .channel_mode = alc260_modes,
4682 .input_mux = &alc260_capture_source,
4683 },
4684 [ALC260_REPLACER_672V] = {
4685 .mixers = { alc260_replacer_672v_mixer,
4686 alc260_capture_mixer },
4687 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4688 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4689 .dac_nids = alc260_dac_nids,
4690 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4691 .adc_nids = alc260_adc_nids,
4692 .dig_out_nid = ALC260_DIGOUT_NID,
4693 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4694 .channel_mode = alc260_modes,
4695 .input_mux = &alc260_capture_source,
4696 .unsol_event = alc260_replacer_672v_unsol_event,
4697 .init_hook = alc260_replacer_672v_automute,
4698 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004699#ifdef CONFIG_SND_DEBUG
4700 [ALC260_TEST] = {
4701 .mixers = { alc260_test_mixer,
4702 alc260_capture_mixer },
4703 .init_verbs = { alc260_test_init_verbs },
4704 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4705 .dac_nids = alc260_test_dac_nids,
4706 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4707 .adc_nids = alc260_test_adc_nids,
4708 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4709 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004710 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4711 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004712 },
4713#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004714};
4715
Linus Torvalds1da177e2005-04-16 15:20:36 -07004716static int patch_alc260(struct hda_codec *codec)
4717{
4718 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004719 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004720
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004721 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004722 if (spec == NULL)
4723 return -ENOMEM;
4724
4725 codec->spec = spec;
4726
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004727 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4728 alc260_models,
4729 alc260_cfg_tbl);
4730 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004731 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4732 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004733 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004734 }
4735
Kailang Yangdf694da2005-12-05 19:42:22 +01004736 if (board_config == ALC260_AUTO) {
4737 /* automatic parse from the BIOS config */
4738 err = alc260_parse_auto_config(codec);
4739 if (err < 0) {
4740 alc_free(codec);
4741 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004743 printk(KERN_INFO
4744 "hda_codec: Cannot set up configuration "
4745 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004746 board_config = ALC260_BASIC;
4747 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004749
Kailang Yangdf694da2005-12-05 19:42:22 +01004750 if (board_config != ALC260_AUTO)
4751 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004752
4753 spec->stream_name_analog = "ALC260 Analog";
4754 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4755 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4756
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004757 spec->stream_name_digital = "ALC260 Digital";
4758 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4759 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4760
Linus Torvalds1da177e2005-04-16 15:20:36 -07004761 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004762 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004763 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004764#ifdef CONFIG_SND_HDA_POWER_SAVE
4765 if (!spec->loopback.amplist)
4766 spec->loopback.amplist = alc260_loopbacks;
4767#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004768
4769 return 0;
4770}
4771
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773/*
4774 * ALC882 support
4775 *
4776 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4777 * configuration. Each pin widget can choose any input DACs and a mixer.
4778 * Each ADC is connected from a mixer of all inputs. This makes possible
4779 * 6-channel independent captures.
4780 *
4781 * In addition, an independent DAC for the multi-playback (not used in this
4782 * driver yet).
4783 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004784#define ALC882_DIGOUT_NID 0x06
4785#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004786
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004787static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004788 { 8, NULL }
4789};
4790
4791static hda_nid_t alc882_dac_nids[4] = {
4792 /* front, rear, clfe, rear_surr */
4793 0x02, 0x03, 0x04, 0x05
4794};
4795
Kailang Yangdf694da2005-12-05 19:42:22 +01004796/* identical with ALC880 */
4797#define alc882_adc_nids alc880_adc_nids
4798#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004799
4800/* input MUX */
4801/* FIXME: should be a matrix-type input source selection */
4802
4803static struct hda_input_mux alc882_capture_source = {
4804 .num_items = 4,
4805 .items = {
4806 { "Mic", 0x0 },
4807 { "Front Mic", 0x1 },
4808 { "Line", 0x2 },
4809 { "CD", 0x4 },
4810 },
4811};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812#define alc882_mux_enum_info alc_mux_enum_info
4813#define alc882_mux_enum_get alc_mux_enum_get
4814
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004815static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4816 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004817{
4818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4819 struct alc_spec *spec = codec->spec;
4820 const struct hda_input_mux *imux = spec->input_mux;
4821 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4822 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4823 hda_nid_t nid = capture_mixers[adc_idx];
4824 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4825 unsigned int i, idx;
4826
4827 idx = ucontrol->value.enumerated.item[0];
4828 if (idx >= imux->num_items)
4829 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004830 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831 return 0;
4832 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02004833 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4834 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004835 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02004836 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004837 }
4838 *cur_val = idx;
4839 return 1;
4840}
4841
Kailang Yangdf694da2005-12-05 19:42:22 +01004842/*
Kailang Yang272a5272007-05-14 11:00:38 +02004843 * 2ch mode
4844 */
4845static struct hda_verb alc882_3ST_ch2_init[] = {
4846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4850 { } /* end */
4851};
4852
4853/*
4854 * 6ch mode
4855 */
4856static struct hda_verb alc882_3ST_ch6_init[] = {
4857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4859 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4862 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4863 { } /* end */
4864};
4865
4866static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4867 { 2, alc882_3ST_ch2_init },
4868 { 6, alc882_3ST_ch6_init },
4869};
4870
4871/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004872 * 6ch mode
4873 */
4874static struct hda_verb alc882_sixstack_ch6_init[] = {
4875 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4876 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4877 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4879 { } /* end */
4880};
4881
4882/*
4883 * 8ch mode
4884 */
4885static struct hda_verb alc882_sixstack_ch8_init[] = {
4886 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4887 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4888 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4889 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4890 { } /* end */
4891};
4892
4893static struct hda_channel_mode alc882_sixstack_modes[2] = {
4894 { 6, alc882_sixstack_ch6_init },
4895 { 8, alc882_sixstack_ch8_init },
4896};
4897
Linus Torvalds1da177e2005-04-16 15:20:36 -07004898/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4899 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4900 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004901static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004903 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004904 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004905 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004906 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4907 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004908 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4909 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004910 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004921 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004922 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4923 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4924 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004925 { } /* end */
4926};
4927
Kailang Yangbdd148a2007-05-08 15:19:08 +02004928static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4938 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4939 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4940 { } /* end */
4941};
4942
Kailang Yang272a5272007-05-14 11:00:38 +02004943static struct snd_kcontrol_new alc882_targa_mixer[] = {
4944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4955 { } /* end */
4956};
4957
4958/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4959 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4960 */
4961static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4963 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4965 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4971 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4974 { } /* end */
4975};
4976
Kailang Yangdf694da2005-12-05 19:42:22 +01004977static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4978 {
4979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4980 .name = "Channel Mode",
4981 .info = alc_ch_mode_info,
4982 .get = alc_ch_mode_get,
4983 .put = alc_ch_mode_put,
4984 },
4985 { } /* end */
4986};
4987
Linus Torvalds1da177e2005-04-16 15:20:36 -07004988static struct hda_verb alc882_init_verbs[] = {
4989 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004993 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005001 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005006 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005010 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005018 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005022 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5025 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5028 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5031 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005035 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005037
5038 /* FIXME: use matrix-type input source selection */
5039 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5040 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5049 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005050 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5055 /* ADC1: mute amp left and right */
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005058 /* ADC2: mute amp left and right */
5059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005061 /* ADC3: mute amp left and right */
5062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005063 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005064
5065 { }
5066};
5067
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005068static struct hda_verb alc882_eapd_verbs[] = {
5069 /* change to EAPD mode */
5070 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005071 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005072 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005073};
5074
Tobin Davis9102cd12006-12-15 10:02:12 +01005075/* Mac Pro test */
5076static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5084 { } /* end */
5085};
5086
5087static struct hda_verb alc882_macpro_init_verbs[] = {
5088 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5092 /* Front Pin: output 0 (0x0c) */
5093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5096 /* Front Mic pin: input vref at 80% */
5097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5099 /* Speaker: output */
5100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5102 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5103 /* Headphone output (output 0 - 0x0c) */
5104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5106 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5107
5108 /* FIXME: use matrix-type input source selection */
5109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5110 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5115 /* Input mixer2 */
5116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5120 /* Input mixer3 */
5121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5125 /* ADC1: mute amp left and right */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5128 /* ADC2: mute amp left and right */
5129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5130 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5131 /* ADC3: mute amp left and right */
5132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5133 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5134
5135 { }
5136};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005137
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005138/* iMac 24 mixer. */
5139static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5140 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5141 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5142 { } /* end */
5143};
5144
5145/* iMac 24 init verbs. */
5146static struct hda_verb alc885_imac24_init_verbs[] = {
5147 /* Internal speakers: output 0 (0x0c) */
5148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5149 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5150 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5151 /* Internal speakers: output 0 (0x0c) */
5152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5154 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5155 /* Headphone: output 0 (0x0c) */
5156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5158 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5159 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5160 /* Front Mic: input vref at 80% */
5161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5163 { }
5164};
5165
5166/* Toggle speaker-output according to the hp-jack state */
5167static void alc885_imac24_automute(struct hda_codec *codec)
5168{
5169 unsigned int present;
5170
5171 present = snd_hda_codec_read(codec, 0x14, 0,
5172 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005173 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5174 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5175 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5176 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005177}
5178
5179/* Processes unsolicited events. */
5180static void alc885_imac24_unsol_event(struct hda_codec *codec,
5181 unsigned int res)
5182{
5183 /* Headphone insertion or removal. */
5184 if ((res >> 26) == ALC880_HP_EVENT)
5185 alc885_imac24_automute(codec);
5186}
5187
Kailang Yang272a5272007-05-14 11:00:38 +02005188static struct hda_verb alc882_targa_verbs[] = {
5189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5191
5192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5194
5195 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5196 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5197 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5198
5199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5200 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5201 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5202 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5203 { } /* end */
5204};
5205
5206/* toggle speaker-output according to the hp-jack state */
5207static void alc882_targa_automute(struct hda_codec *codec)
5208{
5209 unsigned int present;
5210
5211 present = snd_hda_codec_read(codec, 0x14, 0,
5212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005213 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5214 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005215 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5216 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005217}
5218
5219static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5220{
5221 /* Looks like the unsol event is incompatible with the standard
5222 * definition. 4bit tag is placed at 26 bit!
5223 */
5224 if (((res >> 26) == ALC880_HP_EVENT)) {
5225 alc882_targa_automute(codec);
5226 }
5227}
5228
5229static struct hda_verb alc882_asus_a7j_verbs[] = {
5230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5232
5233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5235 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5236
5237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5239 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5240
5241 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5242 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5243 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5244 { } /* end */
5245};
5246
Tobin Davis9102cd12006-12-15 10:02:12 +01005247static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5248{
5249 unsigned int gpiostate, gpiomask, gpiodir;
5250
5251 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5252 AC_VERB_GET_GPIO_DATA, 0);
5253
5254 if (!muted)
5255 gpiostate |= (1 << pin);
5256 else
5257 gpiostate &= ~(1 << pin);
5258
5259 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5260 AC_VERB_GET_GPIO_MASK, 0);
5261 gpiomask |= (1 << pin);
5262
5263 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5264 AC_VERB_GET_GPIO_DIRECTION, 0);
5265 gpiodir |= (1 << pin);
5266
5267
5268 snd_hda_codec_write(codec, codec->afg, 0,
5269 AC_VERB_SET_GPIO_MASK, gpiomask);
5270 snd_hda_codec_write(codec, codec->afg, 0,
5271 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5272
5273 msleep(1);
5274
5275 snd_hda_codec_write(codec, codec->afg, 0,
5276 AC_VERB_SET_GPIO_DATA, gpiostate);
5277}
5278
Kailang Yangdf694da2005-12-05 19:42:22 +01005279/*
5280 * generic initialization of ADC, input mixers and output mixers
5281 */
5282static struct hda_verb alc882_auto_init_verbs[] = {
5283 /*
5284 * Unmute ADC0-2 and set the default input to mic-in
5285 */
5286 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5288 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5290 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5292
Takashi Iwaicb53c622007-08-10 17:21:45 +02005293 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005294 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005295 * Note: PASD motherboards uses the Line In 2 as the input for
5296 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005297 */
5298 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005304
5305 /*
5306 * Set up output mixers (0x0c - 0x0f)
5307 */
5308 /* set vol=0 to output mixers */
5309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5313 /* set up input amps for analog loopback */
5314 /* Amp Indices: DAC = 0, mixer = 1 */
5315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5322 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5323 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5324 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5325
5326 /* FIXME: use matrix-type input source selection */
5327 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5328 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5333 /* Input mixer2 */
5334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5338 /* Input mixer3 */
5339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5343
5344 { }
5345};
5346
5347/* capture mixer elements */
5348static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5349 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5350 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5351 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5352 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5353 {
5354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5355 /* The multiple "Capture Source" controls confuse alsamixer
5356 * So call somewhat different..
5357 * FIXME: the controls appear in the "playback" view!
5358 */
5359 /* .name = "Capture Source", */
5360 .name = "Input Source",
5361 .count = 2,
5362 .info = alc882_mux_enum_info,
5363 .get = alc882_mux_enum_get,
5364 .put = alc882_mux_enum_put,
5365 },
5366 { } /* end */
5367};
5368
5369static struct snd_kcontrol_new alc882_capture_mixer[] = {
5370 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5371 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5372 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5373 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5374 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5375 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5376 {
5377 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5378 /* The multiple "Capture Source" controls confuse alsamixer
5379 * So call somewhat different..
5380 * FIXME: the controls appear in the "playback" view!
5381 */
5382 /* .name = "Capture Source", */
5383 .name = "Input Source",
5384 .count = 3,
5385 .info = alc882_mux_enum_info,
5386 .get = alc882_mux_enum_get,
5387 .put = alc882_mux_enum_put,
5388 },
5389 { } /* end */
5390};
5391
Takashi Iwaicb53c622007-08-10 17:21:45 +02005392#ifdef CONFIG_SND_HDA_POWER_SAVE
5393#define alc882_loopbacks alc880_loopbacks
5394#endif
5395
Kailang Yangdf694da2005-12-05 19:42:22 +01005396/* pcm configuration: identiacal with ALC880 */
5397#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5398#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5399#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5400#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5401
5402/*
5403 * configuration and preset
5404 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005405static const char *alc882_models[ALC882_MODEL_LAST] = {
5406 [ALC882_3ST_DIG] = "3stack-dig",
5407 [ALC882_6ST_DIG] = "6stack-dig",
5408 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005409 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005410 [ALC885_MACPRO] = "macpro",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005411 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005412 [ALC882_AUTO] = "auto",
5413};
5414
5415static struct snd_pci_quirk alc882_cfg_tbl[] = {
5416 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5417 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5418 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005419 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005420 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005421 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005422 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005423 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005424 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005425 {}
5426};
5427
5428static struct alc_config_preset alc882_presets[] = {
5429 [ALC882_3ST_DIG] = {
5430 .mixers = { alc882_base_mixer },
5431 .init_verbs = { alc882_init_verbs },
5432 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5433 .dac_nids = alc882_dac_nids,
5434 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005435 .dig_in_nid = ALC882_DIGIN_NID,
5436 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5437 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005438 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005439 .input_mux = &alc882_capture_source,
5440 },
5441 [ALC882_6ST_DIG] = {
5442 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5443 .init_verbs = { alc882_init_verbs },
5444 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5445 .dac_nids = alc882_dac_nids,
5446 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005447 .dig_in_nid = ALC882_DIGIN_NID,
5448 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5449 .channel_mode = alc882_sixstack_modes,
5450 .input_mux = &alc882_capture_source,
5451 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005452 [ALC882_ARIMA] = {
5453 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5454 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5455 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5456 .dac_nids = alc882_dac_nids,
5457 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5458 .channel_mode = alc882_sixstack_modes,
5459 .input_mux = &alc882_capture_source,
5460 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005461 [ALC882_W2JC] = {
5462 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5463 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5464 alc880_gpio1_init_verbs },
5465 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5466 .dac_nids = alc882_dac_nids,
5467 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5468 .channel_mode = alc880_threestack_modes,
5469 .need_dac_fix = 1,
5470 .input_mux = &alc882_capture_source,
5471 .dig_out_nid = ALC882_DIGOUT_NID,
5472 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005473 [ALC885_MACPRO] = {
5474 .mixers = { alc882_macpro_mixer },
5475 .init_verbs = { alc882_macpro_init_verbs },
5476 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5477 .dac_nids = alc882_dac_nids,
5478 .dig_out_nid = ALC882_DIGOUT_NID,
5479 .dig_in_nid = ALC882_DIGIN_NID,
5480 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5481 .channel_mode = alc882_ch_modes,
5482 .input_mux = &alc882_capture_source,
5483 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005484 [ALC885_IMAC24] = {
5485 .mixers = { alc885_imac24_mixer },
5486 .init_verbs = { alc885_imac24_init_verbs },
5487 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5488 .dac_nids = alc882_dac_nids,
5489 .dig_out_nid = ALC882_DIGOUT_NID,
5490 .dig_in_nid = ALC882_DIGIN_NID,
5491 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5492 .channel_mode = alc882_ch_modes,
5493 .input_mux = &alc882_capture_source,
5494 .unsol_event = alc885_imac24_unsol_event,
5495 .init_hook = alc885_imac24_automute,
5496 },
Kailang Yang272a5272007-05-14 11:00:38 +02005497 [ALC882_TARGA] = {
5498 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5499 alc882_capture_mixer },
5500 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5501 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5502 .dac_nids = alc882_dac_nids,
5503 .dig_out_nid = ALC882_DIGOUT_NID,
5504 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5505 .adc_nids = alc882_adc_nids,
5506 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5507 .channel_mode = alc882_3ST_6ch_modes,
5508 .need_dac_fix = 1,
5509 .input_mux = &alc882_capture_source,
5510 .unsol_event = alc882_targa_unsol_event,
5511 .init_hook = alc882_targa_automute,
5512 },
5513 [ALC882_ASUS_A7J] = {
5514 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5515 alc882_capture_mixer },
5516 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5517 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5518 .dac_nids = alc882_dac_nids,
5519 .dig_out_nid = ALC882_DIGOUT_NID,
5520 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5521 .adc_nids = alc882_adc_nids,
5522 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5523 .channel_mode = alc882_3ST_6ch_modes,
5524 .need_dac_fix = 1,
5525 .input_mux = &alc882_capture_source,
5526 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005527};
5528
5529
5530/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005531 * Pin config fixes
5532 */
5533enum {
5534 PINFIX_ABIT_AW9D_MAX
5535};
5536
5537static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5538 { 0x15, 0x01080104 }, /* side */
5539 { 0x16, 0x01011012 }, /* rear */
5540 { 0x17, 0x01016011 }, /* clfe */
5541 { }
5542};
5543
5544static const struct alc_pincfg *alc882_pin_fixes[] = {
5545 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5546};
5547
5548static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5549 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5550 {}
5551};
5552
5553/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005554 * BIOS auto configuration
5555 */
5556static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5557 hda_nid_t nid, int pin_type,
5558 int dac_idx)
5559{
5560 /* set as output */
5561 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005562 int idx;
5563
Kailang Yangdf694da2005-12-05 19:42:22 +01005564 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5565 idx = 4;
5566 else
5567 idx = spec->multiout.dac_nids[dac_idx] - 2;
5568
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005569 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5570 pin_type);
5571 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5572 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005573 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5574
5575}
5576
5577static void alc882_auto_init_multi_out(struct hda_codec *codec)
5578{
5579 struct alc_spec *spec = codec->spec;
5580 int i;
5581
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005582 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005583 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005584 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005585 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005586 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005587 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005588 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005589 }
5590}
5591
5592static void alc882_auto_init_hp_out(struct hda_codec *codec)
5593{
5594 struct alc_spec *spec = codec->spec;
5595 hda_nid_t pin;
5596
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005597 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005598 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005599 /* use dac 0 */
5600 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005601}
5602
5603#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5604#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5605
5606static void alc882_auto_init_analog_input(struct hda_codec *codec)
5607{
5608 struct alc_spec *spec = codec->spec;
5609 int i;
5610
5611 for (i = 0; i < AUTO_PIN_LAST; i++) {
5612 hda_nid_t nid = spec->autocfg.input_pins[i];
5613 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005614 snd_hda_codec_write(codec, nid, 0,
5615 AC_VERB_SET_PIN_WIDGET_CONTROL,
5616 i <= AUTO_PIN_FRONT_MIC ?
5617 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005618 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005619 snd_hda_codec_write(codec, nid, 0,
5620 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005621 AMP_OUT_MUTE);
5622 }
5623 }
5624}
5625
5626/* almost identical with ALC880 parser... */
5627static int alc882_parse_auto_config(struct hda_codec *codec)
5628{
5629 struct alc_spec *spec = codec->spec;
5630 int err = alc880_parse_auto_config(codec);
5631
5632 if (err < 0)
5633 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005634 else if (err > 0)
5635 /* hack - override the init verbs */
5636 spec->init_verbs[0] = alc882_auto_init_verbs;
5637 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005638}
5639
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005640/* additional initialization for auto-configuration model */
5641static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005642{
Kailang Yangdf694da2005-12-05 19:42:22 +01005643 alc882_auto_init_multi_out(codec);
5644 alc882_auto_init_hp_out(codec);
5645 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005646}
5647
Linus Torvalds1da177e2005-04-16 15:20:36 -07005648static int patch_alc882(struct hda_codec *codec)
5649{
5650 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005651 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005652
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005653 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005654 if (spec == NULL)
5655 return -ENOMEM;
5656
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 codec->spec = spec;
5658
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005659 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5660 alc882_models,
5661 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005662
Kailang Yangdf694da2005-12-05 19:42:22 +01005663 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005664 /* Pick up systems that don't supply PCI SSID */
5665 switch (codec->subsystem_id) {
5666 case 0x106b0c00: /* Mac Pro */
5667 board_config = ALC885_MACPRO;
5668 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005669 case 0x106b1000: /* iMac 24 */
5670 board_config = ALC885_IMAC24;
5671 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005672 default:
5673 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5674 "trying auto-probe from BIOS...\n");
5675 board_config = ALC882_AUTO;
5676 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005677 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005678
Takashi Iwaif95474e2007-07-10 00:47:43 +02005679 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5680
Kailang Yangdf694da2005-12-05 19:42:22 +01005681 if (board_config == ALC882_AUTO) {
5682 /* automatic parse from the BIOS config */
5683 err = alc882_parse_auto_config(codec);
5684 if (err < 0) {
5685 alc_free(codec);
5686 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005687 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005688 printk(KERN_INFO
5689 "hda_codec: Cannot set up configuration "
5690 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005691 board_config = ALC882_3ST_DIG;
5692 }
5693 }
5694
5695 if (board_config != ALC882_AUTO)
5696 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005698 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
Tobin Davis9102cd12006-12-15 10:02:12 +01005699 alc882_gpio_mute(codec, 0, 0);
5700 alc882_gpio_mute(codec, 1, 0);
5701 }
5702
Linus Torvalds1da177e2005-04-16 15:20:36 -07005703 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5705 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706
5707 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5709 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005710
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005711 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005713 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005714 /* get type */
5715 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005716 if (wcap != AC_WID_AUD_IN) {
5717 spec->adc_nids = alc882_adc_nids_alt;
5718 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005719 spec->mixers[spec->num_mixers] =
5720 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005721 spec->num_mixers++;
5722 } else {
5723 spec->adc_nids = alc882_adc_nids;
5724 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5725 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5726 spec->num_mixers++;
5727 }
5728 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005729
5730 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005732 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005733#ifdef CONFIG_SND_HDA_POWER_SAVE
5734 if (!spec->loopback.amplist)
5735 spec->loopback.amplist = alc882_loopbacks;
5736#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737
5738 return 0;
5739}
5740
5741/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005742 * ALC883 support
5743 *
5744 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5745 * configuration. Each pin widget can choose any input DACs and a mixer.
5746 * Each ADC is connected from a mixer of all inputs. This makes possible
5747 * 6-channel independent captures.
5748 *
5749 * In addition, an independent DAC for the multi-playback (not used in this
5750 * driver yet).
5751 */
5752#define ALC883_DIGOUT_NID 0x06
5753#define ALC883_DIGIN_NID 0x0a
5754
5755static hda_nid_t alc883_dac_nids[4] = {
5756 /* front, rear, clfe, rear_surr */
5757 0x02, 0x04, 0x03, 0x05
5758};
5759
5760static hda_nid_t alc883_adc_nids[2] = {
5761 /* ADC1-2 */
5762 0x08, 0x09,
5763};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005764
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005765/* input MUX */
5766/* FIXME: should be a matrix-type input source selection */
5767
5768static struct hda_input_mux alc883_capture_source = {
5769 .num_items = 4,
5770 .items = {
5771 { "Mic", 0x0 },
5772 { "Front Mic", 0x1 },
5773 { "Line", 0x2 },
5774 { "CD", 0x4 },
5775 },
5776};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005777
5778static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5779 .num_items = 2,
5780 .items = {
5781 { "Mic", 0x1 },
5782 { "Line", 0x2 },
5783 },
5784};
5785
Kailang Yang272a5272007-05-14 11:00:38 +02005786static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5787 .num_items = 4,
5788 .items = {
5789 { "Mic", 0x0 },
5790 { "iMic", 0x1 },
5791 { "Line", 0x2 },
5792 { "CD", 0x4 },
5793 },
5794};
5795
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005796#define alc883_mux_enum_info alc_mux_enum_info
5797#define alc883_mux_enum_get alc_mux_enum_get
5798
5799static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5800 struct snd_ctl_elem_value *ucontrol)
5801{
5802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5803 struct alc_spec *spec = codec->spec;
5804 const struct hda_input_mux *imux = spec->input_mux;
5805 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5806 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5807 hda_nid_t nid = capture_mixers[adc_idx];
5808 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5809 unsigned int i, idx;
5810
5811 idx = ucontrol->value.enumerated.item[0];
5812 if (idx >= imux->num_items)
5813 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005814 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005815 return 0;
5816 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005817 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5818 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005819 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005820 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005821 }
5822 *cur_val = idx;
5823 return 1;
5824}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005825
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005826/*
5827 * 2ch mode
5828 */
5829static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5830 { 2, NULL }
5831};
5832
5833/*
5834 * 2ch mode
5835 */
5836static struct hda_verb alc883_3ST_ch2_init[] = {
5837 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5838 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5841 { } /* end */
5842};
5843
5844/*
5845 * 6ch mode
5846 */
5847static struct hda_verb alc883_3ST_ch6_init[] = {
5848 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5849 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5850 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5853 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5854 { } /* end */
5855};
5856
5857static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5858 { 2, alc883_3ST_ch2_init },
5859 { 6, alc883_3ST_ch6_init },
5860};
5861
5862/*
5863 * 6ch mode
5864 */
5865static struct hda_verb alc883_sixstack_ch6_init[] = {
5866 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5867 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5868 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5869 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5870 { } /* end */
5871};
5872
5873/*
5874 * 8ch mode
5875 */
5876static struct hda_verb alc883_sixstack_ch8_init[] = {
5877 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5878 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5879 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5880 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5881 { } /* end */
5882};
5883
5884static struct hda_channel_mode alc883_sixstack_modes[2] = {
5885 { 6, alc883_sixstack_ch6_init },
5886 { 8, alc883_sixstack_ch8_init },
5887};
5888
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005889static struct hda_verb alc883_medion_eapd_verbs[] = {
5890 /* eanable EAPD on medion laptop */
5891 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5892 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5893 { }
5894};
5895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005896/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5897 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5898 */
5899
5900static struct snd_kcontrol_new alc883_base_mixer[] = {
5901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5902 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5903 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5904 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5905 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5906 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5907 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5908 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5909 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5910 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5912 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5913 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5914 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5915 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005917 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5919 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005920 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005921 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5922 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5923 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5924 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5925 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5926 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5927 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5928 {
5929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5930 /* .name = "Capture Source", */
5931 .name = "Input Source",
5932 .count = 2,
5933 .info = alc883_mux_enum_info,
5934 .get = alc883_mux_enum_get,
5935 .put = alc883_mux_enum_put,
5936 },
5937 { } /* end */
5938};
5939
5940static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5941 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5942 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5946 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5947 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005950 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005952 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5954 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5955 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5957 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5958 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5959 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5960 {
5961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5962 /* .name = "Capture Source", */
5963 .name = "Input Source",
5964 .count = 2,
5965 .info = alc883_mux_enum_info,
5966 .get = alc883_mux_enum_get,
5967 .put = alc883_mux_enum_put,
5968 },
5969 { } /* end */
5970};
5971
5972static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5976 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005990 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5992 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5993 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5994 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5995 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5996 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5997 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5998 {
5999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6000 /* .name = "Capture Source", */
6001 .name = "Input Source",
6002 .count = 2,
6003 .info = alc883_mux_enum_info,
6004 .get = alc883_mux_enum_get,
6005 .put = alc883_mux_enum_put,
6006 },
6007 { } /* end */
6008};
6009
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006010static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006011 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6012 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6013 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6014 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6015 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6017 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6018 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006025 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6030 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6031 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6032 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6033 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6034
6035 {
6036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6037 /* .name = "Capture Source", */
6038 .name = "Input Source",
6039 .count = 1,
6040 .info = alc883_mux_enum_info,
6041 .get = alc883_mux_enum_get,
6042 .put = alc883_mux_enum_put,
6043 },
6044 { } /* end */
6045};
6046
Kailang Yangccc656c2006-10-17 12:32:26 +02006047static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6050 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6052 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6055 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6056 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6064 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6065 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6066 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6067 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6068 {
6069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6070 /* .name = "Capture Source", */
6071 .name = "Input Source",
6072 .count = 2,
6073 .info = alc883_mux_enum_info,
6074 .get = alc883_mux_enum_get,
6075 .put = alc883_mux_enum_put,
6076 },
6077 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006078};
Kailang Yangccc656c2006-10-17 12:32:26 +02006079
6080static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6083 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6084 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6085 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6089 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6090 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6091 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6092 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6093 {
6094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6095 /* .name = "Capture Source", */
6096 .name = "Input Source",
6097 .count = 2,
6098 .info = alc883_mux_enum_info,
6099 .get = alc883_mux_enum_get,
6100 .put = alc883_mux_enum_put,
6101 },
6102 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006103};
Kailang Yangccc656c2006-10-17 12:32:26 +02006104
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006105static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6106 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6107 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6108 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6109 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6112 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6116 {
6117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6118 /* .name = "Capture Source", */
6119 .name = "Input Source",
6120 .count = 1,
6121 .info = alc883_mux_enum_info,
6122 .get = alc883_mux_enum_get,
6123 .put = alc883_mux_enum_put,
6124 },
6125 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006126};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006127
Kailang Yang272a5272007-05-14 11:00:38 +02006128static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6129 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6130 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6136 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6137 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6138 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6139 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6140 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6142 {
6143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6144 /* .name = "Capture Source", */
6145 .name = "Input Source",
6146 .count = 2,
6147 .info = alc883_mux_enum_info,
6148 .get = alc883_mux_enum_get,
6149 .put = alc883_mux_enum_put,
6150 },
6151 { } /* end */
6152};
6153
6154static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6155 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6157 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6164 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6165 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6166 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6167 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6168 {
6169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6170 /* .name = "Capture Source", */
6171 .name = "Input Source",
6172 .count = 2,
6173 .info = alc883_mux_enum_info,
6174 .get = alc883_mux_enum_get,
6175 .put = alc883_mux_enum_put,
6176 },
6177 { } /* end */
6178};
6179
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006180static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6182 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6183 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6184 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6185 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6186 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6187 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6188 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6189 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6190 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6200 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6201 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6202 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6203 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6204 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6205 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6206 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6207 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6208 {
6209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6210 /* .name = "Capture Source", */
6211 .name = "Input Source",
6212 .count = 2,
6213 .info = alc883_mux_enum_info,
6214 .get = alc883_mux_enum_get,
6215 .put = alc883_mux_enum_put,
6216 },
6217 { } /* end */
6218};
6219
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006220static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6222 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6223 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6224 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6225 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6226 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6227 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6228 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6229 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6237 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6238 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6240 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6241 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6243 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6244 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6245 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6246 {
6247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6248 /* .name = "Capture Source", */
6249 .name = "Input Source",
6250 .count = 2,
6251 .info = alc883_mux_enum_info,
6252 .get = alc883_mux_enum_get,
6253 .put = alc883_mux_enum_put,
6254 },
6255 { } /* end */
6256};
6257
Tobin Davis2880a862007-08-07 11:50:26 +02006258static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006267 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6268 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6269 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6270 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6271 {
6272 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6273 /* .name = "Capture Source", */
6274 .name = "Input Source",
6275 .count = 2,
6276 .info = alc883_mux_enum_info,
6277 .get = alc883_mux_enum_get,
6278 .put = alc883_mux_enum_put,
6279 },
6280 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006281};
Tobin Davis2880a862007-08-07 11:50:26 +02006282
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006283static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6284 {
6285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6286 .name = "Channel Mode",
6287 .info = alc_ch_mode_info,
6288 .get = alc_ch_mode_get,
6289 .put = alc_ch_mode_put,
6290 },
6291 { } /* end */
6292};
6293
6294static struct hda_verb alc883_init_verbs[] = {
6295 /* ADC1: mute amp left and right */
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6297 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6298 /* ADC2: mute amp left and right */
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6301 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6305 /* Rear mixer */
6306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6309 /* CLFE mixer */
6310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6313 /* Side mixer */
6314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6317
Takashi Iwaicb53c622007-08-10 17:21:45 +02006318 /* mute analog input loopbacks */
6319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006324
6325 /* Front Pin: output 0 (0x0c) */
6326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6329 /* Rear Pin: output 1 (0x0d) */
6330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6333 /* CLFE Pin: output 2 (0x0e) */
6334 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6335 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6336 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6337 /* Side Pin: output 3 (0x0f) */
6338 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6339 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6340 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6341 /* Mic (rear) pin: input vref at 80% */
6342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6344 /* Front Mic pin: input vref at 80% */
6345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6347 /* Line In pin: input */
6348 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6349 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6350 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6351 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6352 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6353 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 /* CD pin widget for input */
6355 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6356
6357 /* FIXME: use matrix-type input source selection */
6358 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6359 /* Input mixer2 */
6360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6361 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6364 /* Input mixer3 */
6365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6369 { }
6370};
6371
Kailang Yangccc656c2006-10-17 12:32:26 +02006372static struct hda_verb alc883_tagra_verbs[] = {
6373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6375
6376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6378
6379 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6380 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6381 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6382
6383 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006384 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6385 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6386 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006387
6388 { } /* end */
6389};
6390
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006391static struct hda_verb alc883_lenovo_101e_verbs[] = {
6392 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6393 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6394 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6395 { } /* end */
6396};
6397
Kailang Yang272a5272007-05-14 11:00:38 +02006398static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6399 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6400 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6401 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6403 { } /* end */
6404};
6405
6406static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6410 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6411 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6412 { } /* end */
6413};
6414
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006415static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006416 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6417 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6418 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6419 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6420 { }
6421};
6422
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006423static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006424 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6425 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6426 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6427 { }
6428};
6429
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006430static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006431 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6432 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6433 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6434 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6435 { }
6436};
6437
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006438static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6441 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6442 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6443 { }
6444};
6445
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006446static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6447 { 2, alc888_3st_hp_2ch_init },
6448 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006449};
6450
Kailang Yang272a5272007-05-14 11:00:38 +02006451/* toggle front-jack and RCA according to the hp-jack state */
6452static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6453{
6454 unsigned int present;
6455
6456 present = snd_hda_codec_read(codec, 0x1b, 0,
6457 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006458 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6459 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6460 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006462}
6463
6464/* toggle RCA according to the front-jack state */
6465static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6466{
6467 unsigned int present;
6468
6469 present = snd_hda_codec_read(codec, 0x14, 0,
6470 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006471 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6472 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006473}
Takashi Iwai47fd8302007-08-10 17:11:07 +02006474
Kailang Yang272a5272007-05-14 11:00:38 +02006475static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6476 unsigned int res)
6477{
6478 if ((res >> 26) == ALC880_HP_EVENT)
6479 alc888_lenovo_ms7195_front_automute(codec);
6480 if ((res >> 26) == ALC880_FRONT_EVENT)
6481 alc888_lenovo_ms7195_rca_automute(codec);
6482}
6483
6484static struct hda_verb alc883_medion_md2_verbs[] = {
6485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6487
6488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6489
6490 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6491 { } /* end */
6492};
6493
6494/* toggle speaker-output according to the hp-jack state */
6495static void alc883_medion_md2_automute(struct hda_codec *codec)
6496{
6497 unsigned int present;
6498
6499 present = snd_hda_codec_read(codec, 0x14, 0,
6500 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006501 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6502 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006503}
6504
6505static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6506 unsigned int res)
6507{
6508 if ((res >> 26) == ALC880_HP_EVENT)
6509 alc883_medion_md2_automute(codec);
6510}
6511
Kailang Yangccc656c2006-10-17 12:32:26 +02006512/* toggle speaker-output according to the hp-jack state */
6513static void alc883_tagra_automute(struct hda_codec *codec)
6514{
6515 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006516 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006517
6518 present = snd_hda_codec_read(codec, 0x14, 0,
6519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006520 bits = present ? HDA_AMP_MUTE : 0;
6521 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6522 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006523 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6524 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006525}
6526
6527static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6528{
6529 if ((res >> 26) == ALC880_HP_EVENT)
6530 alc883_tagra_automute(codec);
6531}
6532
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006533static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6534{
6535 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006536 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006537
6538 present = snd_hda_codec_read(codec, 0x14, 0,
6539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006540 bits = present ? HDA_AMP_MUTE : 0;
6541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6542 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006543}
6544
6545static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6546{
6547 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006548 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006549
6550 present = snd_hda_codec_read(codec, 0x1b, 0,
6551 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006552 bits = present ? HDA_AMP_MUTE : 0;
6553 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6554 HDA_AMP_MUTE, bits);
6555 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6556 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006557}
6558
6559static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6560 unsigned int res)
6561{
6562 if ((res >> 26) == ALC880_HP_EVENT)
6563 alc883_lenovo_101e_all_automute(codec);
6564 if ((res >> 26) == ALC880_FRONT_EVENT)
6565 alc883_lenovo_101e_ispeaker_automute(codec);
6566}
6567
Kailang Yangd1a991a2007-08-15 16:21:59 +02006568static struct hda_verb alc883_acer_eapd_verbs[] = {
6569 /* HP Pin: output 0 (0x0c) */
6570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6571 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6572 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6573 /* Front Pin: output 0 (0x0c) */
6574 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6575 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6576 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6577 /* eanable EAPD on medion laptop */
6578 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6579 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
6580 { }
6581};
6582
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006583/*
6584 * generic initialization of ADC, input mixers and output mixers
6585 */
6586static struct hda_verb alc883_auto_init_verbs[] = {
6587 /*
6588 * Unmute ADC0-2 and set the default input to mic-in
6589 */
6590 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6591 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6594
Takashi Iwaicb53c622007-08-10 17:21:45 +02006595 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006596 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006597 * Note: PASD motherboards uses the Line In 2 as the input for
6598 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006599 */
6600 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006606
6607 /*
6608 * Set up output mixers (0x0c - 0x0f)
6609 */
6610 /* set vol=0 to output mixers */
6611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6613 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6615 /* set up input amps for analog loopback */
6616 /* Amp Indices: DAC = 0, mixer = 1 */
6617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6625 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6626 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6627
6628 /* FIXME: use matrix-type input source selection */
6629 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6630 /* Input mixer1 */
6631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006634 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6636 /* Input mixer2 */
6637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006640 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006641 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6642
6643 { }
6644};
6645
6646/* capture mixer elements */
6647static struct snd_kcontrol_new alc883_capture_mixer[] = {
6648 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6649 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6650 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6651 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6652 {
6653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6654 /* The multiple "Capture Source" controls confuse alsamixer
6655 * So call somewhat different..
6656 * FIXME: the controls appear in the "playback" view!
6657 */
6658 /* .name = "Capture Source", */
6659 .name = "Input Source",
6660 .count = 2,
6661 .info = alc882_mux_enum_info,
6662 .get = alc882_mux_enum_get,
6663 .put = alc882_mux_enum_put,
6664 },
6665 { } /* end */
6666};
6667
Takashi Iwaicb53c622007-08-10 17:21:45 +02006668#ifdef CONFIG_SND_HDA_POWER_SAVE
6669#define alc883_loopbacks alc880_loopbacks
6670#endif
6671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006672/* pcm configuration: identiacal with ALC880 */
6673#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6674#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6675#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6676#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6677
6678/*
6679 * configuration and preset
6680 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006681static const char *alc883_models[ALC883_MODEL_LAST] = {
6682 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6683 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6684 [ALC883_3ST_6ch] = "3stack-6ch",
6685 [ALC883_6ST_DIG] = "6stack-dig",
6686 [ALC883_TARGA_DIG] = "targa-dig",
6687 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006688 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02006689 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006690 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006691 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006692 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006693 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006694 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6695 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006696 [ALC888_6ST_HP] = "6stack-hp",
6697 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006698 [ALC883_AUTO] = "auto",
6699};
6700
6701static struct snd_pci_quirk alc883_cfg_tbl[] = {
6702 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006703 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006704 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6705 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6706 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006707 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006708 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6709 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006710 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006711 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006712 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006713 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006714 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006715 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006716 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6717 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6718 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6719 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6720 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6721 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6722 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6723 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6724 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006725 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Tobin Davis2880a862007-08-07 11:50:26 +02006726 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006727 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006728 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006729 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6730 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6731 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006732 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6733 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6734 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006735 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6736 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6737 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006738 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006739 {}
6740};
6741
6742static struct alc_config_preset alc883_presets[] = {
6743 [ALC883_3ST_2ch_DIG] = {
6744 .mixers = { alc883_3ST_2ch_mixer },
6745 .init_verbs = { alc883_init_verbs },
6746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6747 .dac_nids = alc883_dac_nids,
6748 .dig_out_nid = ALC883_DIGOUT_NID,
6749 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6750 .adc_nids = alc883_adc_nids,
6751 .dig_in_nid = ALC883_DIGIN_NID,
6752 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6753 .channel_mode = alc883_3ST_2ch_modes,
6754 .input_mux = &alc883_capture_source,
6755 },
6756 [ALC883_3ST_6ch_DIG] = {
6757 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6758 .init_verbs = { alc883_init_verbs },
6759 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6760 .dac_nids = alc883_dac_nids,
6761 .dig_out_nid = ALC883_DIGOUT_NID,
6762 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6763 .adc_nids = alc883_adc_nids,
6764 .dig_in_nid = ALC883_DIGIN_NID,
6765 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6766 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006767 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006768 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006769 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006770 [ALC883_3ST_6ch] = {
6771 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6772 .init_verbs = { alc883_init_verbs },
6773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6774 .dac_nids = alc883_dac_nids,
6775 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6776 .adc_nids = alc883_adc_nids,
6777 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6778 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006779 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006780 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006781 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006782 [ALC883_6ST_DIG] = {
6783 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6784 .init_verbs = { alc883_init_verbs },
6785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6786 .dac_nids = alc883_dac_nids,
6787 .dig_out_nid = ALC883_DIGOUT_NID,
6788 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6789 .adc_nids = alc883_adc_nids,
6790 .dig_in_nid = ALC883_DIGIN_NID,
6791 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6792 .channel_mode = alc883_sixstack_modes,
6793 .input_mux = &alc883_capture_source,
6794 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006795 [ALC883_TARGA_DIG] = {
6796 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6797 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6798 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6799 .dac_nids = alc883_dac_nids,
6800 .dig_out_nid = ALC883_DIGOUT_NID,
6801 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6802 .adc_nids = alc883_adc_nids,
6803 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6804 .channel_mode = alc883_3ST_6ch_modes,
6805 .need_dac_fix = 1,
6806 .input_mux = &alc883_capture_source,
6807 .unsol_event = alc883_tagra_unsol_event,
6808 .init_hook = alc883_tagra_automute,
6809 },
6810 [ALC883_TARGA_2ch_DIG] = {
6811 .mixers = { alc883_tagra_2ch_mixer},
6812 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6813 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6814 .dac_nids = alc883_dac_nids,
6815 .dig_out_nid = ALC883_DIGOUT_NID,
6816 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6817 .adc_nids = alc883_adc_nids,
6818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6819 .channel_mode = alc883_3ST_2ch_modes,
6820 .input_mux = &alc883_capture_source,
6821 .unsol_event = alc883_tagra_unsol_event,
6822 .init_hook = alc883_tagra_automute,
6823 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006824 [ALC883_ACER] = {
6825 .mixers = { alc883_base_mixer,
6826 alc883_chmode_mixer },
6827 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6828 * and the headphone jack. Turn this on and rely on the
6829 * standard mute methods whenever the user wants to turn
6830 * these outputs off.
6831 */
6832 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6833 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6834 .dac_nids = alc883_dac_nids,
6835 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6836 .adc_nids = alc883_adc_nids,
6837 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6838 .channel_mode = alc883_3ST_2ch_modes,
6839 .input_mux = &alc883_capture_source,
6840 },
Tobin Davis2880a862007-08-07 11:50:26 +02006841 [ALC883_ACER_ASPIRE] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006842 .mixers = { alc883_acer_aspire_mixer, alc883_chmode_mixer },
6843 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6844 * and the headphone jack. Turn this on and rely on the
6845 * standard mute methods whenever the user wants to turn
6846 * these outputs off.
6847 */
6848 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02006849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6850 .dac_nids = alc883_dac_nids,
6851 .dig_out_nid = ALC883_DIGOUT_NID,
6852 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6853 .adc_nids = alc883_adc_nids,
6854 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6855 .channel_mode = alc883_3ST_2ch_modes,
6856 .input_mux = &alc883_capture_source,
Kailang Yangd1a991a2007-08-15 16:21:59 +02006857 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006858 [ALC883_MEDION] = {
6859 .mixers = { alc883_fivestack_mixer,
6860 alc883_chmode_mixer },
6861 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006862 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006863 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6864 .dac_nids = alc883_dac_nids,
6865 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6866 .adc_nids = alc883_adc_nids,
6867 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6868 .channel_mode = alc883_sixstack_modes,
6869 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006870 },
Kailang Yang272a5272007-05-14 11:00:38 +02006871 [ALC883_MEDION_MD2] = {
6872 .mixers = { alc883_medion_md2_mixer},
6873 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6875 .dac_nids = alc883_dac_nids,
6876 .dig_out_nid = ALC883_DIGOUT_NID,
6877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6878 .adc_nids = alc883_adc_nids,
6879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6880 .channel_mode = alc883_3ST_2ch_modes,
6881 .input_mux = &alc883_capture_source,
6882 .unsol_event = alc883_medion_md2_unsol_event,
6883 .init_hook = alc883_medion_md2_automute,
6884 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006885 [ALC883_LAPTOP_EAPD] = {
6886 .mixers = { alc883_base_mixer,
6887 alc883_chmode_mixer },
6888 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6889 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6890 .dac_nids = alc883_dac_nids,
6891 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6892 .adc_nids = alc883_adc_nids,
6893 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6894 .channel_mode = alc883_3ST_2ch_modes,
6895 .input_mux = &alc883_capture_source,
6896 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006897 [ALC883_LENOVO_101E_2ch] = {
6898 .mixers = { alc883_lenovo_101e_2ch_mixer},
6899 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6900 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6901 .dac_nids = alc883_dac_nids,
6902 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6903 .adc_nids = alc883_adc_nids,
6904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6905 .channel_mode = alc883_3ST_2ch_modes,
6906 .input_mux = &alc883_lenovo_101e_capture_source,
6907 .unsol_event = alc883_lenovo_101e_unsol_event,
6908 .init_hook = alc883_lenovo_101e_all_automute,
6909 },
Kailang Yang272a5272007-05-14 11:00:38 +02006910 [ALC883_LENOVO_NB0763] = {
6911 .mixers = { alc883_lenovo_nb0763_mixer },
6912 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6913 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6914 .dac_nids = alc883_dac_nids,
6915 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6916 .adc_nids = alc883_adc_nids,
6917 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6918 .channel_mode = alc883_3ST_2ch_modes,
6919 .need_dac_fix = 1,
6920 .input_mux = &alc883_lenovo_nb0763_capture_source,
6921 .unsol_event = alc883_medion_md2_unsol_event,
6922 .init_hook = alc883_medion_md2_automute,
6923 },
6924 [ALC888_LENOVO_MS7195_DIG] = {
6925 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6926 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6927 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6928 .dac_nids = alc883_dac_nids,
6929 .dig_out_nid = ALC883_DIGOUT_NID,
6930 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6931 .adc_nids = alc883_adc_nids,
6932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6933 .channel_mode = alc883_3ST_6ch_modes,
6934 .need_dac_fix = 1,
6935 .input_mux = &alc883_capture_source,
6936 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6937 .init_hook = alc888_lenovo_ms7195_front_automute,
6938 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006939 [ALC888_6ST_HP] = {
6940 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6941 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006942 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6943 .dac_nids = alc883_dac_nids,
6944 .dig_out_nid = ALC883_DIGOUT_NID,
6945 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6946 .adc_nids = alc883_adc_nids,
6947 .dig_in_nid = ALC883_DIGIN_NID,
6948 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6949 .channel_mode = alc883_sixstack_modes,
6950 .input_mux = &alc883_capture_source,
6951 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006952 [ALC888_3ST_HP] = {
6953 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6954 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006955 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6956 .dac_nids = alc883_dac_nids,
6957 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6958 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006959 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6960 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006961 .need_dac_fix = 1,
6962 .input_mux = &alc883_capture_source,
6963 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006964};
6965
6966
6967/*
6968 * BIOS auto configuration
6969 */
6970static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6971 hda_nid_t nid, int pin_type,
6972 int dac_idx)
6973{
6974 /* set as output */
6975 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006976 int idx;
6977
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006978 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6979 idx = 4;
6980 else
6981 idx = spec->multiout.dac_nids[dac_idx] - 2;
6982
6983 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6984 pin_type);
6985 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6986 AMP_OUT_UNMUTE);
6987 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6988
6989}
6990
6991static void alc883_auto_init_multi_out(struct hda_codec *codec)
6992{
6993 struct alc_spec *spec = codec->spec;
6994 int i;
6995
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006996 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006997 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006998 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006999 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007000 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007001 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007002 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007003 }
7004}
7005
7006static void alc883_auto_init_hp_out(struct hda_codec *codec)
7007{
7008 struct alc_spec *spec = codec->spec;
7009 hda_nid_t pin;
7010
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007011 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007012 if (pin) /* connect to front */
7013 /* use dac 0 */
7014 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7015}
7016
7017#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7018#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7019
7020static void alc883_auto_init_analog_input(struct hda_codec *codec)
7021{
7022 struct alc_spec *spec = codec->spec;
7023 int i;
7024
7025 for (i = 0; i < AUTO_PIN_LAST; i++) {
7026 hda_nid_t nid = spec->autocfg.input_pins[i];
7027 if (alc883_is_input_pin(nid)) {
7028 snd_hda_codec_write(codec, nid, 0,
7029 AC_VERB_SET_PIN_WIDGET_CONTROL,
7030 (i <= AUTO_PIN_FRONT_MIC ?
7031 PIN_VREF80 : PIN_IN));
7032 if (nid != ALC883_PIN_CD_NID)
7033 snd_hda_codec_write(codec, nid, 0,
7034 AC_VERB_SET_AMP_GAIN_MUTE,
7035 AMP_OUT_MUTE);
7036 }
7037 }
7038}
7039
7040/* almost identical with ALC880 parser... */
7041static int alc883_parse_auto_config(struct hda_codec *codec)
7042{
7043 struct alc_spec *spec = codec->spec;
7044 int err = alc880_parse_auto_config(codec);
7045
7046 if (err < 0)
7047 return err;
7048 else if (err > 0)
7049 /* hack - override the init verbs */
7050 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007051 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7052 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007053 return err;
7054}
7055
7056/* additional initialization for auto-configuration model */
7057static void alc883_auto_init(struct hda_codec *codec)
7058{
7059 alc883_auto_init_multi_out(codec);
7060 alc883_auto_init_hp_out(codec);
7061 alc883_auto_init_analog_input(codec);
7062}
7063
7064static int patch_alc883(struct hda_codec *codec)
7065{
7066 struct alc_spec *spec;
7067 int err, board_config;
7068
7069 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7070 if (spec == NULL)
7071 return -ENOMEM;
7072
7073 codec->spec = spec;
7074
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007075 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7076 alc883_models,
7077 alc883_cfg_tbl);
7078 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007079 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7080 "trying auto-probe from BIOS...\n");
7081 board_config = ALC883_AUTO;
7082 }
7083
7084 if (board_config == ALC883_AUTO) {
7085 /* automatic parse from the BIOS config */
7086 err = alc883_parse_auto_config(codec);
7087 if (err < 0) {
7088 alc_free(codec);
7089 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007090 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007091 printk(KERN_INFO
7092 "hda_codec: Cannot set up configuration "
7093 "from BIOS. Using base mode...\n");
7094 board_config = ALC883_3ST_2ch_DIG;
7095 }
7096 }
7097
7098 if (board_config != ALC883_AUTO)
7099 setup_preset(spec, &alc883_presets[board_config]);
7100
7101 spec->stream_name_analog = "ALC883 Analog";
7102 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7103 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7104
7105 spec->stream_name_digital = "ALC883 Digital";
7106 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7107 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7108
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007109 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007110 spec->adc_nids = alc883_adc_nids;
7111 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7112 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007113
7114 codec->patch_ops = alc_patch_ops;
7115 if (board_config == ALC883_AUTO)
7116 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007117#ifdef CONFIG_SND_HDA_POWER_SAVE
7118 if (!spec->loopback.amplist)
7119 spec->loopback.amplist = alc883_loopbacks;
7120#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007121
7122 return 0;
7123}
7124
7125/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 * ALC262 support
7127 */
7128
7129#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7130#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7131
7132#define alc262_dac_nids alc260_dac_nids
7133#define alc262_adc_nids alc882_adc_nids
7134#define alc262_adc_nids_alt alc882_adc_nids_alt
7135
7136#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007137#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007138
7139static struct snd_kcontrol_new alc262_base_mixer[] = {
7140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7141 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007148 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007149 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7150 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007151 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7153 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7156 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7157 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007158 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007159};
7160
Kailang Yangccc656c2006-10-17 12:32:26 +02007161static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7163 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7164 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7165 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7167 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007170 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007171 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7172 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007173 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007174 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7175 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7176 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7178 { } /* end */
7179};
7180
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007181static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7183 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7185 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7186 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7187
7188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007191 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7192 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007193 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7198 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7199 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7200 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7201 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7202 { } /* end */
7203};
7204
Kailang Yangcd7509a2007-01-26 18:33:17 +01007205static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7206 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7207 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7210 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7211 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007214 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7219 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7220 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7221 { } /* end */
7222};
7223
7224static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7225 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7226 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007227 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007228 { } /* end */
7229};
7230
Takashi Iwai532d5382007-07-27 19:02:40 +02007231static struct hda_bind_ctls alc262_sony_bind_sw = {
7232 .ops = &snd_hda_bind_sw,
7233 .values = {
7234 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7235 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7236 0,
7237 },
7238};
Takashi Iwai5b319542007-07-26 11:49:22 +02007239
Kailang Yang272a5272007-05-14 11:00:38 +02007240static struct snd_kcontrol_new alc262_sony_mixer[] = {
7241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai532d5382007-07-27 19:02:40 +02007242 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
Kailang Yang272a5272007-05-14 11:00:38 +02007243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7245 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7246 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7247 { } /* end */
7248};
7249
Kailang Yang83c34212007-07-05 11:43:05 +02007250static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7252 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7256 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7257 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7258 { } /* end */
7259};
Kailang Yang272a5272007-05-14 11:00:38 +02007260
Kailang Yangdf694da2005-12-05 19:42:22 +01007261#define alc262_capture_mixer alc882_capture_mixer
7262#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7263
7264/*
7265 * generic initialization of ADC, input mixers and output mixers
7266 */
7267static struct hda_verb alc262_init_verbs[] = {
7268 /*
7269 * Unmute ADC0-2 and set the default input to mic-in
7270 */
7271 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7273 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7275 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7277
Takashi Iwaicb53c622007-08-10 17:21:45 +02007278 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007279 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007280 * Note: PASD motherboards uses the Line In 2 as the input for
7281 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007282 */
7283 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007289
7290 /*
7291 * Set up output mixers (0x0c - 0x0e)
7292 */
7293 /* set vol=0 to output mixers */
7294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7297 /* set up input amps for analog loopback */
7298 /* Amp Indices: DAC = 0, mixer = 1 */
7299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7301 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7304 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7305
7306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7308 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7309 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7310 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7311 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7312
7313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7314 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7315 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7317 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7318
7319 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7320 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7321
7322 /* FIXME: use matrix-type input source selection */
7323 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7324 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7329 /* Input mixer2 */
7330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7334 /* Input mixer3 */
7335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007339
7340 { }
7341};
7342
Kailang Yangccc656c2006-10-17 12:32:26 +02007343static struct hda_verb alc262_hippo_unsol_verbs[] = {
7344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7346 {}
7347};
7348
7349static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7350 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7351 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7352 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7353
7354 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7356 {}
7357};
7358
Kailang Yang272a5272007-05-14 11:00:38 +02007359static struct hda_verb alc262_sony_unsol_verbs[] = {
7360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7363
7364 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7365 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7366};
7367
Kailang Yangccc656c2006-10-17 12:32:26 +02007368/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007369static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007370{
7371 struct alc_spec *spec = codec->spec;
7372 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007373 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007374
Takashi Iwai5b319542007-07-26 11:49:22 +02007375 /* need to execute and sync at first */
7376 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7377 present = snd_hda_codec_read(codec, 0x15, 0,
7378 AC_VERB_GET_PIN_SENSE, 0);
7379 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007380 if (spec->jack_present) {
7381 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007382 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7383 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007384 } else {
7385 /* unmute internal speaker if necessary */
7386 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007387 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7388 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007389 }
7390}
7391
7392/* unsolicited event for HP jack sensing */
7393static void alc262_hippo_unsol_event(struct hda_codec *codec,
7394 unsigned int res)
7395{
7396 if ((res >> 26) != ALC880_HP_EVENT)
7397 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007398 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007399}
7400
Takashi Iwai5b319542007-07-26 11:49:22 +02007401static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007402{
Kailang Yangccc656c2006-10-17 12:32:26 +02007403 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007404 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007405
Takashi Iwai5b319542007-07-26 11:49:22 +02007406 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7407 present = snd_hda_codec_read(codec, 0x1b, 0,
7408 AC_VERB_GET_PIN_SENSE, 0);
7409 present = (present & 0x80000000) != 0;
7410 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007411 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007412 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7413 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007414 } else {
7415 /* unmute internal speaker if necessary */
7416 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7418 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007419 }
7420}
7421
7422/* unsolicited event for HP jack sensing */
7423static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7424 unsigned int res)
7425{
7426 if ((res >> 26) != ALC880_HP_EVENT)
7427 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007428 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007429}
7430
Takashi Iwai834be882006-03-01 14:16:17 +01007431/*
7432 * fujitsu model
7433 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7434 */
7435
7436#define ALC_HP_EVENT 0x37
7437
7438static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7439 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7441 {}
7442};
7443
7444static struct hda_input_mux alc262_fujitsu_capture_source = {
7445 .num_items = 2,
7446 .items = {
7447 { "Mic", 0x0 },
7448 { "CD", 0x4 },
7449 },
7450};
7451
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007452static struct hda_input_mux alc262_HP_capture_source = {
7453 .num_items = 5,
7454 .items = {
7455 { "Mic", 0x0 },
7456 { "Front Mic", 0x3 },
7457 { "Line", 0x2 },
7458 { "CD", 0x4 },
7459 { "AUX IN", 0x6 },
7460 },
7461};
7462
Takashi Iwai834be882006-03-01 14:16:17 +01007463/* mute/unmute internal speaker according to the hp jack and mute state */
7464static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7465{
7466 struct alc_spec *spec = codec->spec;
7467 unsigned int mute;
7468
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007469 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007470 unsigned int present;
7471 /* need to execute and sync at first */
7472 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7473 present = snd_hda_codec_read(codec, 0x14, 0,
7474 AC_VERB_GET_PIN_SENSE, 0);
7475 spec->jack_present = (present & 0x80000000) != 0;
7476 spec->sense_updated = 1;
7477 }
7478 if (spec->jack_present) {
7479 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007480 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7481 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007482 } else {
7483 /* unmute internal speaker if necessary */
7484 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007485 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7486 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01007487 }
7488}
7489
7490/* unsolicited event for HP jack sensing */
7491static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7492 unsigned int res)
7493{
7494 if ((res >> 26) != ALC_HP_EVENT)
7495 return;
7496 alc262_fujitsu_automute(codec, 1);
7497}
7498
7499/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02007500static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7501 .ops = &snd_hda_bind_vol,
7502 .values = {
7503 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7504 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7505 0
7506 },
7507};
Takashi Iwai834be882006-03-01 14:16:17 +01007508
7509/* bind hp and internal speaker mute (with plug check) */
7510static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7511 struct snd_ctl_elem_value *ucontrol)
7512{
7513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7514 long *valp = ucontrol->value.integer.value;
7515 int change;
7516
7517 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007518 HDA_AMP_MUTE,
7519 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007520 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007521 HDA_AMP_MUTE,
7522 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007523 if (change)
7524 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01007525 return change;
7526}
7527
7528static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02007529 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01007530 {
7531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7532 .name = "Master Playback Switch",
7533 .info = snd_hda_mixer_amp_switch_info,
7534 .get = snd_hda_mixer_amp_switch_get,
7535 .put = alc262_fujitsu_master_sw_put,
7536 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7537 },
7538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7543 { } /* end */
7544};
7545
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007546/* additional init verbs for Benq laptops */
7547static struct hda_verb alc262_EAPD_verbs[] = {
7548 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7549 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7550 {}
7551};
7552
Kailang Yang83c34212007-07-05 11:43:05 +02007553static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7554 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7555 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7556
7557 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7558 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7559 {}
7560};
7561
Kailang Yangdf694da2005-12-05 19:42:22 +01007562/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007563static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7564 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007565{
7566 hda_nid_t nid;
7567 int err;
7568
7569 spec->multiout.num_dacs = 1; /* only use one dac */
7570 spec->multiout.dac_nids = spec->private_dac_nids;
7571 spec->multiout.dac_nids[0] = 2;
7572
7573 nid = cfg->line_out_pins[0];
7574 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007575 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7576 "Front Playback Volume",
7577 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7578 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007579 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007580 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7581 "Front Playback Switch",
7582 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7583 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007584 return err;
7585 }
7586
Takashi Iwai82bc9552006-03-21 11:24:42 +01007587 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007588 if (nid) {
7589 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007590 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7591 "Speaker Playback Volume",
7592 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7593 HDA_OUTPUT));
7594 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007596 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7597 "Speaker Playback Switch",
7598 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7599 HDA_OUTPUT));
7600 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007601 return err;
7602 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007603 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7604 "Speaker Playback Switch",
7605 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7606 HDA_OUTPUT));
7607 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007608 return err;
7609 }
7610 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007611 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007612 if (nid) {
7613 /* spec->multiout.hp_nid = 2; */
7614 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007615 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7616 "Headphone Playback Volume",
7617 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7618 HDA_OUTPUT));
7619 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007620 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007621 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7622 "Headphone Playback Switch",
7623 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7624 HDA_OUTPUT));
7625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007626 return err;
7627 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007628 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7629 "Headphone Playback Switch",
7630 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7631 HDA_OUTPUT));
7632 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007633 return err;
7634 }
7635 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007636 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007637}
7638
7639/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007640#define alc262_auto_create_analog_input_ctls \
7641 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007642
7643/*
7644 * generic initialization of ADC, input mixers and output mixers
7645 */
7646static struct hda_verb alc262_volume_init_verbs[] = {
7647 /*
7648 * Unmute ADC0-2 and set the default input to mic-in
7649 */
7650 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7652 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7653 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7655 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656
Takashi Iwaicb53c622007-08-10 17:21:45 +02007657 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007658 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007659 * Note: PASD motherboards uses the Line In 2 as the input for
7660 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007661 */
7662 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007668
7669 /*
7670 * Set up output mixers (0x0c - 0x0f)
7671 */
7672 /* set vol=0 to output mixers */
7673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7676
7677 /* set up input amps for analog loopback */
7678 /* Amp Indices: DAC = 0, mixer = 1 */
7679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7685
7686 /* FIXME: use matrix-type input source selection */
7687 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7688 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7693 /* Input mixer2 */
7694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7696 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7698 /* Input mixer3 */
7699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7703
7704 { }
7705};
7706
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007707static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7708 /*
7709 * Unmute ADC0-2 and set the default input to mic-in
7710 */
7711 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7716 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717
Takashi Iwaicb53c622007-08-10 17:21:45 +02007718 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007719 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007720 * Note: PASD motherboards uses the Line In 2 as the input for
7721 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007722 */
7723 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007731
7732 /*
7733 * Set up output mixers (0x0c - 0x0e)
7734 */
7735 /* set vol=0 to output mixers */
7736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7739
7740 /* set up input amps for analog loopback */
7741 /* Amp Indices: DAC = 0, mixer = 1 */
7742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7748
7749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752
7753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7754 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7755
7756 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7757 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7758
7759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7763 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7764
7765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7769 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7770 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7771
7772
7773 /* FIXME: use matrix-type input source selection */
7774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7775 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7780 /* Input mixer2 */
7781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7785 /* Input mixer3 */
7786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7790
7791 { }
7792};
7793
Kailang Yangcd7509a2007-01-26 18:33:17 +01007794static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7795 /*
7796 * Unmute ADC0-2 and set the default input to mic-in
7797 */
7798 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7800 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7802 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7803 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7804
Takashi Iwaicb53c622007-08-10 17:21:45 +02007805 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01007806 * mixer widget
7807 * Note: PASD motherboards uses the Line In 2 as the input for front
7808 * panel mic (mic 2)
7809 */
7810 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01007819 /*
7820 * Set up output mixers (0x0c - 0x0e)
7821 */
7822 /* set vol=0 to output mixers */
7823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7826
7827 /* set up input amps for analog loopback */
7828 /* Amp Indices: DAC = 0, mixer = 1 */
7829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7835
7836
7837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7838 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7842 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7843 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7844
7845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7847
7848 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7849 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7850
7851 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7855 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7856 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7857
7858 /* FIXME: use matrix-type input source selection */
7859 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7860 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7866 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7868 /* Input mixer2 */
7869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7874 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7876 /* Input mixer3 */
7877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7882 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7884
7885 { }
7886};
7887
Takashi Iwaicb53c622007-08-10 17:21:45 +02007888#ifdef CONFIG_SND_HDA_POWER_SAVE
7889#define alc262_loopbacks alc880_loopbacks
7890#endif
7891
Kailang Yangdf694da2005-12-05 19:42:22 +01007892/* pcm configuration: identiacal with ALC880 */
7893#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7894#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7895#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7896#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7897
7898/*
7899 * BIOS auto configuration
7900 */
7901static int alc262_parse_auto_config(struct hda_codec *codec)
7902{
7903 struct alc_spec *spec = codec->spec;
7904 int err;
7905 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7906
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007907 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7908 alc262_ignore);
7909 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007911 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007912 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007913 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7914 if (err < 0)
7915 return err;
7916 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7917 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007918 return err;
7919
7920 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7921
7922 if (spec->autocfg.dig_out_pin)
7923 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7924 if (spec->autocfg.dig_in_pin)
7925 spec->dig_in_nid = ALC262_DIGIN_NID;
7926
7927 if (spec->kctl_alloc)
7928 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7929
7930 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007931 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007932 spec->input_mux = &spec->private_imux;
7933
7934 return 1;
7935}
7936
7937#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7938#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7939#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7940
7941
7942/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007943static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007944{
Kailang Yangdf694da2005-12-05 19:42:22 +01007945 alc262_auto_init_multi_out(codec);
7946 alc262_auto_init_hp_out(codec);
7947 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007948}
7949
7950/*
7951 * configuration and preset
7952 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007953static const char *alc262_models[ALC262_MODEL_LAST] = {
7954 [ALC262_BASIC] = "basic",
7955 [ALC262_HIPPO] = "hippo",
7956 [ALC262_HIPPO_1] = "hippo_1",
7957 [ALC262_FUJITSU] = "fujitsu",
7958 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007959 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007960 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007961 [ALC262_BENQ_T31] = "benq-t31",
7962 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007963 [ALC262_AUTO] = "auto",
7964};
7965
7966static struct snd_pci_quirk alc262_cfg_tbl[] = {
7967 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7968 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7969 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007970 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7971 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007972 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007973 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007974 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007975 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007976 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7977 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7978 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7979 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7980 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7981 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7982 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7983 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007984 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7985 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7986 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7987 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007988 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02007989 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02007990 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7991 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7992 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007993 {}
7994};
7995
7996static struct alc_config_preset alc262_presets[] = {
7997 [ALC262_BASIC] = {
7998 .mixers = { alc262_base_mixer },
7999 .init_verbs = { alc262_init_verbs },
8000 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8001 .dac_nids = alc262_dac_nids,
8002 .hp_nid = 0x03,
8003 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8004 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01008005 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008006 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008007 [ALC262_HIPPO] = {
8008 .mixers = { alc262_base_mixer },
8009 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8010 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8011 .dac_nids = alc262_dac_nids,
8012 .hp_nid = 0x03,
8013 .dig_out_nid = ALC262_DIGOUT_NID,
8014 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8015 .channel_mode = alc262_modes,
8016 .input_mux = &alc262_capture_source,
8017 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008018 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008019 },
8020 [ALC262_HIPPO_1] = {
8021 .mixers = { alc262_hippo1_mixer },
8022 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8023 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8024 .dac_nids = alc262_dac_nids,
8025 .hp_nid = 0x02,
8026 .dig_out_nid = ALC262_DIGOUT_NID,
8027 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8028 .channel_mode = alc262_modes,
8029 .input_mux = &alc262_capture_source,
8030 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008031 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008032 },
Takashi Iwai834be882006-03-01 14:16:17 +01008033 [ALC262_FUJITSU] = {
8034 .mixers = { alc262_fujitsu_mixer },
8035 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8036 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8037 .dac_nids = alc262_dac_nids,
8038 .hp_nid = 0x03,
8039 .dig_out_nid = ALC262_DIGOUT_NID,
8040 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8041 .channel_mode = alc262_modes,
8042 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008043 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008044 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008045 [ALC262_HP_BPC] = {
8046 .mixers = { alc262_HP_BPC_mixer },
8047 .init_verbs = { alc262_HP_BPC_init_verbs },
8048 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8049 .dac_nids = alc262_dac_nids,
8050 .hp_nid = 0x03,
8051 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8052 .channel_mode = alc262_modes,
8053 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008054 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008055 [ALC262_HP_BPC_D7000_WF] = {
8056 .mixers = { alc262_HP_BPC_WildWest_mixer },
8057 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8059 .dac_nids = alc262_dac_nids,
8060 .hp_nid = 0x03,
8061 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8062 .channel_mode = alc262_modes,
8063 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008064 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008065 [ALC262_HP_BPC_D7000_WL] = {
8066 .mixers = { alc262_HP_BPC_WildWest_mixer,
8067 alc262_HP_BPC_WildWest_option_mixer },
8068 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8069 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8070 .dac_nids = alc262_dac_nids,
8071 .hp_nid = 0x03,
8072 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8073 .channel_mode = alc262_modes,
8074 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008075 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008076 [ALC262_BENQ_ED8] = {
8077 .mixers = { alc262_base_mixer },
8078 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8079 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8080 .dac_nids = alc262_dac_nids,
8081 .hp_nid = 0x03,
8082 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8083 .channel_mode = alc262_modes,
8084 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008085 },
Kailang Yang272a5272007-05-14 11:00:38 +02008086 [ALC262_SONY_ASSAMD] = {
8087 .mixers = { alc262_sony_mixer },
8088 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8089 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8090 .dac_nids = alc262_dac_nids,
8091 .hp_nid = 0x02,
8092 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8093 .channel_mode = alc262_modes,
8094 .input_mux = &alc262_capture_source,
8095 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008096 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008097 },
8098 [ALC262_BENQ_T31] = {
8099 .mixers = { alc262_benq_t31_mixer },
8100 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8101 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8102 .dac_nids = alc262_dac_nids,
8103 .hp_nid = 0x03,
8104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8105 .channel_mode = alc262_modes,
8106 .input_mux = &alc262_capture_source,
8107 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008108 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008109 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008110};
8111
8112static int patch_alc262(struct hda_codec *codec)
8113{
8114 struct alc_spec *spec;
8115 int board_config;
8116 int err;
8117
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008118 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008119 if (spec == NULL)
8120 return -ENOMEM;
8121
8122 codec->spec = spec;
8123#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008124 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8125 * under-run
8126 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008127 {
8128 int tmp;
8129 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8130 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8131 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8132 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8133 }
8134#endif
8135
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008136 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8137 alc262_models,
8138 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008139
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008140 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008141 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8142 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008143 board_config = ALC262_AUTO;
8144 }
8145
8146 if (board_config == ALC262_AUTO) {
8147 /* automatic parse from the BIOS config */
8148 err = alc262_parse_auto_config(codec);
8149 if (err < 0) {
8150 alc_free(codec);
8151 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008152 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008153 printk(KERN_INFO
8154 "hda_codec: Cannot set up configuration "
8155 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008156 board_config = ALC262_BASIC;
8157 }
8158 }
8159
8160 if (board_config != ALC262_AUTO)
8161 setup_preset(spec, &alc262_presets[board_config]);
8162
8163 spec->stream_name_analog = "ALC262 Analog";
8164 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8165 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8166
8167 spec->stream_name_digital = "ALC262 Digital";
8168 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8169 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8170
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008171 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008172 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008173 unsigned int wcap = get_wcaps(codec, 0x07);
8174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008175 /* get type */
8176 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008177 if (wcap != AC_WID_AUD_IN) {
8178 spec->adc_nids = alc262_adc_nids_alt;
8179 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008180 spec->mixers[spec->num_mixers] =
8181 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008182 spec->num_mixers++;
8183 } else {
8184 spec->adc_nids = alc262_adc_nids;
8185 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8186 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8187 spec->num_mixers++;
8188 }
8189 }
8190
8191 codec->patch_ops = alc_patch_ops;
8192 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008193 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008194#ifdef CONFIG_SND_HDA_POWER_SAVE
8195 if (!spec->loopback.amplist)
8196 spec->loopback.amplist = alc262_loopbacks;
8197#endif
Takashi Iwai834be882006-03-01 14:16:17 +01008198
Kailang Yangdf694da2005-12-05 19:42:22 +01008199 return 0;
8200}
8201
Kailang Yangdf694da2005-12-05 19:42:22 +01008202/*
Kailang Yanga361d842007-06-05 12:30:55 +02008203 * ALC268 channel source setting (2 channel)
8204 */
8205#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8206#define alc268_modes alc260_modes
8207
8208static hda_nid_t alc268_dac_nids[2] = {
8209 /* front, hp */
8210 0x02, 0x03
8211};
8212
8213static hda_nid_t alc268_adc_nids[2] = {
8214 /* ADC0-1 */
8215 0x08, 0x07
8216};
8217
8218static hda_nid_t alc268_adc_nids_alt[1] = {
8219 /* ADC0 */
8220 0x08
8221};
8222
8223static struct snd_kcontrol_new alc268_base_mixer[] = {
8224 /* output mixer control */
8225 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8226 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8227 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8229 { }
8230};
8231
Kailang Yangd1a991a2007-08-15 16:21:59 +02008232static struct hda_verb alc268_eapd_verbs[] = {
8233 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8234 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8235 { }
8236};
8237
Takashi Iwaid2738092007-08-16 14:59:45 +02008238/* Toshiba specific */
8239#define alc268_toshiba_automute alc262_hippo_automute
8240
8241static struct hda_verb alc268_toshiba_verbs[] = {
8242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8243 { } /* end */
8244};
8245
8246/* Acer specific */
8247#define alc268_acer_bind_master_vol alc262_fujitsu_bind_master_vol
8248#define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
8249#define alc268_acer_automute alc262_fujitsu_automute
8250
8251static struct snd_kcontrol_new alc268_acer_mixer[] = {
8252 /* output mixer control */
8253 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8254 {
8255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8256 .name = "Master Playback Switch",
8257 .info = snd_hda_mixer_amp_switch_info,
8258 .get = snd_hda_mixer_amp_switch_get,
8259 .put = alc268_acer_master_sw_put,
8260 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8261 },
8262 { }
8263};
8264
8265static struct hda_verb alc268_acer_verbs[] = {
8266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8268
8269 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8270 { }
8271};
8272
8273/* unsolicited event for HP jack sensing */
8274static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8275 unsigned int res)
8276{
8277 if ((res >> 28) != ALC880_HP_EVENT)
8278 return;
8279 alc268_toshiba_automute(codec);
8280}
8281
8282static void alc268_acer_unsol_event(struct hda_codec *codec,
8283 unsigned int res)
8284{
8285 if ((res >> 28) != ALC880_HP_EVENT)
8286 return;
8287 alc268_acer_automute(codec, 1);
8288}
8289
Kailang Yanga361d842007-06-05 12:30:55 +02008290/*
8291 * generic initialization of ADC, input mixers and output mixers
8292 */
8293static struct hda_verb alc268_base_init_verbs[] = {
8294 /* Unmute DAC0-1 and set vol = 0 */
8295 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8296 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8298 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8299 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8301
8302 /*
8303 * Set up output mixers (0x0c - 0x0e)
8304 */
8305 /* set vol=0 to output mixers */
8306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8309 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8310
8311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8313
8314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8320 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8321 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8322
8323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8325 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8329 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8330 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8331
8332 /* FIXME: use matrix-type input source selection */
8333 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8334 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8335 /* Input mixer2 */
8336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8340
8341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8345 { }
8346};
8347
8348/*
8349 * generic initialization of ADC, input mixers and output mixers
8350 */
8351static struct hda_verb alc268_volume_init_verbs[] = {
8352 /* set output DAC */
8353 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8354 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8355 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8356 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8357
8358 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8360 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8361 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8362 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8363
8364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8368 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8369
8370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8373 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8374
8375 /* set PCBEEP vol = 0 */
8376 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8377
8378 { }
8379};
8380
8381#define alc268_mux_enum_info alc_mux_enum_info
8382#define alc268_mux_enum_get alc_mux_enum_get
8383
8384static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8385 struct snd_ctl_elem_value *ucontrol)
8386{
8387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8388 struct alc_spec *spec = codec->spec;
8389 const struct hda_input_mux *imux = spec->input_mux;
8390 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8391 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8392 hda_nid_t nid = capture_mixers[adc_idx];
8393 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8394 unsigned int i, idx;
8395
8396 idx = ucontrol->value.enumerated.item[0];
8397 if (idx >= imux->num_items)
8398 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008399 if (*cur_val == idx)
Kailang Yanga361d842007-06-05 12:30:55 +02008400 return 0;
8401 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02008402 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8403 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8404 imux->items[i].index,
8405 HDA_AMP_MUTE, v);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008406 snd_hda_codec_write_cache(codec, nid, 0,
8407 AC_VERB_SET_CONNECT_SEL,
8408 idx );
Kailang Yanga361d842007-06-05 12:30:55 +02008409 }
8410 *cur_val = idx;
8411 return 1;
8412}
8413
8414static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8415 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8416 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8417 {
8418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8419 /* The multiple "Capture Source" controls confuse alsamixer
8420 * So call somewhat different..
8421 * FIXME: the controls appear in the "playback" view!
8422 */
8423 /* .name = "Capture Source", */
8424 .name = "Input Source",
8425 .count = 1,
8426 .info = alc268_mux_enum_info,
8427 .get = alc268_mux_enum_get,
8428 .put = alc268_mux_enum_put,
8429 },
8430 { } /* end */
8431};
8432
8433static struct snd_kcontrol_new alc268_capture_mixer[] = {
8434 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8435 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8436 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8438 {
8439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8440 /* The multiple "Capture Source" controls confuse alsamixer
8441 * So call somewhat different..
8442 * FIXME: the controls appear in the "playback" view!
8443 */
8444 /* .name = "Capture Source", */
8445 .name = "Input Source",
8446 .count = 2,
8447 .info = alc268_mux_enum_info,
8448 .get = alc268_mux_enum_get,
8449 .put = alc268_mux_enum_put,
8450 },
8451 { } /* end */
8452};
8453
8454static struct hda_input_mux alc268_capture_source = {
8455 .num_items = 4,
8456 .items = {
8457 { "Mic", 0x0 },
8458 { "Front Mic", 0x1 },
8459 { "Line", 0x2 },
8460 { "CD", 0x3 },
8461 },
8462};
8463
8464/* create input playback/capture controls for the given pin */
8465static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8466 const char *ctlname, int idx)
8467{
8468 char name[32];
8469 int err;
8470
8471 sprintf(name, "%s Playback Volume", ctlname);
8472 if (nid == 0x14) {
8473 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8474 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8475 HDA_OUTPUT));
8476 if (err < 0)
8477 return err;
8478 } else if (nid == 0x15) {
8479 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8480 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8481 HDA_OUTPUT));
8482 if (err < 0)
8483 return err;
8484 } else
8485 return -1;
8486 sprintf(name, "%s Playback Switch", ctlname);
8487 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8488 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8489 if (err < 0)
8490 return err;
8491 return 0;
8492}
8493
8494/* add playback controls from the parsed DAC table */
8495static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8496 const struct auto_pin_cfg *cfg)
8497{
8498 hda_nid_t nid;
8499 int err;
8500
8501 spec->multiout.num_dacs = 2; /* only use one dac */
8502 spec->multiout.dac_nids = spec->private_dac_nids;
8503 spec->multiout.dac_nids[0] = 2;
8504 spec->multiout.dac_nids[1] = 3;
8505
8506 nid = cfg->line_out_pins[0];
8507 if (nid)
8508 alc268_new_analog_output(spec, nid, "Front", 0);
8509
8510 nid = cfg->speaker_pins[0];
8511 if (nid == 0x1d) {
8512 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8513 "Speaker Playback Volume",
8514 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8515 if (err < 0)
8516 return err;
8517 }
8518 nid = cfg->hp_pins[0];
8519 if (nid)
8520 alc268_new_analog_output(spec, nid, "Headphone", 0);
8521
8522 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8523 if (nid == 0x16) {
8524 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8525 "Mono Playback Switch",
8526 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8527 if (err < 0)
8528 return err;
8529 }
8530 return 0;
8531}
8532
8533/* create playback/capture controls for input pins */
8534static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8535 const struct auto_pin_cfg *cfg)
8536{
8537 struct hda_input_mux *imux = &spec->private_imux;
8538 int i, idx1;
8539
8540 for (i = 0; i < AUTO_PIN_LAST; i++) {
8541 switch(cfg->input_pins[i]) {
8542 case 0x18:
8543 idx1 = 0; /* Mic 1 */
8544 break;
8545 case 0x19:
8546 idx1 = 1; /* Mic 2 */
8547 break;
8548 case 0x1a:
8549 idx1 = 2; /* Line In */
8550 break;
8551 case 0x1c:
8552 idx1 = 3; /* CD */
8553 break;
8554 default:
8555 continue;
8556 }
8557 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8558 imux->items[imux->num_items].index = idx1;
8559 imux->num_items++;
8560 }
8561 return 0;
8562}
8563
8564static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8565{
8566 struct alc_spec *spec = codec->spec;
8567 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8568 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8569 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8570 unsigned int dac_vol1, dac_vol2;
8571
8572 if (speaker_nid) {
8573 snd_hda_codec_write(codec, speaker_nid, 0,
8574 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8575 snd_hda_codec_write(codec, 0x0f, 0,
8576 AC_VERB_SET_AMP_GAIN_MUTE,
8577 AMP_IN_UNMUTE(1));
8578 snd_hda_codec_write(codec, 0x10, 0,
8579 AC_VERB_SET_AMP_GAIN_MUTE,
8580 AMP_IN_UNMUTE(1));
8581 } else {
8582 snd_hda_codec_write(codec, 0x0f, 0,
8583 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8584 snd_hda_codec_write(codec, 0x10, 0,
8585 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8586 }
8587
8588 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8589 if (line_nid == 0x14)
8590 dac_vol2 = AMP_OUT_ZERO;
8591 else if (line_nid == 0x15)
8592 dac_vol1 = AMP_OUT_ZERO;
8593 if (hp_nid == 0x14)
8594 dac_vol2 = AMP_OUT_ZERO;
8595 else if (hp_nid == 0x15)
8596 dac_vol1 = AMP_OUT_ZERO;
8597 if (line_nid != 0x16 || hp_nid != 0x16 ||
8598 spec->autocfg.line_out_pins[1] != 0x16 ||
8599 spec->autocfg.line_out_pins[2] != 0x16)
8600 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8601
8602 snd_hda_codec_write(codec, 0x02, 0,
8603 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8604 snd_hda_codec_write(codec, 0x03, 0,
8605 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8606}
8607
8608/* pcm configuration: identiacal with ALC880 */
8609#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8610#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8611#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8612
8613/*
8614 * BIOS auto configuration
8615 */
8616static int alc268_parse_auto_config(struct hda_codec *codec)
8617{
8618 struct alc_spec *spec = codec->spec;
8619 int err;
8620 static hda_nid_t alc268_ignore[] = { 0 };
8621
8622 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8623 alc268_ignore);
8624 if (err < 0)
8625 return err;
8626 if (!spec->autocfg.line_outs)
8627 return 0; /* can't find valid BIOS pin config */
8628
8629 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8630 if (err < 0)
8631 return err;
8632 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8633 if (err < 0)
8634 return err;
8635
8636 spec->multiout.max_channels = 2;
8637
8638 /* digital only support output */
8639 if (spec->autocfg.dig_out_pin)
8640 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8641
8642 if (spec->kctl_alloc)
8643 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8644
8645 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8646 spec->num_mux_defs = 1;
8647 spec->input_mux = &spec->private_imux;
8648
8649 return 1;
8650}
8651
8652#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8653#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8654#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8655
8656/* init callback for auto-configuration model -- overriding the default init */
8657static void alc268_auto_init(struct hda_codec *codec)
8658{
8659 alc268_auto_init_multi_out(codec);
8660 alc268_auto_init_hp_out(codec);
8661 alc268_auto_init_mono_speaker_out(codec);
8662 alc268_auto_init_analog_input(codec);
8663}
8664
Takashi Iwaicb53c622007-08-10 17:21:45 +02008665#ifdef CONFIG_SND_HDA_POWER_SAVE
8666#define alc883_loopbacks alc880_loopbacks
8667#endif
8668
Kailang Yanga361d842007-06-05 12:30:55 +02008669/*
8670 * configuration and preset
8671 */
8672static const char *alc268_models[ALC268_MODEL_LAST] = {
8673 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02008674 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02008675 [ALC268_ACER] = "acer",
Kailang Yanga361d842007-06-05 12:30:55 +02008676 [ALC268_AUTO] = "auto",
8677};
8678
8679static struct snd_pci_quirk alc268_cfg_tbl[] = {
8680 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008681 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwaid2738092007-08-16 14:59:45 +02008682 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
8683 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02008684 {}
8685};
8686
8687static struct alc_config_preset alc268_presets[] = {
8688 [ALC268_3ST] = {
8689 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8690 .init_verbs = { alc268_base_init_verbs },
8691 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8692 .dac_nids = alc268_dac_nids,
8693 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8694 .adc_nids = alc268_adc_nids_alt,
8695 .hp_nid = 0x03,
8696 .dig_out_nid = ALC268_DIGOUT_NID,
8697 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8698 .channel_mode = alc268_modes,
8699 .input_mux = &alc268_capture_source,
8700 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008701 [ALC268_TOSHIBA] = {
8702 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02008703 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8704 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008705 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8706 .dac_nids = alc268_dac_nids,
8707 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8708 .adc_nids = alc268_adc_nids_alt,
8709 .hp_nid = 0x03,
8710 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8711 .channel_mode = alc268_modes,
8712 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02008713 .input_mux = &alc268_capture_source,
8714 .unsol_event = alc268_toshiba_unsol_event,
8715 .init_hook = alc268_toshiba_automute,
8716 },
8717 [ALC268_ACER] = {
8718 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
8719 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8720 alc268_acer_verbs },
8721 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8722 .dac_nids = alc268_dac_nids,
8723 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8724 .adc_nids = alc268_adc_nids_alt,
8725 .hp_nid = 0x02,
8726 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8727 .channel_mode = alc268_modes,
8728 .input_mux = &alc268_capture_source,
8729 .unsol_event = alc268_acer_unsol_event,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008730 },
Kailang Yanga361d842007-06-05 12:30:55 +02008731};
8732
8733static int patch_alc268(struct hda_codec *codec)
8734{
8735 struct alc_spec *spec;
8736 int board_config;
8737 int err;
8738
8739 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8740 if (spec == NULL)
8741 return -ENOMEM;
8742
8743 codec->spec = spec;
8744
8745 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8746 alc268_models,
8747 alc268_cfg_tbl);
8748
8749 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8750 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8751 "trying auto-probe from BIOS...\n");
8752 board_config = ALC268_AUTO;
8753 }
8754
8755 if (board_config == ALC268_AUTO) {
8756 /* automatic parse from the BIOS config */
8757 err = alc268_parse_auto_config(codec);
8758 if (err < 0) {
8759 alc_free(codec);
8760 return err;
8761 } else if (!err) {
8762 printk(KERN_INFO
8763 "hda_codec: Cannot set up configuration "
8764 "from BIOS. Using base mode...\n");
8765 board_config = ALC268_3ST;
8766 }
8767 }
8768
8769 if (board_config != ALC268_AUTO)
8770 setup_preset(spec, &alc268_presets[board_config]);
8771
8772 spec->stream_name_analog = "ALC268 Analog";
8773 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8774 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8775
8776 spec->stream_name_digital = "ALC268 Digital";
8777 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8778
8779 if (board_config == ALC268_AUTO) {
8780 if (!spec->adc_nids && spec->input_mux) {
8781 /* check whether NID 0x07 is valid */
8782 unsigned int wcap = get_wcaps(codec, 0x07);
8783
8784 /* get type */
8785 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8786 if (wcap != AC_WID_AUD_IN) {
8787 spec->adc_nids = alc268_adc_nids_alt;
8788 spec->num_adc_nids =
8789 ARRAY_SIZE(alc268_adc_nids_alt);
8790 spec->mixers[spec->num_mixers] =
8791 alc268_capture_alt_mixer;
8792 spec->num_mixers++;
8793 } else {
8794 spec->adc_nids = alc268_adc_nids;
8795 spec->num_adc_nids =
8796 ARRAY_SIZE(alc268_adc_nids);
8797 spec->mixers[spec->num_mixers] =
8798 alc268_capture_mixer;
8799 spec->num_mixers++;
8800 }
8801 }
8802 }
8803 codec->patch_ops = alc_patch_ops;
8804 if (board_config == ALC268_AUTO)
8805 spec->init_hook = alc268_auto_init;
8806
8807 return 0;
8808}
8809
8810/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008811 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8812 */
8813
8814/*
8815 * set the path ways for 2 channel output
8816 * need to set the codec line out and mic 1 pin widgets to inputs
8817 */
8818static struct hda_verb alc861_threestack_ch2_init[] = {
8819 /* set pin widget 1Ah (line in) for input */
8820 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008821 /* set pin widget 18h (mic1/2) for input, for mic also enable
8822 * the vref
8823 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008824 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8825
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008826 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8827#if 0
8828 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8829 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8830#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008831 { } /* end */
8832};
8833/*
8834 * 6ch mode
8835 * need to set the codec line out and mic 1 pin widgets to outputs
8836 */
8837static struct hda_verb alc861_threestack_ch6_init[] = {
8838 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8839 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8840 /* set pin widget 18h (mic1) for output (CLFE)*/
8841 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8842
8843 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008844 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008845
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008846 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8847#if 0
8848 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8849 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8850#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008851 { } /* end */
8852};
8853
8854static struct hda_channel_mode alc861_threestack_modes[2] = {
8855 { 2, alc861_threestack_ch2_init },
8856 { 6, alc861_threestack_ch6_init },
8857};
Takashi Iwai22309c32006-08-09 16:57:28 +02008858/* Set mic1 as input and unmute the mixer */
8859static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8860 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8861 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8862 { } /* end */
8863};
8864/* Set mic1 as output and mute mixer */
8865static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8866 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8867 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8868 { } /* end */
8869};
8870
8871static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8872 { 2, alc861_uniwill_m31_ch2_init },
8873 { 4, alc861_uniwill_m31_ch4_init },
8874};
Kailang Yangdf694da2005-12-05 19:42:22 +01008875
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008876/* Set mic1 and line-in as input and unmute the mixer */
8877static struct hda_verb alc861_asus_ch2_init[] = {
8878 /* set pin widget 1Ah (line in) for input */
8879 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008880 /* set pin widget 18h (mic1/2) for input, for mic also enable
8881 * the vref
8882 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008883 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8884
8885 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8886#if 0
8887 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8888 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8889#endif
8890 { } /* end */
8891};
8892/* Set mic1 nad line-in as output and mute mixer */
8893static struct hda_verb alc861_asus_ch6_init[] = {
8894 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8895 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8896 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8897 /* set pin widget 18h (mic1) for output (CLFE)*/
8898 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8899 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8900 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8901 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8902
8903 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8904#if 0
8905 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8906 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8907#endif
8908 { } /* end */
8909};
8910
8911static struct hda_channel_mode alc861_asus_modes[2] = {
8912 { 2, alc861_asus_ch2_init },
8913 { 6, alc861_asus_ch6_init },
8914};
8915
Kailang Yangdf694da2005-12-05 19:42:22 +01008916/* patch-ALC861 */
8917
8918static struct snd_kcontrol_new alc861_base_mixer[] = {
8919 /* output mixer control */
8920 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8921 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8922 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8923 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8924 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8925
8926 /*Input mixer control */
8927 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8928 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8929 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8930 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8931 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8932 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8934 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008937
Kailang Yangdf694da2005-12-05 19:42:22 +01008938 /* Capture mixer control */
8939 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8940 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8941 {
8942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8943 .name = "Capture Source",
8944 .count = 1,
8945 .info = alc_mux_enum_info,
8946 .get = alc_mux_enum_get,
8947 .put = alc_mux_enum_put,
8948 },
8949 { } /* end */
8950};
8951
8952static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8953 /* output mixer control */
8954 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8955 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8956 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8957 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8958 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8959
8960 /* Input mixer control */
8961 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8962 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8963 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8964 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8965 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8966 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8968 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8969 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008971
Kailang Yangdf694da2005-12-05 19:42:22 +01008972 /* Capture mixer control */
8973 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8974 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8975 {
8976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8977 .name = "Capture Source",
8978 .count = 1,
8979 .info = alc_mux_enum_info,
8980 .get = alc_mux_enum_get,
8981 .put = alc_mux_enum_put,
8982 },
8983 {
8984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8985 .name = "Channel Mode",
8986 .info = alc_ch_mode_info,
8987 .get = alc_ch_mode_get,
8988 .put = alc_ch_mode_put,
8989 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8990 },
8991 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008992};
8993
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008994static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008995 /* output mixer control */
8996 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8998 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8999
9000 /*Capture mixer control */
9001 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9002 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9003 {
9004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9005 .name = "Capture Source",
9006 .count = 1,
9007 .info = alc_mux_enum_info,
9008 .get = alc_mux_enum_get,
9009 .put = alc_mux_enum_put,
9010 },
9011
9012 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009013};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009014
Takashi Iwai22309c32006-08-09 16:57:28 +02009015static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9016 /* output mixer control */
9017 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9018 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9019 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9020 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9021 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9022
9023 /* Input mixer control */
9024 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9025 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9026 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9027 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9028 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9029 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9031 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009034
Takashi Iwai22309c32006-08-09 16:57:28 +02009035 /* Capture mixer control */
9036 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9037 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9038 {
9039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9040 .name = "Capture Source",
9041 .count = 1,
9042 .info = alc_mux_enum_info,
9043 .get = alc_mux_enum_get,
9044 .put = alc_mux_enum_put,
9045 },
9046 {
9047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9048 .name = "Channel Mode",
9049 .info = alc_ch_mode_info,
9050 .get = alc_ch_mode_get,
9051 .put = alc_ch_mode_put,
9052 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9053 },
9054 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009055};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009056
9057static struct snd_kcontrol_new alc861_asus_mixer[] = {
9058 /* output mixer control */
9059 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9060 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9061 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9062 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9063 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9064
9065 /* Input mixer control */
9066 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9067 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9068 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9069 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9070 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9071 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9073 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9074 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9076
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009077 /* Capture mixer control */
9078 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9079 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9080 {
9081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9082 .name = "Capture Source",
9083 .count = 1,
9084 .info = alc_mux_enum_info,
9085 .get = alc_mux_enum_get,
9086 .put = alc_mux_enum_put,
9087 },
9088 {
9089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9090 .name = "Channel Mode",
9091 .info = alc_ch_mode_info,
9092 .get = alc_ch_mode_get,
9093 .put = alc_ch_mode_put,
9094 .private_value = ARRAY_SIZE(alc861_asus_modes),
9095 },
9096 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009097};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009098
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009099/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009100static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009101 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9102 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9103 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9104 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9105 { }
9106};
9107
Kailang Yangdf694da2005-12-05 19:42:22 +01009108/*
9109 * generic initialization of ADC, input mixers and output mixers
9110 */
9111static struct hda_verb alc861_base_init_verbs[] = {
9112 /*
9113 * Unmute ADC0 and set the default input to mic-in
9114 */
9115 /* port-A for surround (rear panel) */
9116 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9117 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9118 /* port-B for mic-in (rear panel) with vref */
9119 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9120 /* port-C for line-in (rear panel) */
9121 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9122 /* port-D for Front */
9123 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9124 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9125 /* port-E for HP out (front panel) */
9126 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9127 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009128 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009129 /* port-F for mic-in (front panel) with vref */
9130 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9131 /* port-G for CLFE (rear panel) */
9132 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9133 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9134 /* port-H for side (rear panel) */
9135 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9136 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9137 /* CD-in */
9138 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9139 /* route front mic to ADC1*/
9140 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9142
9143 /* Unmute DAC0~3 & spdif out*/
9144 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9145 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9146 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9147 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9149
9150 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9151 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9152 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9153 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9154 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9155
9156 /* Unmute Stereo Mixer 15 */
9157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009161
9162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9164 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9165 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9166 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9167 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009170 /* hp used DAC 3 (Front) */
9171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9173
9174 { }
9175};
9176
9177static struct hda_verb alc861_threestack_init_verbs[] = {
9178 /*
9179 * Unmute ADC0 and set the default input to mic-in
9180 */
9181 /* port-A for surround (rear panel) */
9182 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9183 /* port-B for mic-in (rear panel) with vref */
9184 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9185 /* port-C for line-in (rear panel) */
9186 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9187 /* port-D for Front */
9188 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9189 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9190 /* port-E for HP out (front panel) */
9191 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9192 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009193 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009194 /* port-F for mic-in (front panel) with vref */
9195 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9196 /* port-G for CLFE (rear panel) */
9197 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9198 /* port-H for side (rear panel) */
9199 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9200 /* CD-in */
9201 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9202 /* route front mic to ADC1*/
9203 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9205 /* Unmute DAC0~3 & spdif out*/
9206 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9207 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9208 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9209 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9211
9212 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9213 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9214 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9215 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9216 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9217
9218 /* Unmute Stereo Mixer 15 */
9219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009223
9224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009232 /* hp used DAC 3 (Front) */
9233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9235 { }
9236};
Takashi Iwai22309c32006-08-09 16:57:28 +02009237
9238static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9239 /*
9240 * Unmute ADC0 and set the default input to mic-in
9241 */
9242 /* port-A for surround (rear panel) */
9243 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9244 /* port-B for mic-in (rear panel) with vref */
9245 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9246 /* port-C for line-in (rear panel) */
9247 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9248 /* port-D for Front */
9249 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9250 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9251 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009252 /* this has to be set to VREF80 */
9253 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009254 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009255 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009256 /* port-F for mic-in (front panel) with vref */
9257 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9258 /* port-G for CLFE (rear panel) */
9259 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9260 /* port-H for side (rear panel) */
9261 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9262 /* CD-in */
9263 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9264 /* route front mic to ADC1*/
9265 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9267 /* Unmute DAC0~3 & spdif out*/
9268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9269 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9270 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9271 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9273
9274 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9275 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9276 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9277 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9278 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9279
9280 /* Unmute Stereo Mixer 15 */
9281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009285
9286 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9287 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9289 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9293 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009294 /* hp used DAC 3 (Front) */
9295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9297 { }
9298};
9299
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009300static struct hda_verb alc861_asus_init_verbs[] = {
9301 /*
9302 * Unmute ADC0 and set the default input to mic-in
9303 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009304 /* port-A for surround (rear panel)
9305 * according to codec#0 this is the HP jack
9306 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009307 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9308 /* route front PCM to HP */
9309 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9310 /* port-B for mic-in (rear panel) with vref */
9311 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9312 /* port-C for line-in (rear panel) */
9313 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9314 /* port-D for Front */
9315 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9316 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9317 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009318 /* this has to be set to VREF80 */
9319 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009320 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009321 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009322 /* port-F for mic-in (front panel) with vref */
9323 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9324 /* port-G for CLFE (rear panel) */
9325 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9326 /* port-H for side (rear panel) */
9327 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9328 /* CD-in */
9329 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9330 /* route front mic to ADC1*/
9331 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9332 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9333 /* Unmute DAC0~3 & spdif out*/
9334 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9336 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9337 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9339 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9340 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9341 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9342 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9343 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9344
9345 /* Unmute Stereo Mixer 15 */
9346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009350
9351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9352 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9353 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9354 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009359 /* hp used DAC 3 (Front) */
9360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009361 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9362 { }
9363};
9364
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009365/* additional init verbs for ASUS laptops */
9366static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9367 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9369 { }
9370};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009371
Kailang Yangdf694da2005-12-05 19:42:22 +01009372/*
9373 * generic initialization of ADC, input mixers and output mixers
9374 */
9375static struct hda_verb alc861_auto_init_verbs[] = {
9376 /*
9377 * Unmute ADC0 and set the default input to mic-in
9378 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009379 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9381
9382 /* Unmute DAC0~3 & spdif out*/
9383 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9386 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9388
9389 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9390 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9391 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9392 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9393 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9394
9395 /* Unmute Stereo Mixer 15 */
9396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9400
9401 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9402 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9403 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9404 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9405 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9407 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9408 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9409
9410 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9411 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009412 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9415 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009416 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9417 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009418
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009419 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009420
9421 { }
9422};
9423
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009424static struct hda_verb alc861_toshiba_init_verbs[] = {
9425 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009426
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009427 { }
9428};
9429
9430/* toggle speaker-output according to the hp-jack state */
9431static void alc861_toshiba_automute(struct hda_codec *codec)
9432{
9433 unsigned int present;
9434
9435 present = snd_hda_codec_read(codec, 0x0f, 0,
9436 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02009437 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9438 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9439 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9440 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009441}
9442
9443static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9444 unsigned int res)
9445{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009446 if ((res >> 26) == ALC880_HP_EVENT)
9447 alc861_toshiba_automute(codec);
9448}
9449
Kailang Yangdf694da2005-12-05 19:42:22 +01009450/* pcm configuration: identiacal with ALC880 */
9451#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9452#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9453#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9454#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9455
9456
9457#define ALC861_DIGOUT_NID 0x07
9458
9459static struct hda_channel_mode alc861_8ch_modes[1] = {
9460 { 8, NULL }
9461};
9462
9463static hda_nid_t alc861_dac_nids[4] = {
9464 /* front, surround, clfe, side */
9465 0x03, 0x06, 0x05, 0x04
9466};
9467
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009468static hda_nid_t alc660_dac_nids[3] = {
9469 /* front, clfe, surround */
9470 0x03, 0x05, 0x06
9471};
9472
Kailang Yangdf694da2005-12-05 19:42:22 +01009473static hda_nid_t alc861_adc_nids[1] = {
9474 /* ADC0-2 */
9475 0x08,
9476};
9477
9478static struct hda_input_mux alc861_capture_source = {
9479 .num_items = 5,
9480 .items = {
9481 { "Mic", 0x0 },
9482 { "Front Mic", 0x3 },
9483 { "Line", 0x1 },
9484 { "CD", 0x4 },
9485 { "Mixer", 0x5 },
9486 },
9487};
9488
9489/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009490static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9491 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009492{
9493 int i;
9494 hda_nid_t nid;
9495
9496 spec->multiout.dac_nids = spec->private_dac_nids;
9497 for (i = 0; i < cfg->line_outs; i++) {
9498 nid = cfg->line_out_pins[i];
9499 if (nid) {
9500 if (i >= ARRAY_SIZE(alc861_dac_nids))
9501 continue;
9502 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9503 }
9504 }
9505 spec->multiout.num_dacs = cfg->line_outs;
9506 return 0;
9507}
9508
9509/* add playback controls from the parsed DAC table */
9510static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9511 const struct auto_pin_cfg *cfg)
9512{
9513 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009514 static const char *chname[4] = {
9515 "Front", "Surround", NULL /*CLFE*/, "Side"
9516 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009517 hda_nid_t nid;
9518 int i, idx, err;
9519
9520 for (i = 0; i < cfg->line_outs; i++) {
9521 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009522 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009523 continue;
9524 if (nid == 0x05) {
9525 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009526 err = add_control(spec, ALC_CTL_BIND_MUTE,
9527 "Center Playback Switch",
9528 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9529 HDA_OUTPUT));
9530 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009532 err = add_control(spec, ALC_CTL_BIND_MUTE,
9533 "LFE Playback Switch",
9534 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9535 HDA_OUTPUT));
9536 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009537 return err;
9538 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009539 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9540 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009541 if (nid == alc861_dac_nids[idx])
9542 break;
9543 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009544 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9545 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9546 HDA_OUTPUT));
9547 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009548 return err;
9549 }
9550 }
9551 return 0;
9552}
9553
9554static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9555{
9556 int err;
9557 hda_nid_t nid;
9558
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009559 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009560 return 0;
9561
9562 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9563 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009564 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9565 "Headphone Playback Switch",
9566 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9567 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009568 return err;
9569 spec->multiout.hp_nid = nid;
9570 }
9571 return 0;
9572}
9573
9574/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009575static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9576 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009577{
Kailang Yangdf694da2005-12-05 19:42:22 +01009578 struct hda_input_mux *imux = &spec->private_imux;
9579 int i, err, idx, idx1;
9580
9581 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009582 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009583 case 0x0c:
9584 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009585 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009586 break;
9587 case 0x0f:
9588 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009589 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009590 break;
9591 case 0x0d:
9592 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009593 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009594 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009595 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009596 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009597 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009598 break;
9599 case 0x11:
9600 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009601 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009602 break;
9603 default:
9604 continue;
9605 }
9606
Takashi Iwai4a471b72005-12-07 13:56:29 +01009607 err = new_analog_input(spec, cfg->input_pins[i],
9608 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 if (err < 0)
9610 return err;
9611
Takashi Iwai4a471b72005-12-07 13:56:29 +01009612 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009613 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009614 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009615 }
9616 return 0;
9617}
9618
9619static struct snd_kcontrol_new alc861_capture_mixer[] = {
9620 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9621 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9622
9623 {
9624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9625 /* The multiple "Capture Source" controls confuse alsamixer
9626 * So call somewhat different..
9627 *FIXME: the controls appear in the "playback" view!
9628 */
9629 /* .name = "Capture Source", */
9630 .name = "Input Source",
9631 .count = 1,
9632 .info = alc_mux_enum_info,
9633 .get = alc_mux_enum_get,
9634 .put = alc_mux_enum_put,
9635 },
9636 { } /* end */
9637};
9638
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009639static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9640 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009641 int pin_type, int dac_idx)
9642{
9643 /* set as output */
9644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009645 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9646 pin_type);
9647 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9648 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009649
9650}
9651
9652static void alc861_auto_init_multi_out(struct hda_codec *codec)
9653{
9654 struct alc_spec *spec = codec->spec;
9655 int i;
9656
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009657 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009658 for (i = 0; i < spec->autocfg.line_outs; i++) {
9659 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009660 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009661 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009662 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009663 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009664 }
9665}
9666
9667static void alc861_auto_init_hp_out(struct hda_codec *codec)
9668{
9669 struct alc_spec *spec = codec->spec;
9670 hda_nid_t pin;
9671
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009672 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009673 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009674 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9675 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009676}
9677
9678static void alc861_auto_init_analog_input(struct hda_codec *codec)
9679{
9680 struct alc_spec *spec = codec->spec;
9681 int i;
9682
9683 for (i = 0; i < AUTO_PIN_LAST; i++) {
9684 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009685 if (nid >= 0x0c && nid <= 0x11) {
9686 snd_hda_codec_write(codec, nid, 0,
9687 AC_VERB_SET_PIN_WIDGET_CONTROL,
9688 i <= AUTO_PIN_FRONT_MIC ?
9689 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009690 }
9691 }
9692}
9693
9694/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009695/* return 1 if successful, 0 if the proper config is not found,
9696 * or a negative error code
9697 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009698static int alc861_parse_auto_config(struct hda_codec *codec)
9699{
9700 struct alc_spec *spec = codec->spec;
9701 int err;
9702 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9703
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009704 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9705 alc861_ignore);
9706 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009707 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009708 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009709 return 0; /* can't find valid BIOS pin config */
9710
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009711 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9712 if (err < 0)
9713 return err;
9714 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9715 if (err < 0)
9716 return err;
9717 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9718 if (err < 0)
9719 return err;
9720 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9721 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009722 return err;
9723
9724 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9725
9726 if (spec->autocfg.dig_out_pin)
9727 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9728
9729 if (spec->kctl_alloc)
9730 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9731
9732 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9733
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009734 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009735 spec->input_mux = &spec->private_imux;
9736
9737 spec->adc_nids = alc861_adc_nids;
9738 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9739 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9740 spec->num_mixers++;
9741
9742 return 1;
9743}
9744
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009745/* additional initialization for auto-configuration model */
9746static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009747{
Kailang Yangdf694da2005-12-05 19:42:22 +01009748 alc861_auto_init_multi_out(codec);
9749 alc861_auto_init_hp_out(codec);
9750 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009751}
9752
Takashi Iwaicb53c622007-08-10 17:21:45 +02009753#ifdef CONFIG_SND_HDA_POWER_SAVE
9754static struct hda_amp_list alc861_loopbacks[] = {
9755 { 0x15, HDA_INPUT, 0 },
9756 { 0x15, HDA_INPUT, 1 },
9757 { 0x15, HDA_INPUT, 2 },
9758 { 0x15, HDA_INPUT, 3 },
9759 { } /* end */
9760};
9761#endif
9762
Kailang Yangdf694da2005-12-05 19:42:22 +01009763
9764/*
9765 * configuration and preset
9766 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009767static const char *alc861_models[ALC861_MODEL_LAST] = {
9768 [ALC861_3ST] = "3stack",
9769 [ALC660_3ST] = "3stack-660",
9770 [ALC861_3ST_DIG] = "3stack-dig",
9771 [ALC861_6ST_DIG] = "6stack-dig",
9772 [ALC861_UNIWILL_M31] = "uniwill-m31",
9773 [ALC861_TOSHIBA] = "toshiba",
9774 [ALC861_ASUS] = "asus",
9775 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9776 [ALC861_AUTO] = "auto",
9777};
9778
9779static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009780 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009781 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9782 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009783 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009784 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009785 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009786 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009787 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009788 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9789 * Any other models that need this preset?
9790 */
9791 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009792 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009793 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009794 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009795 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009796 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +02009797 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9798 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009799 {}
9800};
9801
9802static struct alc_config_preset alc861_presets[] = {
9803 [ALC861_3ST] = {
9804 .mixers = { alc861_3ST_mixer },
9805 .init_verbs = { alc861_threestack_init_verbs },
9806 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9807 .dac_nids = alc861_dac_nids,
9808 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9809 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009810 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009811 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9812 .adc_nids = alc861_adc_nids,
9813 .input_mux = &alc861_capture_source,
9814 },
9815 [ALC861_3ST_DIG] = {
9816 .mixers = { alc861_base_mixer },
9817 .init_verbs = { alc861_threestack_init_verbs },
9818 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9819 .dac_nids = alc861_dac_nids,
9820 .dig_out_nid = ALC861_DIGOUT_NID,
9821 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9822 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009823 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009824 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9825 .adc_nids = alc861_adc_nids,
9826 .input_mux = &alc861_capture_source,
9827 },
9828 [ALC861_6ST_DIG] = {
9829 .mixers = { alc861_base_mixer },
9830 .init_verbs = { alc861_base_init_verbs },
9831 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9832 .dac_nids = alc861_dac_nids,
9833 .dig_out_nid = ALC861_DIGOUT_NID,
9834 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9835 .channel_mode = alc861_8ch_modes,
9836 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9837 .adc_nids = alc861_adc_nids,
9838 .input_mux = &alc861_capture_source,
9839 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009840 [ALC660_3ST] = {
9841 .mixers = { alc861_3ST_mixer },
9842 .init_verbs = { alc861_threestack_init_verbs },
9843 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9844 .dac_nids = alc660_dac_nids,
9845 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9846 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009847 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009848 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9849 .adc_nids = alc861_adc_nids,
9850 .input_mux = &alc861_capture_source,
9851 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009852 [ALC861_UNIWILL_M31] = {
9853 .mixers = { alc861_uniwill_m31_mixer },
9854 .init_verbs = { alc861_uniwill_m31_init_verbs },
9855 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9856 .dac_nids = alc861_dac_nids,
9857 .dig_out_nid = ALC861_DIGOUT_NID,
9858 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9859 .channel_mode = alc861_uniwill_m31_modes,
9860 .need_dac_fix = 1,
9861 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9862 .adc_nids = alc861_adc_nids,
9863 .input_mux = &alc861_capture_source,
9864 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009865 [ALC861_TOSHIBA] = {
9866 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009867 .init_verbs = { alc861_base_init_verbs,
9868 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009869 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9870 .dac_nids = alc861_dac_nids,
9871 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9872 .channel_mode = alc883_3ST_2ch_modes,
9873 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9874 .adc_nids = alc861_adc_nids,
9875 .input_mux = &alc861_capture_source,
9876 .unsol_event = alc861_toshiba_unsol_event,
9877 .init_hook = alc861_toshiba_automute,
9878 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009879 [ALC861_ASUS] = {
9880 .mixers = { alc861_asus_mixer },
9881 .init_verbs = { alc861_asus_init_verbs },
9882 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9883 .dac_nids = alc861_dac_nids,
9884 .dig_out_nid = ALC861_DIGOUT_NID,
9885 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9886 .channel_mode = alc861_asus_modes,
9887 .need_dac_fix = 1,
9888 .hp_nid = 0x06,
9889 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9890 .adc_nids = alc861_adc_nids,
9891 .input_mux = &alc861_capture_source,
9892 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009893 [ALC861_ASUS_LAPTOP] = {
9894 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9895 .init_verbs = { alc861_asus_init_verbs,
9896 alc861_asus_laptop_init_verbs },
9897 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9898 .dac_nids = alc861_dac_nids,
9899 .dig_out_nid = ALC861_DIGOUT_NID,
9900 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9901 .channel_mode = alc883_3ST_2ch_modes,
9902 .need_dac_fix = 1,
9903 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9904 .adc_nids = alc861_adc_nids,
9905 .input_mux = &alc861_capture_source,
9906 },
9907};
Kailang Yangdf694da2005-12-05 19:42:22 +01009908
9909
9910static int patch_alc861(struct hda_codec *codec)
9911{
9912 struct alc_spec *spec;
9913 int board_config;
9914 int err;
9915
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009917 if (spec == NULL)
9918 return -ENOMEM;
9919
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009920 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009921
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009922 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9923 alc861_models,
9924 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009925
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009926 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009927 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9928 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009929 board_config = ALC861_AUTO;
9930 }
9931
9932 if (board_config == ALC861_AUTO) {
9933 /* automatic parse from the BIOS config */
9934 err = alc861_parse_auto_config(codec);
9935 if (err < 0) {
9936 alc_free(codec);
9937 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009938 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009939 printk(KERN_INFO
9940 "hda_codec: Cannot set up configuration "
9941 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009942 board_config = ALC861_3ST_DIG;
9943 }
9944 }
9945
9946 if (board_config != ALC861_AUTO)
9947 setup_preset(spec, &alc861_presets[board_config]);
9948
9949 spec->stream_name_analog = "ALC861 Analog";
9950 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9951 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9952
9953 spec->stream_name_digital = "ALC861 Digital";
9954 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9955 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9956
9957 codec->patch_ops = alc_patch_ops;
9958 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009959 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009960#ifdef CONFIG_SND_HDA_POWER_SAVE
9961 if (!spec->loopback.amplist)
9962 spec->loopback.amplist = alc861_loopbacks;
9963#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01009964
9965 return 0;
9966}
9967
9968/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009969 * ALC861-VD support
9970 *
9971 * Based on ALC882
9972 *
9973 * In addition, an independent DAC
9974 */
9975#define ALC861VD_DIGOUT_NID 0x06
9976
9977static hda_nid_t alc861vd_dac_nids[4] = {
9978 /* front, surr, clfe, side surr */
9979 0x02, 0x03, 0x04, 0x05
9980};
9981
9982/* dac_nids for ALC660vd are in a different order - according to
9983 * Realtek's driver.
9984 * This should probably tesult in a different mixer for 6stack models
9985 * of ALC660vd codecs, but for now there is only 3stack mixer
9986 * - and it is the same as in 861vd.
9987 * adc_nids in ALC660vd are (is) the same as in 861vd
9988 */
9989static hda_nid_t alc660vd_dac_nids[3] = {
9990 /* front, rear, clfe, rear_surr */
9991 0x02, 0x04, 0x03
9992};
9993
9994static hda_nid_t alc861vd_adc_nids[1] = {
9995 /* ADC0 */
9996 0x09,
9997};
9998
9999/* input MUX */
10000/* FIXME: should be a matrix-type input source selection */
10001static struct hda_input_mux alc861vd_capture_source = {
10002 .num_items = 4,
10003 .items = {
10004 { "Mic", 0x0 },
10005 { "Front Mic", 0x1 },
10006 { "Line", 0x2 },
10007 { "CD", 0x4 },
10008 },
10009};
10010
Kailang Yang272a5272007-05-14 11:00:38 +020010011static struct hda_input_mux alc861vd_dallas_capture_source = {
10012 .num_items = 3,
10013 .items = {
10014 { "Front Mic", 0x0 },
10015 { "ATAPI Mic", 0x1 },
10016 { "Line In", 0x5 },
10017 },
10018};
10019
Kailang Yangd1a991a2007-08-15 16:21:59 +020010020static struct hda_input_mux alc861vd_hp_capture_source = {
10021 .num_items = 2,
10022 .items = {
10023 { "Front Mic", 0x0 },
10024 { "ATAPI Mic", 0x1 },
10025 },
10026};
10027
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010028#define alc861vd_mux_enum_info alc_mux_enum_info
10029#define alc861vd_mux_enum_get alc_mux_enum_get
10030
10031static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10032 struct snd_ctl_elem_value *ucontrol)
10033{
10034 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10035 struct alc_spec *spec = codec->spec;
10036 const struct hda_input_mux *imux = spec->input_mux;
10037 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10038 static hda_nid_t capture_mixers[1] = { 0x22 };
10039 hda_nid_t nid = capture_mixers[adc_idx];
10040 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10041 unsigned int i, idx;
10042
10043 idx = ucontrol->value.enumerated.item[0];
10044 if (idx >= imux->num_items)
10045 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010046 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010047 return 0;
10048 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020010049 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10050 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10051 imux->items[i].index,
10052 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010053 }
10054 *cur_val = idx;
10055 return 1;
10056}
10057
10058/*
10059 * 2ch mode
10060 */
10061static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10062 { 2, NULL }
10063};
10064
10065/*
10066 * 6ch mode
10067 */
10068static struct hda_verb alc861vd_6stack_ch6_init[] = {
10069 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10070 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10071 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10072 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10073 { } /* end */
10074};
10075
10076/*
10077 * 8ch mode
10078 */
10079static struct hda_verb alc861vd_6stack_ch8_init[] = {
10080 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10081 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10082 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10083 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10084 { } /* end */
10085};
10086
10087static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10088 { 6, alc861vd_6stack_ch6_init },
10089 { 8, alc861vd_6stack_ch8_init },
10090};
10091
10092static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10093 {
10094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10095 .name = "Channel Mode",
10096 .info = alc_ch_mode_info,
10097 .get = alc_ch_mode_get,
10098 .put = alc_ch_mode_put,
10099 },
10100 { } /* end */
10101};
10102
10103static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10104 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10105 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10106
10107 {
10108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10109 /* The multiple "Capture Source" controls confuse alsamixer
10110 * So call somewhat different..
10111 *FIXME: the controls appear in the "playback" view!
10112 */
10113 /* .name = "Capture Source", */
10114 .name = "Input Source",
10115 .count = 1,
10116 .info = alc861vd_mux_enum_info,
10117 .get = alc861vd_mux_enum_get,
10118 .put = alc861vd_mux_enum_put,
10119 },
10120 { } /* end */
10121};
10122
10123/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10124 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10125 */
10126static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10127 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10128 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10129
10130 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10131 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10132
10133 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10134 HDA_OUTPUT),
10135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10136 HDA_OUTPUT),
10137 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10138 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10139
10140 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10141 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10142
10143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10144
10145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10148
10149 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10151 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10152
10153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10155
10156 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10157 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10158
10159 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10160 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10161
10162 { } /* end */
10163};
10164
10165static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10166 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10167 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10168
10169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10170
10171 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10174
10175 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10176 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10177 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10178
10179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10181
10182 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10183 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10184
10185 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10186 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10187
10188 { } /* end */
10189};
10190
Kailang Yangbdd148a2007-05-08 15:19:08 +020010191static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10192 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10193 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10194 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10195
10196 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10197
10198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10201
10202 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10205
10206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10208
10209 { } /* end */
10210};
10211
Kailang Yang272a5272007-05-14 11:00:38 +020010212/* Pin assignment: Front=0x14, HP = 0x15,
10213 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10214 */
10215static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10216 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10219 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10220 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10222 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10223 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020010226 { } /* end */
10227};
10228
Kailang Yangd1a991a2007-08-15 16:21:59 +020010229/* Pin assignment: Speaker=0x14, Line-out = 0x15,
10230 * Front Mic=0x18, ATAPI Mic = 0x19,
10231 */
10232static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10233 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10234 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10235 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10236 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10237 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10239 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10240 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10241
10242 { } /* end */
10243};
10244
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010245/*
10246 * generic initialization of ADC, input mixers and output mixers
10247 */
10248static struct hda_verb alc861vd_volume_init_verbs[] = {
10249 /*
10250 * Unmute ADC0 and set the default input to mic-in
10251 */
10252 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10254
10255 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10256 * the analog-loopback mixer widget
10257 */
10258 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010264
10265 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010270
10271 /*
10272 * Set up output mixers (0x02 - 0x05)
10273 */
10274 /* set vol=0 to output mixers */
10275 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10276 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10277 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10278 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10279
10280 /* set up input amps for analog loopback */
10281 /* Amp Indices: DAC = 0, mixer = 1 */
10282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10290
10291 { }
10292};
10293
10294/*
10295 * 3-stack pin configuration:
10296 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10297 */
10298static struct hda_verb alc861vd_3stack_init_verbs[] = {
10299 /*
10300 * Set pin mode and muting
10301 */
10302 /* set front pin widgets 0x14 for output */
10303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10305 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10306
10307 /* Mic (rear) pin: input vref at 80% */
10308 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10310 /* Front Mic pin: input vref at 80% */
10311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10313 /* Line In pin: input */
10314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10316 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10320 /* CD pin widget for input */
10321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10322
10323 { }
10324};
10325
10326/*
10327 * 6-stack pin configuration:
10328 */
10329static struct hda_verb alc861vd_6stack_init_verbs[] = {
10330 /*
10331 * Set pin mode and muting
10332 */
10333 /* set front pin widgets 0x14 for output */
10334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10336 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10337
10338 /* Rear Pin: output 1 (0x0d) */
10339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10342 /* CLFE Pin: output 2 (0x0e) */
10343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10345 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10346 /* Side Pin: output 3 (0x0f) */
10347 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10348 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10349 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10350
10351 /* Mic (rear) pin: input vref at 80% */
10352 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10354 /* Front Mic pin: input vref at 80% */
10355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10357 /* Line In pin: input */
10358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10360 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10362 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10364 /* CD pin widget for input */
10365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10366
10367 { }
10368};
10369
Kailang Yangbdd148a2007-05-08 15:19:08 +020010370static struct hda_verb alc861vd_eapd_verbs[] = {
10371 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10372 { }
10373};
10374
10375static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10379 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10380 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10381 {}
10382};
10383
10384/* toggle speaker-output according to the hp-jack state */
10385static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10386{
10387 unsigned int present;
10388 unsigned char bits;
10389
10390 present = snd_hda_codec_read(codec, 0x1b, 0,
10391 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010392 bits = present ? HDA_AMP_MUTE : 0;
10393 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10394 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010395}
10396
10397static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10398{
10399 unsigned int present;
10400 unsigned char bits;
10401
10402 present = snd_hda_codec_read(codec, 0x18, 0,
10403 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010404 bits = present ? HDA_AMP_MUTE : 0;
10405 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10406 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010407}
10408
10409static void alc861vd_lenovo_automute(struct hda_codec *codec)
10410{
10411 alc861vd_lenovo_hp_automute(codec);
10412 alc861vd_lenovo_mic_automute(codec);
10413}
10414
10415static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10416 unsigned int res)
10417{
10418 switch (res >> 26) {
10419 case ALC880_HP_EVENT:
10420 alc861vd_lenovo_hp_automute(codec);
10421 break;
10422 case ALC880_MIC_EVENT:
10423 alc861vd_lenovo_mic_automute(codec);
10424 break;
10425 }
10426}
10427
Kailang Yang272a5272007-05-14 11:00:38 +020010428static struct hda_verb alc861vd_dallas_verbs[] = {
10429 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10430 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10431 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10432 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10433
10434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10440 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10442
10443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10447 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10448 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10449 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10450 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10451
10452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10457 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10458 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10459 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10460
10461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10465
10466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10467 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10468 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10469
10470 { } /* end */
10471};
10472
10473/* toggle speaker-output according to the hp-jack state */
10474static void alc861vd_dallas_automute(struct hda_codec *codec)
10475{
10476 unsigned int present;
10477
10478 present = snd_hda_codec_read(codec, 0x15, 0,
10479 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010480 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10481 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020010482}
10483
10484static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10485{
10486 if ((res >> 26) == ALC880_HP_EVENT)
10487 alc861vd_dallas_automute(codec);
10488}
10489
Takashi Iwaicb53c622007-08-10 17:21:45 +020010490#ifdef CONFIG_SND_HDA_POWER_SAVE
10491#define alc861vd_loopbacks alc880_loopbacks
10492#endif
10493
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010494/* pcm configuration: identiacal with ALC880 */
10495#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10496#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10497#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10498#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10499
10500/*
10501 * configuration and preset
10502 */
10503static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10504 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010505 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010506 [ALC861VD_3ST] = "3stack",
10507 [ALC861VD_3ST_DIG] = "3stack-digout",
10508 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010509 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010510 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010511 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010512 [ALC861VD_AUTO] = "auto",
10513};
10514
10515static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010516 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010517 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010518 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010519 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10520 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10521
Kailang Yang272a5272007-05-14 11:00:38 +020010522 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10523 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010524 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10525 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010526 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020010527 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Tobin Davis625dc0b2007-07-30 21:42:10 +020010528 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010529 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010530 {}
10531};
10532
10533static struct alc_config_preset alc861vd_presets[] = {
10534 [ALC660VD_3ST] = {
10535 .mixers = { alc861vd_3st_mixer },
10536 .init_verbs = { alc861vd_volume_init_verbs,
10537 alc861vd_3stack_init_verbs },
10538 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10539 .dac_nids = alc660vd_dac_nids,
10540 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10541 .adc_nids = alc861vd_adc_nids,
10542 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10543 .channel_mode = alc861vd_3stack_2ch_modes,
10544 .input_mux = &alc861vd_capture_source,
10545 },
Mike Crash6963f842007-06-25 12:12:51 +020010546 [ALC660VD_3ST_DIG] = {
10547 .mixers = { alc861vd_3st_mixer },
10548 .init_verbs = { alc861vd_volume_init_verbs,
10549 alc861vd_3stack_init_verbs },
10550 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10551 .dac_nids = alc660vd_dac_nids,
10552 .dig_out_nid = ALC861VD_DIGOUT_NID,
10553 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10554 .adc_nids = alc861vd_adc_nids,
10555 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10556 .channel_mode = alc861vd_3stack_2ch_modes,
10557 .input_mux = &alc861vd_capture_source,
10558 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010559 [ALC861VD_3ST] = {
10560 .mixers = { alc861vd_3st_mixer },
10561 .init_verbs = { alc861vd_volume_init_verbs,
10562 alc861vd_3stack_init_verbs },
10563 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10564 .dac_nids = alc861vd_dac_nids,
10565 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10566 .channel_mode = alc861vd_3stack_2ch_modes,
10567 .input_mux = &alc861vd_capture_source,
10568 },
10569 [ALC861VD_3ST_DIG] = {
10570 .mixers = { alc861vd_3st_mixer },
10571 .init_verbs = { alc861vd_volume_init_verbs,
10572 alc861vd_3stack_init_verbs },
10573 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10574 .dac_nids = alc861vd_dac_nids,
10575 .dig_out_nid = ALC861VD_DIGOUT_NID,
10576 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10577 .channel_mode = alc861vd_3stack_2ch_modes,
10578 .input_mux = &alc861vd_capture_source,
10579 },
10580 [ALC861VD_6ST_DIG] = {
10581 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10582 .init_verbs = { alc861vd_volume_init_verbs,
10583 alc861vd_6stack_init_verbs },
10584 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10585 .dac_nids = alc861vd_dac_nids,
10586 .dig_out_nid = ALC861VD_DIGOUT_NID,
10587 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10588 .channel_mode = alc861vd_6stack_modes,
10589 .input_mux = &alc861vd_capture_source,
10590 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010591 [ALC861VD_LENOVO] = {
10592 .mixers = { alc861vd_lenovo_mixer },
10593 .init_verbs = { alc861vd_volume_init_verbs,
10594 alc861vd_3stack_init_verbs,
10595 alc861vd_eapd_verbs,
10596 alc861vd_lenovo_unsol_verbs },
10597 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10598 .dac_nids = alc660vd_dac_nids,
10599 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10600 .adc_nids = alc861vd_adc_nids,
10601 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10602 .channel_mode = alc861vd_3stack_2ch_modes,
10603 .input_mux = &alc861vd_capture_source,
10604 .unsol_event = alc861vd_lenovo_unsol_event,
10605 .init_hook = alc861vd_lenovo_automute,
10606 },
Kailang Yang272a5272007-05-14 11:00:38 +020010607 [ALC861VD_DALLAS] = {
10608 .mixers = { alc861vd_dallas_mixer },
10609 .init_verbs = { alc861vd_dallas_verbs },
10610 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10611 .dac_nids = alc861vd_dac_nids,
10612 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10613 .adc_nids = alc861vd_adc_nids,
10614 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10615 .channel_mode = alc861vd_3stack_2ch_modes,
10616 .input_mux = &alc861vd_dallas_capture_source,
10617 .unsol_event = alc861vd_dallas_unsol_event,
10618 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010619 },
10620 [ALC861VD_HP] = {
10621 .mixers = { alc861vd_hp_mixer },
10622 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
10623 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10624 .dac_nids = alc861vd_dac_nids,
10625 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10626 .dig_out_nid = ALC861VD_DIGOUT_NID,
10627 .adc_nids = alc861vd_adc_nids,
10628 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10629 .channel_mode = alc861vd_3stack_2ch_modes,
10630 .input_mux = &alc861vd_hp_capture_source,
10631 .unsol_event = alc861vd_dallas_unsol_event,
10632 .init_hook = alc861vd_dallas_automute,
10633 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010634};
10635
10636/*
10637 * BIOS auto configuration
10638 */
10639static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10640 hda_nid_t nid, int pin_type, int dac_idx)
10641{
10642 /* set as output */
10643 snd_hda_codec_write(codec, nid, 0,
10644 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10645 snd_hda_codec_write(codec, nid, 0,
10646 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10647}
10648
10649static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10650{
10651 struct alc_spec *spec = codec->spec;
10652 int i;
10653
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010654 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010655 for (i = 0; i <= HDA_SIDE; i++) {
10656 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010657 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010658 if (nid)
10659 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010660 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010661 }
10662}
10663
10664
10665static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10666{
10667 struct alc_spec *spec = codec->spec;
10668 hda_nid_t pin;
10669
10670 pin = spec->autocfg.hp_pins[0];
10671 if (pin) /* connect to front and use dac 0 */
10672 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10673}
10674
10675#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10676#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10677
10678static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10679{
10680 struct alc_spec *spec = codec->spec;
10681 int i;
10682
10683 for (i = 0; i < AUTO_PIN_LAST; i++) {
10684 hda_nid_t nid = spec->autocfg.input_pins[i];
10685 if (alc861vd_is_input_pin(nid)) {
10686 snd_hda_codec_write(codec, nid, 0,
10687 AC_VERB_SET_PIN_WIDGET_CONTROL,
10688 i <= AUTO_PIN_FRONT_MIC ?
10689 PIN_VREF80 : PIN_IN);
10690 if (nid != ALC861VD_PIN_CD_NID)
10691 snd_hda_codec_write(codec, nid, 0,
10692 AC_VERB_SET_AMP_GAIN_MUTE,
10693 AMP_OUT_MUTE);
10694 }
10695 }
10696}
10697
10698#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10699#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10700
10701/* add playback controls from the parsed DAC table */
10702/* Based on ALC880 version. But ALC861VD has separate,
10703 * different NIDs for mute/unmute switch and volume control */
10704static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10705 const struct auto_pin_cfg *cfg)
10706{
10707 char name[32];
10708 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10709 hda_nid_t nid_v, nid_s;
10710 int i, err;
10711
10712 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010713 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010714 continue;
10715 nid_v = alc861vd_idx_to_mixer_vol(
10716 alc880_dac_to_idx(
10717 spec->multiout.dac_nids[i]));
10718 nid_s = alc861vd_idx_to_mixer_switch(
10719 alc880_dac_to_idx(
10720 spec->multiout.dac_nids[i]));
10721
10722 if (i == 2) {
10723 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010724 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10725 "Center Playback Volume",
10726 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10727 HDA_OUTPUT));
10728 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010729 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010730 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10731 "LFE Playback Volume",
10732 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10733 HDA_OUTPUT));
10734 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010735 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010736 err = add_control(spec, ALC_CTL_BIND_MUTE,
10737 "Center Playback Switch",
10738 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10739 HDA_INPUT));
10740 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010741 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010742 err = add_control(spec, ALC_CTL_BIND_MUTE,
10743 "LFE Playback Switch",
10744 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10745 HDA_INPUT));
10746 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010747 return err;
10748 } else {
10749 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010750 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10751 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10752 HDA_OUTPUT));
10753 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010754 return err;
10755 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010756 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010757 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010758 HDA_INPUT));
10759 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010760 return err;
10761 }
10762 }
10763 return 0;
10764}
10765
10766/* add playback controls for speaker and HP outputs */
10767/* Based on ALC880 version. But ALC861VD has separate,
10768 * different NIDs for mute/unmute switch and volume control */
10769static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10770 hda_nid_t pin, const char *pfx)
10771{
10772 hda_nid_t nid_v, nid_s;
10773 int err;
10774 char name[32];
10775
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010776 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010777 return 0;
10778
10779 if (alc880_is_fixed_pin(pin)) {
10780 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10781 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010782 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010783 spec->multiout.hp_nid = nid_v;
10784 else
10785 spec->multiout.extra_out_nid[0] = nid_v;
10786 /* control HP volume/switch on the output mixer amp */
10787 nid_v = alc861vd_idx_to_mixer_vol(
10788 alc880_fixed_pin_idx(pin));
10789 nid_s = alc861vd_idx_to_mixer_switch(
10790 alc880_fixed_pin_idx(pin));
10791
10792 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010793 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10794 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10795 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010796 return err;
10797 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010798 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10799 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10800 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010801 return err;
10802 } else if (alc880_is_multi_pin(pin)) {
10803 /* set manual connection */
10804 /* we have only a switch on HP-out PIN */
10805 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010806 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10807 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10808 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010809 return err;
10810 }
10811 return 0;
10812}
10813
10814/* parse the BIOS configuration and set up the alc_spec
10815 * return 1 if successful, 0 if the proper config is not found,
10816 * or a negative error code
10817 * Based on ALC880 version - had to change it to override
10818 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10819static int alc861vd_parse_auto_config(struct hda_codec *codec)
10820{
10821 struct alc_spec *spec = codec->spec;
10822 int err;
10823 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10824
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010825 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10826 alc861vd_ignore);
10827 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010828 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010829 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010830 return 0; /* can't find valid BIOS pin config */
10831
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010832 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10833 if (err < 0)
10834 return err;
10835 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10836 if (err < 0)
10837 return err;
10838 err = alc861vd_auto_create_extra_out(spec,
10839 spec->autocfg.speaker_pins[0],
10840 "Speaker");
10841 if (err < 0)
10842 return err;
10843 err = alc861vd_auto_create_extra_out(spec,
10844 spec->autocfg.hp_pins[0],
10845 "Headphone");
10846 if (err < 0)
10847 return err;
10848 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10849 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010850 return err;
10851
10852 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10853
10854 if (spec->autocfg.dig_out_pin)
10855 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10856
10857 if (spec->kctl_alloc)
10858 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10859
10860 spec->init_verbs[spec->num_init_verbs++]
10861 = alc861vd_volume_init_verbs;
10862
10863 spec->num_mux_defs = 1;
10864 spec->input_mux = &spec->private_imux;
10865
10866 return 1;
10867}
10868
10869/* additional initialization for auto-configuration model */
10870static void alc861vd_auto_init(struct hda_codec *codec)
10871{
10872 alc861vd_auto_init_multi_out(codec);
10873 alc861vd_auto_init_hp_out(codec);
10874 alc861vd_auto_init_analog_input(codec);
10875}
10876
10877static int patch_alc861vd(struct hda_codec *codec)
10878{
10879 struct alc_spec *spec;
10880 int err, board_config;
10881
10882 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10883 if (spec == NULL)
10884 return -ENOMEM;
10885
10886 codec->spec = spec;
10887
10888 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10889 alc861vd_models,
10890 alc861vd_cfg_tbl);
10891
10892 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10893 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10894 "ALC861VD, trying auto-probe from BIOS...\n");
10895 board_config = ALC861VD_AUTO;
10896 }
10897
10898 if (board_config == ALC861VD_AUTO) {
10899 /* automatic parse from the BIOS config */
10900 err = alc861vd_parse_auto_config(codec);
10901 if (err < 0) {
10902 alc_free(codec);
10903 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010904 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010905 printk(KERN_INFO
10906 "hda_codec: Cannot set up configuration "
10907 "from BIOS. Using base mode...\n");
10908 board_config = ALC861VD_3ST;
10909 }
10910 }
10911
10912 if (board_config != ALC861VD_AUTO)
10913 setup_preset(spec, &alc861vd_presets[board_config]);
10914
10915 spec->stream_name_analog = "ALC861VD Analog";
10916 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10917 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10918
10919 spec->stream_name_digital = "ALC861VD Digital";
10920 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10921 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10922
10923 spec->adc_nids = alc861vd_adc_nids;
10924 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10925
10926 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10927 spec->num_mixers++;
10928
10929 codec->patch_ops = alc_patch_ops;
10930
10931 if (board_config == ALC861VD_AUTO)
10932 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010933#ifdef CONFIG_SND_HDA_POWER_SAVE
10934 if (!spec->loopback.amplist)
10935 spec->loopback.amplist = alc861vd_loopbacks;
10936#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010937
10938 return 0;
10939}
10940
10941/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010942 * ALC662 support
10943 *
10944 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10945 * configuration. Each pin widget can choose any input DACs and a mixer.
10946 * Each ADC is connected from a mixer of all inputs. This makes possible
10947 * 6-channel independent captures.
10948 *
10949 * In addition, an independent DAC for the multi-playback (not used in this
10950 * driver yet).
10951 */
10952#define ALC662_DIGOUT_NID 0x06
10953#define ALC662_DIGIN_NID 0x0a
10954
10955static hda_nid_t alc662_dac_nids[4] = {
10956 /* front, rear, clfe, rear_surr */
10957 0x02, 0x03, 0x04
10958};
10959
10960static hda_nid_t alc662_adc_nids[1] = {
10961 /* ADC1-2 */
10962 0x09,
10963};
10964/* input MUX */
10965/* FIXME: should be a matrix-type input source selection */
10966
10967static struct hda_input_mux alc662_capture_source = {
10968 .num_items = 4,
10969 .items = {
10970 { "Mic", 0x0 },
10971 { "Front Mic", 0x1 },
10972 { "Line", 0x2 },
10973 { "CD", 0x4 },
10974 },
10975};
10976
10977static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10978 .num_items = 2,
10979 .items = {
10980 { "Mic", 0x1 },
10981 { "Line", 0x2 },
10982 },
10983};
10984#define alc662_mux_enum_info alc_mux_enum_info
10985#define alc662_mux_enum_get alc_mux_enum_get
10986
10987static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10988 struct snd_ctl_elem_value *ucontrol)
10989{
10990 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10991 struct alc_spec *spec = codec->spec;
10992 const struct hda_input_mux *imux = spec->input_mux;
10993 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020010994 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010995 hda_nid_t nid = capture_mixers[adc_idx];
10996 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10997 unsigned int i, idx;
10998
10999 idx = ucontrol->value.enumerated.item[0];
11000 if (idx >= imux->num_items)
11001 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011002 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011003 return 0;
11004 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011005 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11006 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11007 imux->items[i].index,
11008 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011009 }
11010 *cur_val = idx;
11011 return 1;
11012}
11013/*
11014 * 2ch mode
11015 */
11016static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11017 { 2, NULL }
11018};
11019
11020/*
11021 * 2ch mode
11022 */
11023static struct hda_verb alc662_3ST_ch2_init[] = {
11024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11026 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11027 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11028 { } /* end */
11029};
11030
11031/*
11032 * 6ch mode
11033 */
11034static struct hda_verb alc662_3ST_ch6_init[] = {
11035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11037 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11038 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11039 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11040 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11041 { } /* end */
11042};
11043
11044static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11045 { 2, alc662_3ST_ch2_init },
11046 { 6, alc662_3ST_ch6_init },
11047};
11048
11049/*
11050 * 2ch mode
11051 */
11052static struct hda_verb alc662_sixstack_ch6_init[] = {
11053 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11054 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11055 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11056 { } /* end */
11057};
11058
11059/*
11060 * 6ch mode
11061 */
11062static struct hda_verb alc662_sixstack_ch8_init[] = {
11063 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11064 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11065 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11066 { } /* end */
11067};
11068
11069static struct hda_channel_mode alc662_5stack_modes[2] = {
11070 { 2, alc662_sixstack_ch6_init },
11071 { 6, alc662_sixstack_ch8_init },
11072};
11073
11074/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11075 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11076 */
11077
11078static struct snd_kcontrol_new alc662_base_mixer[] = {
11079 /* output mixer control */
11080 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11081 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11082 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11083 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11085 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11086 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11087 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11089
11090 /*Input mixer control */
11091 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11092 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11093 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11094 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11095 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11096 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11099
11100 /* Capture mixer control */
11101 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11102 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11103 {
11104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11105 .name = "Capture Source",
11106 .count = 1,
11107 .info = alc_mux_enum_info,
11108 .get = alc_mux_enum_get,
11109 .put = alc_mux_enum_put,
11110 },
11111 { } /* end */
11112};
11113
11114static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11115 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11116 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11126 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11127 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11130 {
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* .name = "Capture Source", */
11133 .name = "Input Source",
11134 .count = 1,
11135 .info = alc662_mux_enum_info,
11136 .get = alc662_mux_enum_get,
11137 .put = alc662_mux_enum_put,
11138 },
11139 { } /* end */
11140};
11141
11142static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11143 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11144 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11146 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11148 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11149 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11150 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11151 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11152 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11153 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11154 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11155 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11158 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11160 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11161 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11162 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11163 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11164 {
11165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11166 /* .name = "Capture Source", */
11167 .name = "Input Source",
11168 .count = 1,
11169 .info = alc662_mux_enum_info,
11170 .get = alc662_mux_enum_get,
11171 .put = alc662_mux_enum_put,
11172 },
11173 { } /* end */
11174};
11175
11176static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11177 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11178 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11179 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11180 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11181 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11186 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11187 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11188 {
11189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11190 /* .name = "Capture Source", */
11191 .name = "Input Source",
11192 .count = 1,
11193 .info = alc662_mux_enum_info,
11194 .get = alc662_mux_enum_get,
11195 .put = alc662_mux_enum_put,
11196 },
11197 { } /* end */
11198};
11199
11200static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11201 {
11202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11203 .name = "Channel Mode",
11204 .info = alc_ch_mode_info,
11205 .get = alc_ch_mode_get,
11206 .put = alc_ch_mode_put,
11207 },
11208 { } /* end */
11209};
11210
11211static struct hda_verb alc662_init_verbs[] = {
11212 /* ADC: mute amp left and right */
11213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11214 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11215 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11216
Takashi Iwaicb53c622007-08-10 17:21:45 +020011217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011222
11223 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11228 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11229
11230 /* Front Pin: output 0 (0x0c) */
11231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11233
11234 /* Rear Pin: output 1 (0x0d) */
11235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11237
11238 /* CLFE Pin: output 2 (0x0e) */
11239 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11241
11242 /* Mic (rear) pin: input vref at 80% */
11243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11245 /* Front Mic pin: input vref at 80% */
11246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11248 /* Line In pin: input */
11249 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11250 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11251 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11252 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11253 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11254 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11255 /* CD pin widget for input */
11256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11257
11258 /* FIXME: use matrix-type input source selection */
11259 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11260 /* Input mixer */
11261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11265 { }
11266};
11267
11268static struct hda_verb alc662_sue_init_verbs[] = {
11269 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11270 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11271 {}
11272};
11273
11274/*
11275 * generic initialization of ADC, input mixers and output mixers
11276 */
11277static struct hda_verb alc662_auto_init_verbs[] = {
11278 /*
11279 * Unmute ADC and set the default input to mic-in
11280 */
11281 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11283
11284 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11285 * mixer widget
11286 * Note: PASD motherboards uses the Line In 2 as the input for front
11287 * panel mic (mic 2)
11288 */
11289 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011295
11296 /*
11297 * Set up output mixers (0x0c - 0x0f)
11298 */
11299 /* set vol=0 to output mixers */
11300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11301 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11302 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11303
11304 /* set up input amps for analog loopback */
11305 /* Amp Indices: DAC = 0, mixer = 1 */
11306 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11310 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11311 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11312
11313
11314 /* FIXME: use matrix-type input source selection */
11315 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11316 /* Input mixer */
11317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020011318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011319 { }
11320};
11321
11322/* capture mixer elements */
11323static struct snd_kcontrol_new alc662_capture_mixer[] = {
11324 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11325 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11326 {
11327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11328 /* The multiple "Capture Source" controls confuse alsamixer
11329 * So call somewhat different..
11330 * FIXME: the controls appear in the "playback" view!
11331 */
11332 /* .name = "Capture Source", */
11333 .name = "Input Source",
11334 .count = 1,
11335 .info = alc882_mux_enum_info,
11336 .get = alc882_mux_enum_get,
11337 .put = alc882_mux_enum_put,
11338 },
11339 { } /* end */
11340};
11341
11342static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11343{
11344 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011345 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011346
11347 present = snd_hda_codec_read(codec, 0x14, 0,
11348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011349 bits = present ? HDA_AMP_MUTE : 0;
11350 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11351 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011352}
11353
11354static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11355{
11356 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011358
11359 present = snd_hda_codec_read(codec, 0x1b, 0,
11360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011361 bits = present ? HDA_AMP_MUTE : 0;
11362 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11363 HDA_AMP_MUTE, bits);
11364 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11365 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011366}
11367
11368static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11369 unsigned int res)
11370{
11371 if ((res >> 26) == ALC880_HP_EVENT)
11372 alc662_lenovo_101e_all_automute(codec);
11373 if ((res >> 26) == ALC880_FRONT_EVENT)
11374 alc662_lenovo_101e_ispeaker_automute(codec);
11375}
11376
Takashi Iwaicb53c622007-08-10 17:21:45 +020011377#ifdef CONFIG_SND_HDA_POWER_SAVE
11378#define alc662_loopbacks alc880_loopbacks
11379#endif
11380
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011381
11382/* pcm configuration: identiacal with ALC880 */
11383#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11384#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11385#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11386#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11387
11388/*
11389 * configuration and preset
11390 */
11391static const char *alc662_models[ALC662_MODEL_LAST] = {
11392 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11393 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11394 [ALC662_3ST_6ch] = "3stack-6ch",
11395 [ALC662_5ST_DIG] = "6stack-dig",
11396 [ALC662_LENOVO_101E] = "lenovo-101e",
11397 [ALC662_AUTO] = "auto",
11398};
11399
11400static struct snd_pci_quirk alc662_cfg_tbl[] = {
11401 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11402 {}
11403};
11404
11405static struct alc_config_preset alc662_presets[] = {
11406 [ALC662_3ST_2ch_DIG] = {
11407 .mixers = { alc662_3ST_2ch_mixer },
11408 .init_verbs = { alc662_init_verbs },
11409 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11410 .dac_nids = alc662_dac_nids,
11411 .dig_out_nid = ALC662_DIGOUT_NID,
11412 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11413 .adc_nids = alc662_adc_nids,
11414 .dig_in_nid = ALC662_DIGIN_NID,
11415 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11416 .channel_mode = alc662_3ST_2ch_modes,
11417 .input_mux = &alc662_capture_source,
11418 },
11419 [ALC662_3ST_6ch_DIG] = {
11420 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11421 .init_verbs = { alc662_init_verbs },
11422 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11423 .dac_nids = alc662_dac_nids,
11424 .dig_out_nid = ALC662_DIGOUT_NID,
11425 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11426 .adc_nids = alc662_adc_nids,
11427 .dig_in_nid = ALC662_DIGIN_NID,
11428 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11429 .channel_mode = alc662_3ST_6ch_modes,
11430 .need_dac_fix = 1,
11431 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011432 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011433 [ALC662_3ST_6ch] = {
11434 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11435 .init_verbs = { alc662_init_verbs },
11436 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11437 .dac_nids = alc662_dac_nids,
11438 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11439 .adc_nids = alc662_adc_nids,
11440 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11441 .channel_mode = alc662_3ST_6ch_modes,
11442 .need_dac_fix = 1,
11443 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011444 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011445 [ALC662_5ST_DIG] = {
11446 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11447 .init_verbs = { alc662_init_verbs },
11448 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11449 .dac_nids = alc662_dac_nids,
11450 .dig_out_nid = ALC662_DIGOUT_NID,
11451 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11452 .adc_nids = alc662_adc_nids,
11453 .dig_in_nid = ALC662_DIGIN_NID,
11454 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11455 .channel_mode = alc662_5stack_modes,
11456 .input_mux = &alc662_capture_source,
11457 },
11458 [ALC662_LENOVO_101E] = {
11459 .mixers = { alc662_lenovo_101e_mixer },
11460 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11461 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11462 .dac_nids = alc662_dac_nids,
11463 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11464 .adc_nids = alc662_adc_nids,
11465 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11466 .channel_mode = alc662_3ST_2ch_modes,
11467 .input_mux = &alc662_lenovo_101e_capture_source,
11468 .unsol_event = alc662_lenovo_101e_unsol_event,
11469 .init_hook = alc662_lenovo_101e_all_automute,
11470 },
11471
11472};
11473
11474
11475/*
11476 * BIOS auto configuration
11477 */
11478
11479/* add playback controls from the parsed DAC table */
11480static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11481 const struct auto_pin_cfg *cfg)
11482{
11483 char name[32];
11484 static const char *chname[4] = {
11485 "Front", "Surround", NULL /*CLFE*/, "Side"
11486 };
11487 hda_nid_t nid;
11488 int i, err;
11489
11490 for (i = 0; i < cfg->line_outs; i++) {
11491 if (!spec->multiout.dac_nids[i])
11492 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011493 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011494 if (i == 2) {
11495 /* Center/LFE */
11496 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11497 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011498 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11499 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011500 if (err < 0)
11501 return err;
11502 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11503 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011504 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11505 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011506 if (err < 0)
11507 return err;
11508 err = add_control(spec, ALC_CTL_BIND_MUTE,
11509 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011510 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11511 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011512 if (err < 0)
11513 return err;
11514 err = add_control(spec, ALC_CTL_BIND_MUTE,
11515 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11517 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011518 if (err < 0)
11519 return err;
11520 } else {
11521 sprintf(name, "%s Playback Volume", chname[i]);
11522 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011523 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11524 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011525 if (err < 0)
11526 return err;
11527 sprintf(name, "%s Playback Switch", chname[i]);
11528 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011529 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11530 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011531 if (err < 0)
11532 return err;
11533 }
11534 }
11535 return 0;
11536}
11537
11538/* add playback controls for speaker and HP outputs */
11539static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11540 const char *pfx)
11541{
11542 hda_nid_t nid;
11543 int err;
11544 char name[32];
11545
11546 if (!pin)
11547 return 0;
11548
11549 if (alc880_is_fixed_pin(pin)) {
11550 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11551 /* printk("DAC nid=%x\n",nid); */
11552 /* specify the DAC as the extra output */
11553 if (!spec->multiout.hp_nid)
11554 spec->multiout.hp_nid = nid;
11555 else
11556 spec->multiout.extra_out_nid[0] = nid;
11557 /* control HP volume/switch on the output mixer amp */
11558 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11559 sprintf(name, "%s Playback Volume", pfx);
11560 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11561 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11562 if (err < 0)
11563 return err;
11564 sprintf(name, "%s Playback Switch", pfx);
11565 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11566 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11567 if (err < 0)
11568 return err;
11569 } else if (alc880_is_multi_pin(pin)) {
11570 /* set manual connection */
11571 /* we have only a switch on HP-out PIN */
11572 sprintf(name, "%s Playback Switch", pfx);
11573 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11574 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11575 if (err < 0)
11576 return err;
11577 }
11578 return 0;
11579}
11580
11581/* create playback/capture controls for input pins */
11582static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11583 const struct auto_pin_cfg *cfg)
11584{
11585 struct hda_input_mux *imux = &spec->private_imux;
11586 int i, err, idx;
11587
11588 for (i = 0; i < AUTO_PIN_LAST; i++) {
11589 if (alc880_is_input_pin(cfg->input_pins[i])) {
11590 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11591 err = new_analog_input(spec, cfg->input_pins[i],
11592 auto_pin_cfg_labels[i],
11593 idx, 0x0b);
11594 if (err < 0)
11595 return err;
11596 imux->items[imux->num_items].label =
11597 auto_pin_cfg_labels[i];
11598 imux->items[imux->num_items].index =
11599 alc880_input_pin_idx(cfg->input_pins[i]);
11600 imux->num_items++;
11601 }
11602 }
11603 return 0;
11604}
11605
11606static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11607 hda_nid_t nid, int pin_type,
11608 int dac_idx)
11609{
11610 /* set as output */
11611 snd_hda_codec_write(codec, nid, 0,
11612 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11613 snd_hda_codec_write(codec, nid, 0,
11614 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11615 /* need the manual connection? */
11616 if (alc880_is_multi_pin(nid)) {
11617 struct alc_spec *spec = codec->spec;
11618 int idx = alc880_multi_pin_idx(nid);
11619 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11620 AC_VERB_SET_CONNECT_SEL,
11621 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11622 }
11623}
11624
11625static void alc662_auto_init_multi_out(struct hda_codec *codec)
11626{
11627 struct alc_spec *spec = codec->spec;
11628 int i;
11629
11630 for (i = 0; i <= HDA_SIDE; i++) {
11631 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011632 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011633 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011634 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011635 i);
11636 }
11637}
11638
11639static void alc662_auto_init_hp_out(struct hda_codec *codec)
11640{
11641 struct alc_spec *spec = codec->spec;
11642 hda_nid_t pin;
11643
11644 pin = spec->autocfg.hp_pins[0];
11645 if (pin) /* connect to front */
11646 /* use dac 0 */
11647 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11648}
11649
11650#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11651#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11652
11653static void alc662_auto_init_analog_input(struct hda_codec *codec)
11654{
11655 struct alc_spec *spec = codec->spec;
11656 int i;
11657
11658 for (i = 0; i < AUTO_PIN_LAST; i++) {
11659 hda_nid_t nid = spec->autocfg.input_pins[i];
11660 if (alc662_is_input_pin(nid)) {
11661 snd_hda_codec_write(codec, nid, 0,
11662 AC_VERB_SET_PIN_WIDGET_CONTROL,
11663 (i <= AUTO_PIN_FRONT_MIC ?
11664 PIN_VREF80 : PIN_IN));
11665 if (nid != ALC662_PIN_CD_NID)
11666 snd_hda_codec_write(codec, nid, 0,
11667 AC_VERB_SET_AMP_GAIN_MUTE,
11668 AMP_OUT_MUTE);
11669 }
11670 }
11671}
11672
11673static int alc662_parse_auto_config(struct hda_codec *codec)
11674{
11675 struct alc_spec *spec = codec->spec;
11676 int err;
11677 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11678
11679 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11680 alc662_ignore);
11681 if (err < 0)
11682 return err;
11683 if (!spec->autocfg.line_outs)
11684 return 0; /* can't find valid BIOS pin config */
11685
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011686 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11687 if (err < 0)
11688 return err;
11689 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11690 if (err < 0)
11691 return err;
11692 err = alc662_auto_create_extra_out(spec,
11693 spec->autocfg.speaker_pins[0],
11694 "Speaker");
11695 if (err < 0)
11696 return err;
11697 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11698 "Headphone");
11699 if (err < 0)
11700 return err;
11701 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11702 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011703 return err;
11704
11705 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11706
11707 if (spec->autocfg.dig_out_pin)
11708 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11709
11710 if (spec->kctl_alloc)
11711 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11712
11713 spec->num_mux_defs = 1;
11714 spec->input_mux = &spec->private_imux;
11715
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011716 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011717 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11718 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011719 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011720}
11721
11722/* additional initialization for auto-configuration model */
11723static void alc662_auto_init(struct hda_codec *codec)
11724{
11725 alc662_auto_init_multi_out(codec);
11726 alc662_auto_init_hp_out(codec);
11727 alc662_auto_init_analog_input(codec);
11728}
11729
11730static int patch_alc662(struct hda_codec *codec)
11731{
11732 struct alc_spec *spec;
11733 int err, board_config;
11734
11735 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11736 if (!spec)
11737 return -ENOMEM;
11738
11739 codec->spec = spec;
11740
11741 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11742 alc662_models,
11743 alc662_cfg_tbl);
11744 if (board_config < 0) {
11745 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11746 "trying auto-probe from BIOS...\n");
11747 board_config = ALC662_AUTO;
11748 }
11749
11750 if (board_config == ALC662_AUTO) {
11751 /* automatic parse from the BIOS config */
11752 err = alc662_parse_auto_config(codec);
11753 if (err < 0) {
11754 alc_free(codec);
11755 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011756 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011757 printk(KERN_INFO
11758 "hda_codec: Cannot set up configuration "
11759 "from BIOS. Using base mode...\n");
11760 board_config = ALC662_3ST_2ch_DIG;
11761 }
11762 }
11763
11764 if (board_config != ALC662_AUTO)
11765 setup_preset(spec, &alc662_presets[board_config]);
11766
11767 spec->stream_name_analog = "ALC662 Analog";
11768 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11769 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11770
11771 spec->stream_name_digital = "ALC662 Digital";
11772 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11773 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11774
11775 if (!spec->adc_nids && spec->input_mux) {
11776 spec->adc_nids = alc662_adc_nids;
11777 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11778 }
11779
11780 codec->patch_ops = alc_patch_ops;
11781 if (board_config == ALC662_AUTO)
11782 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011783#ifdef CONFIG_SND_HDA_POWER_SAVE
11784 if (!spec->loopback.amplist)
11785 spec->loopback.amplist = alc662_loopbacks;
11786#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011787
11788 return 0;
11789}
11790
11791/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011792 * patch entries
11793 */
11794struct hda_codec_preset snd_hda_preset_realtek[] = {
11795 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011796 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011797 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011798 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011799 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011800 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11801 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11802 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011803 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11804 .patch = patch_alc883 },
11805 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11806 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011807 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011808 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011809 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011810 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011811 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011812 {} /* terminator */
11813};