blob: 79eb0c17d453a3858c081cb453683a4459ded71f [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115};
116
Kailang Yangf6a92242007-12-13 16:52:54 +0100117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
Kailang Yangdf694da2005-12-05 19:42:22 +0100124/* ALC861 models */
125enum {
126 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200127 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200130 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200131 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200132 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100133 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136};
137
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100138/* ALC861-VD models */
139enum {
140 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200141 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200145 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200146 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200147 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150};
151
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200152/* ALC662 models */
153enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200159 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100160 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163};
164
Kailang Yangdf694da2005-12-05 19:42:22 +0100165/* ALC882 models */
166enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200169 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200170 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200173 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100174 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200175 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200176 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200177 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 ALC882_MODEL_LAST,
179};
180
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200181/* ALC883 models */
182enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200189 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200190 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200191 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200192 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100193 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100200 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100201 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204};
205
Kailang Yangdf694da2005-12-05 19:42:22 +0100206/* for GPIO Poll */
207#define GPIO_MASK 0x03
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209struct alc_spec {
210 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 unsigned int num_mixers;
213
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215 * don't forget NULL
216 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200217 */
218 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Takashi Iwai16ded522005-06-10 19:58:24 +0200220 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200226 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
229
230 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
234 */
Takashi Iwai63300792008-01-24 15:31:36 +0100235 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
242 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200243 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
246
247 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100248 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200250 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200254
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100258 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200259 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100261
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
265
Takashi Iwai834be882006-03-01 14:16:17 +0100266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200269
Takashi Iwai2134ea42008-01-10 16:53:55 +0100270 /* for virtual master */
271 hda_nid_t vmaster_nid;
272 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200273#ifdef CONFIG_SND_HDA_POWER_SAVE
274 struct hda_loopback_check loopback;
275#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100276};
277
278/*
279 * configuration template - to be copied to the spec instance
280 */
281struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282 struct snd_kcontrol_new *mixers[5]; /* should be identical size
283 * with spec
284 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100285 const struct hda_verb *init_verbs[5];
286 unsigned int num_dacs;
287 hda_nid_t *dac_nids;
288 hda_nid_t dig_out_nid; /* optional */
289 hda_nid_t hp_nid; /* optional */
290 unsigned int num_adc_nids;
291 hda_nid_t *adc_nids;
292 hda_nid_t dig_in_nid;
293 unsigned int num_channel_mode;
294 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200295 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200296 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100297 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100298 void (*unsol_event)(struct hda_codec *, unsigned int);
299 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200300#ifdef CONFIG_SND_HDA_POWER_SAVE
301 struct hda_amp_list *loopbacks;
302#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303};
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306/*
307 * input MUX handling
308 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200309static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311{
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200314 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
315 if (mux_idx >= spec->num_mux_defs)
316 mux_idx = 0;
317 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200320static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
325 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
326
327 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
328 return 0;
329}
330
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200331static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
335 struct alc_spec *spec = codec->spec;
336 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200337 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
338 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 spec->adc_nids[adc_idx],
340 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344/*
345 * channel mode setting
346 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200347static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
351 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100352 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
353 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354}
355
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200356static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358{
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100361 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362 spec->num_channel_mode,
363 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200371 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
372 spec->num_channel_mode,
373 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200374 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200375 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
376 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380 * Control the mode of pin widget settings via the mixer. "pc" is used
381 * instead of "%" to avoid consequences of accidently treating the % as
382 * being part of a format specifier. Maximum allowed length of a value is
383 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100384 *
385 * Note: some retasking pin complexes seem to ignore requests for input
386 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
387 * are requested. Therefore order this list so that this behaviour will not
388 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
390 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200391 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100393 "Mic 50pc bias", "Mic 80pc bias",
394 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100395};
396static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100397 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398};
399/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200400 * in the pin being assumed to be exclusively an input or an output pin. In
401 * addition, "input" pins may or may not process the mic bias option
402 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
403 * accept requests for bias as of chip versions up to March 2006) and/or
404 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200406#define ALC_PIN_DIR_IN 0x00
407#define ALC_PIN_DIR_OUT 0x01
408#define ALC_PIN_DIR_INOUT 0x02
409#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
410#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200412/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 * For each direction the minimum and maximum values are given.
414 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200415static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 { 0, 2 }, /* ALC_PIN_DIR_IN */
417 { 3, 4 }, /* ALC_PIN_DIR_OUT */
418 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200419 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
420 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421};
422#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
423#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
424#define alc_pin_mode_n_items(_dir) \
425 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200429{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100430 unsigned int item_num = uinfo->value.enumerated.item;
431 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
432
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200434 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
436
437 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
438 item_num = alc_pin_mode_min(dir);
439 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200440 return 0;
441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200445{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200450 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200451 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
452 AC_VERB_GET_PIN_WIDGET_CONTROL,
453 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200454
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100455 /* Find enumerated value for current pinctl setting */
456 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100458 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 return 0;
461}
462
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465{
466 signed int change;
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_PIN_WIDGET_CONTROL,
473 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200475 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 val = alc_pin_mode_min(dir);
477
478 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100479 if (change) {
480 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200481 snd_hda_codec_write_cache(codec, nid, 0,
482 AC_VERB_SET_PIN_WIDGET_CONTROL,
483 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100484
485 /* Also enable the retasking pin's input/output as required
486 * for the requested pin mode. Enum values of 2 or less are
487 * input modes.
488 *
489 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200490 * reduces noise slightly (particularly on input) so we'll
491 * do it. However, having both input and output buffers
492 * enabled simultaneously doesn't seem to be problematic if
493 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100494 */
495 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200496 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
497 HDA_AMP_MUTE, HDA_AMP_MUTE);
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
499 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100500 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200501 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
502 HDA_AMP_MUTE, HDA_AMP_MUTE);
503 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
504 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100505 }
506 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200507 return change;
508}
509
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 .info = alc_pin_mode_info, \
513 .get = alc_pin_mode_get, \
514 .put = alc_pin_mode_put, \
515 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100516
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100517/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
518 * together using a mask with more than one bit set. This control is
519 * currently used only by the ALC260 test model. At this stage they are not
520 * needed for any "production" models.
521 */
522#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200523#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 hda_nid_t nid = kcontrol->private_value & 0xffff;
530 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
531 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532 unsigned int val = snd_hda_codec_read(codec, nid, 0,
533 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100534
535 *valp = (val & mask) != 0;
536 return 0;
537}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100540{
541 signed int change;
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 hda_nid_t nid = kcontrol->private_value & 0xffff;
544 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
545 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
547 AC_VERB_GET_GPIO_DATA,
548 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100549
550 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
552 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100553 gpio_data &= ~mask;
554 else
555 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200556 snd_hda_codec_write_cache(codec, nid, 0,
557 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100558
559 return change;
560}
561#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
563 .info = alc_gpio_data_info, \
564 .get = alc_gpio_data_get, \
565 .put = alc_gpio_data_put, \
566 .private_value = nid | (mask<<16) }
567#endif /* CONFIG_SND_DEBUG */
568
Jonathan Woithe92621f12006-02-28 11:47:47 +0100569/* A switch control to allow the enabling of the digital IO pins on the
570 * ALC260. This is incredibly simplistic; the intention of this control is
571 * to provide something in the test model allowing digital outputs to be
572 * identified if present. If models are found which can utilise these
573 * outputs a more complete mixer control can be devised for those models if
574 * necessary.
575 */
576#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200577#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200578
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100581{
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
585 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100587 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100588
589 *valp = (val & mask) != 0;
590 return 0;
591}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100594{
595 signed int change;
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 hda_nid_t nid = kcontrol->private_value & 0xffff;
598 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
599 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200600 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100601 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100603
604 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100606 if (val==0)
607 ctrl_data &= ~mask;
608 else
609 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
611 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100612
613 return change;
614}
615#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
617 .info = alc_spdif_ctrl_info, \
618 .get = alc_spdif_ctrl_get, \
619 .put = alc_spdif_ctrl_put, \
620 .private_value = nid | (mask<<16) }
621#endif /* CONFIG_SND_DEBUG */
622
Jonathan Woithef8225f62008-01-08 12:16:54 +0100623/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
624 * Again, this is only used in the ALC26x test models to help identify when
625 * the EAPD line must be asserted for features to work.
626 */
627#ifdef CONFIG_SND_DEBUG
628#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
629
630static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
639
640 *valp = (val & mask) != 0;
641 return 0;
642}
643
644static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 int change;
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long val = *ucontrol->value.integer.value;
652 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_EAPD_BTLENABLE,
654 0x00);
655
656 /* Set/unset the masked control bit(s) as needed */
657 change = (!val ? 0 : mask) != (ctrl_data & mask);
658 if (!val)
659 ctrl_data &= ~mask;
660 else
661 ctrl_data |= mask;
662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
663 ctrl_data);
664
665 return change;
666}
667
668#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
670 .info = alc_eapd_ctrl_info, \
671 .get = alc_eapd_ctrl_get, \
672 .put = alc_eapd_ctrl_put, \
673 .private_value = nid | (mask<<16) }
674#endif /* CONFIG_SND_DEBUG */
675
Kailang Yangdf694da2005-12-05 19:42:22 +0100676/*
677 * set up from the preset table
678 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static void setup_preset(struct alc_spec *spec,
680 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100681{
682 int i;
683
684 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
685 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200686 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
687 i++)
688 spec->init_verbs[spec->num_init_verbs++] =
689 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100690
691 spec->channel_mode = preset->channel_mode;
692 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200693 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100694
695 spec->multiout.max_channels = spec->channel_mode[0].channels;
696
697 spec->multiout.num_dacs = preset->num_dacs;
698 spec->multiout.dac_nids = preset->dac_nids;
699 spec->multiout.dig_out_nid = preset->dig_out_nid;
700 spec->multiout.hp_nid = preset->hp_nid;
701
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200702 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200703 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200704 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100705 spec->input_mux = preset->input_mux;
706
707 spec->num_adc_nids = preset->num_adc_nids;
708 spec->adc_nids = preset->adc_nids;
709 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100710
711 spec->unsol_event = preset->unsol_event;
712 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200713#ifdef CONFIG_SND_HDA_POWER_SAVE
714 spec->loopback.amplist = preset->loopbacks;
715#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100716}
717
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200718/* Enable GPIO mask and set output */
719static struct hda_verb alc_gpio1_init_verbs[] = {
720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
723 { }
724};
725
726static struct hda_verb alc_gpio2_init_verbs[] = {
727 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
730 { }
731};
732
Kailang Yangbdd148a2007-05-08 15:19:08 +0200733static struct hda_verb alc_gpio3_init_verbs[] = {
734 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
735 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
737 { }
738};
739
Kailang Yangc9b58002007-10-16 14:30:01 +0200740static void alc_sku_automute(struct hda_codec *codec)
741{
742 struct alc_spec *spec = codec->spec;
743 unsigned int mute;
744 unsigned int present;
745 unsigned int hp_nid = spec->autocfg.hp_pins[0];
746 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
747
748 /* need to execute and sync at first */
749 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
750 present = snd_hda_codec_read(codec, hp_nid, 0,
751 AC_VERB_GET_PIN_SENSE, 0);
752 spec->jack_present = (present & 0x80000000) != 0;
753 if (spec->jack_present) {
754 /* mute internal speaker */
755 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
756 HDA_AMP_MUTE, HDA_AMP_MUTE);
757 } else {
758 /* unmute internal speaker if necessary */
759 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
760 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
761 HDA_AMP_MUTE, mute);
762 }
763}
764
765/* unsolicited event for HP jack sensing */
766static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
767{
768 if (codec->vendor_id == 0x10ec0880)
769 res >>= 28;
770 else
771 res >>= 26;
772 if (res != ALC880_HP_EVENT)
773 return;
774
775 alc_sku_automute(codec);
776}
777
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200778/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
779 * 31 ~ 16 : Manufacture ID
780 * 15 ~ 8 : SKU ID
781 * 7 ~ 0 : Assembly ID
782 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
783 */
784static void alc_subsystem_id(struct hda_codec *codec,
785 unsigned int porta, unsigned int porte,
786 unsigned int portd)
787{
Kailang Yangc9b58002007-10-16 14:30:01 +0200788 unsigned int ass, tmp, i;
789 unsigned nid;
790 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200791
Kailang Yangc9b58002007-10-16 14:30:01 +0200792 ass = codec->subsystem_id & 0xffff;
793 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
794 goto do_sku;
795
796 /*
797 * 31~30 : port conetcivity
798 * 29~21 : reserve
799 * 20 : PCBEEP input
800 * 19~16 : Check sum (15:1)
801 * 15~1 : Custom
802 * 0 : override
803 */
804 nid = 0x1d;
805 if (codec->vendor_id == 0x10ec0260)
806 nid = 0x17;
807 ass = snd_hda_codec_read(codec, nid, 0,
808 AC_VERB_GET_CONFIG_DEFAULT, 0);
809 if (!(ass & 1) && !(ass & 0x100000))
810 return;
811 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200812 return;
813
Kailang Yangc9b58002007-10-16 14:30:01 +0200814 /* check sum */
815 tmp = 0;
816 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100817 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200818 tmp++;
819 }
820 if (((ass >> 16) & 0xf) != tmp)
821 return;
822do_sku:
823 /*
824 * 0 : override
825 * 1 : Swap Jack
826 * 2 : 0 --> Desktop, 1 --> Laptop
827 * 3~5 : External Amplifier control
828 * 7~6 : Reserved
829 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200830 tmp = (ass & 0x38) >> 3; /* external Amp control */
831 switch (tmp) {
832 case 1:
833 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
834 break;
835 case 3:
836 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
837 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200838 case 7:
839 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
840 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200841 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200842 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200843 case 0x10ec0260:
844 snd_hda_codec_write(codec, 0x0f, 0,
845 AC_VERB_SET_EAPD_BTLENABLE, 2);
846 snd_hda_codec_write(codec, 0x10, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 break;
849 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200850 case 0x10ec0267:
851 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200852 case 0x10ec0269:
853 case 0x10ec0862:
854 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200855 snd_hda_codec_write(codec, 0x14, 0,
856 AC_VERB_SET_EAPD_BTLENABLE, 2);
857 snd_hda_codec_write(codec, 0x15, 0,
858 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200859 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200860 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200861 switch (codec->vendor_id) {
862 case 0x10ec0260:
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 tmp = snd_hda_codec_read(codec, 0x1a, 0,
866 AC_VERB_GET_PROC_COEF, 0);
867 snd_hda_codec_write(codec, 0x1a, 0,
868 AC_VERB_SET_COEF_INDEX, 7);
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_PROC_COEF,
871 tmp | 0x2010);
872 break;
873 case 0x10ec0262:
874 case 0x10ec0880:
875 case 0x10ec0882:
876 case 0x10ec0883:
877 case 0x10ec0885:
878 case 0x10ec0888:
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 tmp = snd_hda_codec_read(codec, 0x20, 0,
882 AC_VERB_GET_PROC_COEF, 0);
883 snd_hda_codec_write(codec, 0x20, 0,
884 AC_VERB_SET_COEF_INDEX, 7);
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_PROC_COEF,
887 tmp | 0x2010);
888 break;
889 case 0x10ec0267:
890 case 0x10ec0268:
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 tmp = snd_hda_codec_read(codec, 0x20, 0,
894 AC_VERB_GET_PROC_COEF, 0);
895 snd_hda_codec_write(codec, 0x20, 0,
896 AC_VERB_SET_COEF_INDEX, 7);
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_PROC_COEF,
899 tmp | 0x3000);
900 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200901 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200902 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200903 break;
904 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200905
Kailang Yang8c427222008-01-10 13:03:59 +0100906 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 * when the external headphone out jack is plugged"
908 */
Kailang Yang8c427222008-01-10 13:03:59 +0100909 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200910 return;
911 /*
912 * 10~8 : Jack location
913 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
914 * 14~13: Resvered
915 * 15 : 1 --> enable the function "Mute internal speaker
916 * when the external headphone out jack is plugged"
917 */
918 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100919 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200920 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100921 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 else
923 return;
924 }
925
926 if (!spec->autocfg.hp_pins[0]) {
927 tmp = (ass >> 11) & 0x3; /* HP to chassis */
928 if (tmp == 0)
929 spec->autocfg.hp_pins[0] = porta;
930 else if (tmp == 1)
931 spec->autocfg.hp_pins[0] = porte;
932 else if (tmp == 2)
933 spec->autocfg.hp_pins[0] = portd;
934 else
935 return;
936 }
937
938 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
939 AC_VERB_SET_UNSOLICITED_ENABLE,
940 AC_USRSP_EN | ALC880_HP_EVENT);
941 spec->unsol_event = alc_sku_unsol_event;
942 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200943}
944
Takashi Iwai41e41f12005-06-08 14:48:49 +0200945/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200946 * Fix-up pin default configurations
947 */
948
949struct alc_pincfg {
950 hda_nid_t nid;
951 u32 val;
952};
953
954static void alc_fix_pincfg(struct hda_codec *codec,
955 const struct snd_pci_quirk *quirk,
956 const struct alc_pincfg **pinfix)
957{
958 const struct alc_pincfg *cfg;
959
960 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
961 if (!quirk)
962 return;
963
964 cfg = pinfix[quirk->value];
965 for (; cfg->nid; cfg++) {
966 int i;
967 u32 val = cfg->val;
968 for (i = 0; i < 4; i++) {
969 snd_hda_codec_write(codec, cfg->nid, 0,
970 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
971 val & 0xff);
972 val >>= 8;
973 }
974 }
975}
976
977/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200978 * ALC880 3-stack model
979 *
980 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200981 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
982 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 */
984
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200985static hda_nid_t alc880_dac_nids[4] = {
986 /* front, rear, clfe, rear_surr */
987 0x02, 0x05, 0x04, 0x03
988};
989
990static hda_nid_t alc880_adc_nids[3] = {
991 /* ADC0-2 */
992 0x07, 0x08, 0x09,
993};
994
995/* The datasheet says the node 0x07 is connected from inputs,
996 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100997 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200999static hda_nid_t alc880_adc_nids_alt[2] = {
1000 /* ADC1-2 */
1001 0x08, 0x09,
1002};
1003
1004#define ALC880_DIGOUT_NID 0x06
1005#define ALC880_DIGIN_NID 0x0a
1006
1007static struct hda_input_mux alc880_capture_source = {
1008 .num_items = 4,
1009 .items = {
1010 { "Mic", 0x0 },
1011 { "Front Mic", 0x3 },
1012 { "Line", 0x2 },
1013 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001015};
1016
1017/* channel source setting (2/6 channel selection for 3-stack) */
1018/* 2ch mode */
1019static struct hda_verb alc880_threestack_ch2_init[] = {
1020 /* set line-in to input, mute it */
1021 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1022 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1023 /* set mic-in to input vref 80%, mute it */
1024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 { } /* end */
1027};
1028
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001029/* 6ch mode */
1030static struct hda_verb alc880_threestack_ch6_init[] = {
1031 /* set line-in to output, unmute it */
1032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1034 /* set mic-in to output, unmute it */
1035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1037 { } /* end */
1038};
1039
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001040static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 { 2, alc880_threestack_ch2_init },
1042 { 6, alc880_threestack_ch6_init },
1043};
1044
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001045static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001048 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001049 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001050 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001065 {
1066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1067 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001068 .info = alc_ch_mode_info,
1069 .get = alc_ch_mode_get,
1070 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 },
1072 { } /* end */
1073};
1074
1075/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001076static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1083 {
1084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1085 /* The multiple "Capture Source" controls confuse alsamixer
1086 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001087 */
1088 /* .name = "Capture Source", */
1089 .name = "Input Source",
1090 .count = 3,
1091 .info = alc_mux_enum_info,
1092 .get = alc_mux_enum_get,
1093 .put = alc_mux_enum_put,
1094 },
1095 { } /* end */
1096};
1097
1098/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001099static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 {
1105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1106 /* The multiple "Capture Source" controls confuse alsamixer
1107 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 */
1109 /* .name = "Capture Source", */
1110 .name = "Input Source",
1111 .count = 2,
1112 .info = alc_mux_enum_info,
1113 .get = alc_mux_enum_get,
1114 .put = alc_mux_enum_put,
1115 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 { } /* end */
1117};
1118
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001119
1120
1121/*
1122 * ALC880 5-stack model
1123 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001124 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1125 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001126 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1127 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1128 */
1129
1130/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001131static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001133 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 { } /* end */
1135};
1136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137/* channel source setting (6/8 channel selection for 5-stack) */
1138/* 6ch mode */
1139static struct hda_verb alc880_fivestack_ch6_init[] = {
1140 /* set line-in to input, mute it */
1141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001143 { } /* end */
1144};
1145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001146/* 8ch mode */
1147static struct hda_verb alc880_fivestack_ch8_init[] = {
1148 /* set line-in to output, unmute it */
1149 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1150 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1151 { } /* end */
1152};
1153
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001154static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155 { 6, alc880_fivestack_ch6_init },
1156 { 8, alc880_fivestack_ch8_init },
1157};
1158
1159
1160/*
1161 * ALC880 6-stack model
1162 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001163 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1164 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001165 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1166 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1167 */
1168
1169static hda_nid_t alc880_6st_dac_nids[4] = {
1170 /* front, rear, clfe, rear_surr */
1171 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001172};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001173
1174static struct hda_input_mux alc880_6stack_capture_source = {
1175 .num_items = 4,
1176 .items = {
1177 { "Mic", 0x0 },
1178 { "Front Mic", 0x1 },
1179 { "Line", 0x2 },
1180 { "CD", 0x4 },
1181 },
1182};
1183
1184/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001185static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001186 { 8, NULL },
1187};
1188
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001189static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001192 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001193 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1209 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001210 {
1211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1212 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001213 .info = alc_ch_mode_info,
1214 .get = alc_ch_mode_get,
1215 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001216 },
1217 { } /* end */
1218};
1219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220
1221/*
1222 * ALC880 W810 model
1223 *
1224 * W810 has rear IO for:
1225 * Front (DAC 02)
1226 * Surround (DAC 03)
1227 * Center/LFE (DAC 04)
1228 * Digital out (06)
1229 *
1230 * The system also has a pair of internal speakers, and a headphone jack.
1231 * These are both connected to Line2 on the codec, hence to DAC 02.
1232 *
1233 * There is a variable resistor to control the speaker or headphone
1234 * volume. This is a hardware-only device without a software API.
1235 *
1236 * Plugging headphones in will disable the internal speakers. This is
1237 * implemented in hardware, not via the driver using jack sense. In
1238 * a similar fashion, plugging into the rear socket marked "front" will
1239 * disable both the speakers and headphones.
1240 *
1241 * For input, there's a microphone jack, and an "audio in" jack.
1242 * These may not do anything useful with this driver yet, because I
1243 * haven't setup any initialization verbs for these yet...
1244 */
1245
1246static hda_nid_t alc880_w810_dac_nids[3] = {
1247 /* front, rear/surround, clfe */
1248 0x02, 0x03, 0x04
1249};
1250
1251/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001252static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 { 6, NULL }
1254};
1255
1256/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001257static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1267 { } /* end */
1268};
1269
1270
1271/*
1272 * Z710V model
1273 *
1274 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001275 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1276 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001277 */
1278
1279static hda_nid_t alc880_z71v_dac_nids[1] = {
1280 0x02
1281};
1282#define ALC880_Z71V_HP_DAC 0x03
1283
1284/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001285static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 { 2, NULL }
1287};
1288
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001289static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001293 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1298 { } /* end */
1299};
1300
1301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001302/*
1303 * ALC880 F1734 model
1304 *
1305 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1306 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1307 */
1308
1309static hda_nid_t alc880_f1734_dac_nids[1] = {
1310 0x03
1311};
1312#define ALC880_F1734_HP_DAC 0x02
1313
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001314static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001316 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1318 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001323 { } /* end */
1324};
1325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001327/*
1328 * ALC880 ASUS model
1329 *
1330 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1331 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1332 * Mic = 0x18, Line = 0x1a
1333 */
1334
1335#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1336#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1337
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001338static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001342 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001343 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001345 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001353 {
1354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1355 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001356 .info = alc_ch_mode_info,
1357 .get = alc_ch_mode_get,
1358 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001359 },
1360 { } /* end */
1361};
1362
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001363/*
1364 * ALC880 ASUS W1V model
1365 *
1366 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1367 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1368 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1369 */
1370
1371/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001372static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001373 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1374 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001375 { } /* end */
1376};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001378/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001379static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1382 { } /* end */
1383};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384
Kailang Yangdf694da2005-12-05 19:42:22 +01001385/* TCL S700 */
1386static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1388 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1396 {
1397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1398 /* The multiple "Capture Source" controls confuse alsamixer
1399 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001400 */
1401 /* .name = "Capture Source", */
1402 .name = "Input Source",
1403 .count = 1,
1404 .info = alc_mux_enum_info,
1405 .get = alc_mux_enum_get,
1406 .put = alc_mux_enum_put,
1407 },
1408 { } /* end */
1409};
1410
Kailang Yangccc656c2006-10-17 12:32:26 +02001411/* Uniwill */
1412static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1414 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1430 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1431 {
1432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1433 .name = "Channel Mode",
1434 .info = alc_ch_mode_info,
1435 .get = alc_ch_mode_get,
1436 .put = alc_ch_mode_put,
1437 },
1438 { } /* end */
1439};
1440
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001441static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1449 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1452 { } /* end */
1453};
1454
Kailang Yangccc656c2006-10-17 12:32:26 +02001455static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1462 { } /* end */
1463};
1464
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001466 * virtual master controls
1467 */
1468
1469/*
1470 * slave controls for virtual master
1471 */
1472static const char *alc_slave_vols[] = {
1473 "Front Playback Volume",
1474 "Surround Playback Volume",
1475 "Center Playback Volume",
1476 "LFE Playback Volume",
1477 "Side Playback Volume",
1478 "Headphone Playback Volume",
1479 "Speaker Playback Volume",
1480 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001481 "Line-Out Playback Volume",
1482 NULL,
1483};
1484
1485static const char *alc_slave_sws[] = {
1486 "Front Playback Switch",
1487 "Surround Playback Switch",
1488 "Center Playback Switch",
1489 "LFE Playback Switch",
1490 "Side Playback Switch",
1491 "Headphone Playback Switch",
1492 "Speaker Playback Switch",
1493 "Mono Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001494 NULL,
1495};
1496
1497/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001498 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 */
1500static int alc_build_controls(struct hda_codec *codec)
1501{
1502 struct alc_spec *spec = codec->spec;
1503 int err;
1504 int i;
1505
1506 for (i = 0; i < spec->num_mixers; i++) {
1507 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1508 if (err < 0)
1509 return err;
1510 }
1511
1512 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001513 err = snd_hda_create_spdif_out_ctls(codec,
1514 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 if (err < 0)
1516 return err;
1517 }
1518 if (spec->dig_in_nid) {
1519 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1520 if (err < 0)
1521 return err;
1522 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001523
1524 /* if we have no master control, let's create it */
1525 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1526 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1527 HDA_OUTPUT, spec->vmaster_tlv);
1528 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1529 spec->vmaster_tlv, alc_slave_vols);
1530 if (err < 0)
1531 return err;
1532 }
1533 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1534 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1535 NULL, alc_slave_sws);
1536 if (err < 0)
1537 return err;
1538 }
1539
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 return 0;
1541}
1542
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001543
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544/*
1545 * initialize the codec volumes, etc
1546 */
1547
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001548/*
1549 * generic initialization of ADC, input mixers and output mixers
1550 */
1551static struct hda_verb alc880_volume_init_verbs[] = {
1552 /*
1553 * Unmute ADC0-2 and set the default input to mic-in
1554 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001555 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001557 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001559 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1563 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001564 * Note: PASD motherboards uses the Line In 2 as the input for front
1565 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001567 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001576 /*
1577 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001579 /* set vol=0 to output mixers */
1580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 /* set up input amps for analog loopback */
1585 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594
1595 { }
1596};
1597
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001598/*
1599 * 3-stack pin configuration:
1600 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1601 */
1602static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1603 /*
1604 * preset connection lists of input pins
1605 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1606 */
1607 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1608 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1609 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1610
1611 /*
1612 * Set pin mode and muting
1613 */
1614 /* set front pin widgets 0x14 for output */
1615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1617 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1619 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1620 /* Mic2 (as headphone out) for HP output */
1621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1623 /* Line In pin widget for input */
1624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1626 /* Line2 (as front mic) pin widget for input and vref at 80% */
1627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1629 /* CD pin widget for input */
1630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1631
1632 { }
1633};
1634
1635/*
1636 * 5-stack pin configuration:
1637 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1638 * line-in/side = 0x1a, f-mic = 0x1b
1639 */
1640static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1641 /*
1642 * preset connection lists of input pins
1643 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1644 */
1645 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1646 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1647
1648 /*
1649 * Set pin mode and muting
1650 */
1651 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1654 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656 /* unmute pins for output (no gain on this amp) */
1657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1665 /* Mic2 (as headphone out) for HP output */
1666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001668 /* Line In pin widget for input */
1669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1671 /* Line2 (as front mic) pin widget for input and vref at 80% */
1672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1673 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1674 /* CD pin widget for input */
1675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676
1677 { }
1678};
1679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001680/*
1681 * W810 pin configuration:
1682 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1683 */
1684static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 /* hphone/speaker input selector: front DAC */
1686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694
1695 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001696 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 { }
1699};
1700
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001701/*
1702 * Z71V pin configuration:
1703 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1704 */
1705static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001708 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001710
Takashi Iwai16ded522005-06-10 19:58:24 +02001711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001714 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001715
1716 { }
1717};
1718
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001719/*
1720 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001721 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1722 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723 */
1724static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1725 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1726
Takashi Iwai16ded522005-06-10 19:58:24 +02001727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001733 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735
Takashi Iwai16ded522005-06-10 19:58:24 +02001736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001743 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001744 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001746 { }
1747};
Takashi Iwai16ded522005-06-10 19:58:24 +02001748
Kailang Yangccc656c2006-10-17 12:32:26 +02001749/*
1750 * Uniwill pin configuration:
1751 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1752 * line = 0x1a
1753 */
1754static struct hda_verb alc880_uniwill_init_verbs[] = {
1755 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1756
1757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1764 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771
1772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1779 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1780 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1781
1782 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1783 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1784
1785 { }
1786};
1787
1788/*
1789* Uniwill P53
1790* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1791 */
1792static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1793 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1794
1795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807
1808 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1813 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814
1815 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1816 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1817
1818 { }
1819};
1820
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001821static struct hda_verb alc880_beep_init_verbs[] = {
1822 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1823 { }
1824};
1825
Kailang Yangccc656c2006-10-17 12:32:26 +02001826/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001827static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001828{
1829 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001830 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001831
1832 present = snd_hda_codec_read(codec, 0x14, 0,
1833 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001834 bits = present ? HDA_AMP_MUTE : 0;
1835 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1836 HDA_AMP_MUTE, bits);
1837 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001839}
1840
1841/* auto-toggle front mic */
1842static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1843{
1844 unsigned int present;
1845 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001846
1847 present = snd_hda_codec_read(codec, 0x18, 0,
1848 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001849 bits = present ? HDA_AMP_MUTE : 0;
1850 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001851}
1852
1853static void alc880_uniwill_automute(struct hda_codec *codec)
1854{
1855 alc880_uniwill_hp_automute(codec);
1856 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001857}
1858
1859static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1860 unsigned int res)
1861{
1862 /* Looks like the unsol event is incompatible with the standard
1863 * definition. 4bit tag is placed at 28 bit!
1864 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001865 switch (res >> 28) {
1866 case ALC880_HP_EVENT:
1867 alc880_uniwill_hp_automute(codec);
1868 break;
1869 case ALC880_MIC_EVENT:
1870 alc880_uniwill_mic_automute(codec);
1871 break;
1872 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001873}
1874
1875static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1876{
1877 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001878 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001879
1880 present = snd_hda_codec_read(codec, 0x14, 0,
1881 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001882 bits = present ? HDA_AMP_MUTE : 0;
1883 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001884}
1885
1886static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1887{
1888 unsigned int present;
1889
1890 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001891 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1892 present &= HDA_AMP_VOLMASK;
1893 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1894 HDA_AMP_VOLMASK, present);
1895 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001897}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001898
Kailang Yangccc656c2006-10-17 12:32:26 +02001899static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1900 unsigned int res)
1901{
1902 /* Looks like the unsol event is incompatible with the standard
1903 * definition. 4bit tag is placed at 28 bit!
1904 */
1905 if ((res >> 28) == ALC880_HP_EVENT)
1906 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001907 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001908 alc880_uniwill_p53_dcvol_automute(codec);
1909}
1910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911/*
1912 * F1734 pin configuration:
1913 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1914 */
1915static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1916 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1917 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1918 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1919 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1920
1921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925
1926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001935
1936 { }
1937};
1938
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001939/*
1940 * ASUS pin configuration:
1941 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1942 */
1943static struct hda_verb alc880_pin_asus_init_verbs[] = {
1944 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1945 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1946 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1947 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1948
1949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957
1958 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1960 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1967
1968 { }
1969};
1970
1971/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001972#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1973#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001974
Kailang Yangdf694da2005-12-05 19:42:22 +01001975/* Clevo m520g init */
1976static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1977 /* headphone output */
1978 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1979 /* line-out */
1980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1982 /* Line-in */
1983 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1985 /* CD */
1986 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1987 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 /* Mic1 (rear panel) */
1989 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1991 /* Mic2 (front panel) */
1992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1994 /* headphone */
1995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1996 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 /* change to EAPD mode */
1998 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1999 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2000
2001 { }
2002};
2003
2004static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002005 /* change to EAPD mode */
2006 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2007 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2008
Kailang Yangdf694da2005-12-05 19:42:22 +01002009 /* Headphone output */
2010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2011 /* Front output*/
2012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2013 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2014
2015 /* Line In pin widget for input */
2016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2017 /* CD pin widget for input */
2018 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2020 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2021
2022 /* change to EAPD mode */
2023 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2024 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2025
2026 { }
2027};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002028
2029/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002030 * LG m1 express dual
2031 *
2032 * Pin assignment:
2033 * Rear Line-In/Out (blue): 0x14
2034 * Build-in Mic-In: 0x15
2035 * Speaker-out: 0x17
2036 * HP-Out (green): 0x1b
2037 * Mic-In/Out (red): 0x19
2038 * SPDIF-Out: 0x1e
2039 */
2040
2041/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2042static hda_nid_t alc880_lg_dac_nids[3] = {
2043 0x05, 0x02, 0x03
2044};
2045
2046/* seems analog CD is not working */
2047static struct hda_input_mux alc880_lg_capture_source = {
2048 .num_items = 3,
2049 .items = {
2050 { "Mic", 0x1 },
2051 { "Line", 0x5 },
2052 { "Internal Mic", 0x6 },
2053 },
2054};
2055
2056/* 2,4,6 channel modes */
2057static struct hda_verb alc880_lg_ch2_init[] = {
2058 /* set line-in and mic-in to input */
2059 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2060 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2061 { }
2062};
2063
2064static struct hda_verb alc880_lg_ch4_init[] = {
2065 /* set line-in to out and mic-in to input */
2066 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2067 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2068 { }
2069};
2070
2071static struct hda_verb alc880_lg_ch6_init[] = {
2072 /* set line-in and mic-in to output */
2073 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2074 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2075 { }
2076};
2077
2078static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2079 { 2, alc880_lg_ch2_init },
2080 { 4, alc880_lg_ch4_init },
2081 { 6, alc880_lg_ch6_init },
2082};
2083
2084static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2086 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002087 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2089 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2091 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2092 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2096 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2098 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2099 {
2100 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2101 .name = "Channel Mode",
2102 .info = alc_ch_mode_info,
2103 .get = alc_ch_mode_get,
2104 .put = alc_ch_mode_put,
2105 },
2106 { } /* end */
2107};
2108
2109static struct hda_verb alc880_lg_init_verbs[] = {
2110 /* set capture source to mic-in */
2111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2112 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2113 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 /* mute all amp mixer inputs */
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002118 /* line-in to input */
2119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2120 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2121 /* built-in mic */
2122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2124 /* speaker-out */
2125 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 /* mic-in to input */
2128 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2131 /* HP-out */
2132 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2133 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2134 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2135 /* jack sense */
2136 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2137 { }
2138};
2139
2140/* toggle speaker-output according to the hp-jack state */
2141static void alc880_lg_automute(struct hda_codec *codec)
2142{
2143 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002144 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002145
2146 present = snd_hda_codec_read(codec, 0x1b, 0,
2147 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002148 bits = present ? HDA_AMP_MUTE : 0;
2149 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2150 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002151}
2152
2153static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2154{
2155 /* Looks like the unsol event is incompatible with the standard
2156 * definition. 4bit tag is placed at 28 bit!
2157 */
2158 if ((res >> 28) == 0x01)
2159 alc880_lg_automute(codec);
2160}
2161
2162/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002163 * LG LW20
2164 *
2165 * Pin assignment:
2166 * Speaker-out: 0x14
2167 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002168 * Built-in Mic-In: 0x19
2169 * Line-In: 0x1b
2170 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002171 * SPDIF-Out: 0x1e
2172 */
2173
Takashi Iwaid6815182006-03-23 16:06:23 +01002174static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002175 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002176 .items = {
2177 { "Mic", 0x0 },
2178 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002179 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002180 },
2181};
2182
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002183#define alc880_lg_lw_modes alc880_threestack_modes
2184
Takashi Iwaid6815182006-03-23 16:06:23 +01002185static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2199 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002200 {
2201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2202 .name = "Channel Mode",
2203 .info = alc_ch_mode_info,
2204 .get = alc_ch_mode_get,
2205 .put = alc_ch_mode_put,
2206 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002207 { } /* end */
2208};
2209
2210static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002211 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2212 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2213 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2214
Takashi Iwaid6815182006-03-23 16:06:23 +01002215 /* set capture source to mic-in */
2216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2217 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002220 /* speaker-out */
2221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 /* mic-in to input */
2227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2229 /* built-in mic */
2230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 /* jack sense */
2233 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2234 { }
2235};
2236
2237/* toggle speaker-output according to the hp-jack state */
2238static void alc880_lg_lw_automute(struct hda_codec *codec)
2239{
2240 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002241 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002242
2243 present = snd_hda_codec_read(codec, 0x1b, 0,
2244 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002245 bits = present ? HDA_AMP_MUTE : 0;
2246 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2247 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002248}
2249
2250static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2251{
2252 /* Looks like the unsol event is incompatible with the standard
2253 * definition. 4bit tag is placed at 28 bit!
2254 */
2255 if ((res >> 28) == 0x01)
2256 alc880_lg_lw_automute(codec);
2257}
2258
Takashi Iwaicb53c622007-08-10 17:21:45 +02002259#ifdef CONFIG_SND_HDA_POWER_SAVE
2260static struct hda_amp_list alc880_loopbacks[] = {
2261 { 0x0b, HDA_INPUT, 0 },
2262 { 0x0b, HDA_INPUT, 1 },
2263 { 0x0b, HDA_INPUT, 2 },
2264 { 0x0b, HDA_INPUT, 3 },
2265 { 0x0b, HDA_INPUT, 4 },
2266 { } /* end */
2267};
2268
2269static struct hda_amp_list alc880_lg_loopbacks[] = {
2270 { 0x0b, HDA_INPUT, 1 },
2271 { 0x0b, HDA_INPUT, 6 },
2272 { 0x0b, HDA_INPUT, 7 },
2273 { } /* end */
2274};
2275#endif
2276
Takashi Iwaid6815182006-03-23 16:06:23 +01002277/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002278 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002279 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002280
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281static int alc_init(struct hda_codec *codec)
2282{
2283 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 unsigned int i;
2285
2286 for (i = 0; i < spec->num_init_verbs; i++)
2287 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002288
2289 if (spec->init_hook)
2290 spec->init_hook(codec);
2291
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 return 0;
2293}
2294
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002295static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2296{
2297 struct alc_spec *spec = codec->spec;
2298
2299 if (spec->unsol_event)
2300 spec->unsol_event(codec, res);
2301}
2302
Takashi Iwaicb53c622007-08-10 17:21:45 +02002303#ifdef CONFIG_SND_HDA_POWER_SAVE
2304static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2305{
2306 struct alc_spec *spec = codec->spec;
2307 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2308}
2309#endif
2310
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311/*
2312 * Analog playback callbacks
2313 */
2314static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2315 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002316 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317{
2318 struct alc_spec *spec = codec->spec;
2319 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2320}
2321
2322static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2323 struct hda_codec *codec,
2324 unsigned int stream_tag,
2325 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002326 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327{
2328 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002329 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2330 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331}
2332
2333static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2334 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002335 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336{
2337 struct alc_spec *spec = codec->spec;
2338 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2339}
2340
2341/*
2342 * Digital out
2343 */
2344static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2345 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002346 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347{
2348 struct alc_spec *spec = codec->spec;
2349 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2350}
2351
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002352static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2353 struct hda_codec *codec,
2354 unsigned int stream_tag,
2355 unsigned int format,
2356 struct snd_pcm_substream *substream)
2357{
2358 struct alc_spec *spec = codec->spec;
2359 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2360 stream_tag, format, substream);
2361}
2362
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002365 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366{
2367 struct alc_spec *spec = codec->spec;
2368 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2369}
2370
2371/*
2372 * Analog capture
2373 */
Takashi Iwai63300792008-01-24 15:31:36 +01002374static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375 struct hda_codec *codec,
2376 unsigned int stream_tag,
2377 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002378 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379{
2380 struct alc_spec *spec = codec->spec;
2381
Takashi Iwai63300792008-01-24 15:31:36 +01002382 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 stream_tag, 0, format);
2384 return 0;
2385}
2386
Takashi Iwai63300792008-01-24 15:31:36 +01002387static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002389 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390{
2391 struct alc_spec *spec = codec->spec;
2392
Takashi Iwai63300792008-01-24 15:31:36 +01002393 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002394 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 return 0;
2396}
2397
2398
2399/*
2400 */
2401static struct hda_pcm_stream alc880_pcm_analog_playback = {
2402 .substreams = 1,
2403 .channels_min = 2,
2404 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 .ops = {
2407 .open = alc880_playback_pcm_open,
2408 .prepare = alc880_playback_pcm_prepare,
2409 .cleanup = alc880_playback_pcm_cleanup
2410 },
2411};
2412
2413static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002414 .substreams = 1,
2415 .channels_min = 2,
2416 .channels_max = 2,
2417 /* NID is set in alc_build_pcms */
2418};
2419
2420static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2421 .substreams = 1,
2422 .channels_min = 2,
2423 .channels_max = 2,
2424 /* NID is set in alc_build_pcms */
2425};
2426
2427static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2428 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 .channels_min = 2,
2430 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002431 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002433 .prepare = alc880_alt_capture_pcm_prepare,
2434 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 },
2436};
2437
2438static struct hda_pcm_stream alc880_pcm_digital_playback = {
2439 .substreams = 1,
2440 .channels_min = 2,
2441 .channels_max = 2,
2442 /* NID is set in alc_build_pcms */
2443 .ops = {
2444 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002445 .close = alc880_dig_playback_pcm_close,
2446 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 },
2448};
2449
2450static struct hda_pcm_stream alc880_pcm_digital_capture = {
2451 .substreams = 1,
2452 .channels_min = 2,
2453 .channels_max = 2,
2454 /* NID is set in alc_build_pcms */
2455};
2456
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002457/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002458static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002459 .substreams = 0,
2460 .channels_min = 0,
2461 .channels_max = 0,
2462};
2463
Linus Torvalds1da177e2005-04-16 15:20:36 -07002464static int alc_build_pcms(struct hda_codec *codec)
2465{
2466 struct alc_spec *spec = codec->spec;
2467 struct hda_pcm *info = spec->pcm_rec;
2468 int i;
2469
2470 codec->num_pcms = 1;
2471 codec->pcm_info = info;
2472
2473 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002474 if (spec->stream_analog_playback) {
2475 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2476 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2477 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2478 }
2479 if (spec->stream_analog_capture) {
2480 snd_assert(spec->adc_nids, return -EINVAL);
2481 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2482 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484
Takashi Iwai4a471b72005-12-07 13:56:29 +01002485 if (spec->channel_mode) {
2486 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2487 for (i = 0; i < spec->num_channel_mode; i++) {
2488 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2489 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2490 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 }
2492 }
2493
Takashi Iwaie08a0072006-09-07 17:52:14 +02002494 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002496 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002497 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002499 if (spec->multiout.dig_out_nid &&
2500 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2502 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2503 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002504 if (spec->dig_in_nid &&
2505 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2507 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2508 }
2509 }
2510
Takashi Iwaie08a0072006-09-07 17:52:14 +02002511 /* If the use of more than one ADC is requested for the current
2512 * model, configure a second analog capture-only PCM.
2513 */
2514 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002515 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2516 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002517 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002518 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002519 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002520 if (spec->alt_dac_nid) {
2521 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2522 *spec->stream_analog_alt_playback;
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2524 spec->alt_dac_nid;
2525 } else {
2526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2527 alc_pcm_null_stream;
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2529 }
2530 if (spec->num_adc_nids > 1) {
2531 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2532 *spec->stream_analog_alt_capture;
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2534 spec->adc_nids[1];
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2536 spec->num_adc_nids - 1;
2537 } else {
2538 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2539 alc_pcm_null_stream;
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002541 }
2542 }
2543
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 return 0;
2545}
2546
2547static void alc_free(struct hda_codec *codec)
2548{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549 struct alc_spec *spec = codec->spec;
2550 unsigned int i;
2551
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002552 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 return;
2554
2555 if (spec->kctl_alloc) {
2556 for (i = 0; i < spec->num_kctl_used; i++)
2557 kfree(spec->kctl_alloc[i].name);
2558 kfree(spec->kctl_alloc);
2559 }
2560 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561}
2562
2563/*
2564 */
2565static struct hda_codec_ops alc_patch_ops = {
2566 .build_controls = alc_build_controls,
2567 .build_pcms = alc_build_pcms,
2568 .init = alc_init,
2569 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002570 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002571#ifdef CONFIG_SND_HDA_POWER_SAVE
2572 .check_power_status = alc_check_power_status,
2573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574};
2575
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002576
2577/*
2578 * Test configuration for debugging
2579 *
2580 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2581 * enum controls.
2582 */
2583#ifdef CONFIG_SND_DEBUG
2584static hda_nid_t alc880_test_dac_nids[4] = {
2585 0x02, 0x03, 0x04, 0x05
2586};
2587
2588static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002589 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002590 .items = {
2591 { "In-1", 0x0 },
2592 { "In-2", 0x1 },
2593 { "In-3", 0x2 },
2594 { "In-4", 0x3 },
2595 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002596 { "Front", 0x5 },
2597 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002598 },
2599};
2600
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002601static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002602 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002603 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002604 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002605 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002606};
2607
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002608static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2609 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002610{
2611 static char *texts[] = {
2612 "N/A", "Line Out", "HP Out",
2613 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2614 };
2615 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2616 uinfo->count = 1;
2617 uinfo->value.enumerated.items = 8;
2618 if (uinfo->value.enumerated.item >= 8)
2619 uinfo->value.enumerated.item = 7;
2620 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2621 return 0;
2622}
2623
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002624static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002626{
2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2628 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2629 unsigned int pin_ctl, item = 0;
2630
2631 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2632 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2633 if (pin_ctl & AC_PINCTL_OUT_EN) {
2634 if (pin_ctl & AC_PINCTL_HP_EN)
2635 item = 2;
2636 else
2637 item = 1;
2638 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2639 switch (pin_ctl & AC_PINCTL_VREFEN) {
2640 case AC_PINCTL_VREF_HIZ: item = 3; break;
2641 case AC_PINCTL_VREF_50: item = 4; break;
2642 case AC_PINCTL_VREF_GRD: item = 5; break;
2643 case AC_PINCTL_VREF_80: item = 6; break;
2644 case AC_PINCTL_VREF_100: item = 7; break;
2645 }
2646 }
2647 ucontrol->value.enumerated.item[0] = item;
2648 return 0;
2649}
2650
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002651static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2652 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002653{
2654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2655 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2656 static unsigned int ctls[] = {
2657 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2658 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2659 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2663 };
2664 unsigned int old_ctl, new_ctl;
2665
2666 old_ctl = snd_hda_codec_read(codec, nid, 0,
2667 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2668 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2669 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002670 int val;
2671 snd_hda_codec_write_cache(codec, nid, 0,
2672 AC_VERB_SET_PIN_WIDGET_CONTROL,
2673 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002674 val = ucontrol->value.enumerated.item[0] >= 3 ?
2675 HDA_AMP_MUTE : 0;
2676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2677 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002678 return 1;
2679 }
2680 return 0;
2681}
2682
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002683static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2684 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002685{
2686 static char *texts[] = {
2687 "Front", "Surround", "CLFE", "Side"
2688 };
2689 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2690 uinfo->count = 1;
2691 uinfo->value.enumerated.items = 4;
2692 if (uinfo->value.enumerated.item >= 4)
2693 uinfo->value.enumerated.item = 3;
2694 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2695 return 0;
2696}
2697
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002698static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2699 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002700{
2701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2702 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2703 unsigned int sel;
2704
2705 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2706 ucontrol->value.enumerated.item[0] = sel & 3;
2707 return 0;
2708}
2709
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002710static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2711 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002712{
2713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2714 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2715 unsigned int sel;
2716
2717 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2718 if (ucontrol->value.enumerated.item[0] != sel) {
2719 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002720 snd_hda_codec_write_cache(codec, nid, 0,
2721 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002722 return 1;
2723 }
2724 return 0;
2725}
2726
2727#define PIN_CTL_TEST(xname,nid) { \
2728 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2729 .name = xname, \
2730 .info = alc_test_pin_ctl_info, \
2731 .get = alc_test_pin_ctl_get, \
2732 .put = alc_test_pin_ctl_put, \
2733 .private_value = nid \
2734 }
2735
2736#define PIN_SRC_TEST(xname,nid) { \
2737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2738 .name = xname, \
2739 .info = alc_test_pin_src_info, \
2740 .get = alc_test_pin_src_get, \
2741 .put = alc_test_pin_src_put, \
2742 .private_value = nid \
2743 }
2744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002745static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002746 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2748 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002750 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2751 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2752 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002754 PIN_CTL_TEST("Front Pin Mode", 0x14),
2755 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2756 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2757 PIN_CTL_TEST("Side Pin Mode", 0x17),
2758 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2759 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2760 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2761 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2762 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2763 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2764 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2765 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2766 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2767 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2768 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2774 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2775 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002776 {
2777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2778 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002779 .info = alc_ch_mode_info,
2780 .get = alc_ch_mode_get,
2781 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002782 },
2783 { } /* end */
2784};
2785
2786static struct hda_verb alc880_test_init_verbs[] = {
2787 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2790 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002796 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2798 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2799 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002801 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2804 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002806 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2809 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002811 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002812 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2815 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2816 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002817 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002818 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002822 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002824 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002826 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002828 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002829 /* Analog input/passthru */
2830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002835 { }
2836};
2837#endif
2838
Linus Torvalds1da177e2005-04-16 15:20:36 -07002839/*
2840 */
2841
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002842static const char *alc880_models[ALC880_MODEL_LAST] = {
2843 [ALC880_3ST] = "3stack",
2844 [ALC880_TCL_S700] = "tcl",
2845 [ALC880_3ST_DIG] = "3stack-digout",
2846 [ALC880_CLEVO] = "clevo",
2847 [ALC880_5ST] = "5stack",
2848 [ALC880_5ST_DIG] = "5stack-digout",
2849 [ALC880_W810] = "w810",
2850 [ALC880_Z71V] = "z71v",
2851 [ALC880_6ST] = "6stack",
2852 [ALC880_6ST_DIG] = "6stack-digout",
2853 [ALC880_ASUS] = "asus",
2854 [ALC880_ASUS_W1V] = "asus-w1v",
2855 [ALC880_ASUS_DIG] = "asus-dig",
2856 [ALC880_ASUS_DIG2] = "asus-dig2",
2857 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002858 [ALC880_UNIWILL_P53] = "uniwill-p53",
2859 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002860 [ALC880_F1734] = "F1734",
2861 [ALC880_LG] = "lg",
2862 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002863#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002864 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002865#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002866 [ALC880_AUTO] = "auto",
2867};
2868
2869static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002870 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002871 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2872 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2873 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2874 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2875 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002879 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2880 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002881 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2882 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2883 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2884 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2888 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2889 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2890 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002891 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002892 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2893 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2894 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002895 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002896 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002897 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2898 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002899 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2900 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002901 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2902 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2903 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002905 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2906 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002907 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002908 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002909 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002910 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002911 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2912 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002913 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2914 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002915 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002916 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002917 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002918 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002919 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002920 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2921 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002922 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002923 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2924 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2925 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2926 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002927 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002929 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002930 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002931 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2932 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002933 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2935 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002936 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2937 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2938 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939 {}
2940};
2941
Takashi Iwai16ded522005-06-10 19:58:24 +02002942/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002943 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002944 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002945static struct alc_config_preset alc880_presets[] = {
2946 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002948 .init_verbs = { alc880_volume_init_verbs,
2949 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002950 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002951 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002952 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2953 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002954 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002955 .input_mux = &alc880_capture_source,
2956 },
2957 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002959 .init_verbs = { alc880_volume_init_verbs,
2960 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002961 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002962 .dac_nids = alc880_dac_nids,
2963 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2965 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002966 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002967 .input_mux = &alc880_capture_source,
2968 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002969 [ALC880_TCL_S700] = {
2970 .mixers = { alc880_tcl_s700_mixer },
2971 .init_verbs = { alc880_volume_init_verbs,
2972 alc880_pin_tcl_S700_init_verbs,
2973 alc880_gpio2_init_verbs },
2974 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2975 .dac_nids = alc880_dac_nids,
2976 .hp_nid = 0x03,
2977 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2978 .channel_mode = alc880_2_jack_modes,
2979 .input_mux = &alc880_capture_source,
2980 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002982 .mixers = { alc880_three_stack_mixer,
2983 alc880_five_stack_mixer},
2984 .init_verbs = { alc880_volume_init_verbs,
2985 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002986 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2987 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002988 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2989 .channel_mode = alc880_fivestack_modes,
2990 .input_mux = &alc880_capture_source,
2991 },
2992 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002993 .mixers = { alc880_three_stack_mixer,
2994 alc880_five_stack_mixer },
2995 .init_verbs = { alc880_volume_init_verbs,
2996 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002997 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2998 .dac_nids = alc880_dac_nids,
2999 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3001 .channel_mode = alc880_fivestack_modes,
3002 .input_mux = &alc880_capture_source,
3003 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003004 [ALC880_6ST] = {
3005 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003006 .init_verbs = { alc880_volume_init_verbs,
3007 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003008 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3009 .dac_nids = alc880_6st_dac_nids,
3010 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3011 .channel_mode = alc880_sixstack_modes,
3012 .input_mux = &alc880_6stack_capture_source,
3013 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003014 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003015 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003016 .init_verbs = { alc880_volume_init_verbs,
3017 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003018 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3019 .dac_nids = alc880_6st_dac_nids,
3020 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003021 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3022 .channel_mode = alc880_sixstack_modes,
3023 .input_mux = &alc880_6stack_capture_source,
3024 },
3025 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003026 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003027 .init_verbs = { alc880_volume_init_verbs,
3028 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003029 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003030 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3031 .dac_nids = alc880_w810_dac_nids,
3032 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003033 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3034 .channel_mode = alc880_w810_modes,
3035 .input_mux = &alc880_capture_source,
3036 },
3037 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003038 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003039 .init_verbs = { alc880_volume_init_verbs,
3040 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003041 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3042 .dac_nids = alc880_z71v_dac_nids,
3043 .dig_out_nid = ALC880_DIGOUT_NID,
3044 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3046 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003047 .input_mux = &alc880_capture_source,
3048 },
3049 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003051 .init_verbs = { alc880_volume_init_verbs,
3052 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3054 .dac_nids = alc880_f1734_dac_nids,
3055 .hp_nid = 0x02,
3056 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3057 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003058 .input_mux = &alc880_capture_source,
3059 },
3060 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003062 .init_verbs = { alc880_volume_init_verbs,
3063 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 alc880_gpio1_init_verbs },
3065 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3066 .dac_nids = alc880_asus_dac_nids,
3067 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3068 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003069 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003070 .input_mux = &alc880_capture_source,
3071 },
3072 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003074 .init_verbs = { alc880_volume_init_verbs,
3075 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 alc880_gpio1_init_verbs },
3077 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3078 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003079 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3081 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003082 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003083 .input_mux = &alc880_capture_source,
3084 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003085 [ALC880_ASUS_DIG2] = {
3086 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003087 .init_verbs = { alc880_volume_init_verbs,
3088 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003089 alc880_gpio2_init_verbs }, /* use GPIO2 */
3090 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3091 .dac_nids = alc880_asus_dac_nids,
3092 .dig_out_nid = ALC880_DIGOUT_NID,
3093 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3094 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003095 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003096 .input_mux = &alc880_capture_source,
3097 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003098 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003100 .init_verbs = { alc880_volume_init_verbs,
3101 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 alc880_gpio1_init_verbs },
3103 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3104 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3107 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003108 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003109 .input_mux = &alc880_capture_source,
3110 },
3111 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003112 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003113 .init_verbs = { alc880_volume_init_verbs,
3114 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3116 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003117 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3119 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003120 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003121 .input_mux = &alc880_capture_source,
3122 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003123 [ALC880_UNIWILL] = {
3124 .mixers = { alc880_uniwill_mixer },
3125 .init_verbs = { alc880_volume_init_verbs,
3126 alc880_uniwill_init_verbs },
3127 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3128 .dac_nids = alc880_asus_dac_nids,
3129 .dig_out_nid = ALC880_DIGOUT_NID,
3130 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3131 .channel_mode = alc880_threestack_modes,
3132 .need_dac_fix = 1,
3133 .input_mux = &alc880_capture_source,
3134 .unsol_event = alc880_uniwill_unsol_event,
3135 .init_hook = alc880_uniwill_automute,
3136 },
3137 [ALC880_UNIWILL_P53] = {
3138 .mixers = { alc880_uniwill_p53_mixer },
3139 .init_verbs = { alc880_volume_init_verbs,
3140 alc880_uniwill_p53_init_verbs },
3141 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3142 .dac_nids = alc880_asus_dac_nids,
3143 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003144 .channel_mode = alc880_threestack_modes,
3145 .input_mux = &alc880_capture_source,
3146 .unsol_event = alc880_uniwill_p53_unsol_event,
3147 .init_hook = alc880_uniwill_p53_hp_automute,
3148 },
3149 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003150 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003151 alc880_pcbeep_mixer, },
3152 .init_verbs = { alc880_volume_init_verbs,
3153 alc880_uniwill_p53_init_verbs,
3154 alc880_beep_init_verbs },
3155 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3156 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003157 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003158 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3159 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003160 .input_mux = &alc880_capture_source,
3161 .unsol_event = alc880_uniwill_p53_unsol_event,
3162 .init_hook = alc880_uniwill_p53_hp_automute,
3163 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003164 [ALC880_CLEVO] = {
3165 .mixers = { alc880_three_stack_mixer },
3166 .init_verbs = { alc880_volume_init_verbs,
3167 alc880_pin_clevo_init_verbs },
3168 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3169 .dac_nids = alc880_dac_nids,
3170 .hp_nid = 0x03,
3171 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3172 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003173 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003174 .input_mux = &alc880_capture_source,
3175 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003176 [ALC880_LG] = {
3177 .mixers = { alc880_lg_mixer },
3178 .init_verbs = { alc880_volume_init_verbs,
3179 alc880_lg_init_verbs },
3180 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3181 .dac_nids = alc880_lg_dac_nids,
3182 .dig_out_nid = ALC880_DIGOUT_NID,
3183 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3184 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003185 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003186 .input_mux = &alc880_lg_capture_source,
3187 .unsol_event = alc880_lg_unsol_event,
3188 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003189#ifdef CONFIG_SND_HDA_POWER_SAVE
3190 .loopbacks = alc880_lg_loopbacks,
3191#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003192 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003193 [ALC880_LG_LW] = {
3194 .mixers = { alc880_lg_lw_mixer },
3195 .init_verbs = { alc880_volume_init_verbs,
3196 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003197 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003198 .dac_nids = alc880_dac_nids,
3199 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003200 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3201 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003202 .input_mux = &alc880_lg_lw_capture_source,
3203 .unsol_event = alc880_lg_lw_unsol_event,
3204 .init_hook = alc880_lg_lw_automute,
3205 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003206#ifdef CONFIG_SND_DEBUG
3207 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208 .mixers = { alc880_test_mixer },
3209 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003210 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3211 .dac_nids = alc880_test_dac_nids,
3212 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003213 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3214 .channel_mode = alc880_test_modes,
3215 .input_mux = &alc880_test_capture_source,
3216 },
3217#endif
3218};
3219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220/*
3221 * Automatic parse of I/O pins from the BIOS configuration
3222 */
3223
3224#define NUM_CONTROL_ALLOC 32
3225#define NUM_VERB_ALLOC 32
3226
3227enum {
3228 ALC_CTL_WIDGET_VOL,
3229 ALC_CTL_WIDGET_MUTE,
3230 ALC_CTL_BIND_MUTE,
3231};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003232static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003233 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3234 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003235 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236};
3237
3238/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003239static int add_control(struct alc_spec *spec, int type, const char *name,
3240 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003242 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243
3244 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3245 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3246
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003247 /* array + terminator */
3248 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3249 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 return -ENOMEM;
3251 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003252 memcpy(knew, spec->kctl_alloc,
3253 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 kfree(spec->kctl_alloc);
3255 }
3256 spec->kctl_alloc = knew;
3257 spec->num_kctl_alloc = num;
3258 }
3259
3260 knew = &spec->kctl_alloc[spec->num_kctl_used];
3261 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003262 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003263 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264 return -ENOMEM;
3265 knew->private_value = val;
3266 spec->num_kctl_used++;
3267 return 0;
3268}
3269
3270#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3271#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3272#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3273#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3274#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3275#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3276#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3277#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3278#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3279#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3280#define ALC880_PIN_CD_NID 0x1c
3281
3282/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003283static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3284 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285{
3286 hda_nid_t nid;
3287 int assigned[4];
3288 int i, j;
3289
3290 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003291 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003292
3293 /* check the pins hardwired to audio widget */
3294 for (i = 0; i < cfg->line_outs; i++) {
3295 nid = cfg->line_out_pins[i];
3296 if (alc880_is_fixed_pin(nid)) {
3297 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003298 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299 assigned[idx] = 1;
3300 }
3301 }
3302 /* left pins can be connect to any audio widget */
3303 for (i = 0; i < cfg->line_outs; i++) {
3304 nid = cfg->line_out_pins[i];
3305 if (alc880_is_fixed_pin(nid))
3306 continue;
3307 /* search for an empty channel */
3308 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003309 if (!assigned[j]) {
3310 spec->multiout.dac_nids[i] =
3311 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312 assigned[j] = 1;
3313 break;
3314 }
3315 }
3316 }
3317 spec->multiout.num_dacs = cfg->line_outs;
3318 return 0;
3319}
3320
3321/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003322static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3323 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324{
3325 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003326 static const char *chname[4] = {
3327 "Front", "Surround", NULL /*CLFE*/, "Side"
3328 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003329 hda_nid_t nid;
3330 int i, err;
3331
3332 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003333 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003334 continue;
3335 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3336 if (i == 2) {
3337 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003338 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3339 "Center Playback Volume",
3340 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3341 HDA_OUTPUT));
3342 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003344 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3345 "LFE Playback Volume",
3346 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3347 HDA_OUTPUT));
3348 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003350 err = add_control(spec, ALC_CTL_BIND_MUTE,
3351 "Center Playback Switch",
3352 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3353 HDA_INPUT));
3354 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003356 err = add_control(spec, ALC_CTL_BIND_MUTE,
3357 "LFE Playback Switch",
3358 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3359 HDA_INPUT));
3360 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003361 return err;
3362 } else {
3363 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003364 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3365 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3366 HDA_OUTPUT));
3367 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368 return err;
3369 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003370 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3371 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3372 HDA_INPUT));
3373 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374 return err;
3375 }
3376 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003377 return 0;
3378}
3379
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003380/* add playback controls for speaker and HP outputs */
3381static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3382 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383{
3384 hda_nid_t nid;
3385 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003386 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003387
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003388 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 return 0;
3390
3391 if (alc880_is_fixed_pin(pin)) {
3392 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003393 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003394 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003396 else
3397 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 /* control HP volume/switch on the output mixer amp */
3399 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003400 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003401 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3402 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3403 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003405 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003406 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3407 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3408 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 return err;
3410 } else if (alc880_is_multi_pin(pin)) {
3411 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003413 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003414 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3415 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3416 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 return err;
3418 }
3419 return 0;
3420}
3421
3422/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3424 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003425 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426{
3427 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003428 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003429
3430 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003431 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3432 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3433 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 return err;
3435 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003436 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3437 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3438 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 return err;
3440 return 0;
3441}
3442
3443/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003444static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3445 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003446{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003448 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449
3450 for (i = 0; i < AUTO_PIN_LAST; i++) {
3451 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003452 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003453 err = new_analog_input(spec, cfg->input_pins[i],
3454 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003455 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 if (err < 0)
3457 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003458 imux->items[imux->num_items].label =
3459 auto_pin_cfg_labels[i];
3460 imux->items[imux->num_items].index =
3461 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462 imux->num_items++;
3463 }
3464 }
3465 return 0;
3466}
3467
Kailang Yangdf694da2005-12-05 19:42:22 +01003468static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3469 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470 int dac_idx)
3471{
3472 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003473 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3474 pin_type);
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3476 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003477 /* need the manual connection? */
3478 if (alc880_is_multi_pin(nid)) {
3479 struct alc_spec *spec = codec->spec;
3480 int idx = alc880_multi_pin_idx(nid);
3481 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3482 AC_VERB_SET_CONNECT_SEL,
3483 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3484 }
3485}
3486
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003487static int get_pin_type(int line_out_type)
3488{
3489 if (line_out_type == AUTO_PIN_HP_OUT)
3490 return PIN_HP;
3491 else
3492 return PIN_OUT;
3493}
3494
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003495static void alc880_auto_init_multi_out(struct hda_codec *codec)
3496{
3497 struct alc_spec *spec = codec->spec;
3498 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003499
3500 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 for (i = 0; i < spec->autocfg.line_outs; i++) {
3502 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003503 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3504 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 }
3506}
3507
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003508static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003509{
3510 struct alc_spec *spec = codec->spec;
3511 hda_nid_t pin;
3512
Takashi Iwai82bc9552006-03-21 11:24:42 +01003513 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003514 if (pin) /* connect to front */
3515 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003516 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003517 if (pin) /* connect to front */
3518 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3519}
3520
3521static void alc880_auto_init_analog_input(struct hda_codec *codec)
3522{
3523 struct alc_spec *spec = codec->spec;
3524 int i;
3525
3526 for (i = 0; i < AUTO_PIN_LAST; i++) {
3527 hda_nid_t nid = spec->autocfg.input_pins[i];
3528 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003529 snd_hda_codec_write(codec, nid, 0,
3530 AC_VERB_SET_PIN_WIDGET_CONTROL,
3531 i <= AUTO_PIN_FRONT_MIC ?
3532 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003534 snd_hda_codec_write(codec, nid, 0,
3535 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003536 AMP_OUT_MUTE);
3537 }
3538 }
3539}
3540
3541/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003542/* return 1 if successful, 0 if the proper config is not found,
3543 * or a negative error code
3544 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545static int alc880_parse_auto_config(struct hda_codec *codec)
3546{
3547 struct alc_spec *spec = codec->spec;
3548 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003549 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003551 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3552 alc880_ignore);
3553 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003555 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003557
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003558 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3559 if (err < 0)
3560 return err;
3561 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3562 if (err < 0)
3563 return err;
3564 err = alc880_auto_create_extra_out(spec,
3565 spec->autocfg.speaker_pins[0],
3566 "Speaker");
3567 if (err < 0)
3568 return err;
3569 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3570 "Headphone");
3571 if (err < 0)
3572 return err;
3573 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3574 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 return err;
3576
3577 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3578
3579 if (spec->autocfg.dig_out_pin)
3580 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3581 if (spec->autocfg.dig_in_pin)
3582 spec->dig_in_nid = ALC880_DIGIN_NID;
3583
3584 if (spec->kctl_alloc)
3585 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3586
3587 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3588
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003589 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590 spec->input_mux = &spec->private_imux;
3591
3592 return 1;
3593}
3594
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003595/* additional initialization for auto-configuration model */
3596static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003598 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003599 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003601}
3602
3603/*
3604 * OK, here we have finally the patch for ALC880
3605 */
3606
Linus Torvalds1da177e2005-04-16 15:20:36 -07003607static int patch_alc880(struct hda_codec *codec)
3608{
3609 struct alc_spec *spec;
3610 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003611 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003612
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003613 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614 if (spec == NULL)
3615 return -ENOMEM;
3616
3617 codec->spec = spec;
3618
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003619 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3620 alc880_models,
3621 alc880_cfg_tbl);
3622 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003623 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3624 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003626 }
3627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628 if (board_config == ALC880_AUTO) {
3629 /* automatic parse from the BIOS config */
3630 err = alc880_parse_auto_config(codec);
3631 if (err < 0) {
3632 alc_free(codec);
3633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003634 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003635 printk(KERN_INFO
3636 "hda_codec: Cannot set up configuration "
3637 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638 board_config = ALC880_3ST;
3639 }
3640 }
3641
Kailang Yangdf694da2005-12-05 19:42:22 +01003642 if (board_config != ALC880_AUTO)
3643 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644
3645 spec->stream_name_analog = "ALC880 Analog";
3646 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3647 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003648 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003649
3650 spec->stream_name_digital = "ALC880 Digital";
3651 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3652 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003654 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003655 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003656 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003657 /* get type */
3658 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659 if (wcap != AC_WID_AUD_IN) {
3660 spec->adc_nids = alc880_adc_nids_alt;
3661 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003662 spec->mixers[spec->num_mixers] =
3663 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003664 spec->num_mixers++;
3665 } else {
3666 spec->adc_nids = alc880_adc_nids;
3667 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3668 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3669 spec->num_mixers++;
3670 }
3671 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003672
Takashi Iwai2134ea42008-01-10 16:53:55 +01003673 spec->vmaster_nid = 0x0c;
3674
Linus Torvalds1da177e2005-04-16 15:20:36 -07003675 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003676 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003677 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003678#ifdef CONFIG_SND_HDA_POWER_SAVE
3679 if (!spec->loopback.amplist)
3680 spec->loopback.amplist = alc880_loopbacks;
3681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682
3683 return 0;
3684}
3685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003686
Linus Torvalds1da177e2005-04-16 15:20:36 -07003687/*
3688 * ALC260 support
3689 */
3690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691static hda_nid_t alc260_dac_nids[1] = {
3692 /* front */
3693 0x02,
3694};
3695
3696static hda_nid_t alc260_adc_nids[1] = {
3697 /* ADC0 */
3698 0x04,
3699};
3700
Kailang Yangdf694da2005-12-05 19:42:22 +01003701static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 /* ADC1 */
3703 0x05,
3704};
3705
Kailang Yangdf694da2005-12-05 19:42:22 +01003706static hda_nid_t alc260_hp_adc_nids[2] = {
3707 /* ADC1, 0 */
3708 0x05, 0x04
3709};
3710
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003711/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3712 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3713 */
3714static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003715 /* ADC0, ADC1 */
3716 0x04, 0x05
3717};
3718
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003719#define ALC260_DIGOUT_NID 0x03
3720#define ALC260_DIGIN_NID 0x06
3721
3722static struct hda_input_mux alc260_capture_source = {
3723 .num_items = 4,
3724 .items = {
3725 { "Mic", 0x0 },
3726 { "Front Mic", 0x1 },
3727 { "Line", 0x2 },
3728 { "CD", 0x4 },
3729 },
3730};
3731
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003732/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003733 * headphone jack and the internal CD lines since these are the only pins at
3734 * which audio can appear. For flexibility, also allow the option of
3735 * recording the mixer output on the second ADC (ADC0 doesn't have a
3736 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003737 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003738static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3739 {
3740 .num_items = 3,
3741 .items = {
3742 { "Mic/Line", 0x0 },
3743 { "CD", 0x4 },
3744 { "Headphone", 0x2 },
3745 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003746 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003747 {
3748 .num_items = 4,
3749 .items = {
3750 { "Mic/Line", 0x0 },
3751 { "CD", 0x4 },
3752 { "Headphone", 0x2 },
3753 { "Mixer", 0x5 },
3754 },
3755 },
3756
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003757};
3758
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003759/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3760 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003761 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003762static struct hda_input_mux alc260_acer_capture_sources[2] = {
3763 {
3764 .num_items = 4,
3765 .items = {
3766 { "Mic", 0x0 },
3767 { "Line", 0x2 },
3768 { "CD", 0x4 },
3769 { "Headphone", 0x5 },
3770 },
3771 },
3772 {
3773 .num_items = 5,
3774 .items = {
3775 { "Mic", 0x0 },
3776 { "Line", 0x2 },
3777 { "CD", 0x4 },
3778 { "Headphone", 0x6 },
3779 { "Mixer", 0x5 },
3780 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003781 },
3782};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003783/*
3784 * This is just place-holder, so there's something for alc_build_pcms to look
3785 * at when it calculates the maximum number of channels. ALC260 has no mixer
3786 * element which allows changing the channel mode, so the verb list is
3787 * never used.
3788 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003789static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003790 { 2, NULL },
3791};
3792
Kailang Yangdf694da2005-12-05 19:42:22 +01003793
3794/* Mixer combinations
3795 *
3796 * basic: base_output + input + pc_beep + capture
3797 * HP: base_output + input + capture_alt
3798 * HP_3013: hp_3013 + input + capture
3799 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003800 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003801 */
3802
3803static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003804 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003805 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3807 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3808 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3810 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003811};
Kailang Yangdf694da2005-12-05 19:42:22 +01003812
3813static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3815 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3816 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3817 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3819 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3821 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003822 { } /* end */
3823};
3824
Kailang Yangdf694da2005-12-05 19:42:22 +01003825static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3826 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3827 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3828 { } /* end */
3829};
3830
3831static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3832 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3833 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3834 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3835 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3836 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003838 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3839 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003840 { } /* end */
3841};
3842
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003843/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3844 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3845 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003846static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003847 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003848 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003849 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003850 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3851 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3852 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3853 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003854 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003855 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3856 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3857 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003858 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003859 { } /* end */
3860};
3861
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003862/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3863 * versions of the ALC260 don't act on requests to enable mic bias from NID
3864 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3865 * datasheet doesn't mention this restriction. At this stage it's not clear
3866 * whether this behaviour is intentional or is a hardware bug in chip
3867 * revisions available in early 2006. Therefore for now allow the
3868 * "Headphone Jack Mode" control to span all choices, but if it turns out
3869 * that the lack of mic bias for this NID is intentional we could change the
3870 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3871 *
3872 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3873 * don't appear to make the mic bias available from the "line" jack, even
3874 * though the NID used for this jack (0x14) can supply it. The theory is
3875 * that perhaps Acer have included blocking capacitors between the ALC260
3876 * and the output jack. If this turns out to be the case for all such
3877 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3878 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003879 *
3880 * The C20x Tablet series have a mono internal speaker which is controlled
3881 * via the chip's Mono sum widget and pin complex, so include the necessary
3882 * controls for such models. On models without a "mono speaker" the control
3883 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003884 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003885static struct snd_kcontrol_new alc260_acer_mixer[] = {
3886 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3887 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003888 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003889 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3890 HDA_OUTPUT),
3891 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3892 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003893 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3894 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3896 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3897 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3898 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3899 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3900 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3901 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3902 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3903 { } /* end */
3904};
3905
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003906/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3907 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3908 */
3909static struct snd_kcontrol_new alc260_will_mixer[] = {
3910 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3911 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3913 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3914 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3915 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3916 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3917 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3918 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3919 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3920 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3921 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3922 { } /* end */
3923};
3924
3925/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3926 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3927 */
3928static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3929 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3930 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3932 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3933 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3934 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3935 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3936 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3937 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3938 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3939 { } /* end */
3940};
3941
Kailang Yangdf694da2005-12-05 19:42:22 +01003942/* capture mixer elements */
3943static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003944 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3945 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003946 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3947 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003948 {
3949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003950 /* The multiple "Capture Source" controls confuse alsamixer
3951 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003952 */
3953 /* .name = "Capture Source", */
3954 .name = "Input Source",
3955 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003956 .info = alc_mux_enum_info,
3957 .get = alc_mux_enum_get,
3958 .put = alc_mux_enum_put,
3959 },
3960 { } /* end */
3961};
3962
Kailang Yangdf694da2005-12-05 19:42:22 +01003963static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3964 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3965 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3966 {
3967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3968 /* The multiple "Capture Source" controls confuse alsamixer
3969 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003970 */
3971 /* .name = "Capture Source", */
3972 .name = "Input Source",
3973 .count = 1,
3974 .info = alc_mux_enum_info,
3975 .get = alc_mux_enum_get,
3976 .put = alc_mux_enum_put,
3977 },
3978 { } /* end */
3979};
3980
3981/*
3982 * initialization verbs
3983 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003984static struct hda_verb alc260_init_verbs[] = {
3985 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003990 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003992 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003996 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003997 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003998 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004000 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004001 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004002 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4003 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004004 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004005 /* set connection select to line in (default select for this ADC) */
4006 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 /* mute capture amp left and right */
4008 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4009 /* set connection select to line in (default select for this ADC) */
4010 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004011 /* set vol=0 Line-Out mixer amp left and right */
4012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4013 /* unmute pin widget amp left and right (no gain on this amp) */
4014 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4015 /* set vol=0 HP mixer amp left and right */
4016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4017 /* unmute pin widget amp left and right (no gain on this amp) */
4018 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4019 /* set vol=0 Mono mixer amp left and right */
4020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4021 /* unmute pin widget amp left and right (no gain on this amp) */
4022 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4023 /* unmute LINE-2 out pin */
4024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004025 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4026 * Line In 2 = 0x03
4027 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004028 /* mute analog inputs */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004034 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004035 /* mute Front out path */
4036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4038 /* mute Headphone out path */
4039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4041 /* mute Mono out path */
4042 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4043 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004044 { }
4045};
4046
Takashi Iwai474167d2006-05-17 17:17:43 +02004047#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004048static struct hda_verb alc260_hp_init_verbs[] = {
4049 /* Headphone and output */
4050 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4051 /* mono output */
4052 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4053 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4054 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4055 /* Mic2 (front panel) pin widget for input and vref at 80% */
4056 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4057 /* Line In pin widget for input */
4058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4059 /* Line-2 pin widget for output */
4060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4061 /* CD pin widget for input */
4062 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4063 /* unmute amp left and right */
4064 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4065 /* set connection select to line in (default select for this ADC) */
4066 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4067 /* unmute Line-Out mixer amp left and right (volume = 0) */
4068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4069 /* mute pin widget amp left and right (no gain on this amp) */
4070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4071 /* unmute HP mixer amp left and right (volume = 0) */
4072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4073 /* mute pin widget amp left and right (no gain on this amp) */
4074 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4076 * Line In 2 = 0x03
4077 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004078 /* mute analog inputs */
4079 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4080 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004084 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4085 /* Unmute Front out path */
4086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4088 /* Unmute Headphone out path */
4089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4091 /* Unmute Mono out path */
4092 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4093 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4094 { }
4095};
Takashi Iwai474167d2006-05-17 17:17:43 +02004096#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004097
4098static struct hda_verb alc260_hp_3013_init_verbs[] = {
4099 /* Line out and output */
4100 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4101 /* mono output */
4102 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4103 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4104 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4105 /* Mic2 (front panel) pin widget for input and vref at 80% */
4106 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4107 /* Line In pin widget for input */
4108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4109 /* Headphone pin widget for output */
4110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4111 /* CD pin widget for input */
4112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4113 /* unmute amp left and right */
4114 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4115 /* set connection select to line in (default select for this ADC) */
4116 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4117 /* unmute Line-Out mixer amp left and right (volume = 0) */
4118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4119 /* mute pin widget amp left and right (no gain on this amp) */
4120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4121 /* unmute HP mixer amp left and right (volume = 0) */
4122 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4123 /* mute pin widget amp left and right (no gain on this amp) */
4124 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004125 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4126 * Line In 2 = 0x03
4127 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004128 /* mute analog inputs */
4129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4135 /* Unmute Front out path */
4136 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4138 /* Unmute Headphone out path */
4139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4141 /* Unmute Mono out path */
4142 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4143 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4144 { }
4145};
4146
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004147/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004148 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4149 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004150 */
4151static struct hda_verb alc260_fujitsu_init_verbs[] = {
4152 /* Disable all GPIOs */
4153 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4154 /* Internal speaker is connected to headphone pin */
4155 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4156 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004158 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4159 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4160 /* Ensure all other unused pins are disabled and muted. */
4161 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004163 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004164 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004166 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4168 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004169
Jonathan Woithef7ace402006-02-28 11:46:14 +01004170 /* Disable digital (SPDIF) pins */
4171 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4172 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004173
Jonathan Woithef7ace402006-02-28 11:46:14 +01004174 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4175 * when acting as an output.
4176 */
4177 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4178
4179 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004180 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4181 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4186 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4187 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4188 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004189
Jonathan Woithef7ace402006-02-28 11:46:14 +01004190 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4191 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4192 /* Unmute Line1 pin widget output buffer since it starts as an output.
4193 * If the pin mode is changed by the user the pin mode control will
4194 * take care of enabling the pin's input/output buffers as needed.
4195 * Therefore there's no need to enable the input buffer at this
4196 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004197 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004199 /* Unmute input buffer of pin widget used for Line-in (no equiv
4200 * mixer ctrl)
4201 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004202 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004203
Jonathan Woithef7ace402006-02-28 11:46:14 +01004204 /* Mute capture amp left and right */
4205 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4206 /* Set ADC connection select to match default mixer setting - line
4207 * in (on mic1 pin)
4208 */
4209 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004210
Jonathan Woithef7ace402006-02-28 11:46:14 +01004211 /* Do the same for the second ADC: mute capture input amp and
4212 * set ADC connection to line in (on mic1 pin)
4213 */
4214 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4215 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004216
Jonathan Woithef7ace402006-02-28 11:46:14 +01004217 /* Mute all inputs to mixer widget (even unconnected ones) */
4218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004226
4227 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004228};
4229
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004230/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4231 * similar laptops (adapted from Fujitsu init verbs).
4232 */
4233static struct hda_verb alc260_acer_init_verbs[] = {
4234 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4235 * the headphone jack. Turn this on and rely on the standard mute
4236 * methods whenever the user wants to turn these outputs off.
4237 */
4238 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4239 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4240 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4241 /* Internal speaker/Headphone jack is connected to Line-out pin */
4242 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4243 /* Internal microphone/Mic jack is connected to Mic1 pin */
4244 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4245 /* Line In jack is connected to Line1 pin */
4246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004247 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4248 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004249 /* Ensure all other unused pins are disabled and muted. */
4250 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4251 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004252 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4253 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 /* Disable digital (SPDIF) pins */
4257 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4258 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4259
4260 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4261 * bus when acting as outputs.
4262 */
4263 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4264 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4265
4266 /* Start with output sum widgets muted and their output gains at min */
4267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4268 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4273 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4274 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4275 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004277 /* Unmute Line-out pin widget amp left and right
4278 * (no equiv mixer ctrl)
4279 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004281 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4282 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004283 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4284 * inputs. If the pin mode is changed by the user the pin mode control
4285 * will take care of enabling the pin's input/output buffers as needed.
4286 * Therefore there's no need to enable the input buffer at this
4287 * stage.
4288 */
4289 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4291
4292 /* Mute capture amp left and right */
4293 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 /* Set ADC connection select to match default mixer setting - mic
4295 * (on mic1 pin)
4296 */
4297 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4298
4299 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004300 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004301 */
4302 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004303 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004304
4305 /* Mute all inputs to mixer widget (even unconnected ones) */
4306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4314
4315 { }
4316};
4317
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004318static struct hda_verb alc260_will_verbs[] = {
4319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4320 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4321 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4322 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4323 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4324 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4325 {}
4326};
4327
4328static struct hda_verb alc260_replacer_672v_verbs[] = {
4329 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4330 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4331 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4332
4333 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4334 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4335 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4336
4337 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4338 {}
4339};
4340
4341/* toggle speaker-output according to the hp-jack state */
4342static void alc260_replacer_672v_automute(struct hda_codec *codec)
4343{
4344 unsigned int present;
4345
4346 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4347 present = snd_hda_codec_read(codec, 0x0f, 0,
4348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4349 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004350 snd_hda_codec_write_cache(codec, 0x01, 0,
4351 AC_VERB_SET_GPIO_DATA, 1);
4352 snd_hda_codec_write_cache(codec, 0x0f, 0,
4353 AC_VERB_SET_PIN_WIDGET_CONTROL,
4354 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004355 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004356 snd_hda_codec_write_cache(codec, 0x01, 0,
4357 AC_VERB_SET_GPIO_DATA, 0);
4358 snd_hda_codec_write_cache(codec, 0x0f, 0,
4359 AC_VERB_SET_PIN_WIDGET_CONTROL,
4360 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004361 }
4362}
4363
4364static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4365 unsigned int res)
4366{
4367 if ((res >> 26) == ALC880_HP_EVENT)
4368 alc260_replacer_672v_automute(codec);
4369}
4370
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004371/* Test configuration for debugging, modelled after the ALC880 test
4372 * configuration.
4373 */
4374#ifdef CONFIG_SND_DEBUG
4375static hda_nid_t alc260_test_dac_nids[1] = {
4376 0x02,
4377};
4378static hda_nid_t alc260_test_adc_nids[2] = {
4379 0x04, 0x05,
4380};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004381/* For testing the ALC260, each input MUX needs its own definition since
4382 * the signal assignments are different. This assumes that the first ADC
4383 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004384 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004385static struct hda_input_mux alc260_test_capture_sources[2] = {
4386 {
4387 .num_items = 7,
4388 .items = {
4389 { "MIC1 pin", 0x0 },
4390 { "MIC2 pin", 0x1 },
4391 { "LINE1 pin", 0x2 },
4392 { "LINE2 pin", 0x3 },
4393 { "CD pin", 0x4 },
4394 { "LINE-OUT pin", 0x5 },
4395 { "HP-OUT pin", 0x6 },
4396 },
4397 },
4398 {
4399 .num_items = 8,
4400 .items = {
4401 { "MIC1 pin", 0x0 },
4402 { "MIC2 pin", 0x1 },
4403 { "LINE1 pin", 0x2 },
4404 { "LINE2 pin", 0x3 },
4405 { "CD pin", 0x4 },
4406 { "Mixer", 0x5 },
4407 { "LINE-OUT pin", 0x6 },
4408 { "HP-OUT pin", 0x7 },
4409 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004410 },
4411};
4412static struct snd_kcontrol_new alc260_test_mixer[] = {
4413 /* Output driver widgets */
4414 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4415 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4416 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4417 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4418 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4419 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4420
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004421 /* Modes for retasking pin widgets
4422 * Note: the ALC260 doesn't seem to act on requests to enable mic
4423 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4424 * mention this restriction. At this stage it's not clear whether
4425 * this behaviour is intentional or is a hardware bug in chip
4426 * revisions available at least up until early 2006. Therefore for
4427 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4428 * choices, but if it turns out that the lack of mic bias for these
4429 * NIDs is intentional we could change their modes from
4430 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4431 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004432 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4433 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4434 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4435 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4436 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4437 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4438
4439 /* Loopback mixer controls */
4440 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4441 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4442 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4443 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4444 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4445 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4446 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4447 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4448 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4449 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4450 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4451 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4452 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4453 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4454 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4455 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004456
4457 /* Controls for GPIO pins, assuming they are configured as outputs */
4458 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4459 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4460 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4461 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4462
Jonathan Woithe92621f12006-02-28 11:47:47 +01004463 /* Switches to allow the digital IO pins to be enabled. The datasheet
4464 * is ambigious as to which NID is which; testing on laptops which
4465 * make this output available should provide clarification.
4466 */
4467 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4468 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4469
Jonathan Woithef8225f62008-01-08 12:16:54 +01004470 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4471 * this output to turn on an external amplifier.
4472 */
4473 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4474 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4475
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004476 { } /* end */
4477};
4478static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004479 /* Enable all GPIOs as outputs with an initial value of 0 */
4480 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4481 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4482 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4483
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004484 /* Enable retasking pins as output, initially without power amp */
4485 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4486 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4489 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4490 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4491
Jonathan Woithe92621f12006-02-28 11:47:47 +01004492 /* Disable digital (SPDIF) pins initially, but users can enable
4493 * them via a mixer switch. In the case of SPDIF-out, this initverb
4494 * payload also sets the generation to 0, output to be in "consumer"
4495 * PCM format, copyright asserted, no pre-emphasis and no validity
4496 * control.
4497 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004498 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4499 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4500
Jonathan Woithef7ace402006-02-28 11:46:14 +01004501 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004502 * OUT1 sum bus when acting as an output.
4503 */
4504 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4505 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4506 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4507 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4508
4509 /* Start with output sum widgets muted and their output gains at min */
4510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4516 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4517 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4518 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4519
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004520 /* Unmute retasking pin widget output buffers since the default
4521 * state appears to be output. As the pin mode is changed by the
4522 * user the pin mode control will take care of enabling the pin's
4523 * input/output buffers as needed.
4524 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004525 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4530 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 /* Also unmute the mono-out pin widget */
4532 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004534 /* Mute capture amp left and right */
4535 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004536 /* Set ADC connection select to match default mixer setting (mic1
4537 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004538 */
4539 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4540
4541 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004542 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004543 */
4544 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4545 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4546
4547 /* Mute all inputs to mixer widget (even unconnected ones) */
4548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4556
4557 { }
4558};
4559#endif
4560
Takashi Iwai63300792008-01-24 15:31:36 +01004561#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4562#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004563
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004564#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4565#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4566
Kailang Yangdf694da2005-12-05 19:42:22 +01004567/*
4568 * for BIOS auto-configuration
4569 */
4570
4571static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4572 const char *pfx)
4573{
4574 hda_nid_t nid_vol;
4575 unsigned long vol_val, sw_val;
4576 char name[32];
4577 int err;
4578
4579 if (nid >= 0x0f && nid < 0x11) {
4580 nid_vol = nid - 0x7;
4581 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4582 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4583 } else if (nid == 0x11) {
4584 nid_vol = nid - 0x7;
4585 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4586 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4587 } else if (nid >= 0x12 && nid <= 0x15) {
4588 nid_vol = 0x08;
4589 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4590 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4591 } else
4592 return 0; /* N/A */
4593
4594 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004595 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4596 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004597 return err;
4598 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004599 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4600 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004601 return err;
4602 return 1;
4603}
4604
4605/* add playback controls from the parsed DAC table */
4606static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4607 const struct auto_pin_cfg *cfg)
4608{
4609 hda_nid_t nid;
4610 int err;
4611
4612 spec->multiout.num_dacs = 1;
4613 spec->multiout.dac_nids = spec->private_dac_nids;
4614 spec->multiout.dac_nids[0] = 0x02;
4615
4616 nid = cfg->line_out_pins[0];
4617 if (nid) {
4618 err = alc260_add_playback_controls(spec, nid, "Front");
4619 if (err < 0)
4620 return err;
4621 }
4622
Takashi Iwai82bc9552006-03-21 11:24:42 +01004623 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004624 if (nid) {
4625 err = alc260_add_playback_controls(spec, nid, "Speaker");
4626 if (err < 0)
4627 return err;
4628 }
4629
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004630 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004631 if (nid) {
4632 err = alc260_add_playback_controls(spec, nid, "Headphone");
4633 if (err < 0)
4634 return err;
4635 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004637}
4638
4639/* create playback/capture controls for input pins */
4640static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4641 const struct auto_pin_cfg *cfg)
4642{
Kailang Yangdf694da2005-12-05 19:42:22 +01004643 struct hda_input_mux *imux = &spec->private_imux;
4644 int i, err, idx;
4645
4646 for (i = 0; i < AUTO_PIN_LAST; i++) {
4647 if (cfg->input_pins[i] >= 0x12) {
4648 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004649 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004650 auto_pin_cfg_labels[i], idx,
4651 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004652 if (err < 0)
4653 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 imux->items[imux->num_items].label =
4655 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004656 imux->items[imux->num_items].index = idx;
4657 imux->num_items++;
4658 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004659 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004660 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004661 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004662 auto_pin_cfg_labels[i], idx,
4663 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004664 if (err < 0)
4665 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 imux->items[imux->num_items].label =
4667 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004668 imux->items[imux->num_items].index = idx;
4669 imux->num_items++;
4670 }
4671 }
4672 return 0;
4673}
4674
4675static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4676 hda_nid_t nid, int pin_type,
4677 int sel_idx)
4678{
4679 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004680 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4681 pin_type);
4682 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4683 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004684 /* need the manual connection? */
4685 if (nid >= 0x12) {
4686 int idx = nid - 0x12;
4687 snd_hda_codec_write(codec, idx + 0x0b, 0,
4688 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004689 }
4690}
4691
4692static void alc260_auto_init_multi_out(struct hda_codec *codec)
4693{
4694 struct alc_spec *spec = codec->spec;
4695 hda_nid_t nid;
4696
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004697 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004698 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004699 if (nid) {
4700 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4701 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4702 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004703
Takashi Iwai82bc9552006-03-21 11:24:42 +01004704 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004705 if (nid)
4706 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4707
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004708 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004709 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004710 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004711}
Kailang Yangdf694da2005-12-05 19:42:22 +01004712
4713#define ALC260_PIN_CD_NID 0x16
4714static void alc260_auto_init_analog_input(struct hda_codec *codec)
4715{
4716 struct alc_spec *spec = codec->spec;
4717 int i;
4718
4719 for (i = 0; i < AUTO_PIN_LAST; i++) {
4720 hda_nid_t nid = spec->autocfg.input_pins[i];
4721 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004722 snd_hda_codec_write(codec, nid, 0,
4723 AC_VERB_SET_PIN_WIDGET_CONTROL,
4724 i <= AUTO_PIN_FRONT_MIC ?
4725 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004726 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004727 snd_hda_codec_write(codec, nid, 0,
4728 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004729 AMP_OUT_MUTE);
4730 }
4731 }
4732}
4733
4734/*
4735 * generic initialization of ADC, input mixers and output mixers
4736 */
4737static struct hda_verb alc260_volume_init_verbs[] = {
4738 /*
4739 * Unmute ADC0-1 and set the default input to mic-in
4740 */
4741 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4742 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4743 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4745
4746 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4747 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004748 * Note: PASD motherboards uses the Line In 2 as the input for
4749 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004750 */
4751 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004752 /* mute analog inputs */
4753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004758
4759 /*
4760 * Set up output mixers (0x08 - 0x0a)
4761 */
4762 /* set vol=0 to output mixers */
4763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4764 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4766 /* set up input amps for analog loopback */
4767 /* Amp Indices: DAC = 0, mixer = 1 */
4768 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4769 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4770 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4771 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4772 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4773 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4774
4775 { }
4776};
4777
4778static int alc260_parse_auto_config(struct hda_codec *codec)
4779{
4780 struct alc_spec *spec = codec->spec;
4781 unsigned int wcap;
4782 int err;
4783 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4784
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4786 alc260_ignore);
4787 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004789 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4790 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004791 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004793 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004794 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4795 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004796 return err;
4797
4798 spec->multiout.max_channels = 2;
4799
4800 if (spec->autocfg.dig_out_pin)
4801 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4802 if (spec->kctl_alloc)
4803 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4804
4805 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4806
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004807 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 spec->input_mux = &spec->private_imux;
4809
4810 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004811 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4813 if (wcap != AC_WID_AUD_IN) {
4814 spec->adc_nids = alc260_adc_nids_alt;
4815 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4816 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004817 } else {
4818 spec->adc_nids = alc260_adc_nids;
4819 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4820 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004821 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004822 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004823
4824 return 1;
4825}
4826
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004827/* additional initialization for auto-configuration model */
4828static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004829{
Kailang Yangdf694da2005-12-05 19:42:22 +01004830 alc260_auto_init_multi_out(codec);
4831 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004832}
4833
Takashi Iwaicb53c622007-08-10 17:21:45 +02004834#ifdef CONFIG_SND_HDA_POWER_SAVE
4835static struct hda_amp_list alc260_loopbacks[] = {
4836 { 0x07, HDA_INPUT, 0 },
4837 { 0x07, HDA_INPUT, 1 },
4838 { 0x07, HDA_INPUT, 2 },
4839 { 0x07, HDA_INPUT, 3 },
4840 { 0x07, HDA_INPUT, 4 },
4841 { } /* end */
4842};
4843#endif
4844
Kailang Yangdf694da2005-12-05 19:42:22 +01004845/*
4846 * ALC260 configurations
4847 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004848static const char *alc260_models[ALC260_MODEL_LAST] = {
4849 [ALC260_BASIC] = "basic",
4850 [ALC260_HP] = "hp",
4851 [ALC260_HP_3013] = "hp-3013",
4852 [ALC260_FUJITSU_S702X] = "fujitsu",
4853 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004854 [ALC260_WILL] = "will",
4855 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004856#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004857 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004858#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004859 [ALC260_AUTO] = "auto",
4860};
4861
4862static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004863 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004864 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004865 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004866 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004867 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4868 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4869 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4870 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4871 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4872 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4873 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4874 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4875 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4876 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4877 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4878 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004879 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004880 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004881 {}
4882};
4883
Kailang Yangdf694da2005-12-05 19:42:22 +01004884static struct alc_config_preset alc260_presets[] = {
4885 [ALC260_BASIC] = {
4886 .mixers = { alc260_base_output_mixer,
4887 alc260_input_mixer,
4888 alc260_pc_beep_mixer,
4889 alc260_capture_mixer },
4890 .init_verbs = { alc260_init_verbs },
4891 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4892 .dac_nids = alc260_dac_nids,
4893 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4894 .adc_nids = alc260_adc_nids,
4895 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4896 .channel_mode = alc260_modes,
4897 .input_mux = &alc260_capture_source,
4898 },
4899 [ALC260_HP] = {
4900 .mixers = { alc260_base_output_mixer,
4901 alc260_input_mixer,
4902 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004903 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004904 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4905 .dac_nids = alc260_dac_nids,
4906 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4907 .adc_nids = alc260_hp_adc_nids,
4908 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4909 .channel_mode = alc260_modes,
4910 .input_mux = &alc260_capture_source,
4911 },
4912 [ALC260_HP_3013] = {
4913 .mixers = { alc260_hp_3013_mixer,
4914 alc260_input_mixer,
4915 alc260_capture_alt_mixer },
4916 .init_verbs = { alc260_hp_3013_init_verbs },
4917 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4918 .dac_nids = alc260_dac_nids,
4919 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4920 .adc_nids = alc260_hp_adc_nids,
4921 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4922 .channel_mode = alc260_modes,
4923 .input_mux = &alc260_capture_source,
4924 },
4925 [ALC260_FUJITSU_S702X] = {
4926 .mixers = { alc260_fujitsu_mixer,
4927 alc260_capture_mixer },
4928 .init_verbs = { alc260_fujitsu_init_verbs },
4929 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4930 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004931 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4932 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004933 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4934 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004935 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4936 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004937 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004938 [ALC260_ACER] = {
4939 .mixers = { alc260_acer_mixer,
4940 alc260_capture_mixer },
4941 .init_verbs = { alc260_acer_init_verbs },
4942 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4943 .dac_nids = alc260_dac_nids,
4944 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4945 .adc_nids = alc260_dual_adc_nids,
4946 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4947 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004948 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4949 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004950 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004951 [ALC260_WILL] = {
4952 .mixers = { alc260_will_mixer,
4953 alc260_capture_mixer },
4954 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4955 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4956 .dac_nids = alc260_dac_nids,
4957 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4958 .adc_nids = alc260_adc_nids,
4959 .dig_out_nid = ALC260_DIGOUT_NID,
4960 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4961 .channel_mode = alc260_modes,
4962 .input_mux = &alc260_capture_source,
4963 },
4964 [ALC260_REPLACER_672V] = {
4965 .mixers = { alc260_replacer_672v_mixer,
4966 alc260_capture_mixer },
4967 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4968 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4969 .dac_nids = alc260_dac_nids,
4970 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4971 .adc_nids = alc260_adc_nids,
4972 .dig_out_nid = ALC260_DIGOUT_NID,
4973 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4974 .channel_mode = alc260_modes,
4975 .input_mux = &alc260_capture_source,
4976 .unsol_event = alc260_replacer_672v_unsol_event,
4977 .init_hook = alc260_replacer_672v_automute,
4978 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004979#ifdef CONFIG_SND_DEBUG
4980 [ALC260_TEST] = {
4981 .mixers = { alc260_test_mixer,
4982 alc260_capture_mixer },
4983 .init_verbs = { alc260_test_init_verbs },
4984 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4985 .dac_nids = alc260_test_dac_nids,
4986 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4987 .adc_nids = alc260_test_adc_nids,
4988 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4989 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004990 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4991 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004992 },
4993#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004994};
4995
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996static int patch_alc260(struct hda_codec *codec)
4997{
4998 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004999 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005000
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005001 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005002 if (spec == NULL)
5003 return -ENOMEM;
5004
5005 codec->spec = spec;
5006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005007 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5008 alc260_models,
5009 alc260_cfg_tbl);
5010 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005011 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5012 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005013 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005014 }
5015
Kailang Yangdf694da2005-12-05 19:42:22 +01005016 if (board_config == ALC260_AUTO) {
5017 /* automatic parse from the BIOS config */
5018 err = alc260_parse_auto_config(codec);
5019 if (err < 0) {
5020 alc_free(codec);
5021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005022 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005023 printk(KERN_INFO
5024 "hda_codec: Cannot set up configuration "
5025 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005026 board_config = ALC260_BASIC;
5027 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005028 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005029
Kailang Yangdf694da2005-12-05 19:42:22 +01005030 if (board_config != ALC260_AUTO)
5031 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005032
5033 spec->stream_name_analog = "ALC260 Analog";
5034 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5035 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5036
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005037 spec->stream_name_digital = "ALC260 Digital";
5038 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5039 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5040
Takashi Iwai2134ea42008-01-10 16:53:55 +01005041 spec->vmaster_nid = 0x08;
5042
Linus Torvalds1da177e2005-04-16 15:20:36 -07005043 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005044 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005045 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005046#ifdef CONFIG_SND_HDA_POWER_SAVE
5047 if (!spec->loopback.amplist)
5048 spec->loopback.amplist = alc260_loopbacks;
5049#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005050
5051 return 0;
5052}
5053
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054
Linus Torvalds1da177e2005-04-16 15:20:36 -07005055/*
5056 * ALC882 support
5057 *
5058 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5059 * configuration. Each pin widget can choose any input DACs and a mixer.
5060 * Each ADC is connected from a mixer of all inputs. This makes possible
5061 * 6-channel independent captures.
5062 *
5063 * In addition, an independent DAC for the multi-playback (not used in this
5064 * driver yet).
5065 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005066#define ALC882_DIGOUT_NID 0x06
5067#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005068
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005069static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005070 { 8, NULL }
5071};
5072
5073static hda_nid_t alc882_dac_nids[4] = {
5074 /* front, rear, clfe, rear_surr */
5075 0x02, 0x03, 0x04, 0x05
5076};
5077
Kailang Yangdf694da2005-12-05 19:42:22 +01005078/* identical with ALC880 */
5079#define alc882_adc_nids alc880_adc_nids
5080#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005081
5082/* input MUX */
5083/* FIXME: should be a matrix-type input source selection */
5084
5085static struct hda_input_mux alc882_capture_source = {
5086 .num_items = 4,
5087 .items = {
5088 { "Mic", 0x0 },
5089 { "Front Mic", 0x1 },
5090 { "Line", 0x2 },
5091 { "CD", 0x4 },
5092 },
5093};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005094#define alc882_mux_enum_info alc_mux_enum_info
5095#define alc882_mux_enum_get alc_mux_enum_get
5096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005097static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5098 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005099{
5100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5101 struct alc_spec *spec = codec->spec;
5102 const struct hda_input_mux *imux = spec->input_mux;
5103 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5104 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5105 hda_nid_t nid = capture_mixers[adc_idx];
5106 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5107 unsigned int i, idx;
5108
5109 idx = ucontrol->value.enumerated.item[0];
5110 if (idx >= imux->num_items)
5111 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005112 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005113 return 0;
5114 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005115 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5116 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005117 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005118 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005119 }
5120 *cur_val = idx;
5121 return 1;
5122}
5123
Kailang Yangdf694da2005-12-05 19:42:22 +01005124/*
Kailang Yang272a5272007-05-14 11:00:38 +02005125 * 2ch mode
5126 */
5127static struct hda_verb alc882_3ST_ch2_init[] = {
5128 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5129 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5130 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5131 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5132 { } /* end */
5133};
5134
5135/*
5136 * 6ch mode
5137 */
5138static struct hda_verb alc882_3ST_ch6_init[] = {
5139 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5140 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5141 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5142 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5143 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5144 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5145 { } /* end */
5146};
5147
5148static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5149 { 2, alc882_3ST_ch2_init },
5150 { 6, alc882_3ST_ch6_init },
5151};
5152
5153/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005154 * 6ch mode
5155 */
5156static struct hda_verb alc882_sixstack_ch6_init[] = {
5157 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5158 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5159 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5160 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5161 { } /* end */
5162};
5163
5164/*
5165 * 8ch mode
5166 */
5167static struct hda_verb alc882_sixstack_ch8_init[] = {
5168 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5169 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5170 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5171 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5172 { } /* end */
5173};
5174
5175static struct hda_channel_mode alc882_sixstack_modes[2] = {
5176 { 6, alc882_sixstack_ch6_init },
5177 { 8, alc882_sixstack_ch8_init },
5178};
5179
Takashi Iwai87350ad2007-08-16 18:19:38 +02005180/*
5181 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5182 */
5183
5184/*
5185 * 2ch mode
5186 */
5187static struct hda_verb alc885_mbp_ch2_init[] = {
5188 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5189 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5191 { } /* end */
5192};
5193
5194/*
5195 * 6ch mode
5196 */
5197static struct hda_verb alc885_mbp_ch6_init[] = {
5198 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5199 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5200 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5201 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5202 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5203 { } /* end */
5204};
5205
5206static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5207 { 2, alc885_mbp_ch2_init },
5208 { 6, alc885_mbp_ch6_init },
5209};
5210
5211
Linus Torvalds1da177e2005-04-16 15:20:36 -07005212/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5213 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5214 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005215static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005218 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005219 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005220 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5221 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005222 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5223 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005224 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005225 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005232 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5234 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005235 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005236 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5237 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5238 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005239 { } /* end */
5240};
5241
Takashi Iwai87350ad2007-08-16 18:19:38 +02005242static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5244 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5245 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5246 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5247 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5248 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5250 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005251 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5253 { } /* end */
5254};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005255static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5263 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5265 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5266 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5267 { } /* end */
5268};
5269
Kailang Yang272a5272007-05-14 11:00:38 +02005270static struct snd_kcontrol_new alc882_targa_mixer[] = {
5271 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5272 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5276 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5277 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005280 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005281 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5282 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005283 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005284 { } /* end */
5285};
5286
5287/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5288 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5289 */
5290static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5292 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5294 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5300 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005303 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005304 { } /* end */
5305};
5306
Takashi Iwai914759b2007-09-06 14:52:04 +02005307static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5309 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5312 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5318 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5319 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5320 { } /* end */
5321};
5322
Kailang Yangdf694da2005-12-05 19:42:22 +01005323static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5324 {
5325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5326 .name = "Channel Mode",
5327 .info = alc_ch_mode_info,
5328 .get = alc_ch_mode_get,
5329 .put = alc_ch_mode_put,
5330 },
5331 { } /* end */
5332};
5333
Linus Torvalds1da177e2005-04-16 15:20:36 -07005334static struct hda_verb alc882_init_verbs[] = {
5335 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005339 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005343 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005347 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005352 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005355 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005356 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005357 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005360 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005361 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005362 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005363 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005364 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005365 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005366 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005367 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005368 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005369 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5371 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5374 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5377 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5379 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5380 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005381 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005382 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005383
5384 /* FIXME: use matrix-type input source selection */
5385 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5386 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005391 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005396 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5401 /* ADC1: mute amp left and right */
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005404 /* ADC2: mute amp left and right */
5405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005406 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005407 /* ADC3: mute amp left and right */
5408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005409 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005410
5411 { }
5412};
5413
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005414static struct hda_verb alc882_eapd_verbs[] = {
5415 /* change to EAPD mode */
5416 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005417 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005418 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005419};
5420
Tobin Davis9102cd12006-12-15 10:02:12 +01005421/* Mac Pro test */
5422static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5423 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5426 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5427 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5428 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5429 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5430 { } /* end */
5431};
5432
5433static struct hda_verb alc882_macpro_init_verbs[] = {
5434 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5438 /* Front Pin: output 0 (0x0c) */
5439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5442 /* Front Mic pin: input vref at 80% */
5443 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5445 /* Speaker: output */
5446 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5447 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5448 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5449 /* Headphone output (output 0 - 0x0c) */
5450 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5451 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5452 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5453
5454 /* FIXME: use matrix-type input source selection */
5455 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5456 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5461 /* Input mixer2 */
5462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5466 /* Input mixer3 */
5467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5471 /* ADC1: mute amp left and right */
5472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5473 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5474 /* ADC2: mute amp left and right */
5475 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5476 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5477 /* ADC3: mute amp left and right */
5478 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5479 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5480
5481 { }
5482};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005483
Takashi Iwai87350ad2007-08-16 18:19:38 +02005484/* Macbook Pro rev3 */
5485static struct hda_verb alc885_mbp3_init_verbs[] = {
5486 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5490 /* Rear mixer */
5491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5494 /* Front Pin: output 0 (0x0c) */
5495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5498 /* HP Pin: output 0 (0x0d) */
5499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5502 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5503 /* Mic (rear) pin: input vref at 80% */
5504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5506 /* Front Mic pin: input vref at 80% */
5507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5509 /* Line In pin: use output 1 when in LineOut mode */
5510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5513
5514 /* FIXME: use matrix-type input source selection */
5515 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5516 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5521 /* Input mixer2 */
5522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5526 /* Input mixer3 */
5527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5531 /* ADC1: mute amp left and right */
5532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5534 /* ADC2: mute amp left and right */
5535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5536 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5537 /* ADC3: mute amp left and right */
5538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5540
5541 { }
5542};
5543
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005544/* iMac 24 mixer. */
5545static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5546 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5547 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5548 { } /* end */
5549};
5550
5551/* iMac 24 init verbs. */
5552static struct hda_verb alc885_imac24_init_verbs[] = {
5553 /* Internal speakers: output 0 (0x0c) */
5554 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5555 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5556 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5557 /* Internal speakers: output 0 (0x0c) */
5558 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5559 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5560 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5561 /* Headphone: output 0 (0x0c) */
5562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5563 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5564 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5566 /* Front Mic: input vref at 80% */
5567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5569 { }
5570};
5571
5572/* Toggle speaker-output according to the hp-jack state */
5573static void alc885_imac24_automute(struct hda_codec *codec)
5574{
5575 unsigned int present;
5576
5577 present = snd_hda_codec_read(codec, 0x14, 0,
5578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005579 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5581 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5582 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005583}
5584
5585/* Processes unsolicited events. */
5586static void alc885_imac24_unsol_event(struct hda_codec *codec,
5587 unsigned int res)
5588{
5589 /* Headphone insertion or removal. */
5590 if ((res >> 26) == ALC880_HP_EVENT)
5591 alc885_imac24_automute(codec);
5592}
5593
Takashi Iwai87350ad2007-08-16 18:19:38 +02005594static void alc885_mbp3_automute(struct hda_codec *codec)
5595{
5596 unsigned int present;
5597
5598 present = snd_hda_codec_read(codec, 0x15, 0,
5599 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5600 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5601 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5602 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5603 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5604
5605}
5606static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5607 unsigned int res)
5608{
5609 /* Headphone insertion or removal. */
5610 if ((res >> 26) == ALC880_HP_EVENT)
5611 alc885_mbp3_automute(codec);
5612}
5613
5614
Kailang Yang272a5272007-05-14 11:00:38 +02005615static struct hda_verb alc882_targa_verbs[] = {
5616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5618
5619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5621
5622 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5623 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5625
5626 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5627 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5628 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5629 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5630 { } /* end */
5631};
5632
5633/* toggle speaker-output according to the hp-jack state */
5634static void alc882_targa_automute(struct hda_codec *codec)
5635{
5636 unsigned int present;
5637
5638 present = snd_hda_codec_read(codec, 0x14, 0,
5639 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005640 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5641 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005642 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5643 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005644}
5645
5646static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5647{
5648 /* Looks like the unsol event is incompatible with the standard
5649 * definition. 4bit tag is placed at 26 bit!
5650 */
5651 if (((res >> 26) == ALC880_HP_EVENT)) {
5652 alc882_targa_automute(codec);
5653 }
5654}
5655
5656static struct hda_verb alc882_asus_a7j_verbs[] = {
5657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5659
5660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5663
5664 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5666 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5667
5668 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5669 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5670 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5671 { } /* end */
5672};
5673
Takashi Iwai914759b2007-09-06 14:52:04 +02005674static struct hda_verb alc882_asus_a7m_verbs[] = {
5675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5677
5678 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5680 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5681
5682 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5684 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5685
5686 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5687 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5688 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5689 { } /* end */
5690};
5691
Tobin Davis9102cd12006-12-15 10:02:12 +01005692static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5693{
5694 unsigned int gpiostate, gpiomask, gpiodir;
5695
5696 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5697 AC_VERB_GET_GPIO_DATA, 0);
5698
5699 if (!muted)
5700 gpiostate |= (1 << pin);
5701 else
5702 gpiostate &= ~(1 << pin);
5703
5704 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5705 AC_VERB_GET_GPIO_MASK, 0);
5706 gpiomask |= (1 << pin);
5707
5708 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5709 AC_VERB_GET_GPIO_DIRECTION, 0);
5710 gpiodir |= (1 << pin);
5711
5712
5713 snd_hda_codec_write(codec, codec->afg, 0,
5714 AC_VERB_SET_GPIO_MASK, gpiomask);
5715 snd_hda_codec_write(codec, codec->afg, 0,
5716 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5717
5718 msleep(1);
5719
5720 snd_hda_codec_write(codec, codec->afg, 0,
5721 AC_VERB_SET_GPIO_DATA, gpiostate);
5722}
5723
Takashi Iwai7debbe52007-08-16 15:01:03 +02005724/* set up GPIO at initialization */
5725static void alc885_macpro_init_hook(struct hda_codec *codec)
5726{
5727 alc882_gpio_mute(codec, 0, 0);
5728 alc882_gpio_mute(codec, 1, 0);
5729}
5730
5731/* set up GPIO and update auto-muting at initialization */
5732static void alc885_imac24_init_hook(struct hda_codec *codec)
5733{
5734 alc885_macpro_init_hook(codec);
5735 alc885_imac24_automute(codec);
5736}
5737
Kailang Yangdf694da2005-12-05 19:42:22 +01005738/*
5739 * generic initialization of ADC, input mixers and output mixers
5740 */
5741static struct hda_verb alc882_auto_init_verbs[] = {
5742 /*
5743 * Unmute ADC0-2 and set the default input to mic-in
5744 */
5745 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5747 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5749 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5751
Takashi Iwaicb53c622007-08-10 17:21:45 +02005752 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005754 * Note: PASD motherboards uses the Line In 2 as the input for
5755 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005756 */
5757 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005763
5764 /*
5765 * Set up output mixers (0x0c - 0x0f)
5766 */
5767 /* set vol=0 to output mixers */
5768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5771 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5772 /* set up input amps for analog loopback */
5773 /* Amp Indices: DAC = 0, mixer = 1 */
5774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5782 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5784
5785 /* FIXME: use matrix-type input source selection */
5786 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5787 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5792 /* Input mixer2 */
5793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5797 /* Input mixer3 */
5798 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5802
5803 { }
5804};
5805
5806/* capture mixer elements */
5807static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5808 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5809 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5810 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5811 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5812 {
5813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5814 /* The multiple "Capture Source" controls confuse alsamixer
5815 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 */
5817 /* .name = "Capture Source", */
5818 .name = "Input Source",
5819 .count = 2,
5820 .info = alc882_mux_enum_info,
5821 .get = alc882_mux_enum_get,
5822 .put = alc882_mux_enum_put,
5823 },
5824 { } /* end */
5825};
5826
5827static struct snd_kcontrol_new alc882_capture_mixer[] = {
5828 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5829 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5830 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5833 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5834 {
5835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5836 /* The multiple "Capture Source" controls confuse alsamixer
5837 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005838 */
5839 /* .name = "Capture Source", */
5840 .name = "Input Source",
5841 .count = 3,
5842 .info = alc882_mux_enum_info,
5843 .get = alc882_mux_enum_get,
5844 .put = alc882_mux_enum_put,
5845 },
5846 { } /* end */
5847};
5848
Takashi Iwaicb53c622007-08-10 17:21:45 +02005849#ifdef CONFIG_SND_HDA_POWER_SAVE
5850#define alc882_loopbacks alc880_loopbacks
5851#endif
5852
Kailang Yangdf694da2005-12-05 19:42:22 +01005853/* pcm configuration: identiacal with ALC880 */
5854#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5855#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5856#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5857#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5858
5859/*
5860 * configuration and preset
5861 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005862static const char *alc882_models[ALC882_MODEL_LAST] = {
5863 [ALC882_3ST_DIG] = "3stack-dig",
5864 [ALC882_6ST_DIG] = "6stack-dig",
5865 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005866 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005867 [ALC882_TARGA] = "targa",
5868 [ALC882_ASUS_A7J] = "asus-a7j",
5869 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005870 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005871 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005872 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005873 [ALC882_AUTO] = "auto",
5874};
5875
5876static struct snd_pci_quirk alc882_cfg_tbl[] = {
5877 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005878 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005879 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005880 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005881 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005882 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005883 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005884 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01005885 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005886 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5887 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5888 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005889 {}
5890};
5891
5892static struct alc_config_preset alc882_presets[] = {
5893 [ALC882_3ST_DIG] = {
5894 .mixers = { alc882_base_mixer },
5895 .init_verbs = { alc882_init_verbs },
5896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5897 .dac_nids = alc882_dac_nids,
5898 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005899 .dig_in_nid = ALC882_DIGIN_NID,
5900 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5901 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005902 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005903 .input_mux = &alc882_capture_source,
5904 },
5905 [ALC882_6ST_DIG] = {
5906 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5907 .init_verbs = { alc882_init_verbs },
5908 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5909 .dac_nids = alc882_dac_nids,
5910 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005911 .dig_in_nid = ALC882_DIGIN_NID,
5912 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5913 .channel_mode = alc882_sixstack_modes,
5914 .input_mux = &alc882_capture_source,
5915 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005916 [ALC882_ARIMA] = {
5917 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5918 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5919 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5920 .dac_nids = alc882_dac_nids,
5921 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5922 .channel_mode = alc882_sixstack_modes,
5923 .input_mux = &alc882_capture_source,
5924 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005925 [ALC882_W2JC] = {
5926 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5927 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5928 alc880_gpio1_init_verbs },
5929 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5930 .dac_nids = alc882_dac_nids,
5931 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5932 .channel_mode = alc880_threestack_modes,
5933 .need_dac_fix = 1,
5934 .input_mux = &alc882_capture_source,
5935 .dig_out_nid = ALC882_DIGOUT_NID,
5936 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005937 [ALC885_MBP3] = {
5938 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5939 .init_verbs = { alc885_mbp3_init_verbs,
5940 alc880_gpio1_init_verbs },
5941 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5942 .dac_nids = alc882_dac_nids,
5943 .channel_mode = alc885_mbp_6ch_modes,
5944 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5945 .input_mux = &alc882_capture_source,
5946 .dig_out_nid = ALC882_DIGOUT_NID,
5947 .dig_in_nid = ALC882_DIGIN_NID,
5948 .unsol_event = alc885_mbp3_unsol_event,
5949 .init_hook = alc885_mbp3_automute,
5950 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005951 [ALC885_MACPRO] = {
5952 .mixers = { alc882_macpro_mixer },
5953 .init_verbs = { alc882_macpro_init_verbs },
5954 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5955 .dac_nids = alc882_dac_nids,
5956 .dig_out_nid = ALC882_DIGOUT_NID,
5957 .dig_in_nid = ALC882_DIGIN_NID,
5958 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5959 .channel_mode = alc882_ch_modes,
5960 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005961 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005962 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005963 [ALC885_IMAC24] = {
5964 .mixers = { alc885_imac24_mixer },
5965 .init_verbs = { alc885_imac24_init_verbs },
5966 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5967 .dac_nids = alc882_dac_nids,
5968 .dig_out_nid = ALC882_DIGOUT_NID,
5969 .dig_in_nid = ALC882_DIGIN_NID,
5970 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5971 .channel_mode = alc882_ch_modes,
5972 .input_mux = &alc882_capture_source,
5973 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005974 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005975 },
Kailang Yang272a5272007-05-14 11:00:38 +02005976 [ALC882_TARGA] = {
5977 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5978 alc882_capture_mixer },
5979 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5980 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5981 .dac_nids = alc882_dac_nids,
5982 .dig_out_nid = ALC882_DIGOUT_NID,
5983 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5984 .adc_nids = alc882_adc_nids,
5985 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5986 .channel_mode = alc882_3ST_6ch_modes,
5987 .need_dac_fix = 1,
5988 .input_mux = &alc882_capture_source,
5989 .unsol_event = alc882_targa_unsol_event,
5990 .init_hook = alc882_targa_automute,
5991 },
5992 [ALC882_ASUS_A7J] = {
5993 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5994 alc882_capture_mixer },
5995 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5996 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5997 .dac_nids = alc882_dac_nids,
5998 .dig_out_nid = ALC882_DIGOUT_NID,
5999 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6000 .adc_nids = alc882_adc_nids,
6001 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6002 .channel_mode = alc882_3ST_6ch_modes,
6003 .need_dac_fix = 1,
6004 .input_mux = &alc882_capture_source,
6005 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006006 [ALC882_ASUS_A7M] = {
6007 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6008 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6009 alc880_gpio1_init_verbs,
6010 alc882_asus_a7m_verbs },
6011 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6012 .dac_nids = alc882_dac_nids,
6013 .dig_out_nid = ALC882_DIGOUT_NID,
6014 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6015 .channel_mode = alc880_threestack_modes,
6016 .need_dac_fix = 1,
6017 .input_mux = &alc882_capture_source,
6018 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006019};
6020
6021
6022/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006023 * Pin config fixes
6024 */
6025enum {
6026 PINFIX_ABIT_AW9D_MAX
6027};
6028
6029static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6030 { 0x15, 0x01080104 }, /* side */
6031 { 0x16, 0x01011012 }, /* rear */
6032 { 0x17, 0x01016011 }, /* clfe */
6033 { }
6034};
6035
6036static const struct alc_pincfg *alc882_pin_fixes[] = {
6037 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6038};
6039
6040static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6041 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6042 {}
6043};
6044
6045/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006046 * BIOS auto configuration
6047 */
6048static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6049 hda_nid_t nid, int pin_type,
6050 int dac_idx)
6051{
6052 /* set as output */
6053 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006054 int idx;
6055
Kailang Yangdf694da2005-12-05 19:42:22 +01006056 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6057 idx = 4;
6058 else
6059 idx = spec->multiout.dac_nids[dac_idx] - 2;
6060
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006061 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6062 pin_type);
6063 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6064 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006065 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6066
6067}
6068
6069static void alc882_auto_init_multi_out(struct hda_codec *codec)
6070{
6071 struct alc_spec *spec = codec->spec;
6072 int i;
6073
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006074 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006075 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006076 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006077 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006078 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006079 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006080 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006081 }
6082}
6083
6084static void alc882_auto_init_hp_out(struct hda_codec *codec)
6085{
6086 struct alc_spec *spec = codec->spec;
6087 hda_nid_t pin;
6088
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006089 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006091 /* use dac 0 */
6092 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006093}
6094
6095#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6096#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6097
6098static void alc882_auto_init_analog_input(struct hda_codec *codec)
6099{
6100 struct alc_spec *spec = codec->spec;
6101 int i;
6102
6103 for (i = 0; i < AUTO_PIN_LAST; i++) {
6104 hda_nid_t nid = spec->autocfg.input_pins[i];
6105 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106 snd_hda_codec_write(codec, nid, 0,
6107 AC_VERB_SET_PIN_WIDGET_CONTROL,
6108 i <= AUTO_PIN_FRONT_MIC ?
6109 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006110 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006111 snd_hda_codec_write(codec, nid, 0,
6112 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006113 AMP_OUT_MUTE);
6114 }
6115 }
6116}
6117
Takashi Iwai776e1842007-08-29 15:07:11 +02006118/* add mic boosts if needed */
6119static int alc_auto_add_mic_boost(struct hda_codec *codec)
6120{
6121 struct alc_spec *spec = codec->spec;
6122 int err;
6123 hda_nid_t nid;
6124
6125 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006126 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006127 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6128 "Mic Boost",
6129 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6130 if (err < 0)
6131 return err;
6132 }
6133 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006134 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006135 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6136 "Front Mic Boost",
6137 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6138 if (err < 0)
6139 return err;
6140 }
6141 return 0;
6142}
6143
Kailang Yangdf694da2005-12-05 19:42:22 +01006144/* almost identical with ALC880 parser... */
6145static int alc882_parse_auto_config(struct hda_codec *codec)
6146{
6147 struct alc_spec *spec = codec->spec;
6148 int err = alc880_parse_auto_config(codec);
6149
6150 if (err < 0)
6151 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006152 else if (!err)
6153 return 0; /* no config found */
6154
6155 err = alc_auto_add_mic_boost(codec);
6156 if (err < 0)
6157 return err;
6158
6159 /* hack - override the init verbs */
6160 spec->init_verbs[0] = alc882_auto_init_verbs;
6161
6162 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006163}
6164
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006165/* additional initialization for auto-configuration model */
6166static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006167{
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 alc882_auto_init_multi_out(codec);
6169 alc882_auto_init_hp_out(codec);
6170 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006171}
6172
Linus Torvalds1da177e2005-04-16 15:20:36 -07006173static int patch_alc882(struct hda_codec *codec)
6174{
6175 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006176 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006177
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006178 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006179 if (spec == NULL)
6180 return -ENOMEM;
6181
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182 codec->spec = spec;
6183
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006184 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6185 alc882_models,
6186 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006187
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006189 /* Pick up systems that don't supply PCI SSID */
6190 switch (codec->subsystem_id) {
6191 case 0x106b0c00: /* Mac Pro */
6192 board_config = ALC885_MACPRO;
6193 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006194 case 0x106b1000: /* iMac 24 */
6195 board_config = ALC885_IMAC24;
6196 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006197 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006198 case 0x106b2c00: /* Macbook Pro rev3 */
6199 board_config = ALC885_MBP3;
6200 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006201 default:
6202 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6203 "trying auto-probe from BIOS...\n");
6204 board_config = ALC882_AUTO;
6205 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006206 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006207
Takashi Iwaif95474e2007-07-10 00:47:43 +02006208 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6209
Kailang Yangdf694da2005-12-05 19:42:22 +01006210 if (board_config == ALC882_AUTO) {
6211 /* automatic parse from the BIOS config */
6212 err = alc882_parse_auto_config(codec);
6213 if (err < 0) {
6214 alc_free(codec);
6215 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006216 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006217 printk(KERN_INFO
6218 "hda_codec: Cannot set up configuration "
6219 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006220 board_config = ALC882_3ST_DIG;
6221 }
6222 }
6223
6224 if (board_config != ALC882_AUTO)
6225 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226
6227 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006228 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6229 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006230 /* FIXME: setup DAC5 */
6231 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6232 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006233
6234 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006235 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6236 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006238 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006239 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006240 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006241 /* get type */
6242 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 if (wcap != AC_WID_AUD_IN) {
6244 spec->adc_nids = alc882_adc_nids_alt;
6245 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006246 spec->mixers[spec->num_mixers] =
6247 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006248 spec->num_mixers++;
6249 } else {
6250 spec->adc_nids = alc882_adc_nids;
6251 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6252 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6253 spec->num_mixers++;
6254 }
6255 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006256
Takashi Iwai2134ea42008-01-10 16:53:55 +01006257 spec->vmaster_nid = 0x0c;
6258
Linus Torvalds1da177e2005-04-16 15:20:36 -07006259 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006261 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006262#ifdef CONFIG_SND_HDA_POWER_SAVE
6263 if (!spec->loopback.amplist)
6264 spec->loopback.amplist = alc882_loopbacks;
6265#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006266
6267 return 0;
6268}
6269
6270/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006271 * ALC883 support
6272 *
6273 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6274 * configuration. Each pin widget can choose any input DACs and a mixer.
6275 * Each ADC is connected from a mixer of all inputs. This makes possible
6276 * 6-channel independent captures.
6277 *
6278 * In addition, an independent DAC for the multi-playback (not used in this
6279 * driver yet).
6280 */
6281#define ALC883_DIGOUT_NID 0x06
6282#define ALC883_DIGIN_NID 0x0a
6283
6284static hda_nid_t alc883_dac_nids[4] = {
6285 /* front, rear, clfe, rear_surr */
6286 0x02, 0x04, 0x03, 0x05
6287};
6288
6289static hda_nid_t alc883_adc_nids[2] = {
6290 /* ADC1-2 */
6291 0x08, 0x09,
6292};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006293
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006294/* input MUX */
6295/* FIXME: should be a matrix-type input source selection */
6296
6297static struct hda_input_mux alc883_capture_source = {
6298 .num_items = 4,
6299 .items = {
6300 { "Mic", 0x0 },
6301 { "Front Mic", 0x1 },
6302 { "Line", 0x2 },
6303 { "CD", 0x4 },
6304 },
6305};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006306
6307static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6308 .num_items = 2,
6309 .items = {
6310 { "Mic", 0x1 },
6311 { "Line", 0x2 },
6312 },
6313};
6314
Kailang Yang272a5272007-05-14 11:00:38 +02006315static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6316 .num_items = 4,
6317 .items = {
6318 { "Mic", 0x0 },
6319 { "iMic", 0x1 },
6320 { "Line", 0x2 },
6321 { "CD", 0x4 },
6322 },
6323};
6324
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006325#define alc883_mux_enum_info alc_mux_enum_info
6326#define alc883_mux_enum_get alc_mux_enum_get
6327
6328static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6329 struct snd_ctl_elem_value *ucontrol)
6330{
6331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6332 struct alc_spec *spec = codec->spec;
6333 const struct hda_input_mux *imux = spec->input_mux;
6334 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6335 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6336 hda_nid_t nid = capture_mixers[adc_idx];
6337 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6338 unsigned int i, idx;
6339
6340 idx = ucontrol->value.enumerated.item[0];
6341 if (idx >= imux->num_items)
6342 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006343 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006344 return 0;
6345 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006346 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6347 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006348 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006349 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006350 }
6351 *cur_val = idx;
6352 return 1;
6353}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006354
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006355/*
6356 * 2ch mode
6357 */
6358static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6359 { 2, NULL }
6360};
6361
6362/*
6363 * 2ch mode
6364 */
6365static struct hda_verb alc883_3ST_ch2_init[] = {
6366 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6367 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6368 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6369 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6370 { } /* end */
6371};
6372
6373/*
Tobin Davisb2011312007-09-17 12:45:11 +02006374 * 4ch mode
6375 */
6376static struct hda_verb alc883_3ST_ch4_init[] = {
6377 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6378 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6379 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6380 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6381 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6382 { } /* end */
6383};
6384
6385/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006386 * 6ch mode
6387 */
6388static struct hda_verb alc883_3ST_ch6_init[] = {
6389 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6390 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6391 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6392 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6393 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6394 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6395 { } /* end */
6396};
6397
Tobin Davisb2011312007-09-17 12:45:11 +02006398static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006399 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006400 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006401 { 6, alc883_3ST_ch6_init },
6402};
6403
6404/*
6405 * 6ch mode
6406 */
6407static struct hda_verb alc883_sixstack_ch6_init[] = {
6408 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6409 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6410 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6411 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6412 { } /* end */
6413};
6414
6415/*
6416 * 8ch mode
6417 */
6418static struct hda_verb alc883_sixstack_ch8_init[] = {
6419 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6420 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6421 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6422 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6423 { } /* end */
6424};
6425
6426static struct hda_channel_mode alc883_sixstack_modes[2] = {
6427 { 6, alc883_sixstack_ch6_init },
6428 { 8, alc883_sixstack_ch8_init },
6429};
6430
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006431static struct hda_verb alc883_medion_eapd_verbs[] = {
6432 /* eanable EAPD on medion laptop */
6433 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6434 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6435 { }
6436};
6437
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006438/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6439 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6440 */
6441
6442static struct snd_kcontrol_new alc883_base_mixer[] = {
6443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6444 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6446 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6451 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6452 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6454 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6455 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6457 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006459 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006462 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6464 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6465 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6466 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6467 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6468 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6469 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6470 {
6471 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6472 /* .name = "Capture Source", */
6473 .name = "Input Source",
6474 .count = 2,
6475 .info = alc883_mux_enum_info,
6476 .get = alc883_mux_enum_get,
6477 .put = alc883_mux_enum_put,
6478 },
6479 { } /* end */
6480};
6481
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006482static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6483 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6484 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6485 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6486 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6487 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6488 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6497 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6498 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6499 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6500 {
6501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6502 /* .name = "Capture Source", */
6503 .name = "Input Source",
6504 .count = 2,
6505 .info = alc883_mux_enum_info,
6506 .get = alc883_mux_enum_get,
6507 .put = alc883_mux_enum_put,
6508 },
6509 { } /* end */
6510};
6511
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006512static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006521 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6523 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006524 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006525 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6526 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6527 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6528 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6529 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6530 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6531 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6532 {
6533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6534 /* .name = "Capture Source", */
6535 .name = "Input Source",
6536 .count = 2,
6537 .info = alc883_mux_enum_info,
6538 .get = alc883_mux_enum_get,
6539 .put = alc883_mux_enum_put,
6540 },
6541 { } /* end */
6542};
6543
6544static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6546 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6547 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6548 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6549 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6551 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6552 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006559 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6561 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006562 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006563 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6564 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6565 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6566 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6567 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6568 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6569 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6570 {
6571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6572 /* .name = "Capture Source", */
6573 .name = "Input Source",
6574 .count = 2,
6575 .info = alc883_mux_enum_info,
6576 .get = alc883_mux_enum_get,
6577 .put = alc883_mux_enum_put,
6578 },
6579 { } /* end */
6580};
6581
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006582static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006583 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6584 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6585 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6586 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6587 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6588 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6589 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6590 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6592 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6593 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6594 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6595 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006597 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006600 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006601 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6602 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6603 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6604 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6605 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6606
6607 {
6608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6609 /* .name = "Capture Source", */
6610 .name = "Input Source",
6611 .count = 1,
6612 .info = alc883_mux_enum_info,
6613 .get = alc883_mux_enum_get,
6614 .put = alc883_mux_enum_put,
6615 },
6616 { } /* end */
6617};
6618
Kailang Yangccc656c2006-10-17 12:32:26 +02006619static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6620 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6622 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6624 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6626 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6627 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6628 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6636 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6637 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6638 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6639 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6640 {
6641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6642 /* .name = "Capture Source", */
6643 .name = "Input Source",
6644 .count = 2,
6645 .info = alc883_mux_enum_info,
6646 .get = alc883_mux_enum_get,
6647 .put = alc883_mux_enum_put,
6648 },
6649 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006650};
Kailang Yangccc656c2006-10-17 12:32:26 +02006651
6652static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6653 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6655 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006659 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6661 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6662 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6663 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6664 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6665 {
6666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6667 /* .name = "Capture Source", */
6668 .name = "Input Source",
6669 .count = 2,
6670 .info = alc883_mux_enum_info,
6671 .get = alc883_mux_enum_get,
6672 .put = alc883_mux_enum_put,
6673 },
6674 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006675};
Kailang Yangccc656c2006-10-17 12:32:26 +02006676
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006677static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6678 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6679 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006680 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6681 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6686 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6687 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6688 {
6689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6690 /* .name = "Capture Source", */
6691 .name = "Input Source",
6692 .count = 1,
6693 .info = alc883_mux_enum_info,
6694 .get = alc883_mux_enum_get,
6695 .put = alc883_mux_enum_put,
6696 },
6697 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006698};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006699
Kailang Yang272a5272007-05-14 11:00:38 +02006700static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6701 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6702 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6708 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6709 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6710 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6711 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6712 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6713 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6714 {
6715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6716 /* .name = "Capture Source", */
6717 .name = "Input Source",
6718 .count = 2,
6719 .info = alc883_mux_enum_info,
6720 .get = alc883_mux_enum_get,
6721 .put = alc883_mux_enum_put,
6722 },
6723 { } /* end */
6724};
6725
6726static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6728 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6729 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6736 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6737 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6738 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6739 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6740 {
6741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6742 /* .name = "Capture Source", */
6743 .name = "Input Source",
6744 .count = 2,
6745 .info = alc883_mux_enum_info,
6746 .get = alc883_mux_enum_get,
6747 .put = alc883_mux_enum_put,
6748 },
6749 { } /* end */
6750};
6751
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006752static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6755 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6757 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6758 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6759 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6760 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6761 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6762 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6774 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6775 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6776 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6777 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6778 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6779 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6780 {
6781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6782 /* .name = "Capture Source", */
6783 .name = "Input Source",
6784 .count = 2,
6785 .info = alc883_mux_enum_info,
6786 .get = alc883_mux_enum_get,
6787 .put = alc883_mux_enum_put,
6788 },
6789 { } /* end */
6790};
6791
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006792static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6796 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6797 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6798 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6799 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6800 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6812 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6813 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6814 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6815 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6818 {
6819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6820 /* .name = "Capture Source", */
6821 .name = "Input Source",
6822 .count = 2,
6823 .info = alc883_mux_enum_info,
6824 .get = alc883_mux_enum_get,
6825 .put = alc883_mux_enum_put,
6826 },
6827 { } /* end */
6828};
6829
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006830static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6831 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6832 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6833 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6834 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6835 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6837 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6838 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6840 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6849 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6852 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6853 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6854 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6855 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6856 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6857 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6858 {
6859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6860 /* .name = "Capture Source", */
6861 .name = "Input Source",
6862 .count = 2,
6863 .info = alc883_mux_enum_info,
6864 .get = alc883_mux_enum_get,
6865 .put = alc883_mux_enum_put,
6866 },
6867 { } /* end */
6868};
6869
Tobin Davis2880a862007-08-07 11:50:26 +02006870static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006874 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6875 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006876 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6881 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6882 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6883 {
6884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6885 /* .name = "Capture Source", */
6886 .name = "Input Source",
6887 .count = 2,
6888 .info = alc883_mux_enum_info,
6889 .get = alc883_mux_enum_get,
6890 .put = alc883_mux_enum_put,
6891 },
6892 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006893};
Tobin Davis2880a862007-08-07 11:50:26 +02006894
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006895static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6896 {
6897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6898 .name = "Channel Mode",
6899 .info = alc_ch_mode_info,
6900 .get = alc_ch_mode_get,
6901 .put = alc_ch_mode_put,
6902 },
6903 { } /* end */
6904};
6905
6906static struct hda_verb alc883_init_verbs[] = {
6907 /* ADC1: mute amp left and right */
6908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6909 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6910 /* ADC2: mute amp left and right */
6911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6912 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6913 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6917 /* Rear mixer */
6918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6921 /* CLFE mixer */
6922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6925 /* Side mixer */
6926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6929
Takashi Iwaicb53c622007-08-10 17:21:45 +02006930 /* mute analog input loopbacks */
6931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006936
6937 /* Front Pin: output 0 (0x0c) */
6938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6939 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6940 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6941 /* Rear Pin: output 1 (0x0d) */
6942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6945 /* CLFE Pin: output 2 (0x0e) */
6946 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6947 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6948 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6949 /* Side Pin: output 3 (0x0f) */
6950 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6951 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6952 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6953 /* Mic (rear) pin: input vref at 80% */
6954 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6955 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6956 /* Front Mic pin: input vref at 80% */
6957 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6958 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6959 /* Line In pin: input */
6960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6962 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6965 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6966 /* CD pin widget for input */
6967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6968
6969 /* FIXME: use matrix-type input source selection */
6970 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6971 /* Input mixer2 */
6972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6976 /* Input mixer3 */
6977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6981 { }
6982};
6983
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006984/* toggle speaker-output according to the hp-jack state */
6985static void alc883_mitac_hp_automute(struct hda_codec *codec)
6986{
6987 unsigned int present;
6988
6989 present = snd_hda_codec_read(codec, 0x15, 0,
6990 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6991 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6992 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6993 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6994 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6995}
6996
6997/* auto-toggle front mic */
6998/*
6999static void alc883_mitac_mic_automute(struct hda_codec *codec)
7000{
7001 unsigned int present;
7002 unsigned char bits;
7003
7004 present = snd_hda_codec_read(codec, 0x18, 0,
7005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7006 bits = present ? HDA_AMP_MUTE : 0;
7007 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7008}
7009*/
7010
7011static void alc883_mitac_automute(struct hda_codec *codec)
7012{
7013 alc883_mitac_hp_automute(codec);
7014 /* alc883_mitac_mic_automute(codec); */
7015}
7016
7017static void alc883_mitac_unsol_event(struct hda_codec *codec,
7018 unsigned int res)
7019{
7020 switch (res >> 26) {
7021 case ALC880_HP_EVENT:
7022 alc883_mitac_hp_automute(codec);
7023 break;
7024 case ALC880_MIC_EVENT:
7025 /* alc883_mitac_mic_automute(codec); */
7026 break;
7027 }
7028}
7029
7030static struct hda_verb alc883_mitac_verbs[] = {
7031 /* HP */
7032 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7034 /* Subwoofer */
7035 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7036 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7037
7038 /* enable unsolicited event */
7039 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7040 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7041
7042 { } /* end */
7043};
7044
Kailang Yangccc656c2006-10-17 12:32:26 +02007045static struct hda_verb alc883_tagra_verbs[] = {
7046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7048
7049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7051
7052 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7053 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7055
7056 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007057 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7058 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7059 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007060
7061 { } /* end */
7062};
7063
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007064static struct hda_verb alc883_lenovo_101e_verbs[] = {
7065 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7066 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7068 { } /* end */
7069};
7070
Kailang Yang272a5272007-05-14 11:00:38 +02007071static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7074 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7075 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7076 { } /* end */
7077};
7078
7079static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7083 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7084 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7085 { } /* end */
7086};
7087
Kailang Yang189609a2007-08-20 11:31:23 +02007088static struct hda_verb alc883_haier_w66_verbs[] = {
7089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7091
7092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7093
7094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7096 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7098 { } /* end */
7099};
7100
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007101static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007102 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7104 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7105 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7106 { }
7107};
7108
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007109static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007110 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7111 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7112 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7113 { }
7114};
7115
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007116static struct hda_verb alc888_6st_dell_verbs[] = {
7117 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7119 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7120 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7121 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7122 { }
7123};
7124
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007125static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007126 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7127 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7128 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7129 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7130 { }
7131};
7132
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007133static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007134 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7135 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7136 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7137 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7138 { }
7139};
7140
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007141static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7142 { 2, alc888_3st_hp_2ch_init },
7143 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007144};
7145
Kailang Yang272a5272007-05-14 11:00:38 +02007146/* toggle front-jack and RCA according to the hp-jack state */
7147static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7148{
7149 unsigned int present;
7150
7151 present = snd_hda_codec_read(codec, 0x1b, 0,
7152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007153 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7154 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7155 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7156 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007157}
7158
7159/* toggle RCA according to the front-jack state */
7160static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7161{
7162 unsigned int present;
7163
7164 present = snd_hda_codec_read(codec, 0x14, 0,
7165 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007166 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7167 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007168}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007169
Kailang Yang272a5272007-05-14 11:00:38 +02007170static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7171 unsigned int res)
7172{
7173 if ((res >> 26) == ALC880_HP_EVENT)
7174 alc888_lenovo_ms7195_front_automute(codec);
7175 if ((res >> 26) == ALC880_FRONT_EVENT)
7176 alc888_lenovo_ms7195_rca_automute(codec);
7177}
7178
7179static struct hda_verb alc883_medion_md2_verbs[] = {
7180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7182
7183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7184
7185 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7186 { } /* end */
7187};
7188
7189/* toggle speaker-output according to the hp-jack state */
7190static void alc883_medion_md2_automute(struct hda_codec *codec)
7191{
7192 unsigned int present;
7193
7194 present = snd_hda_codec_read(codec, 0x14, 0,
7195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007196 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7197 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007198}
7199
7200static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7201 unsigned int res)
7202{
7203 if ((res >> 26) == ALC880_HP_EVENT)
7204 alc883_medion_md2_automute(codec);
7205}
7206
Kailang Yangccc656c2006-10-17 12:32:26 +02007207/* toggle speaker-output according to the hp-jack state */
7208static void alc883_tagra_automute(struct hda_codec *codec)
7209{
7210 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007211 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007212
7213 present = snd_hda_codec_read(codec, 0x14, 0,
7214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007215 bits = present ? HDA_AMP_MUTE : 0;
7216 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7217 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007218 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7219 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007220}
7221
7222static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7223{
7224 if ((res >> 26) == ALC880_HP_EVENT)
7225 alc883_tagra_automute(codec);
7226}
7227
Kailang Yang189609a2007-08-20 11:31:23 +02007228static void alc883_haier_w66_automute(struct hda_codec *codec)
7229{
7230 unsigned int present;
7231 unsigned char bits;
7232
7233 present = snd_hda_codec_read(codec, 0x1b, 0,
7234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7235 bits = present ? 0x80 : 0;
7236 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7237 0x80, bits);
7238}
7239
7240static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7241 unsigned int res)
7242{
7243 if ((res >> 26) == ALC880_HP_EVENT)
7244 alc883_haier_w66_automute(codec);
7245}
7246
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007247static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7248{
7249 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007250 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007251
7252 present = snd_hda_codec_read(codec, 0x14, 0,
7253 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007254 bits = present ? HDA_AMP_MUTE : 0;
7255 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7256 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007257}
7258
7259static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7260{
7261 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007262 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007263
7264 present = snd_hda_codec_read(codec, 0x1b, 0,
7265 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007266 bits = present ? HDA_AMP_MUTE : 0;
7267 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7268 HDA_AMP_MUTE, bits);
7269 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7270 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007271}
7272
7273static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7274 unsigned int res)
7275{
7276 if ((res >> 26) == ALC880_HP_EVENT)
7277 alc883_lenovo_101e_all_automute(codec);
7278 if ((res >> 26) == ALC880_FRONT_EVENT)
7279 alc883_lenovo_101e_ispeaker_automute(codec);
7280}
7281
Takashi Iwai676a9b52007-08-16 15:23:35 +02007282/* toggle speaker-output according to the hp-jack state */
7283static void alc883_acer_aspire_automute(struct hda_codec *codec)
7284{
7285 unsigned int present;
7286
7287 present = snd_hda_codec_read(codec, 0x14, 0,
7288 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7289 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7290 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7291 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7292 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7293}
7294
7295static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7296 unsigned int res)
7297{
7298 if ((res >> 26) == ALC880_HP_EVENT)
7299 alc883_acer_aspire_automute(codec);
7300}
7301
Kailang Yangd1a991a2007-08-15 16:21:59 +02007302static struct hda_verb alc883_acer_eapd_verbs[] = {
7303 /* HP Pin: output 0 (0x0c) */
7304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7306 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007311 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7312 /* eanable EAPD on medion laptop */
7313 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7314 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007315 /* enable unsolicited event */
7316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007317 { }
7318};
7319
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007320static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7321{
7322 unsigned int present;
7323
7324 present = snd_hda_codec_read(codec, 0x1b, 0,
7325 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7326 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7327 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7328 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7329 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7330 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7331 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7332 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7333 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7334}
7335
7336static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7337 unsigned int res)
7338{
7339 switch (res >> 26) {
7340 case ALC880_HP_EVENT:
7341 printk("hp_event\n");
7342 alc888_6st_dell_front_automute(codec);
7343 break;
7344 }
7345}
7346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007347/*
7348 * generic initialization of ADC, input mixers and output mixers
7349 */
7350static struct hda_verb alc883_auto_init_verbs[] = {
7351 /*
7352 * Unmute ADC0-2 and set the default input to mic-in
7353 */
7354 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7356 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7358
Takashi Iwaicb53c622007-08-10 17:21:45 +02007359 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007360 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007361 * Note: PASD motherboards uses the Line In 2 as the input for
7362 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007363 */
7364 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007370
7371 /*
7372 * Set up output mixers (0x0c - 0x0f)
7373 */
7374 /* set vol=0 to output mixers */
7375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379 /* set up input amps for analog loopback */
7380 /* Amp Indices: DAC = 0, mixer = 1 */
7381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7389 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7390 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7391
7392 /* FIXME: use matrix-type input source selection */
7393 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7394 /* Input mixer1 */
7395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007398 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7400 /* Input mixer2 */
7401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007404 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007406
7407 { }
7408};
7409
7410/* capture mixer elements */
7411static struct snd_kcontrol_new alc883_capture_mixer[] = {
7412 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7413 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7414 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7415 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7416 {
7417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7418 /* The multiple "Capture Source" controls confuse alsamixer
7419 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007420 */
7421 /* .name = "Capture Source", */
7422 .name = "Input Source",
7423 .count = 2,
7424 .info = alc882_mux_enum_info,
7425 .get = alc882_mux_enum_get,
7426 .put = alc882_mux_enum_put,
7427 },
7428 { } /* end */
7429};
7430
Takashi Iwaicb53c622007-08-10 17:21:45 +02007431#ifdef CONFIG_SND_HDA_POWER_SAVE
7432#define alc883_loopbacks alc880_loopbacks
7433#endif
7434
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007435/* pcm configuration: identiacal with ALC880 */
7436#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7437#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007438#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007439#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7440#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7441
7442/*
7443 * configuration and preset
7444 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007445static const char *alc883_models[ALC883_MODEL_LAST] = {
7446 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7447 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7448 [ALC883_3ST_6ch] = "3stack-6ch",
7449 [ALC883_6ST_DIG] = "6stack-dig",
7450 [ALC883_TARGA_DIG] = "targa-dig",
7451 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007452 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007453 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007454 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007455 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007456 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007457 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007458 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7459 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007460 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007461 [ALC888_6ST_HP] = "6stack-hp",
7462 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007463 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007464 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007465 [ALC883_AUTO] = "auto",
7466};
7467
7468static struct snd_pci_quirk alc883_cfg_tbl[] = {
7469 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007470 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7471 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7472 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7473 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007474 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007475 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007476 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7477 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7478 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7479 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007480 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007481 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7482 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7483 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007484 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007485 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7486 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7487 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7488 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7489 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7490 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7491 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7492 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7493 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7494 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7495 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7496 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7497 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007498 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7499 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007500 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007501 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007502 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007503 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007504 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7505 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007506 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007507 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007508 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007509 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007510 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7511 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007512 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007513 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007514 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007515 {}
7516};
7517
7518static struct alc_config_preset alc883_presets[] = {
7519 [ALC883_3ST_2ch_DIG] = {
7520 .mixers = { alc883_3ST_2ch_mixer },
7521 .init_verbs = { alc883_init_verbs },
7522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7523 .dac_nids = alc883_dac_nids,
7524 .dig_out_nid = ALC883_DIGOUT_NID,
7525 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7526 .adc_nids = alc883_adc_nids,
7527 .dig_in_nid = ALC883_DIGIN_NID,
7528 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7529 .channel_mode = alc883_3ST_2ch_modes,
7530 .input_mux = &alc883_capture_source,
7531 },
7532 [ALC883_3ST_6ch_DIG] = {
7533 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7534 .init_verbs = { alc883_init_verbs },
7535 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7536 .dac_nids = alc883_dac_nids,
7537 .dig_out_nid = ALC883_DIGOUT_NID,
7538 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7539 .adc_nids = alc883_adc_nids,
7540 .dig_in_nid = ALC883_DIGIN_NID,
7541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7542 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007543 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007544 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007545 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007546 [ALC883_3ST_6ch] = {
7547 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7548 .init_verbs = { alc883_init_verbs },
7549 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7550 .dac_nids = alc883_dac_nids,
7551 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7552 .adc_nids = alc883_adc_nids,
7553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7554 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007555 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007556 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007557 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007558 [ALC883_6ST_DIG] = {
7559 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7560 .init_verbs = { alc883_init_verbs },
7561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7562 .dac_nids = alc883_dac_nids,
7563 .dig_out_nid = ALC883_DIGOUT_NID,
7564 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7565 .adc_nids = alc883_adc_nids,
7566 .dig_in_nid = ALC883_DIGIN_NID,
7567 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7568 .channel_mode = alc883_sixstack_modes,
7569 .input_mux = &alc883_capture_source,
7570 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007571 [ALC883_TARGA_DIG] = {
7572 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7573 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7575 .dac_nids = alc883_dac_nids,
7576 .dig_out_nid = ALC883_DIGOUT_NID,
7577 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7578 .adc_nids = alc883_adc_nids,
7579 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7580 .channel_mode = alc883_3ST_6ch_modes,
7581 .need_dac_fix = 1,
7582 .input_mux = &alc883_capture_source,
7583 .unsol_event = alc883_tagra_unsol_event,
7584 .init_hook = alc883_tagra_automute,
7585 },
7586 [ALC883_TARGA_2ch_DIG] = {
7587 .mixers = { alc883_tagra_2ch_mixer},
7588 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7590 .dac_nids = alc883_dac_nids,
7591 .dig_out_nid = ALC883_DIGOUT_NID,
7592 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7593 .adc_nids = alc883_adc_nids,
7594 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7595 .channel_mode = alc883_3ST_2ch_modes,
7596 .input_mux = &alc883_capture_source,
7597 .unsol_event = alc883_tagra_unsol_event,
7598 .init_hook = alc883_tagra_automute,
7599 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007600 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007601 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007602 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7603 * and the headphone jack. Turn this on and rely on the
7604 * standard mute methods whenever the user wants to turn
7605 * these outputs off.
7606 */
7607 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7608 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7609 .dac_nids = alc883_dac_nids,
7610 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7611 .adc_nids = alc883_adc_nids,
7612 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7613 .channel_mode = alc883_3ST_2ch_modes,
7614 .input_mux = &alc883_capture_source,
7615 },
Tobin Davis2880a862007-08-07 11:50:26 +02007616 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007617 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007618 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7620 .dac_nids = alc883_dac_nids,
7621 .dig_out_nid = ALC883_DIGOUT_NID,
7622 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7623 .adc_nids = alc883_adc_nids,
7624 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7625 .channel_mode = alc883_3ST_2ch_modes,
7626 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007627 .unsol_event = alc883_acer_aspire_unsol_event,
7628 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007629 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007630 [ALC883_MEDION] = {
7631 .mixers = { alc883_fivestack_mixer,
7632 alc883_chmode_mixer },
7633 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007634 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7636 .dac_nids = alc883_dac_nids,
7637 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7638 .adc_nids = alc883_adc_nids,
7639 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7640 .channel_mode = alc883_sixstack_modes,
7641 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007642 },
Kailang Yang272a5272007-05-14 11:00:38 +02007643 [ALC883_MEDION_MD2] = {
7644 .mixers = { alc883_medion_md2_mixer},
7645 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7646 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7647 .dac_nids = alc883_dac_nids,
7648 .dig_out_nid = ALC883_DIGOUT_NID,
7649 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7650 .adc_nids = alc883_adc_nids,
7651 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7652 .channel_mode = alc883_3ST_2ch_modes,
7653 .input_mux = &alc883_capture_source,
7654 .unsol_event = alc883_medion_md2_unsol_event,
7655 .init_hook = alc883_medion_md2_automute,
7656 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007657 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007658 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007659 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7660 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7661 .dac_nids = alc883_dac_nids,
7662 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7663 .adc_nids = alc883_adc_nids,
7664 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7665 .channel_mode = alc883_3ST_2ch_modes,
7666 .input_mux = &alc883_capture_source,
7667 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007668 [ALC883_LENOVO_101E_2ch] = {
7669 .mixers = { alc883_lenovo_101e_2ch_mixer},
7670 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7671 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7672 .dac_nids = alc883_dac_nids,
7673 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7674 .adc_nids = alc883_adc_nids,
7675 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7676 .channel_mode = alc883_3ST_2ch_modes,
7677 .input_mux = &alc883_lenovo_101e_capture_source,
7678 .unsol_event = alc883_lenovo_101e_unsol_event,
7679 .init_hook = alc883_lenovo_101e_all_automute,
7680 },
Kailang Yang272a5272007-05-14 11:00:38 +02007681 [ALC883_LENOVO_NB0763] = {
7682 .mixers = { alc883_lenovo_nb0763_mixer },
7683 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7684 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7685 .dac_nids = alc883_dac_nids,
7686 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7687 .adc_nids = alc883_adc_nids,
7688 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7689 .channel_mode = alc883_3ST_2ch_modes,
7690 .need_dac_fix = 1,
7691 .input_mux = &alc883_lenovo_nb0763_capture_source,
7692 .unsol_event = alc883_medion_md2_unsol_event,
7693 .init_hook = alc883_medion_md2_automute,
7694 },
7695 [ALC888_LENOVO_MS7195_DIG] = {
7696 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7697 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7698 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7699 .dac_nids = alc883_dac_nids,
7700 .dig_out_nid = ALC883_DIGOUT_NID,
7701 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7702 .adc_nids = alc883_adc_nids,
7703 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7704 .channel_mode = alc883_3ST_6ch_modes,
7705 .need_dac_fix = 1,
7706 .input_mux = &alc883_capture_source,
7707 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7708 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007709 },
7710 [ALC883_HAIER_W66] = {
7711 .mixers = { alc883_tagra_2ch_mixer},
7712 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7714 .dac_nids = alc883_dac_nids,
7715 .dig_out_nid = ALC883_DIGOUT_NID,
7716 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7717 .adc_nids = alc883_adc_nids,
7718 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7719 .channel_mode = alc883_3ST_2ch_modes,
7720 .input_mux = &alc883_capture_source,
7721 .unsol_event = alc883_haier_w66_unsol_event,
7722 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007723 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007724 [ALC888_6ST_HP] = {
7725 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7726 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007727 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7728 .dac_nids = alc883_dac_nids,
7729 .dig_out_nid = ALC883_DIGOUT_NID,
7730 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7731 .adc_nids = alc883_adc_nids,
7732 .dig_in_nid = ALC883_DIGIN_NID,
7733 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7734 .channel_mode = alc883_sixstack_modes,
7735 .input_mux = &alc883_capture_source,
7736 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007737 [ALC888_3ST_HP] = {
7738 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7739 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007740 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7741 .dac_nids = alc883_dac_nids,
7742 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7743 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007744 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7745 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007746 .need_dac_fix = 1,
7747 .input_mux = &alc883_capture_source,
7748 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007749 [ALC888_6ST_DELL] = {
7750 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7751 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7752 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7753 .dac_nids = alc883_dac_nids,
7754 .dig_out_nid = ALC883_DIGOUT_NID,
7755 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7756 .adc_nids = alc883_adc_nids,
7757 .dig_in_nid = ALC883_DIGIN_NID,
7758 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7759 .channel_mode = alc883_sixstack_modes,
7760 .input_mux = &alc883_capture_source,
7761 .unsol_event = alc888_6st_dell_unsol_event,
7762 .init_hook = alc888_6st_dell_front_automute,
7763 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007764 [ALC883_MITAC] = {
7765 .mixers = { alc883_mitac_mixer },
7766 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7768 .dac_nids = alc883_dac_nids,
7769 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7770 .adc_nids = alc883_adc_nids,
7771 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7772 .channel_mode = alc883_3ST_2ch_modes,
7773 .input_mux = &alc883_capture_source,
7774 .unsol_event = alc883_mitac_unsol_event,
7775 .init_hook = alc883_mitac_automute,
7776 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007777};
7778
7779
7780/*
7781 * BIOS auto configuration
7782 */
7783static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7784 hda_nid_t nid, int pin_type,
7785 int dac_idx)
7786{
7787 /* set as output */
7788 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 int idx;
7790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007791 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7792 idx = 4;
7793 else
7794 idx = spec->multiout.dac_nids[dac_idx] - 2;
7795
7796 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7797 pin_type);
7798 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7799 AMP_OUT_UNMUTE);
7800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7801
7802}
7803
7804static void alc883_auto_init_multi_out(struct hda_codec *codec)
7805{
7806 struct alc_spec *spec = codec->spec;
7807 int i;
7808
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007809 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007810 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007811 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007812 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007813 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007814 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007815 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007816 }
7817}
7818
7819static void alc883_auto_init_hp_out(struct hda_codec *codec)
7820{
7821 struct alc_spec *spec = codec->spec;
7822 hda_nid_t pin;
7823
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007824 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007825 if (pin) /* connect to front */
7826 /* use dac 0 */
7827 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7828}
7829
7830#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7831#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7832
7833static void alc883_auto_init_analog_input(struct hda_codec *codec)
7834{
7835 struct alc_spec *spec = codec->spec;
7836 int i;
7837
7838 for (i = 0; i < AUTO_PIN_LAST; i++) {
7839 hda_nid_t nid = spec->autocfg.input_pins[i];
7840 if (alc883_is_input_pin(nid)) {
7841 snd_hda_codec_write(codec, nid, 0,
7842 AC_VERB_SET_PIN_WIDGET_CONTROL,
7843 (i <= AUTO_PIN_FRONT_MIC ?
7844 PIN_VREF80 : PIN_IN));
7845 if (nid != ALC883_PIN_CD_NID)
7846 snd_hda_codec_write(codec, nid, 0,
7847 AC_VERB_SET_AMP_GAIN_MUTE,
7848 AMP_OUT_MUTE);
7849 }
7850 }
7851}
7852
7853/* almost identical with ALC880 parser... */
7854static int alc883_parse_auto_config(struct hda_codec *codec)
7855{
7856 struct alc_spec *spec = codec->spec;
7857 int err = alc880_parse_auto_config(codec);
7858
7859 if (err < 0)
7860 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007861 else if (!err)
7862 return 0; /* no config found */
7863
7864 err = alc_auto_add_mic_boost(codec);
7865 if (err < 0)
7866 return err;
7867
7868 /* hack - override the init verbs */
7869 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007870 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7871 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007872
7873 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007874}
7875
7876/* additional initialization for auto-configuration model */
7877static void alc883_auto_init(struct hda_codec *codec)
7878{
7879 alc883_auto_init_multi_out(codec);
7880 alc883_auto_init_hp_out(codec);
7881 alc883_auto_init_analog_input(codec);
7882}
7883
7884static int patch_alc883(struct hda_codec *codec)
7885{
7886 struct alc_spec *spec;
7887 int err, board_config;
7888
7889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7890 if (spec == NULL)
7891 return -ENOMEM;
7892
7893 codec->spec = spec;
7894
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007895 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7896 alc883_models,
7897 alc883_cfg_tbl);
7898 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007899 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7900 "trying auto-probe from BIOS...\n");
7901 board_config = ALC883_AUTO;
7902 }
7903
7904 if (board_config == ALC883_AUTO) {
7905 /* automatic parse from the BIOS config */
7906 err = alc883_parse_auto_config(codec);
7907 if (err < 0) {
7908 alc_free(codec);
7909 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007910 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007911 printk(KERN_INFO
7912 "hda_codec: Cannot set up configuration "
7913 "from BIOS. Using base mode...\n");
7914 board_config = ALC883_3ST_2ch_DIG;
7915 }
7916 }
7917
7918 if (board_config != ALC883_AUTO)
7919 setup_preset(spec, &alc883_presets[board_config]);
7920
7921 spec->stream_name_analog = "ALC883 Analog";
7922 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7923 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007924 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007925
7926 spec->stream_name_digital = "ALC883 Digital";
7927 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7928 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7929
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007930 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007931 spec->adc_nids = alc883_adc_nids;
7932 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7933 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007934
Takashi Iwai2134ea42008-01-10 16:53:55 +01007935 spec->vmaster_nid = 0x0c;
7936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007937 codec->patch_ops = alc_patch_ops;
7938 if (board_config == ALC883_AUTO)
7939 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007940#ifdef CONFIG_SND_HDA_POWER_SAVE
7941 if (!spec->loopback.amplist)
7942 spec->loopback.amplist = alc883_loopbacks;
7943#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007944
7945 return 0;
7946}
7947
7948/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007949 * ALC262 support
7950 */
7951
7952#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7953#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7954
7955#define alc262_dac_nids alc260_dac_nids
7956#define alc262_adc_nids alc882_adc_nids
7957#define alc262_adc_nids_alt alc882_adc_nids_alt
7958
7959#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007960#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007961
7962static struct snd_kcontrol_new alc262_base_mixer[] = {
7963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7964 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007972 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7973 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007974 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007975 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7976 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007981 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007982};
7983
Kailang Yangccc656c2006-10-17 12:32:26 +02007984static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7986 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7987 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7988 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007997 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7998 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7999 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8001 { } /* end */
8002};
8003
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008004static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8010
8011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8015 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8022 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8023 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8024 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8025 { } /* end */
8026};
8027
Kailang Yangcd7509a2007-01-26 18:33:17 +01008028static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8030 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8036 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008037 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008038 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8039 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8043 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8044 { } /* end */
8045};
8046
8047static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8048 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008050 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008051 { } /* end */
8052};
8053
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008054static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8055 .ops = &snd_hda_bind_vol,
8056 .values = {
8057 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8058 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8059 0
8060 },
8061};
8062
8063static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8064 .ops = &snd_hda_bind_sw,
8065 .values = {
8066 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8067 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8068 0
8069 },
8070};
8071
8072/* mute/unmute internal speaker according to the hp jack and mute state */
8073static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8074{
8075 struct alc_spec *spec = codec->spec;
8076 unsigned int mute;
8077
8078 if (force || !spec->sense_updated) {
8079 unsigned int present;
8080 present = snd_hda_codec_read(codec, 0x15, 0,
8081 AC_VERB_GET_PIN_SENSE, 0);
8082 spec->jack_present = (present & 0x80000000) != 0;
8083 spec->sense_updated = 1;
8084 }
8085 if (spec->jack_present)
8086 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8087 else /* unmute internal speaker if necessary */
8088 mute = (0x7000 | ((0)<<8));
8089 snd_hda_codec_write(codec, 0x0c, 0,
8090 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8091}
8092
8093static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8094 unsigned int res)
8095{
8096 if ((res >> 26) != ALC880_HP_EVENT)
8097 return;
8098 alc262_hp_t5735_automute(codec, 1);
8099}
8100
8101static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8102{
8103 alc262_hp_t5735_automute(codec, 1);
8104}
8105
8106static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8107 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8108 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8109 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8110 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008111 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008113 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8118 { } /* end */
8119};
8120
8121static struct hda_verb alc262_hp_t5735_verbs[] = {
8122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8124
8125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8126 { }
8127};
8128
Kailang Yang8c427222008-01-10 13:03:59 +01008129static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8130 .ops = &snd_hda_bind_vol,
8131 .values = {
8132 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8133 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8134 0
8135 },
8136};
8137
8138static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8139 .ops = &snd_hda_bind_sw,
8140 .values = {
8141 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8142 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8143 0
8144 },
8145};
8146
8147static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8148 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8149 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8150 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8151 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008152 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008154 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8155 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8156 { } /* end */
8157};
8158
8159static struct hda_verb alc262_hp_rp5700_verbs[] = {
8160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8161 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8164 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8165 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8168 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8170 {}
8171};
8172
8173static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8174 .num_items = 1,
8175 .items = {
8176 { "Line", 0x1 },
8177 },
8178};
8179
Takashi Iwai0724ea22007-08-23 00:31:43 +02008180/* bind hp and internal speaker mute (with plug check) */
8181static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8182 struct snd_ctl_elem_value *ucontrol)
8183{
8184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8185 long *valp = ucontrol->value.integer.value;
8186 int change;
8187
8188 /* change hp mute */
8189 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8190 HDA_AMP_MUTE,
8191 valp[0] ? 0 : HDA_AMP_MUTE);
8192 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8193 HDA_AMP_MUTE,
8194 valp[1] ? 0 : HDA_AMP_MUTE);
8195 if (change) {
8196 /* change speaker according to HP jack state */
8197 struct alc_spec *spec = codec->spec;
8198 unsigned int mute;
8199 if (spec->jack_present)
8200 mute = HDA_AMP_MUTE;
8201 else
8202 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8203 HDA_OUTPUT, 0);
8204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8205 HDA_AMP_MUTE, mute);
8206 }
8207 return change;
8208}
Takashi Iwai5b319542007-07-26 11:49:22 +02008209
Kailang Yang272a5272007-05-14 11:00:38 +02008210static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008211 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8212 {
8213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8214 .name = "Master Playback Switch",
8215 .info = snd_hda_mixer_amp_switch_info,
8216 .get = snd_hda_mixer_amp_switch_get,
8217 .put = alc262_sony_master_sw_put,
8218 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8219 },
Kailang Yang272a5272007-05-14 11:00:38 +02008220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8223 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8224 { } /* end */
8225};
8226
Kailang Yang83c34212007-07-05 11:43:05 +02008227static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8229 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8233 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8234 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8235 { } /* end */
8236};
Kailang Yang272a5272007-05-14 11:00:38 +02008237
Kailang Yangdf694da2005-12-05 19:42:22 +01008238#define alc262_capture_mixer alc882_capture_mixer
8239#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8240
8241/*
8242 * generic initialization of ADC, input mixers and output mixers
8243 */
8244static struct hda_verb alc262_init_verbs[] = {
8245 /*
8246 * Unmute ADC0-2 and set the default input to mic-in
8247 */
8248 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8250 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254
Takashi Iwaicb53c622007-08-10 17:21:45 +02008255 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008256 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008257 * Note: PASD motherboards uses the Line In 2 as the input for
8258 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008259 */
8260 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008266
8267 /*
8268 * Set up output mixers (0x0c - 0x0e)
8269 */
8270 /* set vol=0 to output mixers */
8271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8272 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8274 /* set up input amps for analog loopback */
8275 /* Amp Indices: DAC = 0, mixer = 1 */
8276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8282
8283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8285 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8288 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8289
8290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8295
8296 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8298
8299 /* FIXME: use matrix-type input source selection */
8300 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8301 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8306 /* Input mixer2 */
8307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8311 /* Input mixer3 */
8312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008316
8317 { }
8318};
8319
Kailang Yangccc656c2006-10-17 12:32:26 +02008320static struct hda_verb alc262_hippo_unsol_verbs[] = {
8321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8323 {}
8324};
8325
8326static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8328 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8329 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8330
8331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8332 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8333 {}
8334};
8335
Kailang Yang272a5272007-05-14 11:00:38 +02008336static struct hda_verb alc262_sony_unsol_verbs[] = {
8337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8338 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8340
8341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8343};
8344
Kailang Yangccc656c2006-10-17 12:32:26 +02008345/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008346static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008347{
8348 struct alc_spec *spec = codec->spec;
8349 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008350 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008351
Takashi Iwai5b319542007-07-26 11:49:22 +02008352 /* need to execute and sync at first */
8353 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8354 present = snd_hda_codec_read(codec, 0x15, 0,
8355 AC_VERB_GET_PIN_SENSE, 0);
8356 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008357 if (spec->jack_present) {
8358 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008359 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8360 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008361 } else {
8362 /* unmute internal speaker if necessary */
8363 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008364 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8365 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008366 }
8367}
8368
8369/* unsolicited event for HP jack sensing */
8370static void alc262_hippo_unsol_event(struct hda_codec *codec,
8371 unsigned int res)
8372{
8373 if ((res >> 26) != ALC880_HP_EVENT)
8374 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008375 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008376}
8377
Takashi Iwai5b319542007-07-26 11:49:22 +02008378static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008379{
Kailang Yangccc656c2006-10-17 12:32:26 +02008380 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008381 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008382
Takashi Iwai5b319542007-07-26 11:49:22 +02008383 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8384 present = snd_hda_codec_read(codec, 0x1b, 0,
8385 AC_VERB_GET_PIN_SENSE, 0);
8386 present = (present & 0x80000000) != 0;
8387 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008388 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008389 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8390 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008391 } else {
8392 /* unmute internal speaker if necessary */
8393 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008394 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8395 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008396 }
8397}
8398
8399/* unsolicited event for HP jack sensing */
8400static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8401 unsigned int res)
8402{
8403 if ((res >> 26) != ALC880_HP_EVENT)
8404 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008405 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008406}
8407
Takashi Iwai834be882006-03-01 14:16:17 +01008408/*
8409 * fujitsu model
8410 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8411 */
8412
8413#define ALC_HP_EVENT 0x37
8414
8415static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8416 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8418 {}
8419};
8420
8421static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008422 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008423 .items = {
8424 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008425 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008426 { "CD", 0x4 },
8427 },
8428};
8429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008430static struct hda_input_mux alc262_HP_capture_source = {
8431 .num_items = 5,
8432 .items = {
8433 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008434 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008435 { "Line", 0x2 },
8436 { "CD", 0x4 },
8437 { "AUX IN", 0x6 },
8438 },
8439};
8440
zhejiangaccbe492007-08-31 12:36:05 +02008441static struct hda_input_mux alc262_HP_D7000_capture_source = {
8442 .num_items = 4,
8443 .items = {
8444 { "Mic", 0x0 },
8445 { "Front Mic", 0x2 },
8446 { "Line", 0x1 },
8447 { "CD", 0x4 },
8448 },
8449};
8450
Takashi Iwai834be882006-03-01 14:16:17 +01008451/* mute/unmute internal speaker according to the hp jack and mute state */
8452static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8453{
8454 struct alc_spec *spec = codec->spec;
8455 unsigned int mute;
8456
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008457 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008458 unsigned int present;
8459 /* need to execute and sync at first */
8460 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8461 present = snd_hda_codec_read(codec, 0x14, 0,
8462 AC_VERB_GET_PIN_SENSE, 0);
8463 spec->jack_present = (present & 0x80000000) != 0;
8464 spec->sense_updated = 1;
8465 }
8466 if (spec->jack_present) {
8467 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008468 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8469 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008470 } else {
8471 /* unmute internal speaker if necessary */
8472 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008473 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8474 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008475 }
8476}
8477
8478/* unsolicited event for HP jack sensing */
8479static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8480 unsigned int res)
8481{
8482 if ((res >> 26) != ALC_HP_EVENT)
8483 return;
8484 alc262_fujitsu_automute(codec, 1);
8485}
8486
8487/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008488static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8489 .ops = &snd_hda_bind_vol,
8490 .values = {
8491 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8492 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8493 0
8494 },
8495};
Takashi Iwai834be882006-03-01 14:16:17 +01008496
8497/* bind hp and internal speaker mute (with plug check) */
8498static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8499 struct snd_ctl_elem_value *ucontrol)
8500{
8501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8502 long *valp = ucontrol->value.integer.value;
8503 int change;
8504
8505 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008506 HDA_AMP_MUTE,
8507 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008508 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008509 HDA_AMP_MUTE,
8510 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008511 if (change)
8512 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008513 return change;
8514}
8515
8516static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008517 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008518 {
8519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8520 .name = "Master Playback Switch",
8521 .info = snd_hda_mixer_amp_switch_info,
8522 .get = snd_hda_mixer_amp_switch_get,
8523 .put = alc262_fujitsu_master_sw_put,
8524 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8525 },
8526 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8527 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8528 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008531 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8532 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8533 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008534 { } /* end */
8535};
8536
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008537/* additional init verbs for Benq laptops */
8538static struct hda_verb alc262_EAPD_verbs[] = {
8539 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8540 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8541 {}
8542};
8543
Kailang Yang83c34212007-07-05 11:43:05 +02008544static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8547
8548 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8549 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8550 {}
8551};
8552
Tobin Davisf651b502007-10-26 12:40:47 +02008553/* Samsung Q1 Ultra Vista model setup */
8554static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8555 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8556 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8560 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8561 { } /* end */
8562};
8563
8564static struct hda_verb alc262_ultra_verbs[] = {
8565 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8568 /* Mic is on Node 0x19 */
8569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8570 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8572 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8574 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8576 {}
8577};
8578
8579static struct hda_input_mux alc262_ultra_capture_source = {
8580 .num_items = 1,
8581 .items = {
8582 { "Mic", 0x1 },
8583 },
8584};
8585
8586/* mute/unmute internal speaker according to the hp jack and mute state */
8587static void alc262_ultra_automute(struct hda_codec *codec)
8588{
8589 struct alc_spec *spec = codec->spec;
8590 unsigned int mute;
8591 unsigned int present;
8592
8593 /* need to execute and sync at first */
8594 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8595 present = snd_hda_codec_read(codec, 0x15, 0,
8596 AC_VERB_GET_PIN_SENSE, 0);
8597 spec->jack_present = (present & 0x80000000) != 0;
8598 if (spec->jack_present) {
8599 /* mute internal speaker */
8600 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8601 HDA_AMP_MUTE, HDA_AMP_MUTE);
8602 } else {
8603 /* unmute internal speaker if necessary */
8604 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8605 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8606 HDA_AMP_MUTE, mute);
8607 }
8608}
8609
8610/* unsolicited event for HP jack sensing */
8611static void alc262_ultra_unsol_event(struct hda_codec *codec,
8612 unsigned int res)
8613{
8614 if ((res >> 26) != ALC880_HP_EVENT)
8615 return;
8616 alc262_ultra_automute(codec);
8617}
8618
Kailang Yangdf694da2005-12-05 19:42:22 +01008619/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008620static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8621 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008622{
8623 hda_nid_t nid;
8624 int err;
8625
8626 spec->multiout.num_dacs = 1; /* only use one dac */
8627 spec->multiout.dac_nids = spec->private_dac_nids;
8628 spec->multiout.dac_nids[0] = 2;
8629
8630 nid = cfg->line_out_pins[0];
8631 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008632 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8633 "Front Playback Volume",
8634 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008637 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8638 "Front Playback Switch",
8639 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8640 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008641 return err;
8642 }
8643
Takashi Iwai82bc9552006-03-21 11:24:42 +01008644 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008645 if (nid) {
8646 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008647 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8648 "Speaker Playback Volume",
8649 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8650 HDA_OUTPUT));
8651 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008652 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008653 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8654 "Speaker Playback Switch",
8655 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8656 HDA_OUTPUT));
8657 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008658 return err;
8659 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008660 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8661 "Speaker Playback Switch",
8662 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8663 HDA_OUTPUT));
8664 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008665 return err;
8666 }
8667 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008668 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008669 if (nid) {
8670 /* spec->multiout.hp_nid = 2; */
8671 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008672 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8673 "Headphone Playback Volume",
8674 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8675 HDA_OUTPUT));
8676 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008677 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008678 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8679 "Headphone Playback Switch",
8680 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8681 HDA_OUTPUT));
8682 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008683 return err;
8684 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008685 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8686 "Headphone Playback Switch",
8687 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8688 HDA_OUTPUT));
8689 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008690 return err;
8691 }
8692 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008693 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008694}
8695
8696/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008697#define alc262_auto_create_analog_input_ctls \
8698 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008699
8700/*
8701 * generic initialization of ADC, input mixers and output mixers
8702 */
8703static struct hda_verb alc262_volume_init_verbs[] = {
8704 /*
8705 * Unmute ADC0-2 and set the default input to mic-in
8706 */
8707 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8711 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8713
Takashi Iwaicb53c622007-08-10 17:21:45 +02008714 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008715 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008716 * Note: PASD motherboards uses the Line In 2 as the input for
8717 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008718 */
8719 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008725
8726 /*
8727 * Set up output mixers (0x0c - 0x0f)
8728 */
8729 /* set vol=0 to output mixers */
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8731 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733
8734 /* set up input amps for analog loopback */
8735 /* Amp Indices: DAC = 0, mixer = 1 */
8736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8742
8743 /* FIXME: use matrix-type input source selection */
8744 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8745 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8750 /* Input mixer2 */
8751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8755 /* Input mixer3 */
8756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8760
8761 { }
8762};
8763
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008764static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8765 /*
8766 * Unmute ADC0-2 and set the default input to mic-in
8767 */
8768 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8769 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8770 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8774
Takashi Iwaicb53c622007-08-10 17:21:45 +02008775 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008776 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008777 * Note: PASD motherboards uses the Line In 2 as the input for
8778 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008779 */
8780 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008788
8789 /*
8790 * Set up output mixers (0x0c - 0x0e)
8791 */
8792 /* set vol=0 to output mixers */
8793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8796
8797 /* set up input amps for analog loopback */
8798 /* Amp Indices: DAC = 0, mixer = 1 */
8799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8805
8806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8809
8810 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8812
8813 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8815
8816 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8817 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8820 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8821
8822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8824 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8825 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8826 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8827 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8828
8829
8830 /* FIXME: use matrix-type input source selection */
8831 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8832 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8833 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8837 /* Input mixer2 */
8838 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8842 /* Input mixer3 */
8843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8847
8848 { }
8849};
8850
Kailang Yangcd7509a2007-01-26 18:33:17 +01008851static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8852 /*
8853 * Unmute ADC0-2 and set the default input to mic-in
8854 */
8855 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8857 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8861
Takashi Iwaicb53c622007-08-10 17:21:45 +02008862 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008863 * mixer widget
8864 * Note: PASD motherboards uses the Line In 2 as the input for front
8865 * panel mic (mic 2)
8866 */
8867 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008876 /*
8877 * Set up output mixers (0x0c - 0x0e)
8878 */
8879 /* set vol=0 to output mixers */
8880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8881 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8882 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8883
8884 /* set up input amps for analog loopback */
8885 /* Amp Indices: DAC = 0, mixer = 1 */
8886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8892
8893
8894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8897 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8899 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8901
8902 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8904
8905 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8907
8908 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8912 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8913 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8914
8915 /* FIXME: use matrix-type input source selection */
8916 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8917 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8923 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8925 /* Input mixer2 */
8926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8931 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8933 /* Input mixer3 */
8934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8939 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8941
8942 { }
8943};
8944
Takashi Iwaicb53c622007-08-10 17:21:45 +02008945#ifdef CONFIG_SND_HDA_POWER_SAVE
8946#define alc262_loopbacks alc880_loopbacks
8947#endif
8948
Kailang Yangdf694da2005-12-05 19:42:22 +01008949/* pcm configuration: identiacal with ALC880 */
8950#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8951#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8952#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8953#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8954
8955/*
8956 * BIOS auto configuration
8957 */
8958static int alc262_parse_auto_config(struct hda_codec *codec)
8959{
8960 struct alc_spec *spec = codec->spec;
8961 int err;
8962 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8963
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008964 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8965 alc262_ignore);
8966 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008968 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008969 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008970 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8971 if (err < 0)
8972 return err;
8973 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8974 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008975 return err;
8976
8977 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8978
8979 if (spec->autocfg.dig_out_pin)
8980 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8981 if (spec->autocfg.dig_in_pin)
8982 spec->dig_in_nid = ALC262_DIGIN_NID;
8983
8984 if (spec->kctl_alloc)
8985 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8986
8987 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008988 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008989 spec->input_mux = &spec->private_imux;
8990
Takashi Iwai776e1842007-08-29 15:07:11 +02008991 err = alc_auto_add_mic_boost(codec);
8992 if (err < 0)
8993 return err;
8994
Kailang Yangdf694da2005-12-05 19:42:22 +01008995 return 1;
8996}
8997
8998#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8999#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9000#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9001
9002
9003/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009004static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009005{
Kailang Yangdf694da2005-12-05 19:42:22 +01009006 alc262_auto_init_multi_out(codec);
9007 alc262_auto_init_hp_out(codec);
9008 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009009}
9010
9011/*
9012 * configuration and preset
9013 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009014static const char *alc262_models[ALC262_MODEL_LAST] = {
9015 [ALC262_BASIC] = "basic",
9016 [ALC262_HIPPO] = "hippo",
9017 [ALC262_HIPPO_1] = "hippo_1",
9018 [ALC262_FUJITSU] = "fujitsu",
9019 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009020 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009021 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009022 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009023 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009024 [ALC262_BENQ_T31] = "benq-t31",
9025 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009026 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009027 [ALC262_AUTO] = "auto",
9028};
9029
9030static struct snd_pci_quirk alc262_cfg_tbl[] = {
9031 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9032 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009033 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009034 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9035 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009036 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009037 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009038 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009039 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009040 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009041 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009042 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009043 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009044 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009045 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009046 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009047 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009048 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9049 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9050 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009051 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9052 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009053 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009054 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009055 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009056 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9057 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9058 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009059 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009060 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009061 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009062 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009063 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009064 {}
9065};
9066
9067static struct alc_config_preset alc262_presets[] = {
9068 [ALC262_BASIC] = {
9069 .mixers = { alc262_base_mixer },
9070 .init_verbs = { alc262_init_verbs },
9071 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9072 .dac_nids = alc262_dac_nids,
9073 .hp_nid = 0x03,
9074 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9075 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009076 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009077 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009078 [ALC262_HIPPO] = {
9079 .mixers = { alc262_base_mixer },
9080 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9081 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9082 .dac_nids = alc262_dac_nids,
9083 .hp_nid = 0x03,
9084 .dig_out_nid = ALC262_DIGOUT_NID,
9085 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9086 .channel_mode = alc262_modes,
9087 .input_mux = &alc262_capture_source,
9088 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009089 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 },
9091 [ALC262_HIPPO_1] = {
9092 .mixers = { alc262_hippo1_mixer },
9093 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9094 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9095 .dac_nids = alc262_dac_nids,
9096 .hp_nid = 0x02,
9097 .dig_out_nid = ALC262_DIGOUT_NID,
9098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9099 .channel_mode = alc262_modes,
9100 .input_mux = &alc262_capture_source,
9101 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009102 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009103 },
Takashi Iwai834be882006-03-01 14:16:17 +01009104 [ALC262_FUJITSU] = {
9105 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009106 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9107 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009108 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9109 .dac_nids = alc262_dac_nids,
9110 .hp_nid = 0x03,
9111 .dig_out_nid = ALC262_DIGOUT_NID,
9112 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9113 .channel_mode = alc262_modes,
9114 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009115 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009116 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009117 [ALC262_HP_BPC] = {
9118 .mixers = { alc262_HP_BPC_mixer },
9119 .init_verbs = { alc262_HP_BPC_init_verbs },
9120 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9121 .dac_nids = alc262_dac_nids,
9122 .hp_nid = 0x03,
9123 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9124 .channel_mode = alc262_modes,
9125 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009126 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009127 [ALC262_HP_BPC_D7000_WF] = {
9128 .mixers = { alc262_HP_BPC_WildWest_mixer },
9129 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9130 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9131 .dac_nids = alc262_dac_nids,
9132 .hp_nid = 0x03,
9133 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9134 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009135 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009136 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009137 [ALC262_HP_BPC_D7000_WL] = {
9138 .mixers = { alc262_HP_BPC_WildWest_mixer,
9139 alc262_HP_BPC_WildWest_option_mixer },
9140 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9141 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9142 .dac_nids = alc262_dac_nids,
9143 .hp_nid = 0x03,
9144 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9145 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009146 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009147 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009148 [ALC262_HP_TC_T5735] = {
9149 .mixers = { alc262_hp_t5735_mixer },
9150 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9151 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9152 .dac_nids = alc262_dac_nids,
9153 .hp_nid = 0x03,
9154 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9155 .channel_mode = alc262_modes,
9156 .input_mux = &alc262_capture_source,
9157 .unsol_event = alc262_hp_t5735_unsol_event,
9158 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009159 },
9160 [ALC262_HP_RP5700] = {
9161 .mixers = { alc262_hp_rp5700_mixer },
9162 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9163 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9164 .dac_nids = alc262_dac_nids,
9165 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9166 .channel_mode = alc262_modes,
9167 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009168 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009169 [ALC262_BENQ_ED8] = {
9170 .mixers = { alc262_base_mixer },
9171 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9172 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9173 .dac_nids = alc262_dac_nids,
9174 .hp_nid = 0x03,
9175 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9176 .channel_mode = alc262_modes,
9177 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 },
Kailang Yang272a5272007-05-14 11:00:38 +02009179 [ALC262_SONY_ASSAMD] = {
9180 .mixers = { alc262_sony_mixer },
9181 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9182 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9183 .dac_nids = alc262_dac_nids,
9184 .hp_nid = 0x02,
9185 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9186 .channel_mode = alc262_modes,
9187 .input_mux = &alc262_capture_source,
9188 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009189 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009190 },
9191 [ALC262_BENQ_T31] = {
9192 .mixers = { alc262_benq_t31_mixer },
9193 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9194 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9195 .dac_nids = alc262_dac_nids,
9196 .hp_nid = 0x03,
9197 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9198 .channel_mode = alc262_modes,
9199 .input_mux = &alc262_capture_source,
9200 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009201 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009202 },
Tobin Davisf651b502007-10-26 12:40:47 +02009203 [ALC262_ULTRA] = {
9204 .mixers = { alc262_ultra_mixer },
9205 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9206 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9207 .dac_nids = alc262_dac_nids,
9208 .hp_nid = 0x03,
9209 .dig_out_nid = ALC262_DIGOUT_NID,
9210 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9211 .channel_mode = alc262_modes,
9212 .input_mux = &alc262_ultra_capture_source,
9213 .unsol_event = alc262_ultra_unsol_event,
9214 .init_hook = alc262_ultra_automute,
9215 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009216};
9217
9218static int patch_alc262(struct hda_codec *codec)
9219{
9220 struct alc_spec *spec;
9221 int board_config;
9222 int err;
9223
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009224 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009225 if (spec == NULL)
9226 return -ENOMEM;
9227
9228 codec->spec = spec;
9229#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009230 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9231 * under-run
9232 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009233 {
9234 int tmp;
9235 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9236 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9237 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9238 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9239 }
9240#endif
9241
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009242 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9243 alc262_models,
9244 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009245
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009246 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009247 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9248 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009249 board_config = ALC262_AUTO;
9250 }
9251
9252 if (board_config == ALC262_AUTO) {
9253 /* automatic parse from the BIOS config */
9254 err = alc262_parse_auto_config(codec);
9255 if (err < 0) {
9256 alc_free(codec);
9257 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009258 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 printk(KERN_INFO
9260 "hda_codec: Cannot set up configuration "
9261 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009262 board_config = ALC262_BASIC;
9263 }
9264 }
9265
9266 if (board_config != ALC262_AUTO)
9267 setup_preset(spec, &alc262_presets[board_config]);
9268
9269 spec->stream_name_analog = "ALC262 Analog";
9270 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9271 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9272
9273 spec->stream_name_digital = "ALC262 Digital";
9274 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9275 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009277 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009278 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009279 unsigned int wcap = get_wcaps(codec, 0x07);
9280
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009281 /* get type */
9282 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009283 if (wcap != AC_WID_AUD_IN) {
9284 spec->adc_nids = alc262_adc_nids_alt;
9285 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009286 spec->mixers[spec->num_mixers] =
9287 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009288 spec->num_mixers++;
9289 } else {
9290 spec->adc_nids = alc262_adc_nids;
9291 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9292 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9293 spec->num_mixers++;
9294 }
9295 }
9296
Takashi Iwai2134ea42008-01-10 16:53:55 +01009297 spec->vmaster_nid = 0x0c;
9298
Kailang Yangdf694da2005-12-05 19:42:22 +01009299 codec->patch_ops = alc_patch_ops;
9300 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009301 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009302#ifdef CONFIG_SND_HDA_POWER_SAVE
9303 if (!spec->loopback.amplist)
9304 spec->loopback.amplist = alc262_loopbacks;
9305#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009306
Kailang Yangdf694da2005-12-05 19:42:22 +01009307 return 0;
9308}
9309
Kailang Yangdf694da2005-12-05 19:42:22 +01009310/*
Kailang Yanga361d842007-06-05 12:30:55 +02009311 * ALC268 channel source setting (2 channel)
9312 */
9313#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9314#define alc268_modes alc260_modes
9315
9316static hda_nid_t alc268_dac_nids[2] = {
9317 /* front, hp */
9318 0x02, 0x03
9319};
9320
9321static hda_nid_t alc268_adc_nids[2] = {
9322 /* ADC0-1 */
9323 0x08, 0x07
9324};
9325
9326static hda_nid_t alc268_adc_nids_alt[1] = {
9327 /* ADC0 */
9328 0x08
9329};
9330
9331static struct snd_kcontrol_new alc268_base_mixer[] = {
9332 /* output mixer control */
9333 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9334 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9335 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9338 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9339 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009340 { }
9341};
9342
Kailang Yangd1a991a2007-08-15 16:21:59 +02009343static struct hda_verb alc268_eapd_verbs[] = {
9344 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9345 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9346 { }
9347};
9348
Takashi Iwaid2738092007-08-16 14:59:45 +02009349/* Toshiba specific */
9350#define alc268_toshiba_automute alc262_hippo_automute
9351
9352static struct hda_verb alc268_toshiba_verbs[] = {
9353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9354 { } /* end */
9355};
9356
9357/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009358/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009359static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9360 .ops = &snd_hda_bind_vol,
9361 .values = {
9362 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9363 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9364 0
9365 },
9366};
9367
Takashi Iwai889c4392007-08-23 18:56:52 +02009368/* mute/unmute internal speaker according to the hp jack and mute state */
9369static void alc268_acer_automute(struct hda_codec *codec, int force)
9370{
9371 struct alc_spec *spec = codec->spec;
9372 unsigned int mute;
9373
9374 if (force || !spec->sense_updated) {
9375 unsigned int present;
9376 present = snd_hda_codec_read(codec, 0x14, 0,
9377 AC_VERB_GET_PIN_SENSE, 0);
9378 spec->jack_present = (present & 0x80000000) != 0;
9379 spec->sense_updated = 1;
9380 }
9381 if (spec->jack_present)
9382 mute = HDA_AMP_MUTE; /* mute internal speaker */
9383 else /* unmute internal speaker if necessary */
9384 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9385 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9386 HDA_AMP_MUTE, mute);
9387}
9388
9389
9390/* bind hp and internal speaker mute (with plug check) */
9391static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9392 struct snd_ctl_elem_value *ucontrol)
9393{
9394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9395 long *valp = ucontrol->value.integer.value;
9396 int change;
9397
9398 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9399 HDA_AMP_MUTE,
9400 valp[0] ? 0 : HDA_AMP_MUTE);
9401 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9402 HDA_AMP_MUTE,
9403 valp[1] ? 0 : HDA_AMP_MUTE);
9404 if (change)
9405 alc268_acer_automute(codec, 0);
9406 return change;
9407}
Takashi Iwaid2738092007-08-16 14:59:45 +02009408
9409static struct snd_kcontrol_new alc268_acer_mixer[] = {
9410 /* output mixer control */
9411 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9412 {
9413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9414 .name = "Master Playback Switch",
9415 .info = snd_hda_mixer_amp_switch_info,
9416 .get = snd_hda_mixer_amp_switch_get,
9417 .put = alc268_acer_master_sw_put,
9418 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9419 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9421 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9422 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009423 { }
9424};
9425
9426static struct hda_verb alc268_acer_verbs[] = {
9427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9429
9430 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9431 { }
9432};
9433
9434/* unsolicited event for HP jack sensing */
9435static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9436 unsigned int res)
9437{
Takashi Iwai889c4392007-08-23 18:56:52 +02009438 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009439 return;
9440 alc268_toshiba_automute(codec);
9441}
9442
9443static void alc268_acer_unsol_event(struct hda_codec *codec,
9444 unsigned int res)
9445{
Takashi Iwai889c4392007-08-23 18:56:52 +02009446 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009447 return;
9448 alc268_acer_automute(codec, 1);
9449}
9450
Takashi Iwai889c4392007-08-23 18:56:52 +02009451static void alc268_acer_init_hook(struct hda_codec *codec)
9452{
9453 alc268_acer_automute(codec, 1);
9454}
9455
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009456static struct snd_kcontrol_new alc268_dell_mixer[] = {
9457 /* output mixer control */
9458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9459 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9460 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9463 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9464 { }
9465};
9466
9467static struct hda_verb alc268_dell_verbs[] = {
9468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9470 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9471 { }
9472};
9473
9474/* mute/unmute internal speaker according to the hp jack and mute state */
9475static void alc268_dell_automute(struct hda_codec *codec)
9476{
9477 unsigned int present;
9478 unsigned int mute;
9479
9480 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9481 if (present & 0x80000000)
9482 mute = HDA_AMP_MUTE;
9483 else
9484 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9485 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9486 HDA_AMP_MUTE, mute);
9487}
9488
9489static void alc268_dell_unsol_event(struct hda_codec *codec,
9490 unsigned int res)
9491{
9492 if ((res >> 26) != ALC880_HP_EVENT)
9493 return;
9494 alc268_dell_automute(codec);
9495}
9496
9497#define alc268_dell_init_hook alc268_dell_automute
9498
Kailang Yanga361d842007-06-05 12:30:55 +02009499/*
9500 * generic initialization of ADC, input mixers and output mixers
9501 */
9502static struct hda_verb alc268_base_init_verbs[] = {
9503 /* Unmute DAC0-1 and set vol = 0 */
9504 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9505 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9506 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9507 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9508 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9509 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9510
9511 /*
9512 * Set up output mixers (0x0c - 0x0e)
9513 */
9514 /* set vol=0 to output mixers */
9515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9518 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9519
9520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9521 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9522
9523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9526 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9527 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9529 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9530 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9531
9532 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9534 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9536 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9537 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9538 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9539 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9540
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009541 /* Unmute Selector 23h,24h and set the default input to mic-in */
9542
9543 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9545 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009547
Kailang Yanga361d842007-06-05 12:30:55 +02009548 { }
9549};
9550
9551/*
9552 * generic initialization of ADC, input mixers and output mixers
9553 */
9554static struct hda_verb alc268_volume_init_verbs[] = {
9555 /* set output DAC */
9556 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9557 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9558 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9560
9561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9562 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9565 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9566
9567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9570 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9571 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9572
9573 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9576 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9577
9578 /* set PCBEEP vol = 0 */
9579 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9580
9581 { }
9582};
9583
9584#define alc268_mux_enum_info alc_mux_enum_info
9585#define alc268_mux_enum_get alc_mux_enum_get
9586
9587static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9588 struct snd_ctl_elem_value *ucontrol)
9589{
9590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9591 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009592
Kailang Yanga361d842007-06-05 12:30:55 +02009593 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9594 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9595 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009596
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009597 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9598 nid,
9599 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009600}
9601
9602static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9603 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9604 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9605 {
9606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9607 /* The multiple "Capture Source" controls confuse alsamixer
9608 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009609 */
9610 /* .name = "Capture Source", */
9611 .name = "Input Source",
9612 .count = 1,
9613 .info = alc268_mux_enum_info,
9614 .get = alc268_mux_enum_get,
9615 .put = alc268_mux_enum_put,
9616 },
9617 { } /* end */
9618};
9619
9620static struct snd_kcontrol_new alc268_capture_mixer[] = {
9621 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9622 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9623 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9624 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9625 {
9626 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9627 /* The multiple "Capture Source" controls confuse alsamixer
9628 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009629 */
9630 /* .name = "Capture Source", */
9631 .name = "Input Source",
9632 .count = 2,
9633 .info = alc268_mux_enum_info,
9634 .get = alc268_mux_enum_get,
9635 .put = alc268_mux_enum_put,
9636 },
9637 { } /* end */
9638};
9639
9640static struct hda_input_mux alc268_capture_source = {
9641 .num_items = 4,
9642 .items = {
9643 { "Mic", 0x0 },
9644 { "Front Mic", 0x1 },
9645 { "Line", 0x2 },
9646 { "CD", 0x3 },
9647 },
9648};
9649
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009650#ifdef CONFIG_SND_DEBUG
9651static struct snd_kcontrol_new alc268_test_mixer[] = {
9652 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9653 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9656
9657 /* Volume widgets */
9658 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9659 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9660 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9661 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9662 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9663 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9664 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9665 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9666 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9667 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9668 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9669 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9670 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009671 /* The below appears problematic on some hardwares */
9672 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009673 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9674 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9675 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9676 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9677
9678 /* Modes for retasking pin widgets */
9679 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9680 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9681 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9682 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9683
9684 /* Controls for GPIO pins, assuming they are configured as outputs */
9685 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9686 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9687 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9688 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9689
9690 /* Switches to allow the digital SPDIF output pin to be enabled.
9691 * The ALC268 does not have an SPDIF input.
9692 */
9693 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9694
9695 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9696 * this output to turn on an external amplifier.
9697 */
9698 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9699 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9700
9701 { } /* end */
9702};
9703#endif
9704
Kailang Yanga361d842007-06-05 12:30:55 +02009705/* create input playback/capture controls for the given pin */
9706static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9707 const char *ctlname, int idx)
9708{
9709 char name[32];
9710 int err;
9711
9712 sprintf(name, "%s Playback Volume", ctlname);
9713 if (nid == 0x14) {
9714 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9715 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9716 HDA_OUTPUT));
9717 if (err < 0)
9718 return err;
9719 } else if (nid == 0x15) {
9720 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9721 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9722 HDA_OUTPUT));
9723 if (err < 0)
9724 return err;
9725 } else
9726 return -1;
9727 sprintf(name, "%s Playback Switch", ctlname);
9728 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9729 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9730 if (err < 0)
9731 return err;
9732 return 0;
9733}
9734
9735/* add playback controls from the parsed DAC table */
9736static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9737 const struct auto_pin_cfg *cfg)
9738{
9739 hda_nid_t nid;
9740 int err;
9741
9742 spec->multiout.num_dacs = 2; /* only use one dac */
9743 spec->multiout.dac_nids = spec->private_dac_nids;
9744 spec->multiout.dac_nids[0] = 2;
9745 spec->multiout.dac_nids[1] = 3;
9746
9747 nid = cfg->line_out_pins[0];
9748 if (nid)
9749 alc268_new_analog_output(spec, nid, "Front", 0);
9750
9751 nid = cfg->speaker_pins[0];
9752 if (nid == 0x1d) {
9753 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9754 "Speaker Playback Volume",
9755 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9756 if (err < 0)
9757 return err;
9758 }
9759 nid = cfg->hp_pins[0];
9760 if (nid)
9761 alc268_new_analog_output(spec, nid, "Headphone", 0);
9762
9763 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9764 if (nid == 0x16) {
9765 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9766 "Mono Playback Switch",
9767 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9768 if (err < 0)
9769 return err;
9770 }
9771 return 0;
9772}
9773
9774/* create playback/capture controls for input pins */
9775static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9776 const struct auto_pin_cfg *cfg)
9777{
9778 struct hda_input_mux *imux = &spec->private_imux;
9779 int i, idx1;
9780
9781 for (i = 0; i < AUTO_PIN_LAST; i++) {
9782 switch(cfg->input_pins[i]) {
9783 case 0x18:
9784 idx1 = 0; /* Mic 1 */
9785 break;
9786 case 0x19:
9787 idx1 = 1; /* Mic 2 */
9788 break;
9789 case 0x1a:
9790 idx1 = 2; /* Line In */
9791 break;
9792 case 0x1c:
9793 idx1 = 3; /* CD */
9794 break;
9795 default:
9796 continue;
9797 }
9798 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9799 imux->items[imux->num_items].index = idx1;
9800 imux->num_items++;
9801 }
9802 return 0;
9803}
9804
9805static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9806{
9807 struct alc_spec *spec = codec->spec;
9808 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9809 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9810 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9811 unsigned int dac_vol1, dac_vol2;
9812
9813 if (speaker_nid) {
9814 snd_hda_codec_write(codec, speaker_nid, 0,
9815 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9816 snd_hda_codec_write(codec, 0x0f, 0,
9817 AC_VERB_SET_AMP_GAIN_MUTE,
9818 AMP_IN_UNMUTE(1));
9819 snd_hda_codec_write(codec, 0x10, 0,
9820 AC_VERB_SET_AMP_GAIN_MUTE,
9821 AMP_IN_UNMUTE(1));
9822 } else {
9823 snd_hda_codec_write(codec, 0x0f, 0,
9824 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9825 snd_hda_codec_write(codec, 0x10, 0,
9826 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9827 }
9828
9829 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9830 if (line_nid == 0x14)
9831 dac_vol2 = AMP_OUT_ZERO;
9832 else if (line_nid == 0x15)
9833 dac_vol1 = AMP_OUT_ZERO;
9834 if (hp_nid == 0x14)
9835 dac_vol2 = AMP_OUT_ZERO;
9836 else if (hp_nid == 0x15)
9837 dac_vol1 = AMP_OUT_ZERO;
9838 if (line_nid != 0x16 || hp_nid != 0x16 ||
9839 spec->autocfg.line_out_pins[1] != 0x16 ||
9840 spec->autocfg.line_out_pins[2] != 0x16)
9841 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9842
9843 snd_hda_codec_write(codec, 0x02, 0,
9844 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9845 snd_hda_codec_write(codec, 0x03, 0,
9846 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9847}
9848
9849/* pcm configuration: identiacal with ALC880 */
9850#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9851#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009852#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +02009853#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9854
9855/*
9856 * BIOS auto configuration
9857 */
9858static int alc268_parse_auto_config(struct hda_codec *codec)
9859{
9860 struct alc_spec *spec = codec->spec;
9861 int err;
9862 static hda_nid_t alc268_ignore[] = { 0 };
9863
9864 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9865 alc268_ignore);
9866 if (err < 0)
9867 return err;
9868 if (!spec->autocfg.line_outs)
9869 return 0; /* can't find valid BIOS pin config */
9870
9871 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9872 if (err < 0)
9873 return err;
9874 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9875 if (err < 0)
9876 return err;
9877
9878 spec->multiout.max_channels = 2;
9879
9880 /* digital only support output */
9881 if (spec->autocfg.dig_out_pin)
9882 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9883
9884 if (spec->kctl_alloc)
9885 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9886
9887 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9888 spec->num_mux_defs = 1;
9889 spec->input_mux = &spec->private_imux;
9890
Takashi Iwai776e1842007-08-29 15:07:11 +02009891 err = alc_auto_add_mic_boost(codec);
9892 if (err < 0)
9893 return err;
9894
Kailang Yanga361d842007-06-05 12:30:55 +02009895 return 1;
9896}
9897
9898#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9899#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9900#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9901
9902/* init callback for auto-configuration model -- overriding the default init */
9903static void alc268_auto_init(struct hda_codec *codec)
9904{
9905 alc268_auto_init_multi_out(codec);
9906 alc268_auto_init_hp_out(codec);
9907 alc268_auto_init_mono_speaker_out(codec);
9908 alc268_auto_init_analog_input(codec);
9909}
9910
9911/*
9912 * configuration and preset
9913 */
9914static const char *alc268_models[ALC268_MODEL_LAST] = {
9915 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009916 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009917 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009918 [ALC268_DELL] = "dell",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009919#ifdef CONFIG_SND_DEBUG
9920 [ALC268_TEST] = "test",
9921#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009922 [ALC268_AUTO] = "auto",
9923};
9924
9925static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009926 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +01009927 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009928 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +01009929 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009930 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009931 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009932 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009933 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009934 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009935 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009936 {}
9937};
9938
9939static struct alc_config_preset alc268_presets[] = {
9940 [ALC268_3ST] = {
9941 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9942 .init_verbs = { alc268_base_init_verbs },
9943 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9944 .dac_nids = alc268_dac_nids,
9945 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9946 .adc_nids = alc268_adc_nids_alt,
9947 .hp_nid = 0x03,
9948 .dig_out_nid = ALC268_DIGOUT_NID,
9949 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9950 .channel_mode = alc268_modes,
9951 .input_mux = &alc268_capture_source,
9952 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009953 [ALC268_TOSHIBA] = {
9954 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009955 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9956 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009957 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9958 .dac_nids = alc268_dac_nids,
9959 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9960 .adc_nids = alc268_adc_nids_alt,
9961 .hp_nid = 0x03,
9962 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9963 .channel_mode = alc268_modes,
9964 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009965 .unsol_event = alc268_toshiba_unsol_event,
9966 .init_hook = alc268_toshiba_automute,
9967 },
9968 [ALC268_ACER] = {
9969 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9970 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9971 alc268_acer_verbs },
9972 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9973 .dac_nids = alc268_dac_nids,
9974 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9975 .adc_nids = alc268_adc_nids_alt,
9976 .hp_nid = 0x02,
9977 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9978 .channel_mode = alc268_modes,
9979 .input_mux = &alc268_capture_source,
9980 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009981 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009982 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009983 [ALC268_DELL] = {
9984 .mixers = { alc268_dell_mixer },
9985 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9986 alc268_dell_verbs },
9987 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9988 .dac_nids = alc268_dac_nids,
9989 .hp_nid = 0x02,
9990 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9991 .channel_mode = alc268_modes,
9992 .unsol_event = alc268_dell_unsol_event,
9993 .init_hook = alc268_dell_init_hook,
9994 .input_mux = &alc268_capture_source,
9995 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009996#ifdef CONFIG_SND_DEBUG
9997 [ALC268_TEST] = {
9998 .mixers = { alc268_test_mixer, alc268_capture_mixer },
9999 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10000 alc268_volume_init_verbs },
10001 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10002 .dac_nids = alc268_dac_nids,
10003 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10004 .adc_nids = alc268_adc_nids_alt,
10005 .hp_nid = 0x03,
10006 .dig_out_nid = ALC268_DIGOUT_NID,
10007 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10008 .channel_mode = alc268_modes,
10009 .input_mux = &alc268_capture_source,
10010 },
10011#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010012};
10013
10014static int patch_alc268(struct hda_codec *codec)
10015{
10016 struct alc_spec *spec;
10017 int board_config;
10018 int err;
10019
10020 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10021 if (spec == NULL)
10022 return -ENOMEM;
10023
10024 codec->spec = spec;
10025
10026 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10027 alc268_models,
10028 alc268_cfg_tbl);
10029
10030 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10031 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10032 "trying auto-probe from BIOS...\n");
10033 board_config = ALC268_AUTO;
10034 }
10035
10036 if (board_config == ALC268_AUTO) {
10037 /* automatic parse from the BIOS config */
10038 err = alc268_parse_auto_config(codec);
10039 if (err < 0) {
10040 alc_free(codec);
10041 return err;
10042 } else if (!err) {
10043 printk(KERN_INFO
10044 "hda_codec: Cannot set up configuration "
10045 "from BIOS. Using base mode...\n");
10046 board_config = ALC268_3ST;
10047 }
10048 }
10049
10050 if (board_config != ALC268_AUTO)
10051 setup_preset(spec, &alc268_presets[board_config]);
10052
10053 spec->stream_name_analog = "ALC268 Analog";
10054 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10055 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010056 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010057
10058 spec->stream_name_digital = "ALC268 Digital";
10059 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10060
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010061 if (!spec->adc_nids && spec->input_mux) {
10062 /* check whether NID 0x07 is valid */
10063 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010064
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010065 /* get type */
10066 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10067 if (wcap != AC_WID_AUD_IN) {
10068 spec->adc_nids = alc268_adc_nids_alt;
10069 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10070 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010071 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010072 spec->num_mixers++;
10073 } else {
10074 spec->adc_nids = alc268_adc_nids;
10075 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10076 spec->mixers[spec->num_mixers] =
10077 alc268_capture_mixer;
10078 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010079 }
10080 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010081
10082 spec->vmaster_nid = 0x02;
10083
Kailang Yanga361d842007-06-05 12:30:55 +020010084 codec->patch_ops = alc_patch_ops;
10085 if (board_config == ALC268_AUTO)
10086 spec->init_hook = alc268_auto_init;
10087
10088 return 0;
10089}
10090
10091/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010092 * ALC269 channel source setting (2 channel)
10093 */
10094#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10095
10096#define alc269_dac_nids alc260_dac_nids
10097
10098static hda_nid_t alc269_adc_nids[1] = {
10099 /* ADC1 */
10100 0x07,
10101};
10102
10103#define alc269_modes alc260_modes
10104#define alc269_capture_source alc880_lg_lw_capture_source
10105
10106static struct snd_kcontrol_new alc269_base_mixer[] = {
10107 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10108 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10119 { } /* end */
10120};
10121
10122/* capture mixer elements */
10123static struct snd_kcontrol_new alc269_capture_mixer[] = {
10124 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10125 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10126 {
10127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10128 /* The multiple "Capture Source" controls confuse alsamixer
10129 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010130 */
10131 /* .name = "Capture Source", */
10132 .name = "Input Source",
10133 .count = 1,
10134 .info = alc_mux_enum_info,
10135 .get = alc_mux_enum_get,
10136 .put = alc_mux_enum_put,
10137 },
10138 { } /* end */
10139};
10140
10141/*
10142 * generic initialization of ADC, input mixers and output mixers
10143 */
10144static struct hda_verb alc269_init_verbs[] = {
10145 /*
10146 * Unmute ADC0 and set the default input to mic-in
10147 */
10148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10149
10150 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10151 * analog-loopback mixer widget
10152 * Note: PASD motherboards uses the Line In 2 as the input for
10153 * front panel mic (mic 2)
10154 */
10155 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10161
10162 /*
10163 * Set up output mixers (0x0c - 0x0e)
10164 */
10165 /* set vol=0 to output mixers */
10166 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10167 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10168
10169 /* set up input amps for analog loopback */
10170 /* Amp Indices: DAC = 0, mixer = 1 */
10171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10173 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10177
10178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10181 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10185
10186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10189 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10193
10194 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10195 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10196
10197 /* FIXME: use matrix-type input source selection */
10198 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10199 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10204
10205 /* set EAPD */
10206 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10207 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10208 { }
10209};
10210
10211/* add playback controls from the parsed DAC table */
10212static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10213 const struct auto_pin_cfg *cfg)
10214{
10215 hda_nid_t nid;
10216 int err;
10217
10218 spec->multiout.num_dacs = 1; /* only use one dac */
10219 spec->multiout.dac_nids = spec->private_dac_nids;
10220 spec->multiout.dac_nids[0] = 2;
10221
10222 nid = cfg->line_out_pins[0];
10223 if (nid) {
10224 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10225 "Front Playback Volume",
10226 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10227 if (err < 0)
10228 return err;
10229 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10230 "Front Playback Switch",
10231 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10232 if (err < 0)
10233 return err;
10234 }
10235
10236 nid = cfg->speaker_pins[0];
10237 if (nid) {
10238 if (!cfg->line_out_pins[0]) {
10239 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10240 "Speaker Playback Volume",
10241 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10242 HDA_OUTPUT));
10243 if (err < 0)
10244 return err;
10245 }
10246 if (nid == 0x16) {
10247 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10248 "Speaker Playback Switch",
10249 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10250 HDA_OUTPUT));
10251 if (err < 0)
10252 return err;
10253 } else {
10254 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10255 "Speaker Playback Switch",
10256 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10257 HDA_OUTPUT));
10258 if (err < 0)
10259 return err;
10260 }
10261 }
10262 nid = cfg->hp_pins[0];
10263 if (nid) {
10264 /* spec->multiout.hp_nid = 2; */
10265 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10266 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10267 "Headphone Playback Volume",
10268 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10269 HDA_OUTPUT));
10270 if (err < 0)
10271 return err;
10272 }
10273 if (nid == 0x16) {
10274 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10275 "Headphone Playback Switch",
10276 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10277 HDA_OUTPUT));
10278 if (err < 0)
10279 return err;
10280 } else {
10281 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10282 "Headphone Playback Switch",
10283 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10284 HDA_OUTPUT));
10285 if (err < 0)
10286 return err;
10287 }
10288 }
10289 return 0;
10290}
10291
10292#define alc269_auto_create_analog_input_ctls \
10293 alc880_auto_create_analog_input_ctls
10294
10295#ifdef CONFIG_SND_HDA_POWER_SAVE
10296#define alc269_loopbacks alc880_loopbacks
10297#endif
10298
10299/* pcm configuration: identiacal with ALC880 */
10300#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10301#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10302#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10303#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10304
10305/*
10306 * BIOS auto configuration
10307 */
10308static int alc269_parse_auto_config(struct hda_codec *codec)
10309{
10310 struct alc_spec *spec = codec->spec;
10311 int err;
10312 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10313
10314 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10315 alc269_ignore);
10316 if (err < 0)
10317 return err;
10318
10319 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10320 if (err < 0)
10321 return err;
10322 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10323 if (err < 0)
10324 return err;
10325
10326 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10327
10328 if (spec->autocfg.dig_out_pin)
10329 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10330
10331 if (spec->kctl_alloc)
10332 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10333
10334 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10335 spec->num_mux_defs = 1;
10336 spec->input_mux = &spec->private_imux;
10337
10338 err = alc_auto_add_mic_boost(codec);
10339 if (err < 0)
10340 return err;
10341
10342 return 1;
10343}
10344
10345#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10346#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10347#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10348
10349
10350/* init callback for auto-configuration model -- overriding the default init */
10351static void alc269_auto_init(struct hda_codec *codec)
10352{
10353 alc269_auto_init_multi_out(codec);
10354 alc269_auto_init_hp_out(codec);
10355 alc269_auto_init_analog_input(codec);
10356}
10357
10358/*
10359 * configuration and preset
10360 */
10361static const char *alc269_models[ALC269_MODEL_LAST] = {
10362 [ALC269_BASIC] = "basic",
10363};
10364
10365static struct snd_pci_quirk alc269_cfg_tbl[] = {
10366 {}
10367};
10368
10369static struct alc_config_preset alc269_presets[] = {
10370 [ALC269_BASIC] = {
10371 .mixers = { alc269_base_mixer },
10372 .init_verbs = { alc269_init_verbs },
10373 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10374 .dac_nids = alc269_dac_nids,
10375 .hp_nid = 0x03,
10376 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10377 .channel_mode = alc269_modes,
10378 .input_mux = &alc269_capture_source,
10379 },
10380};
10381
10382static int patch_alc269(struct hda_codec *codec)
10383{
10384 struct alc_spec *spec;
10385 int board_config;
10386 int err;
10387
10388 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10389 if (spec == NULL)
10390 return -ENOMEM;
10391
10392 codec->spec = spec;
10393
10394 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10395 alc269_models,
10396 alc269_cfg_tbl);
10397
10398 if (board_config < 0) {
10399 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10400 "trying auto-probe from BIOS...\n");
10401 board_config = ALC269_AUTO;
10402 }
10403
10404 if (board_config == ALC269_AUTO) {
10405 /* automatic parse from the BIOS config */
10406 err = alc269_parse_auto_config(codec);
10407 if (err < 0) {
10408 alc_free(codec);
10409 return err;
10410 } else if (!err) {
10411 printk(KERN_INFO
10412 "hda_codec: Cannot set up configuration "
10413 "from BIOS. Using base mode...\n");
10414 board_config = ALC269_BASIC;
10415 }
10416 }
10417
10418 if (board_config != ALC269_AUTO)
10419 setup_preset(spec, &alc269_presets[board_config]);
10420
10421 spec->stream_name_analog = "ALC269 Analog";
10422 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10423 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10424
10425 spec->stream_name_digital = "ALC269 Digital";
10426 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10427 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10428
10429 spec->adc_nids = alc269_adc_nids;
10430 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10431 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10432 spec->num_mixers++;
10433
10434 codec->patch_ops = alc_patch_ops;
10435 if (board_config == ALC269_AUTO)
10436 spec->init_hook = alc269_auto_init;
10437#ifdef CONFIG_SND_HDA_POWER_SAVE
10438 if (!spec->loopback.amplist)
10439 spec->loopback.amplist = alc269_loopbacks;
10440#endif
10441
10442 return 0;
10443}
10444
10445/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010446 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10447 */
10448
10449/*
10450 * set the path ways for 2 channel output
10451 * need to set the codec line out and mic 1 pin widgets to inputs
10452 */
10453static struct hda_verb alc861_threestack_ch2_init[] = {
10454 /* set pin widget 1Ah (line in) for input */
10455 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010456 /* set pin widget 18h (mic1/2) for input, for mic also enable
10457 * the vref
10458 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010459 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10460
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010461 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10462#if 0
10463 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10464 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10465#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010466 { } /* end */
10467};
10468/*
10469 * 6ch mode
10470 * need to set the codec line out and mic 1 pin widgets to outputs
10471 */
10472static struct hda_verb alc861_threestack_ch6_init[] = {
10473 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10474 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10475 /* set pin widget 18h (mic1) for output (CLFE)*/
10476 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10477
10478 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010479 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010480
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010481 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10482#if 0
10483 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10484 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10485#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010486 { } /* end */
10487};
10488
10489static struct hda_channel_mode alc861_threestack_modes[2] = {
10490 { 2, alc861_threestack_ch2_init },
10491 { 6, alc861_threestack_ch6_init },
10492};
Takashi Iwai22309c32006-08-09 16:57:28 +020010493/* Set mic1 as input and unmute the mixer */
10494static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10495 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10496 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10497 { } /* end */
10498};
10499/* Set mic1 as output and mute mixer */
10500static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10501 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10502 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10503 { } /* end */
10504};
10505
10506static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10507 { 2, alc861_uniwill_m31_ch2_init },
10508 { 4, alc861_uniwill_m31_ch4_init },
10509};
Kailang Yangdf694da2005-12-05 19:42:22 +010010510
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010511/* Set mic1 and line-in as input and unmute the mixer */
10512static struct hda_verb alc861_asus_ch2_init[] = {
10513 /* set pin widget 1Ah (line in) for input */
10514 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010515 /* set pin widget 18h (mic1/2) for input, for mic also enable
10516 * the vref
10517 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010518 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10519
10520 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10521#if 0
10522 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10523 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10524#endif
10525 { } /* end */
10526};
10527/* Set mic1 nad line-in as output and mute mixer */
10528static struct hda_verb alc861_asus_ch6_init[] = {
10529 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10530 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10531 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10532 /* set pin widget 18h (mic1) for output (CLFE)*/
10533 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10534 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10535 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10536 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10537
10538 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10539#if 0
10540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10541 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10542#endif
10543 { } /* end */
10544};
10545
10546static struct hda_channel_mode alc861_asus_modes[2] = {
10547 { 2, alc861_asus_ch2_init },
10548 { 6, alc861_asus_ch6_init },
10549};
10550
Kailang Yangdf694da2005-12-05 19:42:22 +010010551/* patch-ALC861 */
10552
10553static struct snd_kcontrol_new alc861_base_mixer[] = {
10554 /* output mixer control */
10555 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10556 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10557 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10558 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10560
10561 /*Input mixer control */
10562 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10563 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10564 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10565 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10566 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10567 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10569 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10570 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010572
Kailang Yangdf694da2005-12-05 19:42:22 +010010573 /* Capture mixer control */
10574 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10575 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10576 {
10577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10578 .name = "Capture Source",
10579 .count = 1,
10580 .info = alc_mux_enum_info,
10581 .get = alc_mux_enum_get,
10582 .put = alc_mux_enum_put,
10583 },
10584 { } /* end */
10585};
10586
10587static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10588 /* output mixer control */
10589 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10590 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10591 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10592 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10593 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10594
10595 /* Input mixer control */
10596 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10597 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10598 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10599 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10600 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10601 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10603 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010606
Kailang Yangdf694da2005-12-05 19:42:22 +010010607 /* Capture mixer control */
10608 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10609 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10610 {
10611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10612 .name = "Capture Source",
10613 .count = 1,
10614 .info = alc_mux_enum_info,
10615 .get = alc_mux_enum_get,
10616 .put = alc_mux_enum_put,
10617 },
10618 {
10619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10620 .name = "Channel Mode",
10621 .info = alc_ch_mode_info,
10622 .get = alc_ch_mode_get,
10623 .put = alc_ch_mode_put,
10624 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10625 },
10626 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010627};
10628
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010629static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010630 /* output mixer control */
10631 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10633 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10634
10635 /*Capture mixer control */
10636 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10637 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10638 {
10639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10640 .name = "Capture Source",
10641 .count = 1,
10642 .info = alc_mux_enum_info,
10643 .get = alc_mux_enum_get,
10644 .put = alc_mux_enum_put,
10645 },
10646
10647 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010648};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010649
Takashi Iwai22309c32006-08-09 16:57:28 +020010650static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10651 /* output mixer control */
10652 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10653 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10654 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10655 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10656 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10657
10658 /* Input mixer control */
10659 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10660 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10661 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10662 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10663 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10664 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10666 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010669
Takashi Iwai22309c32006-08-09 16:57:28 +020010670 /* Capture mixer control */
10671 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10672 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10673 {
10674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10675 .name = "Capture Source",
10676 .count = 1,
10677 .info = alc_mux_enum_info,
10678 .get = alc_mux_enum_get,
10679 .put = alc_mux_enum_put,
10680 },
10681 {
10682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10683 .name = "Channel Mode",
10684 .info = alc_ch_mode_info,
10685 .get = alc_ch_mode_get,
10686 .put = alc_ch_mode_put,
10687 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10688 },
10689 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010690};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010691
10692static struct snd_kcontrol_new alc861_asus_mixer[] = {
10693 /* output mixer control */
10694 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10695 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10696 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10697 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10699
10700 /* Input mixer control */
10701 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10702 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10703 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10704 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10705 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10706 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10708 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10711
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010712 /* Capture mixer control */
10713 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10714 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10715 {
10716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10717 .name = "Capture Source",
10718 .count = 1,
10719 .info = alc_mux_enum_info,
10720 .get = alc_mux_enum_get,
10721 .put = alc_mux_enum_put,
10722 },
10723 {
10724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10725 .name = "Channel Mode",
10726 .info = alc_ch_mode_info,
10727 .get = alc_ch_mode_get,
10728 .put = alc_ch_mode_put,
10729 .private_value = ARRAY_SIZE(alc861_asus_modes),
10730 },
10731 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010732};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010733
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010734/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010735static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010736 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10737 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10738 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10739 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10740 { }
10741};
10742
Kailang Yangdf694da2005-12-05 19:42:22 +010010743/*
10744 * generic initialization of ADC, input mixers and output mixers
10745 */
10746static struct hda_verb alc861_base_init_verbs[] = {
10747 /*
10748 * Unmute ADC0 and set the default input to mic-in
10749 */
10750 /* port-A for surround (rear panel) */
10751 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10752 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10753 /* port-B for mic-in (rear panel) with vref */
10754 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10755 /* port-C for line-in (rear panel) */
10756 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10757 /* port-D for Front */
10758 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10759 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10760 /* port-E for HP out (front panel) */
10761 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10762 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010764 /* port-F for mic-in (front panel) with vref */
10765 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10766 /* port-G for CLFE (rear panel) */
10767 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10768 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10769 /* port-H for side (rear panel) */
10770 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10771 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10772 /* CD-in */
10773 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10774 /* route front mic to ADC1*/
10775 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10776 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10777
10778 /* Unmute DAC0~3 & spdif out*/
10779 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10780 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10781 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10782 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10784
10785 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10786 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10787 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10788 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10789 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10790
10791 /* Unmute Stereo Mixer 15 */
10792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010796
10797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10803 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010805 /* hp used DAC 3 (Front) */
10806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10808
10809 { }
10810};
10811
10812static struct hda_verb alc861_threestack_init_verbs[] = {
10813 /*
10814 * Unmute ADC0 and set the default input to mic-in
10815 */
10816 /* port-A for surround (rear panel) */
10817 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10818 /* port-B for mic-in (rear panel) with vref */
10819 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10820 /* port-C for line-in (rear panel) */
10821 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10822 /* port-D for Front */
10823 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10824 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10825 /* port-E for HP out (front panel) */
10826 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10827 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010828 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010829 /* port-F for mic-in (front panel) with vref */
10830 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10831 /* port-G for CLFE (rear panel) */
10832 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10833 /* port-H for side (rear panel) */
10834 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10835 /* CD-in */
10836 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10837 /* route front mic to ADC1*/
10838 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10840 /* Unmute DAC0~3 & spdif out*/
10841 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10842 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10843 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10844 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10846
10847 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10848 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10849 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10850 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10851 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10852
10853 /* Unmute Stereo Mixer 15 */
10854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010858
10859 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10866 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010867 /* hp used DAC 3 (Front) */
10868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10870 { }
10871};
Takashi Iwai22309c32006-08-09 16:57:28 +020010872
10873static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10874 /*
10875 * Unmute ADC0 and set the default input to mic-in
10876 */
10877 /* port-A for surround (rear panel) */
10878 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10879 /* port-B for mic-in (rear panel) with vref */
10880 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10881 /* port-C for line-in (rear panel) */
10882 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10883 /* port-D for Front */
10884 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10885 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10886 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010887 /* this has to be set to VREF80 */
10888 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010889 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010890 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010891 /* port-F for mic-in (front panel) with vref */
10892 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10893 /* port-G for CLFE (rear panel) */
10894 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10895 /* port-H for side (rear panel) */
10896 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10897 /* CD-in */
10898 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10899 /* route front mic to ADC1*/
10900 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10902 /* Unmute DAC0~3 & spdif out*/
10903 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10904 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10905 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10906 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10908
10909 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10910 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10911 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10912 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10913 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10914
10915 /* Unmute Stereo Mixer 15 */
10916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010920
10921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010929 /* hp used DAC 3 (Front) */
10930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10932 { }
10933};
10934
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010935static struct hda_verb alc861_asus_init_verbs[] = {
10936 /*
10937 * Unmute ADC0 and set the default input to mic-in
10938 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010939 /* port-A for surround (rear panel)
10940 * according to codec#0 this is the HP jack
10941 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010942 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10943 /* route front PCM to HP */
10944 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10945 /* port-B for mic-in (rear panel) with vref */
10946 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10947 /* port-C for line-in (rear panel) */
10948 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10949 /* port-D for Front */
10950 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10951 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10952 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010953 /* this has to be set to VREF80 */
10954 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010955 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010956 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010957 /* port-F for mic-in (front panel) with vref */
10958 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10959 /* port-G for CLFE (rear panel) */
10960 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10961 /* port-H for side (rear panel) */
10962 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10963 /* CD-in */
10964 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10965 /* route front mic to ADC1*/
10966 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10968 /* Unmute DAC0~3 & spdif out*/
10969 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10970 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10971 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10972 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10974 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10975 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10979
10980 /* Unmute Stereo Mixer 15 */
10981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010985
10986 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10988 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010994 /* hp used DAC 3 (Front) */
10995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10997 { }
10998};
10999
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011000/* additional init verbs for ASUS laptops */
11001static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11002 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11003 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11004 { }
11005};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011006
Kailang Yangdf694da2005-12-05 19:42:22 +010011007/*
11008 * generic initialization of ADC, input mixers and output mixers
11009 */
11010static struct hda_verb alc861_auto_init_verbs[] = {
11011 /*
11012 * Unmute ADC0 and set the default input to mic-in
11013 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011014 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011015 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11016
11017 /* Unmute DAC0~3 & spdif out*/
11018 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11019 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11020 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11021 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11023
11024 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11025 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029
11030 /* Unmute Stereo Mixer 15 */
11031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11035
11036 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11038 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11044
11045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011051 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011053
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011054 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011055
11056 { }
11057};
11058
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011059static struct hda_verb alc861_toshiba_init_verbs[] = {
11060 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011061
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011062 { }
11063};
11064
11065/* toggle speaker-output according to the hp-jack state */
11066static void alc861_toshiba_automute(struct hda_codec *codec)
11067{
11068 unsigned int present;
11069
11070 present = snd_hda_codec_read(codec, 0x0f, 0,
11071 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011072 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11073 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11074 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11075 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011076}
11077
11078static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11079 unsigned int res)
11080{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011081 if ((res >> 26) == ALC880_HP_EVENT)
11082 alc861_toshiba_automute(codec);
11083}
11084
Kailang Yangdf694da2005-12-05 19:42:22 +010011085/* pcm configuration: identiacal with ALC880 */
11086#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11087#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11088#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11089#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11090
11091
11092#define ALC861_DIGOUT_NID 0x07
11093
11094static struct hda_channel_mode alc861_8ch_modes[1] = {
11095 { 8, NULL }
11096};
11097
11098static hda_nid_t alc861_dac_nids[4] = {
11099 /* front, surround, clfe, side */
11100 0x03, 0x06, 0x05, 0x04
11101};
11102
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011103static hda_nid_t alc660_dac_nids[3] = {
11104 /* front, clfe, surround */
11105 0x03, 0x05, 0x06
11106};
11107
Kailang Yangdf694da2005-12-05 19:42:22 +010011108static hda_nid_t alc861_adc_nids[1] = {
11109 /* ADC0-2 */
11110 0x08,
11111};
11112
11113static struct hda_input_mux alc861_capture_source = {
11114 .num_items = 5,
11115 .items = {
11116 { "Mic", 0x0 },
11117 { "Front Mic", 0x3 },
11118 { "Line", 0x1 },
11119 { "CD", 0x4 },
11120 { "Mixer", 0x5 },
11121 },
11122};
11123
11124/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011125static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11126 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011127{
11128 int i;
11129 hda_nid_t nid;
11130
11131 spec->multiout.dac_nids = spec->private_dac_nids;
11132 for (i = 0; i < cfg->line_outs; i++) {
11133 nid = cfg->line_out_pins[i];
11134 if (nid) {
11135 if (i >= ARRAY_SIZE(alc861_dac_nids))
11136 continue;
11137 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11138 }
11139 }
11140 spec->multiout.num_dacs = cfg->line_outs;
11141 return 0;
11142}
11143
11144/* add playback controls from the parsed DAC table */
11145static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11146 const struct auto_pin_cfg *cfg)
11147{
11148 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011149 static const char *chname[4] = {
11150 "Front", "Surround", NULL /*CLFE*/, "Side"
11151 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011152 hda_nid_t nid;
11153 int i, idx, err;
11154
11155 for (i = 0; i < cfg->line_outs; i++) {
11156 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011157 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011158 continue;
11159 if (nid == 0x05) {
11160 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011161 err = add_control(spec, ALC_CTL_BIND_MUTE,
11162 "Center Playback Switch",
11163 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11164 HDA_OUTPUT));
11165 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011166 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 err = add_control(spec, ALC_CTL_BIND_MUTE,
11168 "LFE Playback Switch",
11169 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11170 HDA_OUTPUT));
11171 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011172 return err;
11173 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011174 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11175 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011176 if (nid == alc861_dac_nids[idx])
11177 break;
11178 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011179 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11180 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11181 HDA_OUTPUT));
11182 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011183 return err;
11184 }
11185 }
11186 return 0;
11187}
11188
11189static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11190{
11191 int err;
11192 hda_nid_t nid;
11193
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011194 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011195 return 0;
11196
11197 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11198 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011199 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11200 "Headphone Playback Switch",
11201 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11202 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011203 return err;
11204 spec->multiout.hp_nid = nid;
11205 }
11206 return 0;
11207}
11208
11209/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011210static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11211 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011212{
Kailang Yangdf694da2005-12-05 19:42:22 +010011213 struct hda_input_mux *imux = &spec->private_imux;
11214 int i, err, idx, idx1;
11215
11216 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011217 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011218 case 0x0c:
11219 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011220 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011221 break;
11222 case 0x0f:
11223 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011224 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011225 break;
11226 case 0x0d:
11227 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011228 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011229 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011230 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011231 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011232 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011233 break;
11234 case 0x11:
11235 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011236 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011237 break;
11238 default:
11239 continue;
11240 }
11241
Takashi Iwai4a471b72005-12-07 13:56:29 +010011242 err = new_analog_input(spec, cfg->input_pins[i],
11243 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011244 if (err < 0)
11245 return err;
11246
Takashi Iwai4a471b72005-12-07 13:56:29 +010011247 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011248 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011249 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011250 }
11251 return 0;
11252}
11253
11254static struct snd_kcontrol_new alc861_capture_mixer[] = {
11255 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11256 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11257
11258 {
11259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11260 /* The multiple "Capture Source" controls confuse alsamixer
11261 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011262 */
11263 /* .name = "Capture Source", */
11264 .name = "Input Source",
11265 .count = 1,
11266 .info = alc_mux_enum_info,
11267 .get = alc_mux_enum_get,
11268 .put = alc_mux_enum_put,
11269 },
11270 { } /* end */
11271};
11272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011273static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11274 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011275 int pin_type, int dac_idx)
11276{
11277 /* set as output */
11278
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011279 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11280 pin_type);
11281 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11282 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011283
11284}
11285
11286static void alc861_auto_init_multi_out(struct hda_codec *codec)
11287{
11288 struct alc_spec *spec = codec->spec;
11289 int i;
11290
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011291 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011292 for (i = 0; i < spec->autocfg.line_outs; i++) {
11293 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011296 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011297 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011298 }
11299}
11300
11301static void alc861_auto_init_hp_out(struct hda_codec *codec)
11302{
11303 struct alc_spec *spec = codec->spec;
11304 hda_nid_t pin;
11305
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011306 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011307 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011308 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11309 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011310}
11311
11312static void alc861_auto_init_analog_input(struct hda_codec *codec)
11313{
11314 struct alc_spec *spec = codec->spec;
11315 int i;
11316
11317 for (i = 0; i < AUTO_PIN_LAST; i++) {
11318 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011319 if (nid >= 0x0c && nid <= 0x11) {
11320 snd_hda_codec_write(codec, nid, 0,
11321 AC_VERB_SET_PIN_WIDGET_CONTROL,
11322 i <= AUTO_PIN_FRONT_MIC ?
11323 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011324 }
11325 }
11326}
11327
11328/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011329/* return 1 if successful, 0 if the proper config is not found,
11330 * or a negative error code
11331 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011332static int alc861_parse_auto_config(struct hda_codec *codec)
11333{
11334 struct alc_spec *spec = codec->spec;
11335 int err;
11336 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11337
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011338 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11339 alc861_ignore);
11340 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011341 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011342 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011343 return 0; /* can't find valid BIOS pin config */
11344
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011345 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11346 if (err < 0)
11347 return err;
11348 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11349 if (err < 0)
11350 return err;
11351 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11352 if (err < 0)
11353 return err;
11354 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11355 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011356 return err;
11357
11358 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11359
11360 if (spec->autocfg.dig_out_pin)
11361 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11362
11363 if (spec->kctl_alloc)
11364 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11365
11366 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11367
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011368 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011369 spec->input_mux = &spec->private_imux;
11370
11371 spec->adc_nids = alc861_adc_nids;
11372 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11373 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11374 spec->num_mixers++;
11375
11376 return 1;
11377}
11378
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011379/* additional initialization for auto-configuration model */
11380static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011381{
Kailang Yangdf694da2005-12-05 19:42:22 +010011382 alc861_auto_init_multi_out(codec);
11383 alc861_auto_init_hp_out(codec);
11384 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011385}
11386
Takashi Iwaicb53c622007-08-10 17:21:45 +020011387#ifdef CONFIG_SND_HDA_POWER_SAVE
11388static struct hda_amp_list alc861_loopbacks[] = {
11389 { 0x15, HDA_INPUT, 0 },
11390 { 0x15, HDA_INPUT, 1 },
11391 { 0x15, HDA_INPUT, 2 },
11392 { 0x15, HDA_INPUT, 3 },
11393 { } /* end */
11394};
11395#endif
11396
Kailang Yangdf694da2005-12-05 19:42:22 +010011397
11398/*
11399 * configuration and preset
11400 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011401static const char *alc861_models[ALC861_MODEL_LAST] = {
11402 [ALC861_3ST] = "3stack",
11403 [ALC660_3ST] = "3stack-660",
11404 [ALC861_3ST_DIG] = "3stack-dig",
11405 [ALC861_6ST_DIG] = "6stack-dig",
11406 [ALC861_UNIWILL_M31] = "uniwill-m31",
11407 [ALC861_TOSHIBA] = "toshiba",
11408 [ALC861_ASUS] = "asus",
11409 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11410 [ALC861_AUTO] = "auto",
11411};
11412
11413static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011414 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011415 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11416 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11417 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011418 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011419 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011420 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011421 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11422 * Any other models that need this preset?
11423 */
11424 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011425 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11426 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011427 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11428 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11429 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11430 /* FIXME: the below seems conflict */
11431 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11432 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11433 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011434 {}
11435};
11436
11437static struct alc_config_preset alc861_presets[] = {
11438 [ALC861_3ST] = {
11439 .mixers = { alc861_3ST_mixer },
11440 .init_verbs = { alc861_threestack_init_verbs },
11441 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11442 .dac_nids = alc861_dac_nids,
11443 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11444 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011445 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011446 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11447 .adc_nids = alc861_adc_nids,
11448 .input_mux = &alc861_capture_source,
11449 },
11450 [ALC861_3ST_DIG] = {
11451 .mixers = { alc861_base_mixer },
11452 .init_verbs = { alc861_threestack_init_verbs },
11453 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11454 .dac_nids = alc861_dac_nids,
11455 .dig_out_nid = ALC861_DIGOUT_NID,
11456 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11457 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011458 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011459 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11460 .adc_nids = alc861_adc_nids,
11461 .input_mux = &alc861_capture_source,
11462 },
11463 [ALC861_6ST_DIG] = {
11464 .mixers = { alc861_base_mixer },
11465 .init_verbs = { alc861_base_init_verbs },
11466 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11467 .dac_nids = alc861_dac_nids,
11468 .dig_out_nid = ALC861_DIGOUT_NID,
11469 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11470 .channel_mode = alc861_8ch_modes,
11471 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11472 .adc_nids = alc861_adc_nids,
11473 .input_mux = &alc861_capture_source,
11474 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011475 [ALC660_3ST] = {
11476 .mixers = { alc861_3ST_mixer },
11477 .init_verbs = { alc861_threestack_init_verbs },
11478 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11479 .dac_nids = alc660_dac_nids,
11480 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11481 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011482 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011483 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11484 .adc_nids = alc861_adc_nids,
11485 .input_mux = &alc861_capture_source,
11486 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011487 [ALC861_UNIWILL_M31] = {
11488 .mixers = { alc861_uniwill_m31_mixer },
11489 .init_verbs = { alc861_uniwill_m31_init_verbs },
11490 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11491 .dac_nids = alc861_dac_nids,
11492 .dig_out_nid = ALC861_DIGOUT_NID,
11493 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11494 .channel_mode = alc861_uniwill_m31_modes,
11495 .need_dac_fix = 1,
11496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11497 .adc_nids = alc861_adc_nids,
11498 .input_mux = &alc861_capture_source,
11499 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011500 [ALC861_TOSHIBA] = {
11501 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011502 .init_verbs = { alc861_base_init_verbs,
11503 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011504 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11505 .dac_nids = alc861_dac_nids,
11506 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11507 .channel_mode = alc883_3ST_2ch_modes,
11508 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11509 .adc_nids = alc861_adc_nids,
11510 .input_mux = &alc861_capture_source,
11511 .unsol_event = alc861_toshiba_unsol_event,
11512 .init_hook = alc861_toshiba_automute,
11513 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011514 [ALC861_ASUS] = {
11515 .mixers = { alc861_asus_mixer },
11516 .init_verbs = { alc861_asus_init_verbs },
11517 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11518 .dac_nids = alc861_dac_nids,
11519 .dig_out_nid = ALC861_DIGOUT_NID,
11520 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11521 .channel_mode = alc861_asus_modes,
11522 .need_dac_fix = 1,
11523 .hp_nid = 0x06,
11524 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11525 .adc_nids = alc861_adc_nids,
11526 .input_mux = &alc861_capture_source,
11527 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011528 [ALC861_ASUS_LAPTOP] = {
11529 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11530 .init_verbs = { alc861_asus_init_verbs,
11531 alc861_asus_laptop_init_verbs },
11532 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11533 .dac_nids = alc861_dac_nids,
11534 .dig_out_nid = ALC861_DIGOUT_NID,
11535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11536 .channel_mode = alc883_3ST_2ch_modes,
11537 .need_dac_fix = 1,
11538 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11539 .adc_nids = alc861_adc_nids,
11540 .input_mux = &alc861_capture_source,
11541 },
11542};
Kailang Yangdf694da2005-12-05 19:42:22 +010011543
11544
11545static int patch_alc861(struct hda_codec *codec)
11546{
11547 struct alc_spec *spec;
11548 int board_config;
11549 int err;
11550
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011551 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011552 if (spec == NULL)
11553 return -ENOMEM;
11554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011555 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011556
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011557 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11558 alc861_models,
11559 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011560
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011561 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011562 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11563 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011564 board_config = ALC861_AUTO;
11565 }
11566
11567 if (board_config == ALC861_AUTO) {
11568 /* automatic parse from the BIOS config */
11569 err = alc861_parse_auto_config(codec);
11570 if (err < 0) {
11571 alc_free(codec);
11572 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011573 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011574 printk(KERN_INFO
11575 "hda_codec: Cannot set up configuration "
11576 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011577 board_config = ALC861_3ST_DIG;
11578 }
11579 }
11580
11581 if (board_config != ALC861_AUTO)
11582 setup_preset(spec, &alc861_presets[board_config]);
11583
11584 spec->stream_name_analog = "ALC861 Analog";
11585 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11586 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11587
11588 spec->stream_name_digital = "ALC861 Digital";
11589 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11590 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11591
Takashi Iwai2134ea42008-01-10 16:53:55 +010011592 spec->vmaster_nid = 0x03;
11593
Kailang Yangdf694da2005-12-05 19:42:22 +010011594 codec->patch_ops = alc_patch_ops;
11595 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011596 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011597#ifdef CONFIG_SND_HDA_POWER_SAVE
11598 if (!spec->loopback.amplist)
11599 spec->loopback.amplist = alc861_loopbacks;
11600#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011601
11602 return 0;
11603}
11604
11605/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011606 * ALC861-VD support
11607 *
11608 * Based on ALC882
11609 *
11610 * In addition, an independent DAC
11611 */
11612#define ALC861VD_DIGOUT_NID 0x06
11613
11614static hda_nid_t alc861vd_dac_nids[4] = {
11615 /* front, surr, clfe, side surr */
11616 0x02, 0x03, 0x04, 0x05
11617};
11618
11619/* dac_nids for ALC660vd are in a different order - according to
11620 * Realtek's driver.
11621 * This should probably tesult in a different mixer for 6stack models
11622 * of ALC660vd codecs, but for now there is only 3stack mixer
11623 * - and it is the same as in 861vd.
11624 * adc_nids in ALC660vd are (is) the same as in 861vd
11625 */
11626static hda_nid_t alc660vd_dac_nids[3] = {
11627 /* front, rear, clfe, rear_surr */
11628 0x02, 0x04, 0x03
11629};
11630
11631static hda_nid_t alc861vd_adc_nids[1] = {
11632 /* ADC0 */
11633 0x09,
11634};
11635
11636/* input MUX */
11637/* FIXME: should be a matrix-type input source selection */
11638static struct hda_input_mux alc861vd_capture_source = {
11639 .num_items = 4,
11640 .items = {
11641 { "Mic", 0x0 },
11642 { "Front Mic", 0x1 },
11643 { "Line", 0x2 },
11644 { "CD", 0x4 },
11645 },
11646};
11647
Kailang Yang272a5272007-05-14 11:00:38 +020011648static struct hda_input_mux alc861vd_dallas_capture_source = {
11649 .num_items = 3,
11650 .items = {
11651 { "Front Mic", 0x0 },
11652 { "ATAPI Mic", 0x1 },
11653 { "Line In", 0x5 },
11654 },
11655};
11656
Kailang Yangd1a991a2007-08-15 16:21:59 +020011657static struct hda_input_mux alc861vd_hp_capture_source = {
11658 .num_items = 2,
11659 .items = {
11660 { "Front Mic", 0x0 },
11661 { "ATAPI Mic", 0x1 },
11662 },
11663};
11664
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011665#define alc861vd_mux_enum_info alc_mux_enum_info
11666#define alc861vd_mux_enum_get alc_mux_enum_get
11667
11668static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11669 struct snd_ctl_elem_value *ucontrol)
11670{
11671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11672 struct alc_spec *spec = codec->spec;
11673 const struct hda_input_mux *imux = spec->input_mux;
11674 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11675 static hda_nid_t capture_mixers[1] = { 0x22 };
11676 hda_nid_t nid = capture_mixers[adc_idx];
11677 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11678 unsigned int i, idx;
11679
11680 idx = ucontrol->value.enumerated.item[0];
11681 if (idx >= imux->num_items)
11682 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011683 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011684 return 0;
11685 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011686 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11687 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11688 imux->items[i].index,
11689 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011690 }
11691 *cur_val = idx;
11692 return 1;
11693}
11694
11695/*
11696 * 2ch mode
11697 */
11698static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11699 { 2, NULL }
11700};
11701
11702/*
11703 * 6ch mode
11704 */
11705static struct hda_verb alc861vd_6stack_ch6_init[] = {
11706 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11707 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11708 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11709 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11710 { } /* end */
11711};
11712
11713/*
11714 * 8ch mode
11715 */
11716static struct hda_verb alc861vd_6stack_ch8_init[] = {
11717 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11718 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11719 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11720 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11721 { } /* end */
11722};
11723
11724static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11725 { 6, alc861vd_6stack_ch6_init },
11726 { 8, alc861vd_6stack_ch8_init },
11727};
11728
11729static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11730 {
11731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11732 .name = "Channel Mode",
11733 .info = alc_ch_mode_info,
11734 .get = alc_ch_mode_get,
11735 .put = alc_ch_mode_put,
11736 },
11737 { } /* end */
11738};
11739
11740static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11741 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11742 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11743
11744 {
11745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11746 /* The multiple "Capture Source" controls confuse alsamixer
11747 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011748 */
11749 /* .name = "Capture Source", */
11750 .name = "Input Source",
11751 .count = 1,
11752 .info = alc861vd_mux_enum_info,
11753 .get = alc861vd_mux_enum_get,
11754 .put = alc861vd_mux_enum_put,
11755 },
11756 { } /* end */
11757};
11758
11759/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11760 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11761 */
11762static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11763 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11764 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11765
11766 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11767 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11768
11769 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11770 HDA_OUTPUT),
11771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11772 HDA_OUTPUT),
11773 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11774 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11775
11776 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11777 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11778
11779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11780
11781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11784
11785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11787 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11788
11789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11791
11792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11794
11795 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11796 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11797
11798 { } /* end */
11799};
11800
11801static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11802 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11804
11805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11806
11807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11810
11811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11812 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11814
11815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11817
11818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11820
11821 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11822 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11823
11824 { } /* end */
11825};
11826
Kailang Yangbdd148a2007-05-08 15:19:08 +020011827static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11828 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11829 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11830 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11831
11832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11833
11834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11837
11838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11839 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11840 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11841
11842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11844
11845 { } /* end */
11846};
11847
Kailang Yang272a5272007-05-14 11:00:38 +020011848/* Pin assignment: Front=0x14, HP = 0x15,
11849 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11850 */
11851static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11852 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11858 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11859 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011862 { } /* end */
11863};
11864
Kailang Yangd1a991a2007-08-15 16:21:59 +020011865/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11866 * Front Mic=0x18, ATAPI Mic = 0x19,
11867 */
11868static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11869 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11870 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11871 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11872 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11875 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11876 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11877
11878 { } /* end */
11879};
11880
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011881/*
11882 * generic initialization of ADC, input mixers and output mixers
11883 */
11884static struct hda_verb alc861vd_volume_init_verbs[] = {
11885 /*
11886 * Unmute ADC0 and set the default input to mic-in
11887 */
11888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11890
11891 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11892 * the analog-loopback mixer widget
11893 */
11894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011900
11901 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011906
11907 /*
11908 * Set up output mixers (0x02 - 0x05)
11909 */
11910 /* set vol=0 to output mixers */
11911 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11913 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11914 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11915
11916 /* set up input amps for analog loopback */
11917 /* Amp Indices: DAC = 0, mixer = 1 */
11918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11926
11927 { }
11928};
11929
11930/*
11931 * 3-stack pin configuration:
11932 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11933 */
11934static struct hda_verb alc861vd_3stack_init_verbs[] = {
11935 /*
11936 * Set pin mode and muting
11937 */
11938 /* set front pin widgets 0x14 for output */
11939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11941 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11942
11943 /* Mic (rear) pin: input vref at 80% */
11944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11945 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11946 /* Front Mic pin: input vref at 80% */
11947 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11949 /* Line In pin: input */
11950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11951 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11952 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11953 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11954 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11955 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11956 /* CD pin widget for input */
11957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11958
11959 { }
11960};
11961
11962/*
11963 * 6-stack pin configuration:
11964 */
11965static struct hda_verb alc861vd_6stack_init_verbs[] = {
11966 /*
11967 * Set pin mode and muting
11968 */
11969 /* set front pin widgets 0x14 for output */
11970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11972 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11973
11974 /* Rear Pin: output 1 (0x0d) */
11975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11978 /* CLFE Pin: output 2 (0x0e) */
11979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11982 /* Side Pin: output 3 (0x0f) */
11983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11985 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11986
11987 /* Mic (rear) pin: input vref at 80% */
11988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11990 /* Front Mic pin: input vref at 80% */
11991 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11993 /* Line In pin: input */
11994 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11996 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12000 /* CD pin widget for input */
12001 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12002
12003 { }
12004};
12005
Kailang Yangbdd148a2007-05-08 15:19:08 +020012006static struct hda_verb alc861vd_eapd_verbs[] = {
12007 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12008 { }
12009};
12010
12011static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12012 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12015 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12016 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12017 {}
12018};
12019
12020/* toggle speaker-output according to the hp-jack state */
12021static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12022{
12023 unsigned int present;
12024 unsigned char bits;
12025
12026 present = snd_hda_codec_read(codec, 0x1b, 0,
12027 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012028 bits = present ? HDA_AMP_MUTE : 0;
12029 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12030 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012031}
12032
12033static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12034{
12035 unsigned int present;
12036 unsigned char bits;
12037
12038 present = snd_hda_codec_read(codec, 0x18, 0,
12039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012040 bits = present ? HDA_AMP_MUTE : 0;
12041 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12042 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012043}
12044
12045static void alc861vd_lenovo_automute(struct hda_codec *codec)
12046{
12047 alc861vd_lenovo_hp_automute(codec);
12048 alc861vd_lenovo_mic_automute(codec);
12049}
12050
12051static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12052 unsigned int res)
12053{
12054 switch (res >> 26) {
12055 case ALC880_HP_EVENT:
12056 alc861vd_lenovo_hp_automute(codec);
12057 break;
12058 case ALC880_MIC_EVENT:
12059 alc861vd_lenovo_mic_automute(codec);
12060 break;
12061 }
12062}
12063
Kailang Yang272a5272007-05-14 11:00:38 +020012064static struct hda_verb alc861vd_dallas_verbs[] = {
12065 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12069
12070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12078
12079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12087
12088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12090 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12095 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12096
12097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12101
12102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12105
12106 { } /* end */
12107};
12108
12109/* toggle speaker-output according to the hp-jack state */
12110static void alc861vd_dallas_automute(struct hda_codec *codec)
12111{
12112 unsigned int present;
12113
12114 present = snd_hda_codec_read(codec, 0x15, 0,
12115 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12117 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012118}
12119
12120static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12121{
12122 if ((res >> 26) == ALC880_HP_EVENT)
12123 alc861vd_dallas_automute(codec);
12124}
12125
Takashi Iwaicb53c622007-08-10 17:21:45 +020012126#ifdef CONFIG_SND_HDA_POWER_SAVE
12127#define alc861vd_loopbacks alc880_loopbacks
12128#endif
12129
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012130/* pcm configuration: identiacal with ALC880 */
12131#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12132#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12133#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12134#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12135
12136/*
12137 * configuration and preset
12138 */
12139static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12140 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012141 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012142 [ALC861VD_3ST] = "3stack",
12143 [ALC861VD_3ST_DIG] = "3stack-digout",
12144 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012145 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012146 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012147 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012148 [ALC861VD_AUTO] = "auto",
12149};
12150
12151static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012152 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12153 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012154 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012155 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012156 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012157 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012158 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012159 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012160 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012161 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012162 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012163 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12164 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012165 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012166 {}
12167};
12168
12169static struct alc_config_preset alc861vd_presets[] = {
12170 [ALC660VD_3ST] = {
12171 .mixers = { alc861vd_3st_mixer },
12172 .init_verbs = { alc861vd_volume_init_verbs,
12173 alc861vd_3stack_init_verbs },
12174 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12175 .dac_nids = alc660vd_dac_nids,
12176 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12177 .adc_nids = alc861vd_adc_nids,
12178 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12179 .channel_mode = alc861vd_3stack_2ch_modes,
12180 .input_mux = &alc861vd_capture_source,
12181 },
Mike Crash6963f842007-06-25 12:12:51 +020012182 [ALC660VD_3ST_DIG] = {
12183 .mixers = { alc861vd_3st_mixer },
12184 .init_verbs = { alc861vd_volume_init_verbs,
12185 alc861vd_3stack_init_verbs },
12186 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12187 .dac_nids = alc660vd_dac_nids,
12188 .dig_out_nid = ALC861VD_DIGOUT_NID,
12189 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12190 .adc_nids = alc861vd_adc_nids,
12191 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12192 .channel_mode = alc861vd_3stack_2ch_modes,
12193 .input_mux = &alc861vd_capture_source,
12194 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012195 [ALC861VD_3ST] = {
12196 .mixers = { alc861vd_3st_mixer },
12197 .init_verbs = { alc861vd_volume_init_verbs,
12198 alc861vd_3stack_init_verbs },
12199 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12200 .dac_nids = alc861vd_dac_nids,
12201 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12202 .channel_mode = alc861vd_3stack_2ch_modes,
12203 .input_mux = &alc861vd_capture_source,
12204 },
12205 [ALC861VD_3ST_DIG] = {
12206 .mixers = { alc861vd_3st_mixer },
12207 .init_verbs = { alc861vd_volume_init_verbs,
12208 alc861vd_3stack_init_verbs },
12209 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12210 .dac_nids = alc861vd_dac_nids,
12211 .dig_out_nid = ALC861VD_DIGOUT_NID,
12212 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12213 .channel_mode = alc861vd_3stack_2ch_modes,
12214 .input_mux = &alc861vd_capture_source,
12215 },
12216 [ALC861VD_6ST_DIG] = {
12217 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12218 .init_verbs = { alc861vd_volume_init_verbs,
12219 alc861vd_6stack_init_verbs },
12220 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12221 .dac_nids = alc861vd_dac_nids,
12222 .dig_out_nid = ALC861VD_DIGOUT_NID,
12223 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12224 .channel_mode = alc861vd_6stack_modes,
12225 .input_mux = &alc861vd_capture_source,
12226 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012227 [ALC861VD_LENOVO] = {
12228 .mixers = { alc861vd_lenovo_mixer },
12229 .init_verbs = { alc861vd_volume_init_verbs,
12230 alc861vd_3stack_init_verbs,
12231 alc861vd_eapd_verbs,
12232 alc861vd_lenovo_unsol_verbs },
12233 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12234 .dac_nids = alc660vd_dac_nids,
12235 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12236 .adc_nids = alc861vd_adc_nids,
12237 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12238 .channel_mode = alc861vd_3stack_2ch_modes,
12239 .input_mux = &alc861vd_capture_source,
12240 .unsol_event = alc861vd_lenovo_unsol_event,
12241 .init_hook = alc861vd_lenovo_automute,
12242 },
Kailang Yang272a5272007-05-14 11:00:38 +020012243 [ALC861VD_DALLAS] = {
12244 .mixers = { alc861vd_dallas_mixer },
12245 .init_verbs = { alc861vd_dallas_verbs },
12246 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12247 .dac_nids = alc861vd_dac_nids,
12248 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12249 .adc_nids = alc861vd_adc_nids,
12250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12251 .channel_mode = alc861vd_3stack_2ch_modes,
12252 .input_mux = &alc861vd_dallas_capture_source,
12253 .unsol_event = alc861vd_dallas_unsol_event,
12254 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012255 },
12256 [ALC861VD_HP] = {
12257 .mixers = { alc861vd_hp_mixer },
12258 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12259 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12260 .dac_nids = alc861vd_dac_nids,
12261 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12262 .dig_out_nid = ALC861VD_DIGOUT_NID,
12263 .adc_nids = alc861vd_adc_nids,
12264 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12265 .channel_mode = alc861vd_3stack_2ch_modes,
12266 .input_mux = &alc861vd_hp_capture_source,
12267 .unsol_event = alc861vd_dallas_unsol_event,
12268 .init_hook = alc861vd_dallas_automute,
12269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012270};
12271
12272/*
12273 * BIOS auto configuration
12274 */
12275static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12276 hda_nid_t nid, int pin_type, int dac_idx)
12277{
12278 /* set as output */
12279 snd_hda_codec_write(codec, nid, 0,
12280 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12281 snd_hda_codec_write(codec, nid, 0,
12282 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12283}
12284
12285static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12286{
12287 struct alc_spec *spec = codec->spec;
12288 int i;
12289
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012290 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012291 for (i = 0; i <= HDA_SIDE; i++) {
12292 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012293 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012294 if (nid)
12295 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012296 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012297 }
12298}
12299
12300
12301static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12302{
12303 struct alc_spec *spec = codec->spec;
12304 hda_nid_t pin;
12305
12306 pin = spec->autocfg.hp_pins[0];
12307 if (pin) /* connect to front and use dac 0 */
12308 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12309}
12310
12311#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12312#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12313
12314static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12315{
12316 struct alc_spec *spec = codec->spec;
12317 int i;
12318
12319 for (i = 0; i < AUTO_PIN_LAST; i++) {
12320 hda_nid_t nid = spec->autocfg.input_pins[i];
12321 if (alc861vd_is_input_pin(nid)) {
12322 snd_hda_codec_write(codec, nid, 0,
12323 AC_VERB_SET_PIN_WIDGET_CONTROL,
12324 i <= AUTO_PIN_FRONT_MIC ?
12325 PIN_VREF80 : PIN_IN);
12326 if (nid != ALC861VD_PIN_CD_NID)
12327 snd_hda_codec_write(codec, nid, 0,
12328 AC_VERB_SET_AMP_GAIN_MUTE,
12329 AMP_OUT_MUTE);
12330 }
12331 }
12332}
12333
12334#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12335#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12336
12337/* add playback controls from the parsed DAC table */
12338/* Based on ALC880 version. But ALC861VD has separate,
12339 * different NIDs for mute/unmute switch and volume control */
12340static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12341 const struct auto_pin_cfg *cfg)
12342{
12343 char name[32];
12344 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12345 hda_nid_t nid_v, nid_s;
12346 int i, err;
12347
12348 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012349 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012350 continue;
12351 nid_v = alc861vd_idx_to_mixer_vol(
12352 alc880_dac_to_idx(
12353 spec->multiout.dac_nids[i]));
12354 nid_s = alc861vd_idx_to_mixer_switch(
12355 alc880_dac_to_idx(
12356 spec->multiout.dac_nids[i]));
12357
12358 if (i == 2) {
12359 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012360 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12361 "Center Playback Volume",
12362 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12363 HDA_OUTPUT));
12364 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012365 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012366 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12367 "LFE Playback Volume",
12368 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12369 HDA_OUTPUT));
12370 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012372 err = add_control(spec, ALC_CTL_BIND_MUTE,
12373 "Center Playback Switch",
12374 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12375 HDA_INPUT));
12376 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012377 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012378 err = add_control(spec, ALC_CTL_BIND_MUTE,
12379 "LFE Playback Switch",
12380 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12381 HDA_INPUT));
12382 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012383 return err;
12384 } else {
12385 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012386 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12387 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12388 HDA_OUTPUT));
12389 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012390 return err;
12391 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012392 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012393 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012394 HDA_INPUT));
12395 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012396 return err;
12397 }
12398 }
12399 return 0;
12400}
12401
12402/* add playback controls for speaker and HP outputs */
12403/* Based on ALC880 version. But ALC861VD has separate,
12404 * different NIDs for mute/unmute switch and volume control */
12405static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12406 hda_nid_t pin, const char *pfx)
12407{
12408 hda_nid_t nid_v, nid_s;
12409 int err;
12410 char name[32];
12411
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012412 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012413 return 0;
12414
12415 if (alc880_is_fixed_pin(pin)) {
12416 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12417 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012418 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012419 spec->multiout.hp_nid = nid_v;
12420 else
12421 spec->multiout.extra_out_nid[0] = nid_v;
12422 /* control HP volume/switch on the output mixer amp */
12423 nid_v = alc861vd_idx_to_mixer_vol(
12424 alc880_fixed_pin_idx(pin));
12425 nid_s = alc861vd_idx_to_mixer_switch(
12426 alc880_fixed_pin_idx(pin));
12427
12428 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012429 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12430 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12431 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012432 return err;
12433 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012434 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12435 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12436 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012437 return err;
12438 } else if (alc880_is_multi_pin(pin)) {
12439 /* set manual connection */
12440 /* we have only a switch on HP-out PIN */
12441 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012442 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12443 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12444 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012445 return err;
12446 }
12447 return 0;
12448}
12449
12450/* parse the BIOS configuration and set up the alc_spec
12451 * return 1 if successful, 0 if the proper config is not found,
12452 * or a negative error code
12453 * Based on ALC880 version - had to change it to override
12454 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12455static int alc861vd_parse_auto_config(struct hda_codec *codec)
12456{
12457 struct alc_spec *spec = codec->spec;
12458 int err;
12459 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12460
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012461 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12462 alc861vd_ignore);
12463 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012464 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012465 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012466 return 0; /* can't find valid BIOS pin config */
12467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012468 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12469 if (err < 0)
12470 return err;
12471 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12472 if (err < 0)
12473 return err;
12474 err = alc861vd_auto_create_extra_out(spec,
12475 spec->autocfg.speaker_pins[0],
12476 "Speaker");
12477 if (err < 0)
12478 return err;
12479 err = alc861vd_auto_create_extra_out(spec,
12480 spec->autocfg.hp_pins[0],
12481 "Headphone");
12482 if (err < 0)
12483 return err;
12484 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12485 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012486 return err;
12487
12488 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12489
12490 if (spec->autocfg.dig_out_pin)
12491 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12492
12493 if (spec->kctl_alloc)
12494 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12495
12496 spec->init_verbs[spec->num_init_verbs++]
12497 = alc861vd_volume_init_verbs;
12498
12499 spec->num_mux_defs = 1;
12500 spec->input_mux = &spec->private_imux;
12501
Takashi Iwai776e1842007-08-29 15:07:11 +020012502 err = alc_auto_add_mic_boost(codec);
12503 if (err < 0)
12504 return err;
12505
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012506 return 1;
12507}
12508
12509/* additional initialization for auto-configuration model */
12510static void alc861vd_auto_init(struct hda_codec *codec)
12511{
12512 alc861vd_auto_init_multi_out(codec);
12513 alc861vd_auto_init_hp_out(codec);
12514 alc861vd_auto_init_analog_input(codec);
12515}
12516
12517static int patch_alc861vd(struct hda_codec *codec)
12518{
12519 struct alc_spec *spec;
12520 int err, board_config;
12521
12522 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12523 if (spec == NULL)
12524 return -ENOMEM;
12525
12526 codec->spec = spec;
12527
12528 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12529 alc861vd_models,
12530 alc861vd_cfg_tbl);
12531
12532 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12533 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12534 "ALC861VD, trying auto-probe from BIOS...\n");
12535 board_config = ALC861VD_AUTO;
12536 }
12537
12538 if (board_config == ALC861VD_AUTO) {
12539 /* automatic parse from the BIOS config */
12540 err = alc861vd_parse_auto_config(codec);
12541 if (err < 0) {
12542 alc_free(codec);
12543 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012544 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012545 printk(KERN_INFO
12546 "hda_codec: Cannot set up configuration "
12547 "from BIOS. Using base mode...\n");
12548 board_config = ALC861VD_3ST;
12549 }
12550 }
12551
12552 if (board_config != ALC861VD_AUTO)
12553 setup_preset(spec, &alc861vd_presets[board_config]);
12554
12555 spec->stream_name_analog = "ALC861VD Analog";
12556 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12557 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12558
12559 spec->stream_name_digital = "ALC861VD Digital";
12560 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12561 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12562
12563 spec->adc_nids = alc861vd_adc_nids;
12564 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12565
12566 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12567 spec->num_mixers++;
12568
Takashi Iwai2134ea42008-01-10 16:53:55 +010012569 spec->vmaster_nid = 0x02;
12570
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012571 codec->patch_ops = alc_patch_ops;
12572
12573 if (board_config == ALC861VD_AUTO)
12574 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012575#ifdef CONFIG_SND_HDA_POWER_SAVE
12576 if (!spec->loopback.amplist)
12577 spec->loopback.amplist = alc861vd_loopbacks;
12578#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012579
12580 return 0;
12581}
12582
12583/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012584 * ALC662 support
12585 *
12586 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12587 * configuration. Each pin widget can choose any input DACs and a mixer.
12588 * Each ADC is connected from a mixer of all inputs. This makes possible
12589 * 6-channel independent captures.
12590 *
12591 * In addition, an independent DAC for the multi-playback (not used in this
12592 * driver yet).
12593 */
12594#define ALC662_DIGOUT_NID 0x06
12595#define ALC662_DIGIN_NID 0x0a
12596
12597static hda_nid_t alc662_dac_nids[4] = {
12598 /* front, rear, clfe, rear_surr */
12599 0x02, 0x03, 0x04
12600};
12601
12602static hda_nid_t alc662_adc_nids[1] = {
12603 /* ADC1-2 */
12604 0x09,
12605};
12606/* input MUX */
12607/* FIXME: should be a matrix-type input source selection */
12608
12609static struct hda_input_mux alc662_capture_source = {
12610 .num_items = 4,
12611 .items = {
12612 { "Mic", 0x0 },
12613 { "Front Mic", 0x1 },
12614 { "Line", 0x2 },
12615 { "CD", 0x4 },
12616 },
12617};
12618
12619static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12620 .num_items = 2,
12621 .items = {
12622 { "Mic", 0x1 },
12623 { "Line", 0x2 },
12624 },
12625};
Kailang Yang291702f2007-10-16 14:28:03 +020012626
12627static struct hda_input_mux alc662_eeepc_capture_source = {
12628 .num_items = 2,
12629 .items = {
12630 { "i-Mic", 0x1 },
12631 { "e-Mic", 0x0 },
12632 },
12633};
12634
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012635#define alc662_mux_enum_info alc_mux_enum_info
12636#define alc662_mux_enum_get alc_mux_enum_get
12637
12638static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12639 struct snd_ctl_elem_value *ucontrol)
12640{
12641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12642 struct alc_spec *spec = codec->spec;
12643 const struct hda_input_mux *imux = spec->input_mux;
12644 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012645 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012646 hda_nid_t nid = capture_mixers[adc_idx];
12647 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12648 unsigned int i, idx;
12649
12650 idx = ucontrol->value.enumerated.item[0];
12651 if (idx >= imux->num_items)
12652 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012653 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012654 return 0;
12655 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012656 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12657 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12658 imux->items[i].index,
12659 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012660 }
12661 *cur_val = idx;
12662 return 1;
12663}
12664/*
12665 * 2ch mode
12666 */
12667static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12668 { 2, NULL }
12669};
12670
12671/*
12672 * 2ch mode
12673 */
12674static struct hda_verb alc662_3ST_ch2_init[] = {
12675 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12676 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12677 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12678 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12679 { } /* end */
12680};
12681
12682/*
12683 * 6ch mode
12684 */
12685static struct hda_verb alc662_3ST_ch6_init[] = {
12686 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12687 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12688 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12691 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12692 { } /* end */
12693};
12694
12695static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12696 { 2, alc662_3ST_ch2_init },
12697 { 6, alc662_3ST_ch6_init },
12698};
12699
12700/*
12701 * 2ch mode
12702 */
12703static struct hda_verb alc662_sixstack_ch6_init[] = {
12704 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12706 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12707 { } /* end */
12708};
12709
12710/*
12711 * 6ch mode
12712 */
12713static struct hda_verb alc662_sixstack_ch8_init[] = {
12714 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12715 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12716 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12717 { } /* end */
12718};
12719
12720static struct hda_channel_mode alc662_5stack_modes[2] = {
12721 { 2, alc662_sixstack_ch6_init },
12722 { 6, alc662_sixstack_ch8_init },
12723};
12724
12725/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12726 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12727 */
12728
12729static struct snd_kcontrol_new alc662_base_mixer[] = {
12730 /* output mixer control */
12731 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12732 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12733 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12735 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12736 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12737 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12738 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12740
12741 /*Input mixer control */
12742 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12743 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12744 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12745 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12746 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12747 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12749 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012750 { } /* end */
12751};
12752
12753static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12754 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12755 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12757 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12758 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12759 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12760 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12763 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12764 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12765 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12766 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012767 { } /* end */
12768};
12769
12770static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12771 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12772 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12773 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12774 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12787 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12788 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12789 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012790 { } /* end */
12791};
12792
12793static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12794 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12795 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012796 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12797 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12801 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012803 { } /* end */
12804};
12805
Kailang Yang291702f2007-10-16 14:28:03 +020012806static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010012807 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012808
12809 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12810 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12811
12812 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12813 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12814 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12815
12816 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12817 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12818 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12819 { } /* end */
12820};
12821
Kailang Yang8c427222008-01-10 13:03:59 +010012822static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12823 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12824 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12826 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012831 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010012832 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12837 { } /* end */
12838};
12839
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012840static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12841 {
12842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12843 .name = "Channel Mode",
12844 .info = alc_ch_mode_info,
12845 .get = alc_ch_mode_get,
12846 .put = alc_ch_mode_put,
12847 },
12848 { } /* end */
12849};
12850
12851static struct hda_verb alc662_init_verbs[] = {
12852 /* ADC: mute amp left and right */
12853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12854 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12855 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12856
Takashi Iwaicb53c622007-08-10 17:21:45 +020012857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012862
Kailang Yangb60dd392007-09-20 12:50:29 +020012863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012869
12870 /* Front Pin: output 0 (0x0c) */
12871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12873
12874 /* Rear Pin: output 1 (0x0d) */
12875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12877
12878 /* CLFE Pin: output 2 (0x0e) */
12879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12881
12882 /* Mic (rear) pin: input vref at 80% */
12883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12885 /* Front Mic pin: input vref at 80% */
12886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12888 /* Line In pin: input */
12889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12891 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12894 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12895 /* CD pin widget for input */
12896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12897
12898 /* FIXME: use matrix-type input source selection */
12899 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12900 /* Input mixer */
12901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012905
12906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012910 { }
12911};
12912
12913static struct hda_verb alc662_sue_init_verbs[] = {
12914 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12915 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012916 {}
12917};
12918
12919static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12922 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012923};
12924
Kailang Yang8c427222008-01-10 13:03:59 +010012925/* Set Unsolicited Event*/
12926static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12927 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12928 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12929 {}
12930};
12931
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012932/*
12933 * generic initialization of ADC, input mixers and output mixers
12934 */
12935static struct hda_verb alc662_auto_init_verbs[] = {
12936 /*
12937 * Unmute ADC and set the default input to mic-in
12938 */
12939 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12941
12942 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12943 * mixer widget
12944 * Note: PASD motherboards uses the Line In 2 as the input for front
12945 * panel mic (mic 2)
12946 */
12947 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012953
12954 /*
12955 * Set up output mixers (0x0c - 0x0f)
12956 */
12957 /* set vol=0 to output mixers */
12958 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12959 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12960 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12961
12962 /* set up input amps for analog loopback */
12963 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12966 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012970
12971
12972 /* FIXME: use matrix-type input source selection */
12973 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12974 /* Input mixer */
12975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012977 { }
12978};
12979
12980/* capture mixer elements */
12981static struct snd_kcontrol_new alc662_capture_mixer[] = {
12982 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12983 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12984 {
12985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12986 /* The multiple "Capture Source" controls confuse alsamixer
12987 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012988 */
12989 /* .name = "Capture Source", */
12990 .name = "Input Source",
12991 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012992 .info = alc662_mux_enum_info,
12993 .get = alc662_mux_enum_get,
12994 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012995 },
12996 { } /* end */
12997};
12998
12999static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13000{
13001 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013002 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013003
13004 present = snd_hda_codec_read(codec, 0x14, 0,
13005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013006 bits = present ? HDA_AMP_MUTE : 0;
13007 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13008 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013009}
13010
13011static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13012{
13013 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013014 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013015
13016 present = snd_hda_codec_read(codec, 0x1b, 0,
13017 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013018 bits = present ? HDA_AMP_MUTE : 0;
13019 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13020 HDA_AMP_MUTE, bits);
13021 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13022 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013023}
13024
13025static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13026 unsigned int res)
13027{
13028 if ((res >> 26) == ALC880_HP_EVENT)
13029 alc662_lenovo_101e_all_automute(codec);
13030 if ((res >> 26) == ALC880_FRONT_EVENT)
13031 alc662_lenovo_101e_ispeaker_automute(codec);
13032}
13033
Kailang Yang291702f2007-10-16 14:28:03 +020013034static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13035{
13036 unsigned int present;
13037
13038 present = snd_hda_codec_read(codec, 0x18, 0,
13039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13040 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13041 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13042 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13043 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13044 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13045 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13046 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13047 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13048}
13049
13050/* unsolicited event for HP jack sensing */
13051static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13052 unsigned int res)
13053{
13054 if ((res >> 26) == ALC880_HP_EVENT)
13055 alc262_hippo1_automute( codec );
13056
13057 if ((res >> 26) == ALC880_MIC_EVENT)
13058 alc662_eeepc_mic_automute(codec);
13059}
13060
13061static void alc662_eeepc_inithook(struct hda_codec *codec)
13062{
13063 alc262_hippo1_automute( codec );
13064 alc662_eeepc_mic_automute(codec);
13065}
13066
Kailang Yang8c427222008-01-10 13:03:59 +010013067static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13068{
13069 unsigned int mute;
13070 unsigned int present;
13071
13072 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13073 present = snd_hda_codec_read(codec, 0x14, 0,
13074 AC_VERB_GET_PIN_SENSE, 0);
13075 present = (present & 0x80000000) != 0;
13076 if (present) {
13077 /* mute internal speaker */
13078 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13079 HDA_AMP_MUTE, HDA_AMP_MUTE);
13080 } else {
13081 /* unmute internal speaker if necessary */
13082 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13083 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13084 HDA_AMP_MUTE, mute);
13085 }
13086}
13087
13088/* unsolicited event for HP jack sensing */
13089static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13090 unsigned int res)
13091{
13092 if ((res >> 26) == ALC880_HP_EVENT)
13093 alc662_eeepc_ep20_automute(codec);
13094}
13095
13096static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13097{
13098 alc662_eeepc_ep20_automute(codec);
13099}
13100
Takashi Iwaicb53c622007-08-10 17:21:45 +020013101#ifdef CONFIG_SND_HDA_POWER_SAVE
13102#define alc662_loopbacks alc880_loopbacks
13103#endif
13104
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013105
13106/* pcm configuration: identiacal with ALC880 */
13107#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13108#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13109#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13110#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13111
13112/*
13113 * configuration and preset
13114 */
13115static const char *alc662_models[ALC662_MODEL_LAST] = {
13116 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13117 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13118 [ALC662_3ST_6ch] = "3stack-6ch",
13119 [ALC662_5ST_DIG] = "6stack-dig",
13120 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013121 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013122 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013123 [ALC662_AUTO] = "auto",
13124};
13125
13126static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013127 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013128 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013129 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013130 {}
13131};
13132
13133static struct alc_config_preset alc662_presets[] = {
13134 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013135 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013136 .init_verbs = { alc662_init_verbs },
13137 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13138 .dac_nids = alc662_dac_nids,
13139 .dig_out_nid = ALC662_DIGOUT_NID,
13140 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13141 .adc_nids = alc662_adc_nids,
13142 .dig_in_nid = ALC662_DIGIN_NID,
13143 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13144 .channel_mode = alc662_3ST_2ch_modes,
13145 .input_mux = &alc662_capture_source,
13146 },
13147 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013148 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13149 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013150 .init_verbs = { alc662_init_verbs },
13151 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13152 .dac_nids = alc662_dac_nids,
13153 .dig_out_nid = ALC662_DIGOUT_NID,
13154 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13155 .adc_nids = alc662_adc_nids,
13156 .dig_in_nid = ALC662_DIGIN_NID,
13157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13158 .channel_mode = alc662_3ST_6ch_modes,
13159 .need_dac_fix = 1,
13160 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013161 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013162 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013163 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13164 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013165 .init_verbs = { alc662_init_verbs },
13166 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13167 .dac_nids = alc662_dac_nids,
13168 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13169 .adc_nids = alc662_adc_nids,
13170 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13171 .channel_mode = alc662_3ST_6ch_modes,
13172 .need_dac_fix = 1,
13173 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013174 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013175 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013176 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13177 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013178 .init_verbs = { alc662_init_verbs },
13179 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13180 .dac_nids = alc662_dac_nids,
13181 .dig_out_nid = ALC662_DIGOUT_NID,
13182 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13183 .adc_nids = alc662_adc_nids,
13184 .dig_in_nid = ALC662_DIGIN_NID,
13185 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13186 .channel_mode = alc662_5stack_modes,
13187 .input_mux = &alc662_capture_source,
13188 },
13189 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013190 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013191 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13192 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13193 .dac_nids = alc662_dac_nids,
13194 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13195 .adc_nids = alc662_adc_nids,
13196 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13197 .channel_mode = alc662_3ST_2ch_modes,
13198 .input_mux = &alc662_lenovo_101e_capture_source,
13199 .unsol_event = alc662_lenovo_101e_unsol_event,
13200 .init_hook = alc662_lenovo_101e_all_automute,
13201 },
Kailang Yang291702f2007-10-16 14:28:03 +020013202 [ALC662_ASUS_EEEPC_P701] = {
13203 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13204 .init_verbs = { alc662_init_verbs,
13205 alc662_eeepc_sue_init_verbs },
13206 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13207 .dac_nids = alc662_dac_nids,
13208 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13209 .adc_nids = alc662_adc_nids,
13210 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13211 .channel_mode = alc662_3ST_2ch_modes,
13212 .input_mux = &alc662_eeepc_capture_source,
13213 .unsol_event = alc662_eeepc_unsol_event,
13214 .init_hook = alc662_eeepc_inithook,
13215 },
Kailang Yang8c427222008-01-10 13:03:59 +010013216 [ALC662_ASUS_EEEPC_EP20] = {
13217 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13218 alc662_chmode_mixer },
13219 .init_verbs = { alc662_init_verbs,
13220 alc662_eeepc_ep20_sue_init_verbs },
13221 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13222 .dac_nids = alc662_dac_nids,
13223 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13224 .adc_nids = alc662_adc_nids,
13225 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13226 .channel_mode = alc662_3ST_6ch_modes,
13227 .input_mux = &alc662_lenovo_101e_capture_source,
13228 .unsol_event = alc662_eeepc_ep20_unsol_event,
13229 .init_hook = alc662_eeepc_ep20_inithook,
13230 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013231
13232};
13233
13234
13235/*
13236 * BIOS auto configuration
13237 */
13238
13239/* add playback controls from the parsed DAC table */
13240static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13241 const struct auto_pin_cfg *cfg)
13242{
13243 char name[32];
13244 static const char *chname[4] = {
13245 "Front", "Surround", NULL /*CLFE*/, "Side"
13246 };
13247 hda_nid_t nid;
13248 int i, err;
13249
13250 for (i = 0; i < cfg->line_outs; i++) {
13251 if (!spec->multiout.dac_nids[i])
13252 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013253 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013254 if (i == 2) {
13255 /* Center/LFE */
13256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13257 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013258 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13259 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013260 if (err < 0)
13261 return err;
13262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13263 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013264 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13265 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013266 if (err < 0)
13267 return err;
13268 err = add_control(spec, ALC_CTL_BIND_MUTE,
13269 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013270 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13271 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013272 if (err < 0)
13273 return err;
13274 err = add_control(spec, ALC_CTL_BIND_MUTE,
13275 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013276 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13277 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013278 if (err < 0)
13279 return err;
13280 } else {
13281 sprintf(name, "%s Playback Volume", chname[i]);
13282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013283 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13284 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013285 if (err < 0)
13286 return err;
13287 sprintf(name, "%s Playback Switch", chname[i]);
13288 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013289 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13290 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013291 if (err < 0)
13292 return err;
13293 }
13294 }
13295 return 0;
13296}
13297
13298/* add playback controls for speaker and HP outputs */
13299static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13300 const char *pfx)
13301{
13302 hda_nid_t nid;
13303 int err;
13304 char name[32];
13305
13306 if (!pin)
13307 return 0;
13308
13309 if (alc880_is_fixed_pin(pin)) {
13310 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13311 /* printk("DAC nid=%x\n",nid); */
13312 /* specify the DAC as the extra output */
13313 if (!spec->multiout.hp_nid)
13314 spec->multiout.hp_nid = nid;
13315 else
13316 spec->multiout.extra_out_nid[0] = nid;
13317 /* control HP volume/switch on the output mixer amp */
13318 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13319 sprintf(name, "%s Playback Volume", pfx);
13320 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13321 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13322 if (err < 0)
13323 return err;
13324 sprintf(name, "%s Playback Switch", pfx);
13325 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13326 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13327 if (err < 0)
13328 return err;
13329 } else if (alc880_is_multi_pin(pin)) {
13330 /* set manual connection */
13331 /* we have only a switch on HP-out PIN */
13332 sprintf(name, "%s Playback Switch", pfx);
13333 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13334 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13335 if (err < 0)
13336 return err;
13337 }
13338 return 0;
13339}
13340
13341/* create playback/capture controls for input pins */
13342static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13343 const struct auto_pin_cfg *cfg)
13344{
13345 struct hda_input_mux *imux = &spec->private_imux;
13346 int i, err, idx;
13347
13348 for (i = 0; i < AUTO_PIN_LAST; i++) {
13349 if (alc880_is_input_pin(cfg->input_pins[i])) {
13350 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13351 err = new_analog_input(spec, cfg->input_pins[i],
13352 auto_pin_cfg_labels[i],
13353 idx, 0x0b);
13354 if (err < 0)
13355 return err;
13356 imux->items[imux->num_items].label =
13357 auto_pin_cfg_labels[i];
13358 imux->items[imux->num_items].index =
13359 alc880_input_pin_idx(cfg->input_pins[i]);
13360 imux->num_items++;
13361 }
13362 }
13363 return 0;
13364}
13365
13366static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13367 hda_nid_t nid, int pin_type,
13368 int dac_idx)
13369{
13370 /* set as output */
13371 snd_hda_codec_write(codec, nid, 0,
13372 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13373 snd_hda_codec_write(codec, nid, 0,
13374 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13375 /* need the manual connection? */
13376 if (alc880_is_multi_pin(nid)) {
13377 struct alc_spec *spec = codec->spec;
13378 int idx = alc880_multi_pin_idx(nid);
13379 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13380 AC_VERB_SET_CONNECT_SEL,
13381 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13382 }
13383}
13384
13385static void alc662_auto_init_multi_out(struct hda_codec *codec)
13386{
13387 struct alc_spec *spec = codec->spec;
13388 int i;
13389
Kailang Yang8c427222008-01-10 13:03:59 +010013390 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013391 for (i = 0; i <= HDA_SIDE; i++) {
13392 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013393 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013394 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013395 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013396 i);
13397 }
13398}
13399
13400static void alc662_auto_init_hp_out(struct hda_codec *codec)
13401{
13402 struct alc_spec *spec = codec->spec;
13403 hda_nid_t pin;
13404
13405 pin = spec->autocfg.hp_pins[0];
13406 if (pin) /* connect to front */
13407 /* use dac 0 */
13408 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13409}
13410
13411#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13412#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13413
13414static void alc662_auto_init_analog_input(struct hda_codec *codec)
13415{
13416 struct alc_spec *spec = codec->spec;
13417 int i;
13418
13419 for (i = 0; i < AUTO_PIN_LAST; i++) {
13420 hda_nid_t nid = spec->autocfg.input_pins[i];
13421 if (alc662_is_input_pin(nid)) {
13422 snd_hda_codec_write(codec, nid, 0,
13423 AC_VERB_SET_PIN_WIDGET_CONTROL,
13424 (i <= AUTO_PIN_FRONT_MIC ?
13425 PIN_VREF80 : PIN_IN));
13426 if (nid != ALC662_PIN_CD_NID)
13427 snd_hda_codec_write(codec, nid, 0,
13428 AC_VERB_SET_AMP_GAIN_MUTE,
13429 AMP_OUT_MUTE);
13430 }
13431 }
13432}
13433
13434static int alc662_parse_auto_config(struct hda_codec *codec)
13435{
13436 struct alc_spec *spec = codec->spec;
13437 int err;
13438 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13439
13440 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13441 alc662_ignore);
13442 if (err < 0)
13443 return err;
13444 if (!spec->autocfg.line_outs)
13445 return 0; /* can't find valid BIOS pin config */
13446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013447 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13448 if (err < 0)
13449 return err;
13450 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13451 if (err < 0)
13452 return err;
13453 err = alc662_auto_create_extra_out(spec,
13454 spec->autocfg.speaker_pins[0],
13455 "Speaker");
13456 if (err < 0)
13457 return err;
13458 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13459 "Headphone");
13460 if (err < 0)
13461 return err;
13462 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13463 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013464 return err;
13465
13466 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13467
13468 if (spec->autocfg.dig_out_pin)
13469 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13470
13471 if (spec->kctl_alloc)
13472 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13473
13474 spec->num_mux_defs = 1;
13475 spec->input_mux = &spec->private_imux;
13476
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013477 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013478 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13479 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013480 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013481}
13482
13483/* additional initialization for auto-configuration model */
13484static void alc662_auto_init(struct hda_codec *codec)
13485{
13486 alc662_auto_init_multi_out(codec);
13487 alc662_auto_init_hp_out(codec);
13488 alc662_auto_init_analog_input(codec);
13489}
13490
13491static int patch_alc662(struct hda_codec *codec)
13492{
13493 struct alc_spec *spec;
13494 int err, board_config;
13495
13496 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13497 if (!spec)
13498 return -ENOMEM;
13499
13500 codec->spec = spec;
13501
13502 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13503 alc662_models,
13504 alc662_cfg_tbl);
13505 if (board_config < 0) {
13506 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13507 "trying auto-probe from BIOS...\n");
13508 board_config = ALC662_AUTO;
13509 }
13510
13511 if (board_config == ALC662_AUTO) {
13512 /* automatic parse from the BIOS config */
13513 err = alc662_parse_auto_config(codec);
13514 if (err < 0) {
13515 alc_free(codec);
13516 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013517 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013518 printk(KERN_INFO
13519 "hda_codec: Cannot set up configuration "
13520 "from BIOS. Using base mode...\n");
13521 board_config = ALC662_3ST_2ch_DIG;
13522 }
13523 }
13524
13525 if (board_config != ALC662_AUTO)
13526 setup_preset(spec, &alc662_presets[board_config]);
13527
13528 spec->stream_name_analog = "ALC662 Analog";
13529 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13530 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13531
13532 spec->stream_name_digital = "ALC662 Digital";
13533 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13534 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13535
13536 if (!spec->adc_nids && spec->input_mux) {
13537 spec->adc_nids = alc662_adc_nids;
13538 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13539 }
13540
Takashi Iwai2134ea42008-01-10 16:53:55 +010013541 spec->vmaster_nid = 0x02;
13542
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013543 codec->patch_ops = alc_patch_ops;
13544 if (board_config == ALC662_AUTO)
13545 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013546#ifdef CONFIG_SND_HDA_POWER_SAVE
13547 if (!spec->loopback.amplist)
13548 spec->loopback.amplist = alc662_loopbacks;
13549#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013550
13551 return 0;
13552}
13553
13554/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013555 * patch entries
13556 */
13557struct hda_codec_preset snd_hda_preset_realtek[] = {
13558 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013559 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013560 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013561 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013562 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013563 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013564 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013565 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13566 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13567 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013568 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13569 .patch = patch_alc883 },
13570 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13571 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013572 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013573 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013574 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013575 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013576 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013577 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013578 {} /* terminator */
13579};