blob: 45e661e42c0bd121f65e54079c56fa71fbf3ddd2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
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 Woithe7cf51e42006-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,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100110 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100111#ifdef CONFIG_SND_DEBUG
112 ALC268_TEST,
113#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_AUTO,
115 ALC268_MODEL_LAST /* last tag */
116};
117
Kailang Yangf6a92242007-12-13 16:52:54 +0100118/* ALC269 models */
119enum {
120 ALC269_BASIC,
121 ALC269_AUTO,
122 ALC269_MODEL_LAST /* last tag */
123};
124
Kailang Yangdf694da2005-12-05 19:42:22 +0100125/* ALC861 models */
126enum {
127 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200128 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100129 ALC861_3ST_DIG,
130 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200131 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200132 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200133 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100134 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100135 ALC861_AUTO,
136 ALC861_MODEL_LAST,
137};
138
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100139/* ALC861-VD models */
140enum {
141 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200142 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100143 ALC861VD_3ST,
144 ALC861VD_3ST_DIG,
145 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200146 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200147 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200148 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100149 ALC861VD_AUTO,
150 ALC861VD_MODEL_LAST,
151};
152
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200153/* ALC662 models */
154enum {
155 ALC662_3ST_2ch_DIG,
156 ALC662_3ST_6ch_DIG,
157 ALC662_3ST_6ch,
158 ALC662_5ST_DIG,
159 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200160 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100161 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200162 ALC662_AUTO,
163 ALC662_MODEL_LAST,
164};
165
Kailang Yangdf694da2005-12-05 19:42:22 +0100166/* ALC882 models */
167enum {
168 ALC882_3ST_DIG,
169 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200170 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200171 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200172 ALC882_TARGA,
173 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200174 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100175 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200176 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200177 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200178 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100179 ALC882_MODEL_LAST,
180};
181
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200182/* ALC883 models */
183enum {
184 ALC883_3ST_2ch_DIG,
185 ALC883_3ST_6ch_DIG,
186 ALC883_3ST_6ch,
187 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200188 ALC883_TARGA_DIG,
189 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200190 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200191 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200192 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200193 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100194 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200195 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200196 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200197 ALC888_LENOVO_MS7195_DIG,
198 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200199 ALC888_6ST_HP,
200 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100201 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100202 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200203 ALC883_AUTO,
204 ALC883_MODEL_LAST,
205};
206
Kailang Yangdf694da2005-12-05 19:42:22 +0100207/* for GPIO Poll */
208#define GPIO_MASK 0x03
209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210struct alc_spec {
211 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 unsigned int num_mixers;
214
Kailang Yangdf694da2005-12-05 19:42:22 +0100215 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200216 * don't forget NULL
217 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200218 */
219 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Takashi Iwai16ded522005-06-10 19:58:24 +0200221 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 struct hda_pcm_stream *stream_analog_playback;
223 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100224 struct hda_pcm_stream *stream_analog_alt_playback;
225 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200227 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 struct hda_pcm_stream *stream_digital_playback;
229 struct hda_pcm_stream *stream_digital_capture;
230
231 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200232 struct hda_multi_out multiout; /* playback set-up
233 * max_channels, dacs must be set
234 * dig_out_nid and hp_nid are optional
235 */
Takashi Iwai63300792008-01-24 15:31:36 +0100236 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 /* capture */
239 unsigned int num_adc_nids;
240 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200241 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200244 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 const struct hda_input_mux *input_mux;
246 unsigned int cur_mux[3];
247
248 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100249 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200251 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100254 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200255
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200256 /* dynamic controls, init_verbs and input_mux */
257 struct auto_pin_cfg autocfg;
258 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100259 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200260 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200261 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100262
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100263 /* hooks */
264 void (*init_hook)(struct hda_codec *codec);
265 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
266
Takashi Iwai834be882006-03-01 14:16:17 +0100267 /* for pin sensing */
268 unsigned int sense_updated: 1;
269 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100270 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200271
Takashi Iwai2134ea42008-01-10 16:53:55 +0100272 /* for virtual master */
273 hda_nid_t vmaster_nid;
274 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200275#ifdef CONFIG_SND_HDA_POWER_SAVE
276 struct hda_loopback_check loopback;
277#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100278};
279
280/*
281 * configuration template - to be copied to the spec instance
282 */
283struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200284 struct snd_kcontrol_new *mixers[5]; /* should be identical size
285 * with spec
286 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100287 const struct hda_verb *init_verbs[5];
288 unsigned int num_dacs;
289 hda_nid_t *dac_nids;
290 hda_nid_t dig_out_nid; /* optional */
291 hda_nid_t hp_nid; /* optional */
292 unsigned int num_adc_nids;
293 hda_nid_t *adc_nids;
294 hda_nid_t dig_in_nid;
295 unsigned int num_channel_mode;
296 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200297 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200298 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100299 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100300 void (*unsol_event)(struct hda_codec *, unsigned int);
301 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200302#ifdef CONFIG_SND_HDA_POWER_SAVE
303 struct hda_amp_list *loopbacks;
304#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305};
306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
308/*
309 * input MUX handling
310 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200311static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200316 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
317 if (mux_idx >= spec->num_mux_defs)
318 mux_idx = 0;
319 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200322static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
323 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324{
325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
326 struct alc_spec *spec = codec->spec;
327 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
328
329 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
330 return 0;
331}
332
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200333static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
337 struct alc_spec *spec = codec->spec;
338 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200339 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
340 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200341 spec->adc_nids[adc_idx],
342 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343}
344
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346/*
347 * channel mode setting
348 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200349static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
350 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351{
352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
353 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100354 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
355 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356}
357
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200358static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
359 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360{
361 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
362 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100363 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200364 spec->num_channel_mode,
365 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
367
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200368static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200373 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
374 spec->num_channel_mode,
375 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200376 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200377 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
378 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379}
380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100382 * Control the mode of pin widget settings via the mixer. "pc" is used
383 * instead of "%" to avoid consequences of accidently treating the % as
384 * being part of a format specifier. Maximum allowed length of a value is
385 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100386 *
387 * Note: some retasking pin complexes seem to ignore requests for input
388 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
389 * are requested. Therefore order this list so that this behaviour will not
390 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
392 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200393 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100394static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100395 "Mic 50pc bias", "Mic 80pc bias",
396 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397};
398static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100399 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100400};
401/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200402 * in the pin being assumed to be exclusively an input or an output pin. In
403 * addition, "input" pins may or may not process the mic bias option
404 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
405 * accept requests for bias as of chip versions up to March 2006) and/or
406 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200408#define ALC_PIN_DIR_IN 0x00
409#define ALC_PIN_DIR_OUT 0x01
410#define ALC_PIN_DIR_INOUT 0x02
411#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
412#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200414/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100415 * For each direction the minimum and maximum values are given.
416 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200417static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 { 0, 2 }, /* ALC_PIN_DIR_IN */
419 { 3, 4 }, /* ALC_PIN_DIR_OUT */
420 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200421 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
422 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423};
424#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
425#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
426#define alc_pin_mode_n_items(_dir) \
427 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
428
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200429static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
430 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200431{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432 unsigned int item_num = uinfo->value.enumerated.item;
433 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
434
435 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200436 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
438
439 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
440 item_num = alc_pin_mode_min(dir);
441 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200442 return 0;
443}
444
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200452 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
454 AC_VERB_GET_PIN_WIDGET_CONTROL,
455 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200456
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457 /* Find enumerated value for current pinctl setting */
458 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462 return 0;
463}
464
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467{
468 signed int change;
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 hda_nid_t nid = kcontrol->private_value & 0xffff;
471 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
472 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
474 AC_VERB_GET_PIN_WIDGET_CONTROL,
475 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200477 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 val = alc_pin_mode_min(dir);
479
480 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100481 if (change) {
482 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200483 snd_hda_codec_write_cache(codec, nid, 0,
484 AC_VERB_SET_PIN_WIDGET_CONTROL,
485 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100486
487 /* Also enable the retasking pin's input/output as required
488 * for the requested pin mode. Enum values of 2 or less are
489 * input modes.
490 *
491 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200492 * reduces noise slightly (particularly on input) so we'll
493 * do it. However, having both input and output buffers
494 * enabled simultaneously doesn't seem to be problematic if
495 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100496 */
497 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200498 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
499 HDA_AMP_MUTE, HDA_AMP_MUTE);
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
501 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100502 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200503 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
504 HDA_AMP_MUTE, HDA_AMP_MUTE);
505 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
506 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100507 }
508 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200509 return change;
510}
511
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200513 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 .info = alc_pin_mode_info, \
515 .get = alc_pin_mode_get, \
516 .put = alc_pin_mode_put, \
517 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100518
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100519/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
520 * together using a mask with more than one bit set. This control is
521 * currently used only by the ALC260 test model. At this stage they are not
522 * needed for any "production" models.
523 */
524#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200525#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200526
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100529{
530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
531 hda_nid_t nid = kcontrol->private_value & 0xffff;
532 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
533 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534 unsigned int val = snd_hda_codec_read(codec, nid, 0,
535 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100536
537 *valp = (val & mask) != 0;
538 return 0;
539}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100542{
543 signed int change;
544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
545 hda_nid_t nid = kcontrol->private_value & 0xffff;
546 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
547 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
549 AC_VERB_GET_GPIO_DATA,
550 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100551
552 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
554 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100555 gpio_data &= ~mask;
556 else
557 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200558 snd_hda_codec_write_cache(codec, nid, 0,
559 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100560
561 return change;
562}
563#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
564 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
565 .info = alc_gpio_data_info, \
566 .get = alc_gpio_data_get, \
567 .put = alc_gpio_data_put, \
568 .private_value = nid | (mask<<16) }
569#endif /* CONFIG_SND_DEBUG */
570
Jonathan Woithe92621f12006-02-28 11:47:47 +0100571/* A switch control to allow the enabling of the digital IO pins on the
572 * ALC260. This is incredibly simplistic; the intention of this control is
573 * to provide something in the test model allowing digital outputs to be
574 * identified if present. If models are found which can utilise these
575 * outputs a more complete mixer control can be devised for those models if
576 * necessary.
577 */
578#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200579#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200580
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
582 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100583{
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 hda_nid_t nid = kcontrol->private_value & 0xffff;
586 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
587 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100589 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100590
591 *valp = (val & mask) != 0;
592 return 0;
593}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200594static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100596{
597 signed int change;
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 hda_nid_t nid = kcontrol->private_value & 0xffff;
600 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
601 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100603 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100605
606 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100608 if (val==0)
609 ctrl_data &= ~mask;
610 else
611 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200612 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
613 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100614
615 return change;
616}
617#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
618 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
619 .info = alc_spdif_ctrl_info, \
620 .get = alc_spdif_ctrl_get, \
621 .put = alc_spdif_ctrl_put, \
622 .private_value = nid | (mask<<16) }
623#endif /* CONFIG_SND_DEBUG */
624
Jonathan Woithef8225f62008-01-08 12:16:54 +0100625/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
626 * Again, this is only used in the ALC26x test models to help identify when
627 * the EAPD line must be asserted for features to work.
628 */
629#ifdef CONFIG_SND_DEBUG
630#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
631
632static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 hda_nid_t nid = kcontrol->private_value & 0xffff;
637 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
638 long *valp = ucontrol->value.integer.value;
639 unsigned int val = snd_hda_codec_read(codec, nid, 0,
640 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
641
642 *valp = (val & mask) != 0;
643 return 0;
644}
645
646static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
647 struct snd_ctl_elem_value *ucontrol)
648{
649 int change;
650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
651 hda_nid_t nid = kcontrol->private_value & 0xffff;
652 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
653 long val = *ucontrol->value.integer.value;
654 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
655 AC_VERB_GET_EAPD_BTLENABLE,
656 0x00);
657
658 /* Set/unset the masked control bit(s) as needed */
659 change = (!val ? 0 : mask) != (ctrl_data & mask);
660 if (!val)
661 ctrl_data &= ~mask;
662 else
663 ctrl_data |= mask;
664 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
665 ctrl_data);
666
667 return change;
668}
669
670#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
671 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
672 .info = alc_eapd_ctrl_info, \
673 .get = alc_eapd_ctrl_get, \
674 .put = alc_eapd_ctrl_put, \
675 .private_value = nid | (mask<<16) }
676#endif /* CONFIG_SND_DEBUG */
677
Kailang Yangdf694da2005-12-05 19:42:22 +0100678/*
679 * set up from the preset table
680 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200681static void setup_preset(struct alc_spec *spec,
682 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100683{
684 int i;
685
686 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
687 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200688 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
689 i++)
690 spec->init_verbs[spec->num_init_verbs++] =
691 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100692
693 spec->channel_mode = preset->channel_mode;
694 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200695 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100696
697 spec->multiout.max_channels = spec->channel_mode[0].channels;
698
699 spec->multiout.num_dacs = preset->num_dacs;
700 spec->multiout.dac_nids = preset->dac_nids;
701 spec->multiout.dig_out_nid = preset->dig_out_nid;
702 spec->multiout.hp_nid = preset->hp_nid;
703
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200704 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200705 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200706 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100707 spec->input_mux = preset->input_mux;
708
709 spec->num_adc_nids = preset->num_adc_nids;
710 spec->adc_nids = preset->adc_nids;
711 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100712
713 spec->unsol_event = preset->unsol_event;
714 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200715#ifdef CONFIG_SND_HDA_POWER_SAVE
716 spec->loopback.amplist = preset->loopbacks;
717#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100718}
719
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200720/* Enable GPIO mask and set output */
721static struct hda_verb alc_gpio1_init_verbs[] = {
722 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
723 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
724 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
725 { }
726};
727
728static struct hda_verb alc_gpio2_init_verbs[] = {
729 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
730 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
731 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
732 { }
733};
734
Kailang Yangbdd148a2007-05-08 15:19:08 +0200735static struct hda_verb alc_gpio3_init_verbs[] = {
736 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
737 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
738 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
739 { }
740};
741
Kailang Yangc9b58002007-10-16 14:30:01 +0200742static void alc_sku_automute(struct hda_codec *codec)
743{
744 struct alc_spec *spec = codec->spec;
745 unsigned int mute;
746 unsigned int present;
747 unsigned int hp_nid = spec->autocfg.hp_pins[0];
748 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
749
750 /* need to execute and sync at first */
751 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
752 present = snd_hda_codec_read(codec, hp_nid, 0,
753 AC_VERB_GET_PIN_SENSE, 0);
754 spec->jack_present = (present & 0x80000000) != 0;
755 if (spec->jack_present) {
756 /* mute internal speaker */
757 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
758 HDA_AMP_MUTE, HDA_AMP_MUTE);
759 } else {
760 /* unmute internal speaker if necessary */
761 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
762 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
763 HDA_AMP_MUTE, mute);
764 }
765}
766
767/* unsolicited event for HP jack sensing */
768static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
769{
770 if (codec->vendor_id == 0x10ec0880)
771 res >>= 28;
772 else
773 res >>= 26;
774 if (res != ALC880_HP_EVENT)
775 return;
776
777 alc_sku_automute(codec);
778}
779
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200780/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
781 * 31 ~ 16 : Manufacture ID
782 * 15 ~ 8 : SKU ID
783 * 7 ~ 0 : Assembly ID
784 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
785 */
786static void alc_subsystem_id(struct hda_codec *codec,
787 unsigned int porta, unsigned int porte,
788 unsigned int portd)
789{
Kailang Yangc9b58002007-10-16 14:30:01 +0200790 unsigned int ass, tmp, i;
791 unsigned nid;
792 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200793
Kailang Yangc9b58002007-10-16 14:30:01 +0200794 ass = codec->subsystem_id & 0xffff;
795 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
796 goto do_sku;
797
798 /*
799 * 31~30 : port conetcivity
800 * 29~21 : reserve
801 * 20 : PCBEEP input
802 * 19~16 : Check sum (15:1)
803 * 15~1 : Custom
804 * 0 : override
805 */
806 nid = 0x1d;
807 if (codec->vendor_id == 0x10ec0260)
808 nid = 0x17;
809 ass = snd_hda_codec_read(codec, nid, 0,
810 AC_VERB_GET_CONFIG_DEFAULT, 0);
811 if (!(ass & 1) && !(ass & 0x100000))
812 return;
813 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200814 return;
815
Kailang Yangc9b58002007-10-16 14:30:01 +0200816 /* check sum */
817 tmp = 0;
818 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100819 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200820 tmp++;
821 }
822 if (((ass >> 16) & 0xf) != tmp)
823 return;
824do_sku:
825 /*
826 * 0 : override
827 * 1 : Swap Jack
828 * 2 : 0 --> Desktop, 1 --> Laptop
829 * 3~5 : External Amplifier control
830 * 7~6 : Reserved
831 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200832 tmp = (ass & 0x38) >> 3; /* external Amp control */
833 switch (tmp) {
834 case 1:
835 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
836 break;
837 case 3:
838 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
839 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200840 case 7:
841 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
842 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200843 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200844 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200845 case 0x10ec0260:
846 snd_hda_codec_write(codec, 0x0f, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 snd_hda_codec_write(codec, 0x10, 0,
849 AC_VERB_SET_EAPD_BTLENABLE, 2);
850 break;
851 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200852 case 0x10ec0267:
853 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200854 case 0x10ec0269:
855 case 0x10ec0862:
856 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200857 snd_hda_codec_write(codec, 0x14, 0,
858 AC_VERB_SET_EAPD_BTLENABLE, 2);
859 snd_hda_codec_write(codec, 0x15, 0,
860 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200861 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200862 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200863 switch (codec->vendor_id) {
864 case 0x10ec0260:
865 snd_hda_codec_write(codec, 0x1a, 0,
866 AC_VERB_SET_COEF_INDEX, 7);
867 tmp = snd_hda_codec_read(codec, 0x1a, 0,
868 AC_VERB_GET_PROC_COEF, 0);
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_COEF_INDEX, 7);
871 snd_hda_codec_write(codec, 0x1a, 0,
872 AC_VERB_SET_PROC_COEF,
873 tmp | 0x2010);
874 break;
875 case 0x10ec0262:
876 case 0x10ec0880:
877 case 0x10ec0882:
878 case 0x10ec0883:
879 case 0x10ec0885:
880 case 0x10ec0888:
881 snd_hda_codec_write(codec, 0x20, 0,
882 AC_VERB_SET_COEF_INDEX, 7);
883 tmp = snd_hda_codec_read(codec, 0x20, 0,
884 AC_VERB_GET_PROC_COEF, 0);
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_COEF_INDEX, 7);
887 snd_hda_codec_write(codec, 0x20, 0,
888 AC_VERB_SET_PROC_COEF,
889 tmp | 0x2010);
890 break;
891 case 0x10ec0267:
892 case 0x10ec0268:
893 snd_hda_codec_write(codec, 0x20, 0,
894 AC_VERB_SET_COEF_INDEX, 7);
895 tmp = snd_hda_codec_read(codec, 0x20, 0,
896 AC_VERB_GET_PROC_COEF, 0);
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_COEF_INDEX, 7);
899 snd_hda_codec_write(codec, 0x20, 0,
900 AC_VERB_SET_PROC_COEF,
901 tmp | 0x3000);
902 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200903 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200904 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200905 break;
906 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200907
Kailang Yang8c427222008-01-10 13:03:59 +0100908 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200909 * when the external headphone out jack is plugged"
910 */
Kailang Yang8c427222008-01-10 13:03:59 +0100911 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200912 return;
913 /*
914 * 10~8 : Jack location
915 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
916 * 14~13: Resvered
917 * 15 : 1 --> enable the function "Mute internal speaker
918 * when the external headphone out jack is plugged"
919 */
920 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100921 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100923 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200924 else
925 return;
926 }
927
928 if (!spec->autocfg.hp_pins[0]) {
929 tmp = (ass >> 11) & 0x3; /* HP to chassis */
930 if (tmp == 0)
931 spec->autocfg.hp_pins[0] = porta;
932 else if (tmp == 1)
933 spec->autocfg.hp_pins[0] = porte;
934 else if (tmp == 2)
935 spec->autocfg.hp_pins[0] = portd;
936 else
937 return;
938 }
939
940 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
941 AC_VERB_SET_UNSOLICITED_ENABLE,
942 AC_USRSP_EN | ALC880_HP_EVENT);
943 spec->unsol_event = alc_sku_unsol_event;
944 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200945}
946
Takashi Iwai41e41f12005-06-08 14:48:49 +0200947/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200948 * Fix-up pin default configurations
949 */
950
951struct alc_pincfg {
952 hda_nid_t nid;
953 u32 val;
954};
955
956static void alc_fix_pincfg(struct hda_codec *codec,
957 const struct snd_pci_quirk *quirk,
958 const struct alc_pincfg **pinfix)
959{
960 const struct alc_pincfg *cfg;
961
962 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
963 if (!quirk)
964 return;
965
966 cfg = pinfix[quirk->value];
967 for (; cfg->nid; cfg++) {
968 int i;
969 u32 val = cfg->val;
970 for (i = 0; i < 4; i++) {
971 snd_hda_codec_write(codec, cfg->nid, 0,
972 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
973 val & 0xff);
974 val >>= 8;
975 }
976 }
977}
978
979/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200980 * ALC880 3-stack model
981 *
982 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200983 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
984 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 */
986
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200987static hda_nid_t alc880_dac_nids[4] = {
988 /* front, rear, clfe, rear_surr */
989 0x02, 0x05, 0x04, 0x03
990};
991
992static hda_nid_t alc880_adc_nids[3] = {
993 /* ADC0-2 */
994 0x07, 0x08, 0x09,
995};
996
997/* The datasheet says the node 0x07 is connected from inputs,
998 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100999 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001001static hda_nid_t alc880_adc_nids_alt[2] = {
1002 /* ADC1-2 */
1003 0x08, 0x09,
1004};
1005
1006#define ALC880_DIGOUT_NID 0x06
1007#define ALC880_DIGIN_NID 0x0a
1008
1009static struct hda_input_mux alc880_capture_source = {
1010 .num_items = 4,
1011 .items = {
1012 { "Mic", 0x0 },
1013 { "Front Mic", 0x3 },
1014 { "Line", 0x2 },
1015 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001017};
1018
1019/* channel source setting (2/6 channel selection for 3-stack) */
1020/* 2ch mode */
1021static struct hda_verb alc880_threestack_ch2_init[] = {
1022 /* set line-in to input, mute it */
1023 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1024 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1025 /* set mic-in to input vref 80%, mute it */
1026 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1027 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 { } /* end */
1029};
1030
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001031/* 6ch mode */
1032static struct hda_verb alc880_threestack_ch6_init[] = {
1033 /* set line-in to output, unmute it */
1034 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1035 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1036 /* set mic-in to output, unmute it */
1037 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1038 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1039 { } /* end */
1040};
1041
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001042static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001043 { 2, alc880_threestack_ch2_init },
1044 { 6, alc880_threestack_ch6_init },
1045};
1046
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001047static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001049 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001050 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001051 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001052 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001054 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1055 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1064 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1065 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067 {
1068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1069 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001070 .info = alc_ch_mode_info,
1071 .get = alc_ch_mode_get,
1072 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 },
1074 { } /* end */
1075};
1076
1077/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001078static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001079 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1083 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1084 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1085 {
1086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1087 /* The multiple "Capture Source" controls confuse alsamixer
1088 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001089 */
1090 /* .name = "Capture Source", */
1091 .name = "Input Source",
1092 .count = 3,
1093 .info = alc_mux_enum_info,
1094 .get = alc_mux_enum_get,
1095 .put = alc_mux_enum_put,
1096 },
1097 { } /* end */
1098};
1099
1100/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001101static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001102 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 {
1107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1108 /* The multiple "Capture Source" controls confuse alsamixer
1109 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 */
1111 /* .name = "Capture Source", */
1112 .name = "Input Source",
1113 .count = 2,
1114 .info = alc_mux_enum_info,
1115 .get = alc_mux_enum_get,
1116 .put = alc_mux_enum_put,
1117 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 { } /* end */
1119};
1120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001121
1122
1123/*
1124 * ALC880 5-stack model
1125 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001126 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1127 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1129 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1130 */
1131
1132/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001133static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001135 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 { } /* end */
1137};
1138
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001139/* channel source setting (6/8 channel selection for 5-stack) */
1140/* 6ch mode */
1141static struct hda_verb alc880_fivestack_ch6_init[] = {
1142 /* set line-in to input, mute it */
1143 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1144 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001145 { } /* end */
1146};
1147
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148/* 8ch mode */
1149static struct hda_verb alc880_fivestack_ch8_init[] = {
1150 /* set line-in to output, unmute it */
1151 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1152 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1153 { } /* end */
1154};
1155
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001156static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001157 { 6, alc880_fivestack_ch6_init },
1158 { 8, alc880_fivestack_ch8_init },
1159};
1160
1161
1162/*
1163 * ALC880 6-stack model
1164 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001165 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1166 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001167 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1168 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1169 */
1170
1171static hda_nid_t alc880_6st_dac_nids[4] = {
1172 /* front, rear, clfe, rear_surr */
1173 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001174};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001175
1176static struct hda_input_mux alc880_6stack_capture_source = {
1177 .num_items = 4,
1178 .items = {
1179 { "Mic", 0x0 },
1180 { "Front Mic", 0x1 },
1181 { "Line", 0x2 },
1182 { "CD", 0x4 },
1183 },
1184};
1185
1186/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001187static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001188 { 8, NULL },
1189};
1190
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001191static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001195 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001196 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1197 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001198 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1199 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001200 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001201 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1208 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1209 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1210 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1211 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001212 {
1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1214 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001215 .info = alc_ch_mode_info,
1216 .get = alc_ch_mode_get,
1217 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001218 },
1219 { } /* end */
1220};
1221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001222
1223/*
1224 * ALC880 W810 model
1225 *
1226 * W810 has rear IO for:
1227 * Front (DAC 02)
1228 * Surround (DAC 03)
1229 * Center/LFE (DAC 04)
1230 * Digital out (06)
1231 *
1232 * The system also has a pair of internal speakers, and a headphone jack.
1233 * These are both connected to Line2 on the codec, hence to DAC 02.
1234 *
1235 * There is a variable resistor to control the speaker or headphone
1236 * volume. This is a hardware-only device without a software API.
1237 *
1238 * Plugging headphones in will disable the internal speakers. This is
1239 * implemented in hardware, not via the driver using jack sense. In
1240 * a similar fashion, plugging into the rear socket marked "front" will
1241 * disable both the speakers and headphones.
1242 *
1243 * For input, there's a microphone jack, and an "audio in" jack.
1244 * These may not do anything useful with this driver yet, because I
1245 * haven't setup any initialization verbs for these yet...
1246 */
1247
1248static hda_nid_t alc880_w810_dac_nids[3] = {
1249 /* front, rear/surround, clfe */
1250 0x02, 0x03, 0x04
1251};
1252
1253/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001254static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001255 { 6, NULL }
1256};
1257
1258/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001259static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001263 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1265 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001266 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1267 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1269 { } /* end */
1270};
1271
1272
1273/*
1274 * Z710V model
1275 *
1276 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001277 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1278 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 */
1280
1281static hda_nid_t alc880_z71v_dac_nids[1] = {
1282 0x02
1283};
1284#define ALC880_Z71V_HP_DAC 0x03
1285
1286/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001287static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 { 2, NULL }
1289};
1290
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001291static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001293 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001295 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1297 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1300 { } /* end */
1301};
1302
1303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304/*
1305 * ALC880 F1734 model
1306 *
1307 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1308 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1309 */
1310
1311static hda_nid_t alc880_f1734_dac_nids[1] = {
1312 0x03
1313};
1314#define ALC880_F1734_HP_DAC 0x02
1315
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001316static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001317 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001318 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001319 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1320 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001325 { } /* end */
1326};
1327
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001328
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001329/*
1330 * ALC880 ASUS model
1331 *
1332 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1333 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1334 * Mic = 0x18, Line = 0x1a
1335 */
1336
1337#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1338#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1339
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001340static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001341 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001342 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001343 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001344 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001345 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1346 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001347 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1348 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001355 {
1356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1357 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001358 .info = alc_ch_mode_info,
1359 .get = alc_ch_mode_get,
1360 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001361 },
1362 { } /* end */
1363};
1364
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001365/*
1366 * ALC880 ASUS W1V model
1367 *
1368 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1369 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1370 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1371 */
1372
1373/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001374static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001375 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1376 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001377 { } /* end */
1378};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001379
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001380/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001381static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001382 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1383 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1384 { } /* end */
1385};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001386
Kailang Yangdf694da2005-12-05 19:42:22 +01001387/* TCL S700 */
1388static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1389 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1393 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1397 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1398 {
1399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1400 /* The multiple "Capture Source" controls confuse alsamixer
1401 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001402 */
1403 /* .name = "Capture Source", */
1404 .name = "Input Source",
1405 .count = 1,
1406 .info = alc_mux_enum_info,
1407 .get = alc_mux_enum_get,
1408 .put = alc_mux_enum_put,
1409 },
1410 { } /* end */
1411};
1412
Kailang Yangccc656c2006-10-17 12:32:26 +02001413/* Uniwill */
1414static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001415 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1417 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1418 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001419 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1423 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1428 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1430 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1431 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1432 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1433 {
1434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1435 .name = "Channel Mode",
1436 .info = alc_ch_mode_info,
1437 .get = alc_ch_mode_get,
1438 .put = alc_ch_mode_put,
1439 },
1440 { } /* end */
1441};
1442
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001443static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1444 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1447 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1451 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1453 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1454 { } /* end */
1455};
1456
Kailang Yangccc656c2006-10-17 12:32:26 +02001457static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1460 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1461 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1464 { } /* end */
1465};
1466
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001468 * virtual master controls
1469 */
1470
1471/*
1472 * slave controls for virtual master
1473 */
1474static const char *alc_slave_vols[] = {
1475 "Front Playback Volume",
1476 "Surround Playback Volume",
1477 "Center Playback Volume",
1478 "LFE Playback Volume",
1479 "Side Playback Volume",
1480 "Headphone Playback Volume",
1481 "Speaker Playback Volume",
1482 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001483 "Line-Out Playback Volume",
1484 NULL,
1485};
1486
1487static const char *alc_slave_sws[] = {
1488 "Front Playback Switch",
1489 "Surround Playback Switch",
1490 "Center Playback Switch",
1491 "LFE Playback Switch",
1492 "Side Playback Switch",
1493 "Headphone Playback Switch",
1494 "Speaker Playback Switch",
1495 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001496 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001497 NULL,
1498};
1499
1500/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001501 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 */
1503static int alc_build_controls(struct hda_codec *codec)
1504{
1505 struct alc_spec *spec = codec->spec;
1506 int err;
1507 int i;
1508
1509 for (i = 0; i < spec->num_mixers; i++) {
1510 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1511 if (err < 0)
1512 return err;
1513 }
1514
1515 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001516 err = snd_hda_create_spdif_out_ctls(codec,
1517 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 if (err < 0)
1519 return err;
1520 }
1521 if (spec->dig_in_nid) {
1522 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1523 if (err < 0)
1524 return err;
1525 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001526
1527 /* if we have no master control, let's create it */
1528 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1529 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1530 HDA_OUTPUT, spec->vmaster_tlv);
1531 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1532 spec->vmaster_tlv, alc_slave_vols);
1533 if (err < 0)
1534 return err;
1535 }
1536 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1537 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1538 NULL, alc_slave_sws);
1539 if (err < 0)
1540 return err;
1541 }
1542
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 return 0;
1544}
1545
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001546
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547/*
1548 * initialize the codec volumes, etc
1549 */
1550
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001551/*
1552 * generic initialization of ADC, input mixers and output mixers
1553 */
1554static struct hda_verb alc880_volume_init_verbs[] = {
1555 /*
1556 * Unmute ADC0-2 and set the default input to mic-in
1557 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001558 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001560 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001562 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001565 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1566 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001567 * Note: PASD motherboards uses the Line In 2 as the input for front
1568 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001570 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001579 /*
1580 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001582 /* set vol=0 to output mixers */
1583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1587 /* set up input amps for analog loopback */
1588 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1594 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1596 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597
1598 { }
1599};
1600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001601/*
1602 * 3-stack pin configuration:
1603 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1604 */
1605static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1606 /*
1607 * preset connection lists of input pins
1608 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1609 */
1610 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1611 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1612 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1613
1614 /*
1615 * Set pin mode and muting
1616 */
1617 /* set front pin widgets 0x14 for output */
1618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1620 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1621 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1622 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1623 /* Mic2 (as headphone out) for HP output */
1624 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1625 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1626 /* Line In pin widget for input */
1627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1629 /* Line2 (as front mic) pin widget for input and vref at 80% */
1630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1632 /* CD pin widget for input */
1633 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1634
1635 { }
1636};
1637
1638/*
1639 * 5-stack pin configuration:
1640 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1641 * line-in/side = 0x1a, f-mic = 0x1b
1642 */
1643static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1644 /*
1645 * preset connection lists of input pins
1646 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1647 */
1648 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1649 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1650
1651 /*
1652 * Set pin mode and muting
1653 */
1654 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1658 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659 /* unmute pins for output (no gain on this amp) */
1660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1668 /* Mic2 (as headphone out) for HP output */
1669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001671 /* Line In pin widget for input */
1672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1674 /* Line2 (as front mic) pin widget for input and vref at 80% */
1675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1677 /* CD pin widget for input */
1678 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679
1680 { }
1681};
1682
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683/*
1684 * W810 pin configuration:
1685 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1686 */
1687static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688 /* hphone/speaker input selector: front DAC */
1689 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697
1698 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 { }
1702};
1703
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001704/*
1705 * Z71V pin configuration:
1706 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1707 */
1708static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001713
Takashi Iwai16ded522005-06-10 19:58:24 +02001714 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001718
1719 { }
1720};
1721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001722/*
1723 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001724 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1725 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726 */
1727static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1728 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1729
Takashi Iwai16ded522005-06-10 19:58:24 +02001730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001736 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1738
Takashi Iwai16ded522005-06-10 19:58:24 +02001739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001747 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1748
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 { }
1750};
Takashi Iwai16ded522005-06-10 19:58:24 +02001751
Kailang Yangccc656c2006-10-17 12:32:26 +02001752/*
1753 * Uniwill pin configuration:
1754 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1755 * line = 0x1a
1756 */
1757static struct hda_verb alc880_uniwill_init_verbs[] = {
1758 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1759
1760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1764 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1765 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1766 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1767 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1773 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1774
1775 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1781 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1782 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1783 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1784
1785 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1786 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1787
1788 { }
1789};
1790
1791/*
1792* Uniwill P53
1793* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1794 */
1795static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1796 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1797
1798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1799 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1810
1811 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1815 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1817
1818 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1819 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1820
1821 { }
1822};
1823
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001824static struct hda_verb alc880_beep_init_verbs[] = {
1825 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1826 { }
1827};
1828
Kailang Yangccc656c2006-10-17 12:32:26 +02001829/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001830static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001831{
1832 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001833 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001834
1835 present = snd_hda_codec_read(codec, 0x14, 0,
1836 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001837 bits = present ? HDA_AMP_MUTE : 0;
1838 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1839 HDA_AMP_MUTE, bits);
1840 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1841 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001842}
1843
1844/* auto-toggle front mic */
1845static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1846{
1847 unsigned int present;
1848 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001849
1850 present = snd_hda_codec_read(codec, 0x18, 0,
1851 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001852 bits = present ? HDA_AMP_MUTE : 0;
1853 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001854}
1855
1856static void alc880_uniwill_automute(struct hda_codec *codec)
1857{
1858 alc880_uniwill_hp_automute(codec);
1859 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001860}
1861
1862static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1863 unsigned int res)
1864{
1865 /* Looks like the unsol event is incompatible with the standard
1866 * definition. 4bit tag is placed at 28 bit!
1867 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001868 switch (res >> 28) {
1869 case ALC880_HP_EVENT:
1870 alc880_uniwill_hp_automute(codec);
1871 break;
1872 case ALC880_MIC_EVENT:
1873 alc880_uniwill_mic_automute(codec);
1874 break;
1875 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001876}
1877
1878static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1879{
1880 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001881 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001882
1883 present = snd_hda_codec_read(codec, 0x14, 0,
1884 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001885 bits = present ? HDA_AMP_MUTE : 0;
1886 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001887}
1888
1889static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1890{
1891 unsigned int present;
1892
1893 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001894 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1895 present &= HDA_AMP_VOLMASK;
1896 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1897 HDA_AMP_VOLMASK, present);
1898 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1899 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001900}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001901
Kailang Yangccc656c2006-10-17 12:32:26 +02001902static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1903 unsigned int res)
1904{
1905 /* Looks like the unsol event is incompatible with the standard
1906 * definition. 4bit tag is placed at 28 bit!
1907 */
1908 if ((res >> 28) == ALC880_HP_EVENT)
1909 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001910 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001911 alc880_uniwill_p53_dcvol_automute(codec);
1912}
1913
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914/*
1915 * F1734 pin configuration:
1916 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1917 */
1918static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1919 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1920 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1921 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1922 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1923
1924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1928
1929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001938
1939 { }
1940};
1941
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001942/*
1943 * ASUS pin configuration:
1944 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1945 */
1946static struct hda_verb alc880_pin_asus_init_verbs[] = {
1947 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1948 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1949 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1950 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1951
1952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1958 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1960
1961 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1967 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1970
1971 { }
1972};
1973
1974/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001975#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1976#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001977
Kailang Yangdf694da2005-12-05 19:42:22 +01001978/* Clevo m520g init */
1979static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1980 /* headphone output */
1981 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1982 /* line-out */
1983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1985 /* Line-in */
1986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 /* CD */
1989 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1990 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1991 /* Mic1 (rear panel) */
1992 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1993 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1994 /* Mic2 (front panel) */
1995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1996 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 /* headphone */
1998 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2000 /* change to EAPD mode */
2001 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2002 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2003
2004 { }
2005};
2006
2007static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002008 /* change to EAPD mode */
2009 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2010 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2011
Kailang Yangdf694da2005-12-05 19:42:22 +01002012 /* Headphone output */
2013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2014 /* Front output*/
2015 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2016 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2017
2018 /* Line In pin widget for input */
2019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2020 /* CD pin widget for input */
2021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2022 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2024
2025 /* change to EAPD mode */
2026 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2027 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2028
2029 { }
2030};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002031
2032/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002033 * LG m1 express dual
2034 *
2035 * Pin assignment:
2036 * Rear Line-In/Out (blue): 0x14
2037 * Build-in Mic-In: 0x15
2038 * Speaker-out: 0x17
2039 * HP-Out (green): 0x1b
2040 * Mic-In/Out (red): 0x19
2041 * SPDIF-Out: 0x1e
2042 */
2043
2044/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2045static hda_nid_t alc880_lg_dac_nids[3] = {
2046 0x05, 0x02, 0x03
2047};
2048
2049/* seems analog CD is not working */
2050static struct hda_input_mux alc880_lg_capture_source = {
2051 .num_items = 3,
2052 .items = {
2053 { "Mic", 0x1 },
2054 { "Line", 0x5 },
2055 { "Internal Mic", 0x6 },
2056 },
2057};
2058
2059/* 2,4,6 channel modes */
2060static struct hda_verb alc880_lg_ch2_init[] = {
2061 /* set line-in and mic-in to input */
2062 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2063 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2064 { }
2065};
2066
2067static struct hda_verb alc880_lg_ch4_init[] = {
2068 /* set line-in to out and mic-in to input */
2069 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2070 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2071 { }
2072};
2073
2074static struct hda_verb alc880_lg_ch6_init[] = {
2075 /* set line-in and mic-in to output */
2076 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2077 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2078 { }
2079};
2080
2081static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2082 { 2, alc880_lg_ch2_init },
2083 { 4, alc880_lg_ch4_init },
2084 { 6, alc880_lg_ch6_init },
2085};
2086
2087static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2089 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002090 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2091 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2092 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2093 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2094 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2095 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2100 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2101 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2102 {
2103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2104 .name = "Channel Mode",
2105 .info = alc_ch_mode_info,
2106 .get = alc_ch_mode_get,
2107 .put = alc_ch_mode_put,
2108 },
2109 { } /* end */
2110};
2111
2112static struct hda_verb alc880_lg_init_verbs[] = {
2113 /* set capture source to mic-in */
2114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2117 /* mute all amp mixer inputs */
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002121 /* line-in to input */
2122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2123 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2124 /* built-in mic */
2125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 /* speaker-out */
2128 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2129 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2130 /* mic-in to input */
2131 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2134 /* HP-out */
2135 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2137 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2138 /* jack sense */
2139 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2140 { }
2141};
2142
2143/* toggle speaker-output according to the hp-jack state */
2144static void alc880_lg_automute(struct hda_codec *codec)
2145{
2146 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002147 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002148
2149 present = snd_hda_codec_read(codec, 0x1b, 0,
2150 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002151 bits = present ? HDA_AMP_MUTE : 0;
2152 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2153 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002154}
2155
2156static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2157{
2158 /* Looks like the unsol event is incompatible with the standard
2159 * definition. 4bit tag is placed at 28 bit!
2160 */
2161 if ((res >> 28) == 0x01)
2162 alc880_lg_automute(codec);
2163}
2164
2165/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002166 * LG LW20
2167 *
2168 * Pin assignment:
2169 * Speaker-out: 0x14
2170 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002171 * Built-in Mic-In: 0x19
2172 * Line-In: 0x1b
2173 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002174 * SPDIF-Out: 0x1e
2175 */
2176
Takashi Iwaid6815182006-03-23 16:06:23 +01002177static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002178 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002179 .items = {
2180 { "Mic", 0x0 },
2181 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002182 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002183 },
2184};
2185
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002186#define alc880_lg_lw_modes alc880_threestack_modes
2187
Takashi Iwaid6815182006-03-23 16:06:23 +01002188static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2196 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2202 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002203 {
2204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2205 .name = "Channel Mode",
2206 .info = alc_ch_mode_info,
2207 .get = alc_ch_mode_get,
2208 .put = alc_ch_mode_put,
2209 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002210 { } /* end */
2211};
2212
2213static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002214 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2215 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2216 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2217
Takashi Iwaid6815182006-03-23 16:06:23 +01002218 /* set capture source to mic-in */
2219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2221 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002223 /* speaker-out */
2224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002227 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2228 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2229 /* mic-in to input */
2230 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 /* built-in mic */
2233 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2234 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 /* jack sense */
2236 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2237 { }
2238};
2239
2240/* toggle speaker-output according to the hp-jack state */
2241static void alc880_lg_lw_automute(struct hda_codec *codec)
2242{
2243 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002244 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002245
2246 present = snd_hda_codec_read(codec, 0x1b, 0,
2247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002248 bits = present ? HDA_AMP_MUTE : 0;
2249 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2250 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002251}
2252
2253static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2254{
2255 /* Looks like the unsol event is incompatible with the standard
2256 * definition. 4bit tag is placed at 28 bit!
2257 */
2258 if ((res >> 28) == 0x01)
2259 alc880_lg_lw_automute(codec);
2260}
2261
Takashi Iwaicb53c622007-08-10 17:21:45 +02002262#ifdef CONFIG_SND_HDA_POWER_SAVE
2263static struct hda_amp_list alc880_loopbacks[] = {
2264 { 0x0b, HDA_INPUT, 0 },
2265 { 0x0b, HDA_INPUT, 1 },
2266 { 0x0b, HDA_INPUT, 2 },
2267 { 0x0b, HDA_INPUT, 3 },
2268 { 0x0b, HDA_INPUT, 4 },
2269 { } /* end */
2270};
2271
2272static struct hda_amp_list alc880_lg_loopbacks[] = {
2273 { 0x0b, HDA_INPUT, 1 },
2274 { 0x0b, HDA_INPUT, 6 },
2275 { 0x0b, HDA_INPUT, 7 },
2276 { } /* end */
2277};
2278#endif
2279
Takashi Iwaid6815182006-03-23 16:06:23 +01002280/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002281 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002283
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284static int alc_init(struct hda_codec *codec)
2285{
2286 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287 unsigned int i;
2288
2289 for (i = 0; i < spec->num_init_verbs; i++)
2290 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002291
2292 if (spec->init_hook)
2293 spec->init_hook(codec);
2294
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 return 0;
2296}
2297
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002298static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2299{
2300 struct alc_spec *spec = codec->spec;
2301
2302 if (spec->unsol_event)
2303 spec->unsol_event(codec, res);
2304}
2305
Takashi Iwaicb53c622007-08-10 17:21:45 +02002306#ifdef CONFIG_SND_HDA_POWER_SAVE
2307static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2308{
2309 struct alc_spec *spec = codec->spec;
2310 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2311}
2312#endif
2313
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314/*
2315 * Analog playback callbacks
2316 */
2317static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2318 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002319 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320{
2321 struct alc_spec *spec = codec->spec;
2322 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2323}
2324
2325static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2326 struct hda_codec *codec,
2327 unsigned int stream_tag,
2328 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002329 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330{
2331 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002332 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2333 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334}
2335
2336static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2337 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002338 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339{
2340 struct alc_spec *spec = codec->spec;
2341 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2342}
2343
2344/*
2345 * Digital out
2346 */
2347static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002349 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350{
2351 struct alc_spec *spec = codec->spec;
2352 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2353}
2354
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002355static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2356 struct hda_codec *codec,
2357 unsigned int stream_tag,
2358 unsigned int format,
2359 struct snd_pcm_substream *substream)
2360{
2361 struct alc_spec *spec = codec->spec;
2362 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2363 stream_tag, format, substream);
2364}
2365
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2367 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002368 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369{
2370 struct alc_spec *spec = codec->spec;
2371 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2372}
2373
2374/*
2375 * Analog capture
2376 */
Takashi Iwai63300792008-01-24 15:31:36 +01002377static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 struct hda_codec *codec,
2379 unsigned int stream_tag,
2380 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002381 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382{
2383 struct alc_spec *spec = codec->spec;
2384
Takashi Iwai63300792008-01-24 15:31:36 +01002385 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 stream_tag, 0, format);
2387 return 0;
2388}
2389
Takashi Iwai63300792008-01-24 15:31:36 +01002390static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002392 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393{
2394 struct alc_spec *spec = codec->spec;
2395
Takashi Iwai63300792008-01-24 15:31:36 +01002396 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002397 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 return 0;
2399}
2400
2401
2402/*
2403 */
2404static struct hda_pcm_stream alc880_pcm_analog_playback = {
2405 .substreams = 1,
2406 .channels_min = 2,
2407 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 .ops = {
2410 .open = alc880_playback_pcm_open,
2411 .prepare = alc880_playback_pcm_prepare,
2412 .cleanup = alc880_playback_pcm_cleanup
2413 },
2414};
2415
2416static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002417 .substreams = 1,
2418 .channels_min = 2,
2419 .channels_max = 2,
2420 /* NID is set in alc_build_pcms */
2421};
2422
2423static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2424 .substreams = 1,
2425 .channels_min = 2,
2426 .channels_max = 2,
2427 /* NID is set in alc_build_pcms */
2428};
2429
2430static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2431 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 .channels_min = 2,
2433 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002434 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002436 .prepare = alc880_alt_capture_pcm_prepare,
2437 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 },
2439};
2440
2441static struct hda_pcm_stream alc880_pcm_digital_playback = {
2442 .substreams = 1,
2443 .channels_min = 2,
2444 .channels_max = 2,
2445 /* NID is set in alc_build_pcms */
2446 .ops = {
2447 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002448 .close = alc880_dig_playback_pcm_close,
2449 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 },
2451};
2452
2453static struct hda_pcm_stream alc880_pcm_digital_capture = {
2454 .substreams = 1,
2455 .channels_min = 2,
2456 .channels_max = 2,
2457 /* NID is set in alc_build_pcms */
2458};
2459
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002460/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002461static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002462 .substreams = 0,
2463 .channels_min = 0,
2464 .channels_max = 0,
2465};
2466
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467static int alc_build_pcms(struct hda_codec *codec)
2468{
2469 struct alc_spec *spec = codec->spec;
2470 struct hda_pcm *info = spec->pcm_rec;
2471 int i;
2472
2473 codec->num_pcms = 1;
2474 codec->pcm_info = info;
2475
2476 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002477 if (spec->stream_analog_playback) {
2478 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2480 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2481 }
2482 if (spec->stream_analog_capture) {
2483 snd_assert(spec->adc_nids, return -EINVAL);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2485 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2486 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487
Takashi Iwai4a471b72005-12-07 13:56:29 +01002488 if (spec->channel_mode) {
2489 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2490 for (i = 0; i < spec->num_channel_mode; i++) {
2491 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2493 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 }
2495 }
2496
Takashi Iwaie08a0072006-09-07 17:52:14 +02002497 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002499 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002500 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002502 if (spec->multiout.dig_out_nid &&
2503 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002504 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2505 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2506 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002507 if (spec->dig_in_nid &&
2508 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2511 }
2512 }
2513
Takashi Iwaie08a0072006-09-07 17:52:14 +02002514 /* If the use of more than one ADC is requested for the current
2515 * model, configure a second analog capture-only PCM.
2516 */
2517 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002518 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2519 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002520 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002521 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002522 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002523 if (spec->alt_dac_nid) {
2524 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2525 *spec->stream_analog_alt_playback;
2526 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2527 spec->alt_dac_nid;
2528 } else {
2529 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2530 alc_pcm_null_stream;
2531 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2532 }
2533 if (spec->num_adc_nids > 1) {
2534 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2535 *spec->stream_analog_alt_capture;
2536 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2537 spec->adc_nids[1];
2538 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2539 spec->num_adc_nids - 1;
2540 } else {
2541 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2542 alc_pcm_null_stream;
2543 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002544 }
2545 }
2546
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 return 0;
2548}
2549
2550static void alc_free(struct hda_codec *codec)
2551{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002552 struct alc_spec *spec = codec->spec;
2553 unsigned int i;
2554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002555 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002556 return;
2557
2558 if (spec->kctl_alloc) {
2559 for (i = 0; i < spec->num_kctl_used; i++)
2560 kfree(spec->kctl_alloc[i].name);
2561 kfree(spec->kctl_alloc);
2562 }
2563 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564}
2565
2566/*
2567 */
2568static struct hda_codec_ops alc_patch_ops = {
2569 .build_controls = alc_build_controls,
2570 .build_pcms = alc_build_pcms,
2571 .init = alc_init,
2572 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002573 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002574#ifdef CONFIG_SND_HDA_POWER_SAVE
2575 .check_power_status = alc_check_power_status,
2576#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577};
2578
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002579
2580/*
2581 * Test configuration for debugging
2582 *
2583 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2584 * enum controls.
2585 */
2586#ifdef CONFIG_SND_DEBUG
2587static hda_nid_t alc880_test_dac_nids[4] = {
2588 0x02, 0x03, 0x04, 0x05
2589};
2590
2591static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002592 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002593 .items = {
2594 { "In-1", 0x0 },
2595 { "In-2", 0x1 },
2596 { "In-3", 0x2 },
2597 { "In-4", 0x3 },
2598 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002599 { "Front", 0x5 },
2600 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002601 },
2602};
2603
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002604static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002605 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002606 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002607 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002608 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002609};
2610
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002611static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2612 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002613{
2614 static char *texts[] = {
2615 "N/A", "Line Out", "HP Out",
2616 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2617 };
2618 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2619 uinfo->count = 1;
2620 uinfo->value.enumerated.items = 8;
2621 if (uinfo->value.enumerated.item >= 8)
2622 uinfo->value.enumerated.item = 7;
2623 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2624 return 0;
2625}
2626
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002627static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2628 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002629{
2630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2631 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2632 unsigned int pin_ctl, item = 0;
2633
2634 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2635 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2636 if (pin_ctl & AC_PINCTL_OUT_EN) {
2637 if (pin_ctl & AC_PINCTL_HP_EN)
2638 item = 2;
2639 else
2640 item = 1;
2641 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2642 switch (pin_ctl & AC_PINCTL_VREFEN) {
2643 case AC_PINCTL_VREF_HIZ: item = 3; break;
2644 case AC_PINCTL_VREF_50: item = 4; break;
2645 case AC_PINCTL_VREF_GRD: item = 5; break;
2646 case AC_PINCTL_VREF_80: item = 6; break;
2647 case AC_PINCTL_VREF_100: item = 7; break;
2648 }
2649 }
2650 ucontrol->value.enumerated.item[0] = item;
2651 return 0;
2652}
2653
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002654static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2655 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002656{
2657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2658 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2659 static unsigned int ctls[] = {
2660 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2665 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2666 };
2667 unsigned int old_ctl, new_ctl;
2668
2669 old_ctl = snd_hda_codec_read(codec, nid, 0,
2670 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2671 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2672 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002673 int val;
2674 snd_hda_codec_write_cache(codec, nid, 0,
2675 AC_VERB_SET_PIN_WIDGET_CONTROL,
2676 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002677 val = ucontrol->value.enumerated.item[0] >= 3 ?
2678 HDA_AMP_MUTE : 0;
2679 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2680 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002681 return 1;
2682 }
2683 return 0;
2684}
2685
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002686static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2687 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002688{
2689 static char *texts[] = {
2690 "Front", "Surround", "CLFE", "Side"
2691 };
2692 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2693 uinfo->count = 1;
2694 uinfo->value.enumerated.items = 4;
2695 if (uinfo->value.enumerated.item >= 4)
2696 uinfo->value.enumerated.item = 3;
2697 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2698 return 0;
2699}
2700
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002701static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2702 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002703{
2704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2705 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2706 unsigned int sel;
2707
2708 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2709 ucontrol->value.enumerated.item[0] = sel & 3;
2710 return 0;
2711}
2712
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002713static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2714 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002715{
2716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2717 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2718 unsigned int sel;
2719
2720 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2721 if (ucontrol->value.enumerated.item[0] != sel) {
2722 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002723 snd_hda_codec_write_cache(codec, nid, 0,
2724 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002725 return 1;
2726 }
2727 return 0;
2728}
2729
2730#define PIN_CTL_TEST(xname,nid) { \
2731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2732 .name = xname, \
2733 .info = alc_test_pin_ctl_info, \
2734 .get = alc_test_pin_ctl_get, \
2735 .put = alc_test_pin_ctl_put, \
2736 .private_value = nid \
2737 }
2738
2739#define PIN_SRC_TEST(xname,nid) { \
2740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2741 .name = xname, \
2742 .info = alc_test_pin_src_info, \
2743 .get = alc_test_pin_src_get, \
2744 .put = alc_test_pin_src_put, \
2745 .private_value = nid \
2746 }
2747
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002748static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2752 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002753 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2756 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002757 PIN_CTL_TEST("Front Pin Mode", 0x14),
2758 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2759 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2760 PIN_CTL_TEST("Side Pin Mode", 0x17),
2761 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2762 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2763 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2764 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2765 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2766 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2767 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2768 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2769 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2771 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2773 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2775 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002779 {
2780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2781 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002782 .info = alc_ch_mode_info,
2783 .get = alc_ch_mode_get,
2784 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002785 },
2786 { } /* end */
2787};
2788
2789static struct hda_verb alc880_test_init_verbs[] = {
2790 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002799 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002804 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002809 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002814 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002817 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2819 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002820 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002821 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2824 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002825 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002827 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002831 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002832 /* Analog input/passthru */
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002838 { }
2839};
2840#endif
2841
Linus Torvalds1da177e2005-04-16 15:20:36 -07002842/*
2843 */
2844
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002845static const char *alc880_models[ALC880_MODEL_LAST] = {
2846 [ALC880_3ST] = "3stack",
2847 [ALC880_TCL_S700] = "tcl",
2848 [ALC880_3ST_DIG] = "3stack-digout",
2849 [ALC880_CLEVO] = "clevo",
2850 [ALC880_5ST] = "5stack",
2851 [ALC880_5ST_DIG] = "5stack-digout",
2852 [ALC880_W810] = "w810",
2853 [ALC880_Z71V] = "z71v",
2854 [ALC880_6ST] = "6stack",
2855 [ALC880_6ST_DIG] = "6stack-digout",
2856 [ALC880_ASUS] = "asus",
2857 [ALC880_ASUS_W1V] = "asus-w1v",
2858 [ALC880_ASUS_DIG] = "asus-dig",
2859 [ALC880_ASUS_DIG2] = "asus-dig2",
2860 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002861 [ALC880_UNIWILL_P53] = "uniwill-p53",
2862 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002863 [ALC880_F1734] = "F1734",
2864 [ALC880_LG] = "lg",
2865 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002866#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002867 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002868#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002869 [ALC880_AUTO] = "auto",
2870};
2871
2872static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002873 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002874 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2875 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2876 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2881 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002882 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2883 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002884 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2885 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2890 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2891 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2892 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2893 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002894 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002895 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2896 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2897 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002898 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002899 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002900 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2901 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002902 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2903 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002904 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2907 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002908 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2909 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002910 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002911 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002912 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002913 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002914 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2915 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002916 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2917 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002918 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002919 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002920 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002921 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002922 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002923 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2924 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002925 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002926 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2927 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2928 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2929 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002930 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2931 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002932 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002933 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002934 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2935 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002936 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2938 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002939 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2940 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2941 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002942 {}
2943};
2944
Takashi Iwai16ded522005-06-10 19:58:24 +02002945/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002946 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002947 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002948static struct alc_config_preset alc880_presets[] = {
2949 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002950 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002951 .init_verbs = { alc880_volume_init_verbs,
2952 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002953 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002954 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002955 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2956 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002957 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002958 .input_mux = &alc880_capture_source,
2959 },
2960 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002962 .init_verbs = { alc880_volume_init_verbs,
2963 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002965 .dac_nids = alc880_dac_nids,
2966 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002967 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2968 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002969 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .input_mux = &alc880_capture_source,
2971 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002972 [ALC880_TCL_S700] = {
2973 .mixers = { alc880_tcl_s700_mixer },
2974 .init_verbs = { alc880_volume_init_verbs,
2975 alc880_pin_tcl_S700_init_verbs,
2976 alc880_gpio2_init_verbs },
2977 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2978 .dac_nids = alc880_dac_nids,
2979 .hp_nid = 0x03,
2980 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2981 .channel_mode = alc880_2_jack_modes,
2982 .input_mux = &alc880_capture_source,
2983 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002984 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002985 .mixers = { alc880_three_stack_mixer,
2986 alc880_five_stack_mixer},
2987 .init_verbs = { alc880_volume_init_verbs,
2988 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002989 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2990 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002991 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2992 .channel_mode = alc880_fivestack_modes,
2993 .input_mux = &alc880_capture_source,
2994 },
2995 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002996 .mixers = { alc880_three_stack_mixer,
2997 alc880_five_stack_mixer },
2998 .init_verbs = { alc880_volume_init_verbs,
2999 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3001 .dac_nids = alc880_dac_nids,
3002 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003003 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3004 .channel_mode = alc880_fivestack_modes,
3005 .input_mux = &alc880_capture_source,
3006 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003007 [ALC880_6ST] = {
3008 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003009 .init_verbs = { alc880_volume_init_verbs,
3010 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003011 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3012 .dac_nids = alc880_6st_dac_nids,
3013 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3014 .channel_mode = alc880_sixstack_modes,
3015 .input_mux = &alc880_6stack_capture_source,
3016 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003017 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003018 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003019 .init_verbs = { alc880_volume_init_verbs,
3020 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003021 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3022 .dac_nids = alc880_6st_dac_nids,
3023 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003024 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3025 .channel_mode = alc880_sixstack_modes,
3026 .input_mux = &alc880_6stack_capture_source,
3027 },
3028 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003029 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003030 .init_verbs = { alc880_volume_init_verbs,
3031 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003032 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003033 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3034 .dac_nids = alc880_w810_dac_nids,
3035 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003036 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3037 .channel_mode = alc880_w810_modes,
3038 .input_mux = &alc880_capture_source,
3039 },
3040 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003041 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003042 .init_verbs = { alc880_volume_init_verbs,
3043 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003044 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3045 .dac_nids = alc880_z71v_dac_nids,
3046 .dig_out_nid = ALC880_DIGOUT_NID,
3047 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003048 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3049 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003050 .input_mux = &alc880_capture_source,
3051 },
3052 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003054 .init_verbs = { alc880_volume_init_verbs,
3055 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003056 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3057 .dac_nids = alc880_f1734_dac_nids,
3058 .hp_nid = 0x02,
3059 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3060 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003061 .input_mux = &alc880_capture_source,
3062 },
3063 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003065 .init_verbs = { alc880_volume_init_verbs,
3066 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 alc880_gpio1_init_verbs },
3068 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3069 .dac_nids = alc880_asus_dac_nids,
3070 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3071 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003072 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003073 .input_mux = &alc880_capture_source,
3074 },
3075 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003077 .init_verbs = { alc880_volume_init_verbs,
3078 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 alc880_gpio1_init_verbs },
3080 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3081 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003082 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003083 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3084 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003085 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003086 .input_mux = &alc880_capture_source,
3087 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003088 [ALC880_ASUS_DIG2] = {
3089 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003090 .init_verbs = { alc880_volume_init_verbs,
3091 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003092 alc880_gpio2_init_verbs }, /* use GPIO2 */
3093 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3094 .dac_nids = alc880_asus_dac_nids,
3095 .dig_out_nid = ALC880_DIGOUT_NID,
3096 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3097 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003098 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003099 .input_mux = &alc880_capture_source,
3100 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003101 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003103 .init_verbs = { alc880_volume_init_verbs,
3104 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 alc880_gpio1_init_verbs },
3106 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3107 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003108 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3110 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003111 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 .input_mux = &alc880_capture_source,
3113 },
3114 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003115 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003116 .init_verbs = { alc880_volume_init_verbs,
3117 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3119 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003120 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3122 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003123 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .input_mux = &alc880_capture_source,
3125 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003126 [ALC880_UNIWILL] = {
3127 .mixers = { alc880_uniwill_mixer },
3128 .init_verbs = { alc880_volume_init_verbs,
3129 alc880_uniwill_init_verbs },
3130 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3131 .dac_nids = alc880_asus_dac_nids,
3132 .dig_out_nid = ALC880_DIGOUT_NID,
3133 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3134 .channel_mode = alc880_threestack_modes,
3135 .need_dac_fix = 1,
3136 .input_mux = &alc880_capture_source,
3137 .unsol_event = alc880_uniwill_unsol_event,
3138 .init_hook = alc880_uniwill_automute,
3139 },
3140 [ALC880_UNIWILL_P53] = {
3141 .mixers = { alc880_uniwill_p53_mixer },
3142 .init_verbs = { alc880_volume_init_verbs,
3143 alc880_uniwill_p53_init_verbs },
3144 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3145 .dac_nids = alc880_asus_dac_nids,
3146 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003147 .channel_mode = alc880_threestack_modes,
3148 .input_mux = &alc880_capture_source,
3149 .unsol_event = alc880_uniwill_p53_unsol_event,
3150 .init_hook = alc880_uniwill_p53_hp_automute,
3151 },
3152 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003153 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003154 alc880_pcbeep_mixer, },
3155 .init_verbs = { alc880_volume_init_verbs,
3156 alc880_uniwill_p53_init_verbs,
3157 alc880_beep_init_verbs },
3158 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3159 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003160 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003161 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3162 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003163 .input_mux = &alc880_capture_source,
3164 .unsol_event = alc880_uniwill_p53_unsol_event,
3165 .init_hook = alc880_uniwill_p53_hp_automute,
3166 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003167 [ALC880_CLEVO] = {
3168 .mixers = { alc880_three_stack_mixer },
3169 .init_verbs = { alc880_volume_init_verbs,
3170 alc880_pin_clevo_init_verbs },
3171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3172 .dac_nids = alc880_dac_nids,
3173 .hp_nid = 0x03,
3174 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3175 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003176 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003177 .input_mux = &alc880_capture_source,
3178 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003179 [ALC880_LG] = {
3180 .mixers = { alc880_lg_mixer },
3181 .init_verbs = { alc880_volume_init_verbs,
3182 alc880_lg_init_verbs },
3183 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3184 .dac_nids = alc880_lg_dac_nids,
3185 .dig_out_nid = ALC880_DIGOUT_NID,
3186 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3187 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003188 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003189 .input_mux = &alc880_lg_capture_source,
3190 .unsol_event = alc880_lg_unsol_event,
3191 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003192#ifdef CONFIG_SND_HDA_POWER_SAVE
3193 .loopbacks = alc880_lg_loopbacks,
3194#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003195 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003196 [ALC880_LG_LW] = {
3197 .mixers = { alc880_lg_lw_mixer },
3198 .init_verbs = { alc880_volume_init_verbs,
3199 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003200 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003201 .dac_nids = alc880_dac_nids,
3202 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003203 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3204 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003205 .input_mux = &alc880_lg_lw_capture_source,
3206 .unsol_event = alc880_lg_lw_unsol_event,
3207 .init_hook = alc880_lg_lw_automute,
3208 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003209#ifdef CONFIG_SND_DEBUG
3210 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 .mixers = { alc880_test_mixer },
3212 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003213 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3214 .dac_nids = alc880_test_dac_nids,
3215 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003216 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3217 .channel_mode = alc880_test_modes,
3218 .input_mux = &alc880_test_capture_source,
3219 },
3220#endif
3221};
3222
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223/*
3224 * Automatic parse of I/O pins from the BIOS configuration
3225 */
3226
3227#define NUM_CONTROL_ALLOC 32
3228#define NUM_VERB_ALLOC 32
3229
3230enum {
3231 ALC_CTL_WIDGET_VOL,
3232 ALC_CTL_WIDGET_MUTE,
3233 ALC_CTL_BIND_MUTE,
3234};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003235static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3237 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003238 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239};
3240
3241/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003242static int add_control(struct alc_spec *spec, int type, const char *name,
3243 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003245 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246
3247 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3248 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 /* array + terminator */
3251 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3252 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 return -ENOMEM;
3254 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003255 memcpy(knew, spec->kctl_alloc,
3256 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 kfree(spec->kctl_alloc);
3258 }
3259 spec->kctl_alloc = knew;
3260 spec->num_kctl_alloc = num;
3261 }
3262
3263 knew = &spec->kctl_alloc[spec->num_kctl_used];
3264 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003265 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003266 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 return -ENOMEM;
3268 knew->private_value = val;
3269 spec->num_kctl_used++;
3270 return 0;
3271}
3272
3273#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3274#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3275#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3276#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3277#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3278#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3279#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3280#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3281#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3282#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3283#define ALC880_PIN_CD_NID 0x1c
3284
3285/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003286static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3287 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288{
3289 hda_nid_t nid;
3290 int assigned[4];
3291 int i, j;
3292
3293 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003294 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003295
3296 /* check the pins hardwired to audio widget */
3297 for (i = 0; i < cfg->line_outs; i++) {
3298 nid = cfg->line_out_pins[i];
3299 if (alc880_is_fixed_pin(nid)) {
3300 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003301 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 assigned[idx] = 1;
3303 }
3304 }
3305 /* left pins can be connect to any audio widget */
3306 for (i = 0; i < cfg->line_outs; i++) {
3307 nid = cfg->line_out_pins[i];
3308 if (alc880_is_fixed_pin(nid))
3309 continue;
3310 /* search for an empty channel */
3311 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003312 if (!assigned[j]) {
3313 spec->multiout.dac_nids[i] =
3314 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315 assigned[j] = 1;
3316 break;
3317 }
3318 }
3319 }
3320 spec->multiout.num_dacs = cfg->line_outs;
3321 return 0;
3322}
3323
3324/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003325static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3326 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327{
3328 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003329 static const char *chname[4] = {
3330 "Front", "Surround", NULL /*CLFE*/, "Side"
3331 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003332 hda_nid_t nid;
3333 int i, err;
3334
3335 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003336 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003337 continue;
3338 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3339 if (i == 2) {
3340 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003341 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3342 "Center Playback Volume",
3343 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3344 HDA_OUTPUT));
3345 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003347 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3348 "LFE Playback Volume",
3349 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3350 HDA_OUTPUT));
3351 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003353 err = add_control(spec, ALC_CTL_BIND_MUTE,
3354 "Center Playback Switch",
3355 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3356 HDA_INPUT));
3357 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003359 err = add_control(spec, ALC_CTL_BIND_MUTE,
3360 "LFE Playback Switch",
3361 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3362 HDA_INPUT));
3363 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 return err;
3365 } else {
3366 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003367 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3368 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3369 HDA_OUTPUT));
3370 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003371 return err;
3372 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003373 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3374 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3375 HDA_INPUT));
3376 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003377 return err;
3378 }
3379 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003380 return 0;
3381}
3382
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003383/* add playback controls for speaker and HP outputs */
3384static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3385 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003386{
3387 hda_nid_t nid;
3388 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003389 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003391 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003392 return 0;
3393
3394 if (alc880_is_fixed_pin(pin)) {
3395 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003396 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003397 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003399 else
3400 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003401 /* control HP volume/switch on the output mixer amp */
3402 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003403 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003404 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3405 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3406 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003408 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003409 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3410 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3411 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412 return err;
3413 } else if (alc880_is_multi_pin(pin)) {
3414 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003416 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003417 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3418 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3419 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420 return err;
3421 }
3422 return 0;
3423}
3424
3425/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003426static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3427 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003428 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003429{
3430 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003431 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432
3433 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003434 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3435 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3436 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437 return err;
3438 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003439 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3440 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3441 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003442 return err;
3443 return 0;
3444}
3445
3446/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003447static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3448 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003450 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003451 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452
3453 for (i = 0; i < AUTO_PIN_LAST; i++) {
3454 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003455 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003456 err = new_analog_input(spec, cfg->input_pins[i],
3457 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003458 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003459 if (err < 0)
3460 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003461 imux->items[imux->num_items].label =
3462 auto_pin_cfg_labels[i];
3463 imux->items[imux->num_items].index =
3464 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465 imux->num_items++;
3466 }
3467 }
3468 return 0;
3469}
3470
Kailang Yangdf694da2005-12-05 19:42:22 +01003471static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3472 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473 int dac_idx)
3474{
3475 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003476 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3477 pin_type);
3478 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3479 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480 /* need the manual connection? */
3481 if (alc880_is_multi_pin(nid)) {
3482 struct alc_spec *spec = codec->spec;
3483 int idx = alc880_multi_pin_idx(nid);
3484 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3485 AC_VERB_SET_CONNECT_SEL,
3486 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3487 }
3488}
3489
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003490static int get_pin_type(int line_out_type)
3491{
3492 if (line_out_type == AUTO_PIN_HP_OUT)
3493 return PIN_HP;
3494 else
3495 return PIN_OUT;
3496}
3497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498static void alc880_auto_init_multi_out(struct hda_codec *codec)
3499{
3500 struct alc_spec *spec = codec->spec;
3501 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003502
3503 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003504 for (i = 0; i < spec->autocfg.line_outs; i++) {
3505 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003506 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3507 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003508 }
3509}
3510
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003511static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003512{
3513 struct alc_spec *spec = codec->spec;
3514 hda_nid_t pin;
3515
Takashi Iwai82bc9552006-03-21 11:24:42 +01003516 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003517 if (pin) /* connect to front */
3518 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003519 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520 if (pin) /* connect to front */
3521 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3522}
3523
3524static void alc880_auto_init_analog_input(struct hda_codec *codec)
3525{
3526 struct alc_spec *spec = codec->spec;
3527 int i;
3528
3529 for (i = 0; i < AUTO_PIN_LAST; i++) {
3530 hda_nid_t nid = spec->autocfg.input_pins[i];
3531 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003532 snd_hda_codec_write(codec, nid, 0,
3533 AC_VERB_SET_PIN_WIDGET_CONTROL,
3534 i <= AUTO_PIN_FRONT_MIC ?
3535 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003536 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003537 snd_hda_codec_write(codec, nid, 0,
3538 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003539 AMP_OUT_MUTE);
3540 }
3541 }
3542}
3543
3544/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003545/* return 1 if successful, 0 if the proper config is not found,
3546 * or a negative error code
3547 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548static int alc880_parse_auto_config(struct hda_codec *codec)
3549{
3550 struct alc_spec *spec = codec->spec;
3551 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003552 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003553
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003554 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3555 alc880_ignore);
3556 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003558 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003560
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003561 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3562 if (err < 0)
3563 return err;
3564 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3565 if (err < 0)
3566 return err;
3567 err = alc880_auto_create_extra_out(spec,
3568 spec->autocfg.speaker_pins[0],
3569 "Speaker");
3570 if (err < 0)
3571 return err;
3572 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3573 "Headphone");
3574 if (err < 0)
3575 return err;
3576 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3577 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578 return err;
3579
3580 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3581
3582 if (spec->autocfg.dig_out_pin)
3583 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3584 if (spec->autocfg.dig_in_pin)
3585 spec->dig_in_nid = ALC880_DIGIN_NID;
3586
3587 if (spec->kctl_alloc)
3588 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3589
3590 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3591
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003592 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 spec->input_mux = &spec->private_imux;
3594
3595 return 1;
3596}
3597
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003598/* additional initialization for auto-configuration model */
3599static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003601 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003602 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003604}
3605
3606/*
3607 * OK, here we have finally the patch for ALC880
3608 */
3609
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610static int patch_alc880(struct hda_codec *codec)
3611{
3612 struct alc_spec *spec;
3613 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003614 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003615
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003616 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003617 if (spec == NULL)
3618 return -ENOMEM;
3619
3620 codec->spec = spec;
3621
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003622 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3623 alc880_models,
3624 alc880_cfg_tbl);
3625 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003626 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3627 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003629 }
3630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003631 if (board_config == ALC880_AUTO) {
3632 /* automatic parse from the BIOS config */
3633 err = alc880_parse_auto_config(codec);
3634 if (err < 0) {
3635 alc_free(codec);
3636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003637 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003638 printk(KERN_INFO
3639 "hda_codec: Cannot set up configuration "
3640 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003641 board_config = ALC880_3ST;
3642 }
3643 }
3644
Kailang Yangdf694da2005-12-05 19:42:22 +01003645 if (board_config != ALC880_AUTO)
3646 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647
3648 spec->stream_name_analog = "ALC880 Analog";
3649 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3650 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003651 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003652
3653 spec->stream_name_digital = "ALC880 Digital";
3654 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3655 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3656
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003657 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003658 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003659 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003660 /* get type */
3661 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003662 if (wcap != AC_WID_AUD_IN) {
3663 spec->adc_nids = alc880_adc_nids_alt;
3664 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003665 spec->mixers[spec->num_mixers] =
3666 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003667 spec->num_mixers++;
3668 } else {
3669 spec->adc_nids = alc880_adc_nids;
3670 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3671 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3672 spec->num_mixers++;
3673 }
3674 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003675
Takashi Iwai2134ea42008-01-10 16:53:55 +01003676 spec->vmaster_nid = 0x0c;
3677
Linus Torvalds1da177e2005-04-16 15:20:36 -07003678 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003679 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003680 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003681#ifdef CONFIG_SND_HDA_POWER_SAVE
3682 if (!spec->loopback.amplist)
3683 spec->loopback.amplist = alc880_loopbacks;
3684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685
3686 return 0;
3687}
3688
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003689
Linus Torvalds1da177e2005-04-16 15:20:36 -07003690/*
3691 * ALC260 support
3692 */
3693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003694static hda_nid_t alc260_dac_nids[1] = {
3695 /* front */
3696 0x02,
3697};
3698
3699static hda_nid_t alc260_adc_nids[1] = {
3700 /* ADC0 */
3701 0x04,
3702};
3703
Kailang Yangdf694da2005-12-05 19:42:22 +01003704static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003705 /* ADC1 */
3706 0x05,
3707};
3708
Kailang Yangdf694da2005-12-05 19:42:22 +01003709static hda_nid_t alc260_hp_adc_nids[2] = {
3710 /* ADC1, 0 */
3711 0x05, 0x04
3712};
3713
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003714/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3715 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3716 */
3717static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003718 /* ADC0, ADC1 */
3719 0x04, 0x05
3720};
3721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722#define ALC260_DIGOUT_NID 0x03
3723#define ALC260_DIGIN_NID 0x06
3724
3725static struct hda_input_mux alc260_capture_source = {
3726 .num_items = 4,
3727 .items = {
3728 { "Mic", 0x0 },
3729 { "Front Mic", 0x1 },
3730 { "Line", 0x2 },
3731 { "CD", 0x4 },
3732 },
3733};
3734
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003735/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003736 * headphone jack and the internal CD lines since these are the only pins at
3737 * which audio can appear. For flexibility, also allow the option of
3738 * recording the mixer output on the second ADC (ADC0 doesn't have a
3739 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003740 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003741static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3742 {
3743 .num_items = 3,
3744 .items = {
3745 { "Mic/Line", 0x0 },
3746 { "CD", 0x4 },
3747 { "Headphone", 0x2 },
3748 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003749 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003750 {
3751 .num_items = 4,
3752 .items = {
3753 { "Mic/Line", 0x0 },
3754 { "CD", 0x4 },
3755 { "Headphone", 0x2 },
3756 { "Mixer", 0x5 },
3757 },
3758 },
3759
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003760};
3761
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003762/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3763 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003764 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003765static struct hda_input_mux alc260_acer_capture_sources[2] = {
3766 {
3767 .num_items = 4,
3768 .items = {
3769 { "Mic", 0x0 },
3770 { "Line", 0x2 },
3771 { "CD", 0x4 },
3772 { "Headphone", 0x5 },
3773 },
3774 },
3775 {
3776 .num_items = 5,
3777 .items = {
3778 { "Mic", 0x0 },
3779 { "Line", 0x2 },
3780 { "CD", 0x4 },
3781 { "Headphone", 0x6 },
3782 { "Mixer", 0x5 },
3783 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003784 },
3785};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003786/*
3787 * This is just place-holder, so there's something for alc_build_pcms to look
3788 * at when it calculates the maximum number of channels. ALC260 has no mixer
3789 * element which allows changing the channel mode, so the verb list is
3790 * never used.
3791 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003792static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003793 { 2, NULL },
3794};
3795
Kailang Yangdf694da2005-12-05 19:42:22 +01003796
3797/* Mixer combinations
3798 *
3799 * basic: base_output + input + pc_beep + capture
3800 * HP: base_output + input + capture_alt
3801 * HP_3013: hp_3013 + input + capture
3802 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003803 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003804 */
3805
3806static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003807 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003808 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3810 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3811 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3812 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3813 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003814};
Kailang Yangdf694da2005-12-05 19:42:22 +01003815
3816static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3819 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003825 { } /* end */
3826};
3827
Kailang Yangdf694da2005-12-05 19:42:22 +01003828static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3829 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3830 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3831 { } /* end */
3832};
3833
Takashi Iwaibec15c32008-01-28 18:16:30 +01003834/* update HP, line and mono out pins according to the master switch */
3835static void alc260_hp_master_update(struct hda_codec *codec,
3836 hda_nid_t hp, hda_nid_t line,
3837 hda_nid_t mono)
3838{
3839 struct alc_spec *spec = codec->spec;
3840 unsigned int val = spec->master_sw ? PIN_HP : 0;
3841 /* change HP and line-out pins */
3842 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3843 val);
3844 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3845 val);
3846 /* mono (speaker) depending on the HP jack sense */
3847 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3848 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3849 val);
3850}
3851
3852static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3853 struct snd_ctl_elem_value *ucontrol)
3854{
3855 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3856 struct alc_spec *spec = codec->spec;
3857 *ucontrol->value.integer.value = spec->master_sw;
3858 return 0;
3859}
3860
3861static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3862 struct snd_ctl_elem_value *ucontrol)
3863{
3864 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3865 struct alc_spec *spec = codec->spec;
3866 int val = !!*ucontrol->value.integer.value;
3867 hda_nid_t hp, line, mono;
3868
3869 if (val == spec->master_sw)
3870 return 0;
3871 spec->master_sw = val;
3872 hp = (kcontrol->private_value >> 16) & 0xff;
3873 line = (kcontrol->private_value >> 8) & 0xff;
3874 mono = kcontrol->private_value & 0xff;
3875 alc260_hp_master_update(codec, hp, line, mono);
3876 return 1;
3877}
3878
3879static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3880 {
3881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3882 .name = "Master Playback Switch",
3883 .info = snd_ctl_boolean_mono_info,
3884 .get = alc260_hp_master_sw_get,
3885 .put = alc260_hp_master_sw_put,
3886 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3887 },
3888 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3889 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3890 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3891 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3892 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3893 HDA_OUTPUT),
3894 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3895 { } /* end */
3896};
3897
3898static struct hda_verb alc260_hp_unsol_verbs[] = {
3899 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3900 {},
3901};
3902
3903static void alc260_hp_automute(struct hda_codec *codec)
3904{
3905 struct alc_spec *spec = codec->spec;
3906 unsigned int present;
3907
3908 present = snd_hda_codec_read(codec, 0x10, 0,
3909 AC_VERB_GET_PIN_SENSE, 0);
3910 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3911 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3912}
3913
3914static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3915{
3916 if ((res >> 26) == ALC880_HP_EVENT)
3917 alc260_hp_automute(codec);
3918}
3919
Kailang Yangdf694da2005-12-05 19:42:22 +01003920static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003921 {
3922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3923 .name = "Master Playback Switch",
3924 .info = snd_ctl_boolean_mono_info,
3925 .get = alc260_hp_master_sw_get,
3926 .put = alc260_hp_master_sw_put,
3927 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3928 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003929 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3931 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3932 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003935 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3936 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003937 { } /* end */
3938};
3939
Takashi Iwaibec15c32008-01-28 18:16:30 +01003940static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3941 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3942 {},
3943};
3944
3945static void alc260_hp_3013_automute(struct hda_codec *codec)
3946{
3947 struct alc_spec *spec = codec->spec;
3948 unsigned int present;
3949
3950 present = snd_hda_codec_read(codec, 0x15, 0,
3951 AC_VERB_GET_PIN_SENSE, 0);
3952 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3953 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3954}
3955
3956static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3957 unsigned int res)
3958{
3959 if ((res >> 26) == ALC880_HP_EVENT)
3960 alc260_hp_3013_automute(codec);
3961}
3962
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003963/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3964 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3965 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003966static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003968 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003969 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003970 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3971 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3972 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3973 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003974 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003975 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3976 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01003977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3978 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003979 { } /* end */
3980};
3981
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003982/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3983 * versions of the ALC260 don't act on requests to enable mic bias from NID
3984 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3985 * datasheet doesn't mention this restriction. At this stage it's not clear
3986 * whether this behaviour is intentional or is a hardware bug in chip
3987 * revisions available in early 2006. Therefore for now allow the
3988 * "Headphone Jack Mode" control to span all choices, but if it turns out
3989 * that the lack of mic bias for this NID is intentional we could change the
3990 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3991 *
3992 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3993 * don't appear to make the mic bias available from the "line" jack, even
3994 * though the NID used for this jack (0x14) can supply it. The theory is
3995 * that perhaps Acer have included blocking capacitors between the ALC260
3996 * and the output jack. If this turns out to be the case for all such
3997 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3998 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003999 *
4000 * The C20x Tablet series have a mono internal speaker which is controlled
4001 * via the chip's Mono sum widget and pin complex, so include the necessary
4002 * controls for such models. On models without a "mono speaker" the control
4003 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004004 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004005static struct snd_kcontrol_new alc260_acer_mixer[] = {
4006 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4007 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004008 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004009 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004010 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004011 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004012 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004013 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4014 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4016 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4017 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4018 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4019 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4020 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4021 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4022 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4023 { } /* end */
4024};
4025
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004026/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4027 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4028 */
4029static struct snd_kcontrol_new alc260_will_mixer[] = {
4030 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4031 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4033 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4034 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4035 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4036 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4037 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4038 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4039 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4040 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4041 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4042 { } /* end */
4043};
4044
4045/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4046 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4047 */
4048static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4049 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4050 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4052 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4053 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4054 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4055 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4056 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4057 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4058 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4059 { } /* end */
4060};
4061
Kailang Yangdf694da2005-12-05 19:42:22 +01004062/* capture mixer elements */
4063static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004064 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4065 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004066 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4067 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004068 {
4069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004070 /* The multiple "Capture Source" controls confuse alsamixer
4071 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004072 */
4073 /* .name = "Capture Source", */
4074 .name = "Input Source",
4075 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004076 .info = alc_mux_enum_info,
4077 .get = alc_mux_enum_get,
4078 .put = alc_mux_enum_put,
4079 },
4080 { } /* end */
4081};
4082
Kailang Yangdf694da2005-12-05 19:42:22 +01004083static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4084 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4085 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4086 {
4087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4088 /* The multiple "Capture Source" controls confuse alsamixer
4089 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004090 */
4091 /* .name = "Capture Source", */
4092 .name = "Input Source",
4093 .count = 1,
4094 .info = alc_mux_enum_info,
4095 .get = alc_mux_enum_get,
4096 .put = alc_mux_enum_put,
4097 },
4098 { } /* end */
4099};
4100
4101/*
4102 * initialization verbs
4103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004104static struct hda_verb alc260_init_verbs[] = {
4105 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004106 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004107 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004108 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004109 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004111 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004112 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004113 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004114 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004115 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004116 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004117 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004118 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004119 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004120 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004121 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004122 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4123 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004125 /* set connection select to line in (default select for this ADC) */
4126 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004127 /* mute capture amp left and right */
4128 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4129 /* set connection select to line in (default select for this ADC) */
4130 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004131 /* set vol=0 Line-Out mixer amp left and right */
4132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4133 /* unmute pin widget amp left and right (no gain on this amp) */
4134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4135 /* set vol=0 HP mixer amp left and right */
4136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4137 /* unmute pin widget amp left and right (no gain on this amp) */
4138 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4139 /* set vol=0 Mono mixer amp left and right */
4140 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4141 /* unmute pin widget amp left and right (no gain on this amp) */
4142 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4143 /* unmute LINE-2 out pin */
4144 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4146 * Line In 2 = 0x03
4147 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004148 /* mute analog inputs */
4149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004154 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004155 /* mute Front out path */
4156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4158 /* mute Headphone out path */
4159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4160 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4161 /* mute Mono out path */
4162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4163 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004164 { }
4165};
4166
Takashi Iwai474167d2006-05-17 17:17:43 +02004167#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004168static struct hda_verb alc260_hp_init_verbs[] = {
4169 /* Headphone and output */
4170 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4171 /* mono output */
4172 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4173 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4175 /* Mic2 (front panel) pin widget for input and vref at 80% */
4176 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4177 /* Line In pin widget for input */
4178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4179 /* Line-2 pin widget for output */
4180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4181 /* CD pin widget for input */
4182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4183 /* unmute amp left and right */
4184 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4185 /* set connection select to line in (default select for this ADC) */
4186 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4187 /* unmute Line-Out mixer amp left and right (volume = 0) */
4188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4189 /* mute pin widget amp left and right (no gain on this amp) */
4190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4191 /* unmute HP mixer amp left and right (volume = 0) */
4192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4193 /* mute pin widget amp left and right (no gain on this amp) */
4194 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004195 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4196 * Line In 2 = 0x03
4197 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004198 /* mute analog inputs */
4199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004204 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4205 /* Unmute Front out path */
4206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4208 /* Unmute Headphone out path */
4209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4211 /* Unmute Mono out path */
4212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4214 { }
4215};
Takashi Iwai474167d2006-05-17 17:17:43 +02004216#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004217
4218static struct hda_verb alc260_hp_3013_init_verbs[] = {
4219 /* Line out and output */
4220 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4221 /* mono output */
4222 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4223 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4224 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4225 /* Mic2 (front panel) pin widget for input and vref at 80% */
4226 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4227 /* Line In pin widget for input */
4228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4229 /* Headphone pin widget for output */
4230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4231 /* CD pin widget for input */
4232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4233 /* unmute amp left and right */
4234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4235 /* set connection select to line in (default select for this ADC) */
4236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4237 /* unmute Line-Out mixer amp left and right (volume = 0) */
4238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4239 /* mute pin widget amp left and right (no gain on this amp) */
4240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4241 /* unmute HP mixer amp left and right (volume = 0) */
4242 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4243 /* mute pin widget amp left and right (no gain on this amp) */
4244 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004245 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4246 * Line In 2 = 0x03
4247 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004248 /* mute analog inputs */
4249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004254 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4255 /* Unmute Front out path */
4256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4258 /* Unmute Headphone out path */
4259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4261 /* Unmute Mono out path */
4262 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4263 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4264 { }
4265};
4266
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004267/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004268 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4269 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004270 */
4271static struct hda_verb alc260_fujitsu_init_verbs[] = {
4272 /* Disable all GPIOs */
4273 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4274 /* Internal speaker is connected to headphone pin */
4275 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4276 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004278 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4280 /* Ensure all other unused pins are disabled and muted. */
4281 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004283 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004286 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004289
Jonathan Woithef7ace402006-02-28 11:46:14 +01004290 /* Disable digital (SPDIF) pins */
4291 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4292 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004293
Jonathan Woithef7ace402006-02-28 11:46:14 +01004294 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4295 * when acting as an output.
4296 */
4297 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4298
4299 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4306 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4307 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4308 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004309
Jonathan Woithef7ace402006-02-28 11:46:14 +01004310 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4311 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4312 /* Unmute Line1 pin widget output buffer since it starts as an output.
4313 * If the pin mode is changed by the user the pin mode control will
4314 * take care of enabling the pin's input/output buffers as needed.
4315 * Therefore there's no need to enable the input buffer at this
4316 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004317 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004319 /* Unmute input buffer of pin widget used for Line-in (no equiv
4320 * mixer ctrl)
4321 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004322 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004323
Jonathan Woithef7ace402006-02-28 11:46:14 +01004324 /* Mute capture amp left and right */
4325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4326 /* Set ADC connection select to match default mixer setting - line
4327 * in (on mic1 pin)
4328 */
4329 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004330
Jonathan Woithef7ace402006-02-28 11:46:14 +01004331 /* Do the same for the second ADC: mute capture input amp and
4332 * set ADC connection to line in (on mic1 pin)
4333 */
4334 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4335 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004336
Jonathan Woithef7ace402006-02-28 11:46:14 +01004337 /* Mute all inputs to mixer widget (even unconnected ones) */
4338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004346
4347 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004348};
4349
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004350/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4351 * similar laptops (adapted from Fujitsu init verbs).
4352 */
4353static struct hda_verb alc260_acer_init_verbs[] = {
4354 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4355 * the headphone jack. Turn this on and rely on the standard mute
4356 * methods whenever the user wants to turn these outputs off.
4357 */
4358 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4359 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4360 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4361 /* Internal speaker/Headphone jack is connected to Line-out pin */
4362 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4363 /* Internal microphone/Mic jack is connected to Mic1 pin */
4364 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4365 /* Line In jack is connected to Line1 pin */
4366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004367 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4368 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004369 /* Ensure all other unused pins are disabled and muted. */
4370 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4371 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004372 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4373 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4376 /* Disable digital (SPDIF) pins */
4377 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4378 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4379
4380 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4381 * bus when acting as outputs.
4382 */
4383 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4384 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4385
4386 /* Start with output sum widgets muted and their output gains at min */
4387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4393 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4396
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004397 /* Unmute Line-out pin widget amp left and right
4398 * (no equiv mixer ctrl)
4399 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004401 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4402 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004403 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4404 * inputs. If the pin mode is changed by the user the pin mode control
4405 * will take care of enabling the pin's input/output buffers as needed.
4406 * Therefore there's no need to enable the input buffer at this
4407 * stage.
4408 */
4409 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4411
4412 /* Mute capture amp left and right */
4413 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4414 /* Set ADC connection select to match default mixer setting - mic
4415 * (on mic1 pin)
4416 */
4417 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4418
4419 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004420 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004421 */
4422 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004423 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004424
4425 /* Mute all inputs to mixer widget (even unconnected ones) */
4426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4434
4435 { }
4436};
4437
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004438static struct hda_verb alc260_will_verbs[] = {
4439 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4440 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4441 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4442 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4443 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4444 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4445 {}
4446};
4447
4448static struct hda_verb alc260_replacer_672v_verbs[] = {
4449 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4450 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4451 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4452
4453 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4454 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4455 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4456
4457 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4458 {}
4459};
4460
4461/* toggle speaker-output according to the hp-jack state */
4462static void alc260_replacer_672v_automute(struct hda_codec *codec)
4463{
4464 unsigned int present;
4465
4466 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4467 present = snd_hda_codec_read(codec, 0x0f, 0,
4468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4469 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004470 snd_hda_codec_write_cache(codec, 0x01, 0,
4471 AC_VERB_SET_GPIO_DATA, 1);
4472 snd_hda_codec_write_cache(codec, 0x0f, 0,
4473 AC_VERB_SET_PIN_WIDGET_CONTROL,
4474 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004475 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004476 snd_hda_codec_write_cache(codec, 0x01, 0,
4477 AC_VERB_SET_GPIO_DATA, 0);
4478 snd_hda_codec_write_cache(codec, 0x0f, 0,
4479 AC_VERB_SET_PIN_WIDGET_CONTROL,
4480 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004481 }
4482}
4483
4484static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4485 unsigned int res)
4486{
4487 if ((res >> 26) == ALC880_HP_EVENT)
4488 alc260_replacer_672v_automute(codec);
4489}
4490
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004491/* Test configuration for debugging, modelled after the ALC880 test
4492 * configuration.
4493 */
4494#ifdef CONFIG_SND_DEBUG
4495static hda_nid_t alc260_test_dac_nids[1] = {
4496 0x02,
4497};
4498static hda_nid_t alc260_test_adc_nids[2] = {
4499 0x04, 0x05,
4500};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004501/* For testing the ALC260, each input MUX needs its own definition since
4502 * the signal assignments are different. This assumes that the first ADC
4503 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004504 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004505static struct hda_input_mux alc260_test_capture_sources[2] = {
4506 {
4507 .num_items = 7,
4508 .items = {
4509 { "MIC1 pin", 0x0 },
4510 { "MIC2 pin", 0x1 },
4511 { "LINE1 pin", 0x2 },
4512 { "LINE2 pin", 0x3 },
4513 { "CD pin", 0x4 },
4514 { "LINE-OUT pin", 0x5 },
4515 { "HP-OUT pin", 0x6 },
4516 },
4517 },
4518 {
4519 .num_items = 8,
4520 .items = {
4521 { "MIC1 pin", 0x0 },
4522 { "MIC2 pin", 0x1 },
4523 { "LINE1 pin", 0x2 },
4524 { "LINE2 pin", 0x3 },
4525 { "CD pin", 0x4 },
4526 { "Mixer", 0x5 },
4527 { "LINE-OUT pin", 0x6 },
4528 { "HP-OUT pin", 0x7 },
4529 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004530 },
4531};
4532static struct snd_kcontrol_new alc260_test_mixer[] = {
4533 /* Output driver widgets */
4534 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4535 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4536 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4537 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4538 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4539 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4540
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004541 /* Modes for retasking pin widgets
4542 * Note: the ALC260 doesn't seem to act on requests to enable mic
4543 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4544 * mention this restriction. At this stage it's not clear whether
4545 * this behaviour is intentional or is a hardware bug in chip
4546 * revisions available at least up until early 2006. Therefore for
4547 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4548 * choices, but if it turns out that the lack of mic bias for these
4549 * NIDs is intentional we could change their modes from
4550 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4551 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004552 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4553 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4554 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4555 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4556 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4557 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4558
4559 /* Loopback mixer controls */
4560 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4561 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4562 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4563 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4564 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4565 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4566 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4567 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4568 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4569 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4570 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4571 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4572 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4573 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4574 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4575 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004576
4577 /* Controls for GPIO pins, assuming they are configured as outputs */
4578 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4579 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4580 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4581 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4582
Jonathan Woithe92621f12006-02-28 11:47:47 +01004583 /* Switches to allow the digital IO pins to be enabled. The datasheet
4584 * is ambigious as to which NID is which; testing on laptops which
4585 * make this output available should provide clarification.
4586 */
4587 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4588 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4589
Jonathan Woithef8225f62008-01-08 12:16:54 +01004590 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4591 * this output to turn on an external amplifier.
4592 */
4593 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4594 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4595
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004596 { } /* end */
4597};
4598static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004599 /* Enable all GPIOs as outputs with an initial value of 0 */
4600 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4601 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4602 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4603
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004604 /* Enable retasking pins as output, initially without power amp */
4605 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4606 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4609 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4610 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4611
Jonathan Woithe92621f12006-02-28 11:47:47 +01004612 /* Disable digital (SPDIF) pins initially, but users can enable
4613 * them via a mixer switch. In the case of SPDIF-out, this initverb
4614 * payload also sets the generation to 0, output to be in "consumer"
4615 * PCM format, copyright asserted, no pre-emphasis and no validity
4616 * control.
4617 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004618 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4619 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4620
Jonathan Woithef7ace402006-02-28 11:46:14 +01004621 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004622 * OUT1 sum bus when acting as an output.
4623 */
4624 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4625 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4626 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4627 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4628
4629 /* Start with output sum widgets muted and their output gains at min */
4630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4636 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4639
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004640 /* Unmute retasking pin widget output buffers since the default
4641 * state appears to be output. As the pin mode is changed by the
4642 * user the pin mode control will take care of enabling the pin's
4643 * input/output buffers as needed.
4644 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004645 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4649 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4650 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4651 /* Also unmute the mono-out pin widget */
4652 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4653
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004654 /* Mute capture amp left and right */
4655 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004656 /* Set ADC connection select to match default mixer setting (mic1
4657 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004658 */
4659 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4660
4661 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004662 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004663 */
4664 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4665 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4666
4667 /* Mute all inputs to mixer widget (even unconnected ones) */
4668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4676
4677 { }
4678};
4679#endif
4680
Takashi Iwai63300792008-01-24 15:31:36 +01004681#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4682#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004683
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004684#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4685#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4686
Kailang Yangdf694da2005-12-05 19:42:22 +01004687/*
4688 * for BIOS auto-configuration
4689 */
4690
4691static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4692 const char *pfx)
4693{
4694 hda_nid_t nid_vol;
4695 unsigned long vol_val, sw_val;
4696 char name[32];
4697 int err;
4698
4699 if (nid >= 0x0f && nid < 0x11) {
4700 nid_vol = nid - 0x7;
4701 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4702 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4703 } else if (nid == 0x11) {
4704 nid_vol = nid - 0x7;
4705 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4706 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4707 } else if (nid >= 0x12 && nid <= 0x15) {
4708 nid_vol = 0x08;
4709 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4710 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4711 } else
4712 return 0; /* N/A */
4713
4714 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004715 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4716 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004717 return err;
4718 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004719 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4720 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004721 return err;
4722 return 1;
4723}
4724
4725/* add playback controls from the parsed DAC table */
4726static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4727 const struct auto_pin_cfg *cfg)
4728{
4729 hda_nid_t nid;
4730 int err;
4731
4732 spec->multiout.num_dacs = 1;
4733 spec->multiout.dac_nids = spec->private_dac_nids;
4734 spec->multiout.dac_nids[0] = 0x02;
4735
4736 nid = cfg->line_out_pins[0];
4737 if (nid) {
4738 err = alc260_add_playback_controls(spec, nid, "Front");
4739 if (err < 0)
4740 return err;
4741 }
4742
Takashi Iwai82bc9552006-03-21 11:24:42 +01004743 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004744 if (nid) {
4745 err = alc260_add_playback_controls(spec, nid, "Speaker");
4746 if (err < 0)
4747 return err;
4748 }
4749
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004750 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004751 if (nid) {
4752 err = alc260_add_playback_controls(spec, nid, "Headphone");
4753 if (err < 0)
4754 return err;
4755 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004756 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004757}
4758
4759/* create playback/capture controls for input pins */
4760static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4761 const struct auto_pin_cfg *cfg)
4762{
Kailang Yangdf694da2005-12-05 19:42:22 +01004763 struct hda_input_mux *imux = &spec->private_imux;
4764 int i, err, idx;
4765
4766 for (i = 0; i < AUTO_PIN_LAST; i++) {
4767 if (cfg->input_pins[i] >= 0x12) {
4768 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004769 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004770 auto_pin_cfg_labels[i], idx,
4771 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004772 if (err < 0)
4773 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004774 imux->items[imux->num_items].label =
4775 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004776 imux->items[imux->num_items].index = idx;
4777 imux->num_items++;
4778 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004779 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004780 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004781 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004782 auto_pin_cfg_labels[i], idx,
4783 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004784 if (err < 0)
4785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004786 imux->items[imux->num_items].label =
4787 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004788 imux->items[imux->num_items].index = idx;
4789 imux->num_items++;
4790 }
4791 }
4792 return 0;
4793}
4794
4795static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4796 hda_nid_t nid, int pin_type,
4797 int sel_idx)
4798{
4799 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4801 pin_type);
4802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4803 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 /* need the manual connection? */
4805 if (nid >= 0x12) {
4806 int idx = nid - 0x12;
4807 snd_hda_codec_write(codec, idx + 0x0b, 0,
4808 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004809 }
4810}
4811
4812static void alc260_auto_init_multi_out(struct hda_codec *codec)
4813{
4814 struct alc_spec *spec = codec->spec;
4815 hda_nid_t nid;
4816
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004817 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004819 if (nid) {
4820 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4821 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4822 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004823
Takashi Iwai82bc9552006-03-21 11:24:42 +01004824 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004825 if (nid)
4826 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4827
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004828 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004829 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004830 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004831}
Kailang Yangdf694da2005-12-05 19:42:22 +01004832
4833#define ALC260_PIN_CD_NID 0x16
4834static void alc260_auto_init_analog_input(struct hda_codec *codec)
4835{
4836 struct alc_spec *spec = codec->spec;
4837 int i;
4838
4839 for (i = 0; i < AUTO_PIN_LAST; i++) {
4840 hda_nid_t nid = spec->autocfg.input_pins[i];
4841 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004842 snd_hda_codec_write(codec, nid, 0,
4843 AC_VERB_SET_PIN_WIDGET_CONTROL,
4844 i <= AUTO_PIN_FRONT_MIC ?
4845 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004846 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004847 snd_hda_codec_write(codec, nid, 0,
4848 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004849 AMP_OUT_MUTE);
4850 }
4851 }
4852}
4853
4854/*
4855 * generic initialization of ADC, input mixers and output mixers
4856 */
4857static struct hda_verb alc260_volume_init_verbs[] = {
4858 /*
4859 * Unmute ADC0-1 and set the default input to mic-in
4860 */
4861 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4862 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4863 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4864 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4865
4866 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4867 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004868 * Note: PASD motherboards uses the Line In 2 as the input for
4869 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004870 */
4871 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004872 /* mute analog inputs */
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004878
4879 /*
4880 * Set up output mixers (0x08 - 0x0a)
4881 */
4882 /* set vol=0 to output mixers */
4883 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4885 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4886 /* set up input amps for analog loopback */
4887 /* Amp Indices: DAC = 0, mixer = 1 */
4888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4892 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4894
4895 { }
4896};
4897
4898static int alc260_parse_auto_config(struct hda_codec *codec)
4899{
4900 struct alc_spec *spec = codec->spec;
4901 unsigned int wcap;
4902 int err;
4903 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004905 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4906 alc260_ignore);
4907 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004908 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004909 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4910 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004911 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004912 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004913 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004914 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4915 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004916 return err;
4917
4918 spec->multiout.max_channels = 2;
4919
4920 if (spec->autocfg.dig_out_pin)
4921 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4922 if (spec->kctl_alloc)
4923 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4924
4925 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4926
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004927 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004928 spec->input_mux = &spec->private_imux;
4929
4930 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004931 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004932 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4933 if (wcap != AC_WID_AUD_IN) {
4934 spec->adc_nids = alc260_adc_nids_alt;
4935 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4936 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004937 } else {
4938 spec->adc_nids = alc260_adc_nids;
4939 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4940 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004941 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004942 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004943
4944 return 1;
4945}
4946
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004947/* additional initialization for auto-configuration model */
4948static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004949{
Kailang Yangdf694da2005-12-05 19:42:22 +01004950 alc260_auto_init_multi_out(codec);
4951 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004952}
4953
Takashi Iwaicb53c622007-08-10 17:21:45 +02004954#ifdef CONFIG_SND_HDA_POWER_SAVE
4955static struct hda_amp_list alc260_loopbacks[] = {
4956 { 0x07, HDA_INPUT, 0 },
4957 { 0x07, HDA_INPUT, 1 },
4958 { 0x07, HDA_INPUT, 2 },
4959 { 0x07, HDA_INPUT, 3 },
4960 { 0x07, HDA_INPUT, 4 },
4961 { } /* end */
4962};
4963#endif
4964
Kailang Yangdf694da2005-12-05 19:42:22 +01004965/*
4966 * ALC260 configurations
4967 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004968static const char *alc260_models[ALC260_MODEL_LAST] = {
4969 [ALC260_BASIC] = "basic",
4970 [ALC260_HP] = "hp",
4971 [ALC260_HP_3013] = "hp-3013",
4972 [ALC260_FUJITSU_S702X] = "fujitsu",
4973 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004974 [ALC260_WILL] = "will",
4975 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004976#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004977 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004978#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004979 [ALC260_AUTO] = "auto",
4980};
4981
4982static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004983 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004984 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004985 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004986 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004987 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4988 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4989 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4990 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4991 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4992 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4993 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4994 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4995 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4996 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4997 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4998 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004999 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005000 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005001 {}
5002};
5003
Kailang Yangdf694da2005-12-05 19:42:22 +01005004static struct alc_config_preset alc260_presets[] = {
5005 [ALC260_BASIC] = {
5006 .mixers = { alc260_base_output_mixer,
5007 alc260_input_mixer,
5008 alc260_pc_beep_mixer,
5009 alc260_capture_mixer },
5010 .init_verbs = { alc260_init_verbs },
5011 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5012 .dac_nids = alc260_dac_nids,
5013 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5014 .adc_nids = alc260_adc_nids,
5015 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5016 .channel_mode = alc260_modes,
5017 .input_mux = &alc260_capture_source,
5018 },
5019 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005020 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005021 alc260_input_mixer,
5022 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005023 .init_verbs = { alc260_init_verbs,
5024 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005025 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5026 .dac_nids = alc260_dac_nids,
5027 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5028 .adc_nids = alc260_hp_adc_nids,
5029 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5030 .channel_mode = alc260_modes,
5031 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005032 .unsol_event = alc260_hp_unsol_event,
5033 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005034 },
5035 [ALC260_HP_3013] = {
5036 .mixers = { alc260_hp_3013_mixer,
5037 alc260_input_mixer,
5038 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005039 .init_verbs = { alc260_hp_3013_init_verbs,
5040 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005041 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5042 .dac_nids = alc260_dac_nids,
5043 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5044 .adc_nids = alc260_hp_adc_nids,
5045 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5046 .channel_mode = alc260_modes,
5047 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005048 .unsol_event = alc260_hp_3013_unsol_event,
5049 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005050 },
5051 [ALC260_FUJITSU_S702X] = {
5052 .mixers = { alc260_fujitsu_mixer,
5053 alc260_capture_mixer },
5054 .init_verbs = { alc260_fujitsu_init_verbs },
5055 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5056 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005057 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5058 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005059 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5060 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005061 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5062 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005063 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005064 [ALC260_ACER] = {
5065 .mixers = { alc260_acer_mixer,
5066 alc260_capture_mixer },
5067 .init_verbs = { alc260_acer_init_verbs },
5068 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5069 .dac_nids = alc260_dac_nids,
5070 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5071 .adc_nids = alc260_dual_adc_nids,
5072 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5073 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005074 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5075 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005076 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005077 [ALC260_WILL] = {
5078 .mixers = { alc260_will_mixer,
5079 alc260_capture_mixer },
5080 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5081 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5082 .dac_nids = alc260_dac_nids,
5083 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5084 .adc_nids = alc260_adc_nids,
5085 .dig_out_nid = ALC260_DIGOUT_NID,
5086 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5087 .channel_mode = alc260_modes,
5088 .input_mux = &alc260_capture_source,
5089 },
5090 [ALC260_REPLACER_672V] = {
5091 .mixers = { alc260_replacer_672v_mixer,
5092 alc260_capture_mixer },
5093 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5094 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5095 .dac_nids = alc260_dac_nids,
5096 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5097 .adc_nids = alc260_adc_nids,
5098 .dig_out_nid = ALC260_DIGOUT_NID,
5099 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5100 .channel_mode = alc260_modes,
5101 .input_mux = &alc260_capture_source,
5102 .unsol_event = alc260_replacer_672v_unsol_event,
5103 .init_hook = alc260_replacer_672v_automute,
5104 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005105#ifdef CONFIG_SND_DEBUG
5106 [ALC260_TEST] = {
5107 .mixers = { alc260_test_mixer,
5108 alc260_capture_mixer },
5109 .init_verbs = { alc260_test_init_verbs },
5110 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5111 .dac_nids = alc260_test_dac_nids,
5112 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5113 .adc_nids = alc260_test_adc_nids,
5114 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5115 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005116 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5117 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005118 },
5119#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005120};
5121
Linus Torvalds1da177e2005-04-16 15:20:36 -07005122static int patch_alc260(struct hda_codec *codec)
5123{
5124 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005125 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005126
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005127 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005128 if (spec == NULL)
5129 return -ENOMEM;
5130
5131 codec->spec = spec;
5132
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005133 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5134 alc260_models,
5135 alc260_cfg_tbl);
5136 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005137 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5138 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005139 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005140 }
5141
Kailang Yangdf694da2005-12-05 19:42:22 +01005142 if (board_config == ALC260_AUTO) {
5143 /* automatic parse from the BIOS config */
5144 err = alc260_parse_auto_config(codec);
5145 if (err < 0) {
5146 alc_free(codec);
5147 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005148 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005149 printk(KERN_INFO
5150 "hda_codec: Cannot set up configuration "
5151 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005152 board_config = ALC260_BASIC;
5153 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005154 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005155
Kailang Yangdf694da2005-12-05 19:42:22 +01005156 if (board_config != ALC260_AUTO)
5157 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005158
5159 spec->stream_name_analog = "ALC260 Analog";
5160 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5161 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5162
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005163 spec->stream_name_digital = "ALC260 Digital";
5164 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5165 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5166
Takashi Iwai2134ea42008-01-10 16:53:55 +01005167 spec->vmaster_nid = 0x08;
5168
Linus Torvalds1da177e2005-04-16 15:20:36 -07005169 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005171 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005172#ifdef CONFIG_SND_HDA_POWER_SAVE
5173 if (!spec->loopback.amplist)
5174 spec->loopback.amplist = alc260_loopbacks;
5175#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005176
5177 return 0;
5178}
5179
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005180
Linus Torvalds1da177e2005-04-16 15:20:36 -07005181/*
5182 * ALC882 support
5183 *
5184 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5185 * configuration. Each pin widget can choose any input DACs and a mixer.
5186 * Each ADC is connected from a mixer of all inputs. This makes possible
5187 * 6-channel independent captures.
5188 *
5189 * In addition, an independent DAC for the multi-playback (not used in this
5190 * driver yet).
5191 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005192#define ALC882_DIGOUT_NID 0x06
5193#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005194
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005195static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005196 { 8, NULL }
5197};
5198
5199static hda_nid_t alc882_dac_nids[4] = {
5200 /* front, rear, clfe, rear_surr */
5201 0x02, 0x03, 0x04, 0x05
5202};
5203
Kailang Yangdf694da2005-12-05 19:42:22 +01005204/* identical with ALC880 */
5205#define alc882_adc_nids alc880_adc_nids
5206#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005207
5208/* input MUX */
5209/* FIXME: should be a matrix-type input source selection */
5210
5211static struct hda_input_mux alc882_capture_source = {
5212 .num_items = 4,
5213 .items = {
5214 { "Mic", 0x0 },
5215 { "Front Mic", 0x1 },
5216 { "Line", 0x2 },
5217 { "CD", 0x4 },
5218 },
5219};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005220#define alc882_mux_enum_info alc_mux_enum_info
5221#define alc882_mux_enum_get alc_mux_enum_get
5222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005223static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5224 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005225{
5226 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5227 struct alc_spec *spec = codec->spec;
5228 const struct hda_input_mux *imux = spec->input_mux;
5229 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5230 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
Takashi Iwaicced83b2008-02-22 18:45:30 +01005231 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005232 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5233 unsigned int i, idx;
5234
Takashi Iwaicced83b2008-02-22 18:45:30 +01005235 if (spec->num_adc_nids < 3)
5236 nid = capture_mixers[adc_idx + 1];
5237 else
5238 nid = capture_mixers[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005239 idx = ucontrol->value.enumerated.item[0];
5240 if (idx >= imux->num_items)
5241 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005242 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005243 return 0;
5244 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005245 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5246 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005247 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005248 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005249 }
5250 *cur_val = idx;
5251 return 1;
5252}
5253
Kailang Yangdf694da2005-12-05 19:42:22 +01005254/*
Kailang Yang272a5272007-05-14 11:00:38 +02005255 * 2ch mode
5256 */
5257static struct hda_verb alc882_3ST_ch2_init[] = {
5258 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5259 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5260 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5261 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5262 { } /* end */
5263};
5264
5265/*
5266 * 6ch mode
5267 */
5268static struct hda_verb alc882_3ST_ch6_init[] = {
5269 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5270 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5271 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5272 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5273 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5274 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5275 { } /* end */
5276};
5277
5278static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5279 { 2, alc882_3ST_ch2_init },
5280 { 6, alc882_3ST_ch6_init },
5281};
5282
5283/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005284 * 6ch mode
5285 */
5286static struct hda_verb alc882_sixstack_ch6_init[] = {
5287 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5288 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5289 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5290 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5291 { } /* end */
5292};
5293
5294/*
5295 * 8ch mode
5296 */
5297static struct hda_verb alc882_sixstack_ch8_init[] = {
5298 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5299 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5300 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5301 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5302 { } /* end */
5303};
5304
5305static struct hda_channel_mode alc882_sixstack_modes[2] = {
5306 { 6, alc882_sixstack_ch6_init },
5307 { 8, alc882_sixstack_ch8_init },
5308};
5309
Takashi Iwai87350ad2007-08-16 18:19:38 +02005310/*
5311 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5312 */
5313
5314/*
5315 * 2ch mode
5316 */
5317static struct hda_verb alc885_mbp_ch2_init[] = {
5318 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5319 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5321 { } /* end */
5322};
5323
5324/*
5325 * 6ch mode
5326 */
5327static struct hda_verb alc885_mbp_ch6_init[] = {
5328 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5329 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5330 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5331 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5333 { } /* end */
5334};
5335
5336static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5337 { 2, alc885_mbp_ch2_init },
5338 { 6, alc885_mbp_ch6_init },
5339};
5340
5341
Linus Torvalds1da177e2005-04-16 15:20:36 -07005342/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5343 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5344 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005345static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005346 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005347 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005348 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005349 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005350 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5351 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005352 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5353 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005354 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005355 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005356 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5357 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5358 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5359 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5360 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005362 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5364 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005365 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005366 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5367 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5368 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005369 { } /* end */
5370};
5371
Takashi Iwai87350ad2007-08-16 18:19:38 +02005372static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005373 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5374 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5375 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5376 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5378 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5380 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005381 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5383 { } /* end */
5384};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005385static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5386 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5387 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5388 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5389 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5390 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5391 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5395 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5396 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5397 { } /* end */
5398};
5399
Kailang Yang272a5272007-05-14 11:00:38 +02005400static struct snd_kcontrol_new alc882_targa_mixer[] = {
5401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5404 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5405 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5406 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5407 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005410 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005411 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5412 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005413 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005414 { } /* end */
5415};
5416
5417/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5418 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5419 */
5420static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5421 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5422 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5424 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5429 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5430 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005434 { } /* end */
5435};
5436
Takashi Iwai914759b2007-09-06 14:52:04 +02005437static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5439 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5443 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5444 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5445 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5446 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5448 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5449 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5450 { } /* end */
5451};
5452
Kailang Yangdf694da2005-12-05 19:42:22 +01005453static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5454 {
5455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5456 .name = "Channel Mode",
5457 .info = alc_ch_mode_info,
5458 .get = alc_ch_mode_get,
5459 .put = alc_ch_mode_put,
5460 },
5461 { } /* end */
5462};
5463
Linus Torvalds1da177e2005-04-16 15:20:36 -07005464static struct hda_verb alc882_init_verbs[] = {
5465 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005469 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005473 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005477 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5480 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005481
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005482 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005486 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005490 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005493 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005494 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005495 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005497 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005498 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5501 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5504 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5507 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513
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 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {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)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005522 {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)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005526 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005527 {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)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005534 /* ADC2: mute amp left and right */
5535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005536 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005537 /* ADC3: mute amp left and right */
5538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005540
5541 { }
5542};
5543
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005544static struct hda_verb alc882_eapd_verbs[] = {
5545 /* change to EAPD mode */
5546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005547 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005548 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005549};
5550
Tobin Davis9102cd12006-12-15 10:02:12 +01005551/* Mac Pro test */
5552static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5554 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5558 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5559 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5560 { } /* end */
5561};
5562
5563static struct hda_verb alc882_macpro_init_verbs[] = {
5564 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5568 /* Front Pin: output 0 (0x0c) */
5569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5570 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5571 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5572 /* Front Mic pin: input vref at 80% */
5573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5575 /* Speaker: output */
5576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5578 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5579 /* Headphone output (output 0 - 0x0c) */
5580 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5582 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5583
5584 /* FIXME: use matrix-type input source selection */
5585 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5586 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5591 /* Input mixer2 */
5592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5596 /* Input mixer3 */
5597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5601 /* ADC1: mute amp left and right */
5602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5603 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5604 /* ADC2: mute amp left and right */
5605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5607 /* ADC3: mute amp left and right */
5608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5609 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5610
5611 { }
5612};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005613
Takashi Iwai87350ad2007-08-16 18:19:38 +02005614/* Macbook Pro rev3 */
5615static struct hda_verb alc885_mbp3_init_verbs[] = {
5616 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5620 /* Rear mixer */
5621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5624 /* Front Pin: output 0 (0x0c) */
5625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5628 /* HP Pin: output 0 (0x0d) */
5629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5632 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5633 /* Mic (rear) pin: input vref at 80% */
5634 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5635 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5636 /* Front Mic pin: input vref at 80% */
5637 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5639 /* Line In pin: use output 1 when in LineOut mode */
5640 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5642 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5643
5644 /* FIXME: use matrix-type input source selection */
5645 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5646 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5650 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5651 /* Input mixer2 */
5652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5656 /* Input mixer3 */
5657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5661 /* ADC1: mute amp left and right */
5662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5664 /* ADC2: mute amp left and right */
5665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5667 /* ADC3: mute amp left and right */
5668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5669 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5670
5671 { }
5672};
5673
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005674/* iMac 24 mixer. */
5675static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5676 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5677 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5678 { } /* end */
5679};
5680
5681/* iMac 24 init verbs. */
5682static struct hda_verb alc885_imac24_init_verbs[] = {
5683 /* Internal speakers: output 0 (0x0c) */
5684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5686 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5687 /* Internal speakers: output 0 (0x0c) */
5688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5690 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5691 /* Headphone: output 0 (0x0c) */
5692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5694 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5695 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5696 /* Front Mic: input vref at 80% */
5697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5699 { }
5700};
5701
5702/* Toggle speaker-output according to the hp-jack state */
5703static void alc885_imac24_automute(struct hda_codec *codec)
5704{
5705 unsigned int present;
5706
5707 present = snd_hda_codec_read(codec, 0x14, 0,
5708 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005709 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5710 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5711 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5712 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005713}
5714
5715/* Processes unsolicited events. */
5716static void alc885_imac24_unsol_event(struct hda_codec *codec,
5717 unsigned int res)
5718{
5719 /* Headphone insertion or removal. */
5720 if ((res >> 26) == ALC880_HP_EVENT)
5721 alc885_imac24_automute(codec);
5722}
5723
Takashi Iwai87350ad2007-08-16 18:19:38 +02005724static void alc885_mbp3_automute(struct hda_codec *codec)
5725{
5726 unsigned int present;
5727
5728 present = snd_hda_codec_read(codec, 0x15, 0,
5729 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5730 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5731 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5732 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5733 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5734
5735}
5736static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5737 unsigned int res)
5738{
5739 /* Headphone insertion or removal. */
5740 if ((res >> 26) == ALC880_HP_EVENT)
5741 alc885_mbp3_automute(codec);
5742}
5743
5744
Kailang Yang272a5272007-05-14 11:00:38 +02005745static struct hda_verb alc882_targa_verbs[] = {
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5748
5749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5751
5752 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5753 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5754 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5755
5756 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5757 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5759 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5760 { } /* end */
5761};
5762
5763/* toggle speaker-output according to the hp-jack state */
5764static void alc882_targa_automute(struct hda_codec *codec)
5765{
5766 unsigned int present;
5767
5768 present = snd_hda_codec_read(codec, 0x14, 0,
5769 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005770 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005772 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5773 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005774}
5775
5776static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5777{
5778 /* Looks like the unsol event is incompatible with the standard
5779 * definition. 4bit tag is placed at 26 bit!
5780 */
5781 if (((res >> 26) == ALC880_HP_EVENT)) {
5782 alc882_targa_automute(codec);
5783 }
5784}
5785
5786static struct hda_verb alc882_asus_a7j_verbs[] = {
5787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5789
5790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5792 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5793
5794 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5795 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5796 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5797
5798 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5799 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5800 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5801 { } /* end */
5802};
5803
Takashi Iwai914759b2007-09-06 14:52:04 +02005804static struct hda_verb alc882_asus_a7m_verbs[] = {
5805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5807
5808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5809 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5811
5812 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5813 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5814 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5815
5816 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5817 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5818 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5819 { } /* end */
5820};
5821
Tobin Davis9102cd12006-12-15 10:02:12 +01005822static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5823{
5824 unsigned int gpiostate, gpiomask, gpiodir;
5825
5826 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5827 AC_VERB_GET_GPIO_DATA, 0);
5828
5829 if (!muted)
5830 gpiostate |= (1 << pin);
5831 else
5832 gpiostate &= ~(1 << pin);
5833
5834 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5835 AC_VERB_GET_GPIO_MASK, 0);
5836 gpiomask |= (1 << pin);
5837
5838 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5839 AC_VERB_GET_GPIO_DIRECTION, 0);
5840 gpiodir |= (1 << pin);
5841
5842
5843 snd_hda_codec_write(codec, codec->afg, 0,
5844 AC_VERB_SET_GPIO_MASK, gpiomask);
5845 snd_hda_codec_write(codec, codec->afg, 0,
5846 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5847
5848 msleep(1);
5849
5850 snd_hda_codec_write(codec, codec->afg, 0,
5851 AC_VERB_SET_GPIO_DATA, gpiostate);
5852}
5853
Takashi Iwai7debbe52007-08-16 15:01:03 +02005854/* set up GPIO at initialization */
5855static void alc885_macpro_init_hook(struct hda_codec *codec)
5856{
5857 alc882_gpio_mute(codec, 0, 0);
5858 alc882_gpio_mute(codec, 1, 0);
5859}
5860
5861/* set up GPIO and update auto-muting at initialization */
5862static void alc885_imac24_init_hook(struct hda_codec *codec)
5863{
5864 alc885_macpro_init_hook(codec);
5865 alc885_imac24_automute(codec);
5866}
5867
Kailang Yangdf694da2005-12-05 19:42:22 +01005868/*
5869 * generic initialization of ADC, input mixers and output mixers
5870 */
5871static struct hda_verb alc882_auto_init_verbs[] = {
5872 /*
5873 * Unmute ADC0-2 and set the default input to mic-in
5874 */
5875 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5877 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5879 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5881
Takashi Iwaicb53c622007-08-10 17:21:45 +02005882 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005883 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005884 * Note: PASD motherboards uses the Line In 2 as the input for
5885 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005886 */
5887 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5892 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005893
5894 /*
5895 * Set up output mixers (0x0c - 0x0f)
5896 */
5897 /* set vol=0 to output mixers */
5898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5900 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5902 /* set up input amps for analog loopback */
5903 /* Amp Indices: DAC = 0, mixer = 1 */
5904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5910 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5911 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5912 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5913 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5914
5915 /* FIXME: use matrix-type input source selection */
5916 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5917 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5922 /* Input mixer2 */
5923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5927 /* Input mixer3 */
5928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5932
5933 { }
5934};
5935
5936/* capture mixer elements */
5937static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5938 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5940 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5941 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5942 {
5943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5944 /* The multiple "Capture Source" controls confuse alsamixer
5945 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005946 */
5947 /* .name = "Capture Source", */
5948 .name = "Input Source",
5949 .count = 2,
5950 .info = alc882_mux_enum_info,
5951 .get = alc882_mux_enum_get,
5952 .put = alc882_mux_enum_put,
5953 },
5954 { } /* end */
5955};
5956
5957static struct snd_kcontrol_new alc882_capture_mixer[] = {
5958 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5959 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5960 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5962 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5963 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5964 {
5965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5966 /* The multiple "Capture Source" controls confuse alsamixer
5967 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005968 */
5969 /* .name = "Capture Source", */
5970 .name = "Input Source",
5971 .count = 3,
5972 .info = alc882_mux_enum_info,
5973 .get = alc882_mux_enum_get,
5974 .put = alc882_mux_enum_put,
5975 },
5976 { } /* end */
5977};
5978
Takashi Iwaicb53c622007-08-10 17:21:45 +02005979#ifdef CONFIG_SND_HDA_POWER_SAVE
5980#define alc882_loopbacks alc880_loopbacks
5981#endif
5982
Kailang Yangdf694da2005-12-05 19:42:22 +01005983/* pcm configuration: identiacal with ALC880 */
5984#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5985#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5986#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5987#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5988
5989/*
5990 * configuration and preset
5991 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005992static const char *alc882_models[ALC882_MODEL_LAST] = {
5993 [ALC882_3ST_DIG] = "3stack-dig",
5994 [ALC882_6ST_DIG] = "6stack-dig",
5995 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005996 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005997 [ALC882_TARGA] = "targa",
5998 [ALC882_ASUS_A7J] = "asus-a7j",
5999 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006000 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006001 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006002 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006003 [ALC882_AUTO] = "auto",
6004};
6005
6006static struct snd_pci_quirk alc882_cfg_tbl[] = {
6007 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006008 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006009 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006010 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006011 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006012 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006013 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006014 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006015 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006016 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6017 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6018 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006019 {}
6020};
6021
6022static struct alc_config_preset alc882_presets[] = {
6023 [ALC882_3ST_DIG] = {
6024 .mixers = { alc882_base_mixer },
6025 .init_verbs = { alc882_init_verbs },
6026 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6027 .dac_nids = alc882_dac_nids,
6028 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006029 .dig_in_nid = ALC882_DIGIN_NID,
6030 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6031 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006032 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 .input_mux = &alc882_capture_source,
6034 },
6035 [ALC882_6ST_DIG] = {
6036 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6037 .init_verbs = { alc882_init_verbs },
6038 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6039 .dac_nids = alc882_dac_nids,
6040 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 .dig_in_nid = ALC882_DIGIN_NID,
6042 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6043 .channel_mode = alc882_sixstack_modes,
6044 .input_mux = &alc882_capture_source,
6045 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006046 [ALC882_ARIMA] = {
6047 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6048 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6049 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6050 .dac_nids = alc882_dac_nids,
6051 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6052 .channel_mode = alc882_sixstack_modes,
6053 .input_mux = &alc882_capture_source,
6054 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006055 [ALC882_W2JC] = {
6056 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6057 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6058 alc880_gpio1_init_verbs },
6059 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6060 .dac_nids = alc882_dac_nids,
6061 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6062 .channel_mode = alc880_threestack_modes,
6063 .need_dac_fix = 1,
6064 .input_mux = &alc882_capture_source,
6065 .dig_out_nid = ALC882_DIGOUT_NID,
6066 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006067 [ALC885_MBP3] = {
6068 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6069 .init_verbs = { alc885_mbp3_init_verbs,
6070 alc880_gpio1_init_verbs },
6071 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6072 .dac_nids = alc882_dac_nids,
6073 .channel_mode = alc885_mbp_6ch_modes,
6074 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6075 .input_mux = &alc882_capture_source,
6076 .dig_out_nid = ALC882_DIGOUT_NID,
6077 .dig_in_nid = ALC882_DIGIN_NID,
6078 .unsol_event = alc885_mbp3_unsol_event,
6079 .init_hook = alc885_mbp3_automute,
6080 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006081 [ALC885_MACPRO] = {
6082 .mixers = { alc882_macpro_mixer },
6083 .init_verbs = { alc882_macpro_init_verbs },
6084 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6085 .dac_nids = alc882_dac_nids,
6086 .dig_out_nid = ALC882_DIGOUT_NID,
6087 .dig_in_nid = ALC882_DIGIN_NID,
6088 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6089 .channel_mode = alc882_ch_modes,
6090 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006091 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006092 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006093 [ALC885_IMAC24] = {
6094 .mixers = { alc885_imac24_mixer },
6095 .init_verbs = { alc885_imac24_init_verbs },
6096 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6097 .dac_nids = alc882_dac_nids,
6098 .dig_out_nid = ALC882_DIGOUT_NID,
6099 .dig_in_nid = ALC882_DIGIN_NID,
6100 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6101 .channel_mode = alc882_ch_modes,
6102 .input_mux = &alc882_capture_source,
6103 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006104 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006105 },
Kailang Yang272a5272007-05-14 11:00:38 +02006106 [ALC882_TARGA] = {
6107 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6108 alc882_capture_mixer },
6109 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6110 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6111 .dac_nids = alc882_dac_nids,
6112 .dig_out_nid = ALC882_DIGOUT_NID,
6113 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6114 .adc_nids = alc882_adc_nids,
6115 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6116 .channel_mode = alc882_3ST_6ch_modes,
6117 .need_dac_fix = 1,
6118 .input_mux = &alc882_capture_source,
6119 .unsol_event = alc882_targa_unsol_event,
6120 .init_hook = alc882_targa_automute,
6121 },
6122 [ALC882_ASUS_A7J] = {
6123 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6124 alc882_capture_mixer },
6125 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6127 .dac_nids = alc882_dac_nids,
6128 .dig_out_nid = ALC882_DIGOUT_NID,
6129 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6130 .adc_nids = alc882_adc_nids,
6131 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6132 .channel_mode = alc882_3ST_6ch_modes,
6133 .need_dac_fix = 1,
6134 .input_mux = &alc882_capture_source,
6135 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006136 [ALC882_ASUS_A7M] = {
6137 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6138 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6139 alc880_gpio1_init_verbs,
6140 alc882_asus_a7m_verbs },
6141 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6142 .dac_nids = alc882_dac_nids,
6143 .dig_out_nid = ALC882_DIGOUT_NID,
6144 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6145 .channel_mode = alc880_threestack_modes,
6146 .need_dac_fix = 1,
6147 .input_mux = &alc882_capture_source,
6148 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006149};
6150
6151
6152/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006153 * Pin config fixes
6154 */
6155enum {
6156 PINFIX_ABIT_AW9D_MAX
6157};
6158
6159static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6160 { 0x15, 0x01080104 }, /* side */
6161 { 0x16, 0x01011012 }, /* rear */
6162 { 0x17, 0x01016011 }, /* clfe */
6163 { }
6164};
6165
6166static const struct alc_pincfg *alc882_pin_fixes[] = {
6167 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6168};
6169
6170static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6171 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6172 {}
6173};
6174
6175/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006176 * BIOS auto configuration
6177 */
6178static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6179 hda_nid_t nid, int pin_type,
6180 int dac_idx)
6181{
6182 /* set as output */
6183 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006184 int idx;
6185
Kailang Yangdf694da2005-12-05 19:42:22 +01006186 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6187 idx = 4;
6188 else
6189 idx = spec->multiout.dac_nids[dac_idx] - 2;
6190
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6192 pin_type);
6193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6194 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006195 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6196
6197}
6198
6199static void alc882_auto_init_multi_out(struct hda_codec *codec)
6200{
6201 struct alc_spec *spec = codec->spec;
6202 int i;
6203
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006204 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006206 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006207 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006209 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006210 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 }
6212}
6213
6214static void alc882_auto_init_hp_out(struct hda_codec *codec)
6215{
6216 struct alc_spec *spec = codec->spec;
6217 hda_nid_t pin;
6218
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006219 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006220 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006221 /* use dac 0 */
6222 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006223}
6224
6225#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6226#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6227
6228static void alc882_auto_init_analog_input(struct hda_codec *codec)
6229{
6230 struct alc_spec *spec = codec->spec;
6231 int i;
6232
6233 for (i = 0; i < AUTO_PIN_LAST; i++) {
6234 hda_nid_t nid = spec->autocfg.input_pins[i];
6235 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006236 snd_hda_codec_write(codec, nid, 0,
6237 AC_VERB_SET_PIN_WIDGET_CONTROL,
6238 i <= AUTO_PIN_FRONT_MIC ?
6239 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006241 snd_hda_codec_write(codec, nid, 0,
6242 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 AMP_OUT_MUTE);
6244 }
6245 }
6246}
6247
Takashi Iwai776e1842007-08-29 15:07:11 +02006248/* add mic boosts if needed */
6249static int alc_auto_add_mic_boost(struct hda_codec *codec)
6250{
6251 struct alc_spec *spec = codec->spec;
6252 int err;
6253 hda_nid_t nid;
6254
6255 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006256 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006257 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6258 "Mic Boost",
6259 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6260 if (err < 0)
6261 return err;
6262 }
6263 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006264 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006265 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6266 "Front Mic Boost",
6267 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6268 if (err < 0)
6269 return err;
6270 }
6271 return 0;
6272}
6273
Kailang Yangdf694da2005-12-05 19:42:22 +01006274/* almost identical with ALC880 parser... */
6275static int alc882_parse_auto_config(struct hda_codec *codec)
6276{
6277 struct alc_spec *spec = codec->spec;
6278 int err = alc880_parse_auto_config(codec);
6279
6280 if (err < 0)
6281 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006282 else if (!err)
6283 return 0; /* no config found */
6284
6285 err = alc_auto_add_mic_boost(codec);
6286 if (err < 0)
6287 return err;
6288
6289 /* hack - override the init verbs */
6290 spec->init_verbs[0] = alc882_auto_init_verbs;
6291
6292 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006293}
6294
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006295/* additional initialization for auto-configuration model */
6296static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006297{
Kailang Yangdf694da2005-12-05 19:42:22 +01006298 alc882_auto_init_multi_out(codec);
6299 alc882_auto_init_hp_out(codec);
6300 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006301}
6302
Linus Torvalds1da177e2005-04-16 15:20:36 -07006303static int patch_alc882(struct hda_codec *codec)
6304{
6305 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006306 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006307
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006308 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006309 if (spec == NULL)
6310 return -ENOMEM;
6311
Linus Torvalds1da177e2005-04-16 15:20:36 -07006312 codec->spec = spec;
6313
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006314 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6315 alc882_models,
6316 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006317
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006319 /* Pick up systems that don't supply PCI SSID */
6320 switch (codec->subsystem_id) {
6321 case 0x106b0c00: /* Mac Pro */
6322 board_config = ALC885_MACPRO;
6323 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006324 case 0x106b1000: /* iMac 24 */
6325 board_config = ALC885_IMAC24;
6326 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006327 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006328 case 0x106b2c00: /* Macbook Pro rev3 */
6329 board_config = ALC885_MBP3;
6330 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006331 default:
6332 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6333 "trying auto-probe from BIOS...\n");
6334 board_config = ALC882_AUTO;
6335 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006336 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006337
Takashi Iwaif95474e2007-07-10 00:47:43 +02006338 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6339
Kailang Yangdf694da2005-12-05 19:42:22 +01006340 if (board_config == ALC882_AUTO) {
6341 /* automatic parse from the BIOS config */
6342 err = alc882_parse_auto_config(codec);
6343 if (err < 0) {
6344 alc_free(codec);
6345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006346 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006347 printk(KERN_INFO
6348 "hda_codec: Cannot set up configuration "
6349 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006350 board_config = ALC882_3ST_DIG;
6351 }
6352 }
6353
6354 if (board_config != ALC882_AUTO)
6355 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006356
6357 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006358 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6359 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006360 /* FIXME: setup DAC5 */
6361 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6362 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006363
6364 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006365 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6366 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006367
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006368 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006370 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006371 /* get type */
6372 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 if (wcap != AC_WID_AUD_IN) {
6374 spec->adc_nids = alc882_adc_nids_alt;
6375 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006376 spec->mixers[spec->num_mixers] =
6377 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 spec->num_mixers++;
6379 } else {
6380 spec->adc_nids = alc882_adc_nids;
6381 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6382 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6383 spec->num_mixers++;
6384 }
6385 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006386
Takashi Iwai2134ea42008-01-10 16:53:55 +01006387 spec->vmaster_nid = 0x0c;
6388
Linus Torvalds1da177e2005-04-16 15:20:36 -07006389 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006390 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006391 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006392#ifdef CONFIG_SND_HDA_POWER_SAVE
6393 if (!spec->loopback.amplist)
6394 spec->loopback.amplist = alc882_loopbacks;
6395#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006396
6397 return 0;
6398}
6399
6400/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006401 * ALC883 support
6402 *
6403 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6404 * configuration. Each pin widget can choose any input DACs and a mixer.
6405 * Each ADC is connected from a mixer of all inputs. This makes possible
6406 * 6-channel independent captures.
6407 *
6408 * In addition, an independent DAC for the multi-playback (not used in this
6409 * driver yet).
6410 */
6411#define ALC883_DIGOUT_NID 0x06
6412#define ALC883_DIGIN_NID 0x0a
6413
6414static hda_nid_t alc883_dac_nids[4] = {
6415 /* front, rear, clfe, rear_surr */
6416 0x02, 0x04, 0x03, 0x05
6417};
6418
6419static hda_nid_t alc883_adc_nids[2] = {
6420 /* ADC1-2 */
6421 0x08, 0x09,
6422};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006423
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006424/* input MUX */
6425/* FIXME: should be a matrix-type input source selection */
6426
6427static struct hda_input_mux alc883_capture_source = {
6428 .num_items = 4,
6429 .items = {
6430 { "Mic", 0x0 },
6431 { "Front Mic", 0x1 },
6432 { "Line", 0x2 },
6433 { "CD", 0x4 },
6434 },
6435};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006436
6437static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6438 .num_items = 2,
6439 .items = {
6440 { "Mic", 0x1 },
6441 { "Line", 0x2 },
6442 },
6443};
6444
Kailang Yang272a5272007-05-14 11:00:38 +02006445static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6446 .num_items = 4,
6447 .items = {
6448 { "Mic", 0x0 },
6449 { "iMic", 0x1 },
6450 { "Line", 0x2 },
6451 { "CD", 0x4 },
6452 },
6453};
6454
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006455#define alc883_mux_enum_info alc_mux_enum_info
6456#define alc883_mux_enum_get alc_mux_enum_get
6457
6458static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6459 struct snd_ctl_elem_value *ucontrol)
6460{
6461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6462 struct alc_spec *spec = codec->spec;
6463 const struct hda_input_mux *imux = spec->input_mux;
6464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai614ca922008-02-22 18:44:21 +01006465 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006466 hda_nid_t nid = capture_mixers[adc_idx];
6467 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6468 unsigned int i, idx;
6469
6470 idx = ucontrol->value.enumerated.item[0];
6471 if (idx >= imux->num_items)
6472 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006473 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006474 return 0;
6475 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006476 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6477 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006478 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006479 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006480 }
6481 *cur_val = idx;
6482 return 1;
6483}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006484
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006485/*
6486 * 2ch mode
6487 */
6488static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6489 { 2, NULL }
6490};
6491
6492/*
6493 * 2ch mode
6494 */
6495static struct hda_verb alc883_3ST_ch2_init[] = {
6496 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6497 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6498 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6499 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6500 { } /* end */
6501};
6502
6503/*
Tobin Davisb2011312007-09-17 12:45:11 +02006504 * 4ch mode
6505 */
6506static struct hda_verb alc883_3ST_ch4_init[] = {
6507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6511 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6512 { } /* end */
6513};
6514
6515/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006516 * 6ch mode
6517 */
6518static struct hda_verb alc883_3ST_ch6_init[] = {
6519 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6520 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6521 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6522 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6523 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6524 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6525 { } /* end */
6526};
6527
Tobin Davisb2011312007-09-17 12:45:11 +02006528static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006529 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006530 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006531 { 6, alc883_3ST_ch6_init },
6532};
6533
6534/*
6535 * 6ch mode
6536 */
6537static struct hda_verb alc883_sixstack_ch6_init[] = {
6538 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6540 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6541 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6542 { } /* end */
6543};
6544
6545/*
6546 * 8ch mode
6547 */
6548static struct hda_verb alc883_sixstack_ch8_init[] = {
6549 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6550 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6551 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6552 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6553 { } /* end */
6554};
6555
6556static struct hda_channel_mode alc883_sixstack_modes[2] = {
6557 { 6, alc883_sixstack_ch6_init },
6558 { 8, alc883_sixstack_ch8_init },
6559};
6560
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006561static struct hda_verb alc883_medion_eapd_verbs[] = {
6562 /* eanable EAPD on medion laptop */
6563 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6564 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6565 { }
6566};
6567
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006568/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6569 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6570 */
6571
6572static struct snd_kcontrol_new alc883_base_mixer[] = {
6573 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6575 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6576 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6577 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6578 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6579 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6580 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6581 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6582 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006592 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6594 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6595 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6596 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6597 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6598 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6599 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6600 {
6601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6602 /* .name = "Capture Source", */
6603 .name = "Input Source",
6604 .count = 2,
6605 .info = alc883_mux_enum_info,
6606 .get = alc883_mux_enum_get,
6607 .put = alc883_mux_enum_put,
6608 },
6609 { } /* end */
6610};
6611
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006612static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6619 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6621 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6622 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6623 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6624 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6625 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6626 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6627 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6628 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6629 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6630 {
6631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6632 /* .name = "Capture Source", */
6633 .name = "Input Source",
6634 .count = 2,
6635 .info = alc883_mux_enum_info,
6636 .get = alc883_mux_enum_get,
6637 .put = alc883_mux_enum_put,
6638 },
6639 { } /* end */
6640};
6641
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006642static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6643 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6644 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6645 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6646 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6647 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6648 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6649 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006651 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6653 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006654 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006655 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6656 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6657 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6658 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6659 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6660 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6661 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6662 {
6663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6664 /* .name = "Capture Source", */
6665 .name = "Input Source",
6666 .count = 2,
6667 .info = alc883_mux_enum_info,
6668 .get = alc883_mux_enum_get,
6669 .put = alc883_mux_enum_put,
6670 },
6671 { } /* end */
6672};
6673
6674static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6675 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6676 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6677 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6678 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6679 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6680 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6681 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6682 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6686 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6687 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006689 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006690 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6691 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006692 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006693 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6694 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6695 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6696 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6697 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6698 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6699 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6700 {
6701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6702 /* .name = "Capture Source", */
6703 .name = "Input Source",
6704 .count = 2,
6705 .info = alc883_mux_enum_info,
6706 .get = alc883_mux_enum_get,
6707 .put = alc883_mux_enum_put,
6708 },
6709 { } /* end */
6710};
6711
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006712static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6715 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6716 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6717 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6718 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6719 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6720 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6722 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6723 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006730 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6732 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6733 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6735 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6736
6737 {
6738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6739 /* .name = "Capture Source", */
6740 .name = "Input Source",
6741 .count = 1,
6742 .info = alc883_mux_enum_info,
6743 .get = alc883_mux_enum_get,
6744 .put = alc883_mux_enum_put,
6745 },
6746 { } /* end */
6747};
6748
Kailang Yangccc656c2006-10-17 12:32:26 +02006749static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6752 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6753 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6754 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6755 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6756 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6757 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6758 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6767 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6768 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6769 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6770 {
6771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6772 /* .name = "Capture Source", */
6773 .name = "Input Source",
6774 .count = 2,
6775 .info = alc883_mux_enum_info,
6776 .get = alc883_mux_enum_get,
6777 .put = alc883_mux_enum_put,
6778 },
6779 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006780};
Kailang Yangccc656c2006-10-17 12:32:26 +02006781
6782static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006789 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6791 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6792 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6793 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6794 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6795 {
6796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6797 /* .name = "Capture Source", */
6798 .name = "Input Source",
6799 .count = 2,
6800 .info = alc883_mux_enum_info,
6801 .get = alc883_mux_enum_get,
6802 .put = alc883_mux_enum_put,
6803 },
6804 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006805};
Kailang Yangccc656c2006-10-17 12:32:26 +02006806
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006807static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006810 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6811 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6814 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6816 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6818 {
6819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6820 /* .name = "Capture Source", */
6821 .name = "Input Source",
6822 .count = 1,
6823 .info = alc883_mux_enum_info,
6824 .get = alc883_mux_enum_get,
6825 .put = alc883_mux_enum_put,
6826 },
6827 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006828};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006829
Kailang Yang272a5272007-05-14 11:00:38 +02006830static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6831 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6832 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6838 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6839 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6840 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6841 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6842 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6843 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6844 {
6845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6846 /* .name = "Capture Source", */
6847 .name = "Input Source",
6848 .count = 2,
6849 .info = alc883_mux_enum_info,
6850 .get = alc883_mux_enum_get,
6851 .put = alc883_mux_enum_put,
6852 },
6853 { } /* end */
6854};
6855
6856static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6867 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6868 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6869 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6870 {
6871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6872 /* .name = "Capture Source", */
6873 .name = "Input Source",
6874 .count = 2,
6875 .info = alc883_mux_enum_info,
6876 .get = alc883_mux_enum_get,
6877 .put = alc883_mux_enum_put,
6878 },
6879 { } /* end */
6880};
6881
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006882static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6885 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6886 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6887 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6891 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6892 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6897 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6902 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6903 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6904 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6905 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6906 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6907 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6908 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6909 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6910 {
6911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6912 /* .name = "Capture Source", */
6913 .name = "Input Source",
6914 .count = 2,
6915 .info = alc883_mux_enum_info,
6916 .get = alc883_mux_enum_get,
6917 .put = alc883_mux_enum_put,
6918 },
6919 { } /* end */
6920};
6921
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006922static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6926 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6942 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6943 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6944 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6946 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6947 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6948 {
6949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6950 /* .name = "Capture Source", */
6951 .name = "Input Source",
6952 .count = 2,
6953 .info = alc883_mux_enum_info,
6954 .get = alc883_mux_enum_get,
6955 .put = alc883_mux_enum_put,
6956 },
6957 { } /* end */
6958};
6959
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006960static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6964 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6966 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6967 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6968 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6970 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6980 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6981 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6982 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6983 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6985 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6986 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6987 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6988 {
6989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6990 /* .name = "Capture Source", */
6991 .name = "Input Source",
6992 .count = 2,
6993 .info = alc883_mux_enum_info,
6994 .get = alc883_mux_enum_get,
6995 .put = alc883_mux_enum_put,
6996 },
6997 { } /* end */
6998};
6999
Tobin Davis2880a862007-08-07 11:50:26 +02007000static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007001 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7002 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007009 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7010 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7011 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7012 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7013 {
7014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7015 /* .name = "Capture Source", */
7016 .name = "Input Source",
7017 .count = 2,
7018 .info = alc883_mux_enum_info,
7019 .get = alc883_mux_enum_get,
7020 .put = alc883_mux_enum_put,
7021 },
7022 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007023};
Tobin Davis2880a862007-08-07 11:50:26 +02007024
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007025static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7026 {
7027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7028 .name = "Channel Mode",
7029 .info = alc_ch_mode_info,
7030 .get = alc_ch_mode_get,
7031 .put = alc_ch_mode_put,
7032 },
7033 { } /* end */
7034};
7035
7036static struct hda_verb alc883_init_verbs[] = {
7037 /* ADC1: mute amp left and right */
7038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7039 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7040 /* ADC2: mute amp left and right */
7041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7042 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7043 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7047 /* Rear mixer */
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7051 /* CLFE mixer */
7052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7055 /* Side mixer */
7056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7059
Takashi Iwaicb53c622007-08-10 17:21:45 +02007060 /* mute analog input loopbacks */
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007066
7067 /* Front Pin: output 0 (0x0c) */
7068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7070 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7071 /* Rear Pin: output 1 (0x0d) */
7072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7075 /* CLFE Pin: output 2 (0x0e) */
7076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7078 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7079 /* Side Pin: output 3 (0x0f) */
7080 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7082 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7083 /* Mic (rear) pin: input vref at 80% */
7084 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7086 /* Front Mic pin: input vref at 80% */
7087 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7089 /* Line In pin: input */
7090 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7092 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7094 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7096 /* CD pin widget for input */
7097 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7098
7099 /* FIXME: use matrix-type input source selection */
7100 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7101 /* Input mixer2 */
7102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7106 /* Input mixer3 */
7107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7111 { }
7112};
7113
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007114/* toggle speaker-output according to the hp-jack state */
7115static void alc883_mitac_hp_automute(struct hda_codec *codec)
7116{
7117 unsigned int present;
7118
7119 present = snd_hda_codec_read(codec, 0x15, 0,
7120 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7121 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7122 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7123 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7124 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7125}
7126
7127/* auto-toggle front mic */
7128/*
7129static void alc883_mitac_mic_automute(struct hda_codec *codec)
7130{
7131 unsigned int present;
7132 unsigned char bits;
7133
7134 present = snd_hda_codec_read(codec, 0x18, 0,
7135 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7136 bits = present ? HDA_AMP_MUTE : 0;
7137 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7138}
7139*/
7140
7141static void alc883_mitac_automute(struct hda_codec *codec)
7142{
7143 alc883_mitac_hp_automute(codec);
7144 /* alc883_mitac_mic_automute(codec); */
7145}
7146
7147static void alc883_mitac_unsol_event(struct hda_codec *codec,
7148 unsigned int res)
7149{
7150 switch (res >> 26) {
7151 case ALC880_HP_EVENT:
7152 alc883_mitac_hp_automute(codec);
7153 break;
7154 case ALC880_MIC_EVENT:
7155 /* alc883_mitac_mic_automute(codec); */
7156 break;
7157 }
7158}
7159
7160static struct hda_verb alc883_mitac_verbs[] = {
7161 /* HP */
7162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7164 /* Subwoofer */
7165 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7166 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7167
7168 /* enable unsolicited event */
7169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7170 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7171
7172 { } /* end */
7173};
7174
Kailang Yangccc656c2006-10-17 12:32:26 +02007175static struct hda_verb alc883_tagra_verbs[] = {
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7178
7179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7181
7182 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7183 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7185
7186 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007187 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7188 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7189 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007190
7191 { } /* end */
7192};
7193
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007194static struct hda_verb alc883_lenovo_101e_verbs[] = {
7195 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7196 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7197 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7198 { } /* end */
7199};
7200
Kailang Yang272a5272007-05-14 11:00:38 +02007201static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7204 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7206 { } /* end */
7207};
7208
7209static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7213 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7214 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7215 { } /* end */
7216};
7217
Kailang Yang189609a2007-08-20 11:31:23 +02007218static struct hda_verb alc883_haier_w66_verbs[] = {
7219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7221
7222 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7223
7224 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7226 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7227 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7228 { } /* end */
7229};
7230
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007231static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007232 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7233 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7234 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7235 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7236 { }
7237};
7238
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007239static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007240 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7241 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7242 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7243 { }
7244};
7245
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007246static struct hda_verb alc888_6st_dell_verbs[] = {
7247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7249 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7250 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7252 { }
7253};
7254
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007255static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007256 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7257 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7258 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7259 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7260 { }
7261};
7262
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007263static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7266 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7267 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7268 { }
7269};
7270
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007271static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7272 { 2, alc888_3st_hp_2ch_init },
7273 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007274};
7275
Kailang Yang272a5272007-05-14 11:00:38 +02007276/* toggle front-jack and RCA according to the hp-jack state */
7277static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7278{
7279 unsigned int present;
7280
7281 present = snd_hda_codec_read(codec, 0x1b, 0,
7282 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007283 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7284 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7285 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7286 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007287}
7288
7289/* toggle RCA according to the front-jack state */
7290static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7291{
7292 unsigned int present;
7293
7294 present = snd_hda_codec_read(codec, 0x14, 0,
7295 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7297 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007298}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007299
Kailang Yang272a5272007-05-14 11:00:38 +02007300static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7301 unsigned int res)
7302{
7303 if ((res >> 26) == ALC880_HP_EVENT)
7304 alc888_lenovo_ms7195_front_automute(codec);
7305 if ((res >> 26) == ALC880_FRONT_EVENT)
7306 alc888_lenovo_ms7195_rca_automute(codec);
7307}
7308
7309static struct hda_verb alc883_medion_md2_verbs[] = {
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7312
7313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7314
7315 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7316 { } /* end */
7317};
7318
7319/* toggle speaker-output according to the hp-jack state */
7320static void alc883_medion_md2_automute(struct hda_codec *codec)
7321{
7322 unsigned int present;
7323
7324 present = snd_hda_codec_read(codec, 0x14, 0,
7325 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007326 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7327 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007328}
7329
7330static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7331 unsigned int res)
7332{
7333 if ((res >> 26) == ALC880_HP_EVENT)
7334 alc883_medion_md2_automute(codec);
7335}
7336
Kailang Yangccc656c2006-10-17 12:32:26 +02007337/* toggle speaker-output according to the hp-jack state */
7338static void alc883_tagra_automute(struct hda_codec *codec)
7339{
7340 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007341 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007342
7343 present = snd_hda_codec_read(codec, 0x14, 0,
7344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007345 bits = present ? HDA_AMP_MUTE : 0;
7346 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7347 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007348 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7349 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007350}
7351
7352static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7353{
7354 if ((res >> 26) == ALC880_HP_EVENT)
7355 alc883_tagra_automute(codec);
7356}
7357
Kailang Yang189609a2007-08-20 11:31:23 +02007358static void alc883_haier_w66_automute(struct hda_codec *codec)
7359{
7360 unsigned int present;
7361 unsigned char bits;
7362
7363 present = snd_hda_codec_read(codec, 0x1b, 0,
7364 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7365 bits = present ? 0x80 : 0;
7366 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7367 0x80, bits);
7368}
7369
7370static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7371 unsigned int res)
7372{
7373 if ((res >> 26) == ALC880_HP_EVENT)
7374 alc883_haier_w66_automute(codec);
7375}
7376
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007377static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7378{
7379 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007380 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007381
7382 present = snd_hda_codec_read(codec, 0x14, 0,
7383 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007384 bits = present ? HDA_AMP_MUTE : 0;
7385 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7386 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007387}
7388
7389static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7390{
7391 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007392 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007393
7394 present = snd_hda_codec_read(codec, 0x1b, 0,
7395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007396 bits = present ? HDA_AMP_MUTE : 0;
7397 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7398 HDA_AMP_MUTE, bits);
7399 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7400 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007401}
7402
7403static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7404 unsigned int res)
7405{
7406 if ((res >> 26) == ALC880_HP_EVENT)
7407 alc883_lenovo_101e_all_automute(codec);
7408 if ((res >> 26) == ALC880_FRONT_EVENT)
7409 alc883_lenovo_101e_ispeaker_automute(codec);
7410}
7411
Takashi Iwai676a9b52007-08-16 15:23:35 +02007412/* toggle speaker-output according to the hp-jack state */
7413static void alc883_acer_aspire_automute(struct hda_codec *codec)
7414{
7415 unsigned int present;
7416
7417 present = snd_hda_codec_read(codec, 0x14, 0,
7418 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7419 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7420 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7421 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7422 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7423}
7424
7425static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7426 unsigned int res)
7427{
7428 if ((res >> 26) == ALC880_HP_EVENT)
7429 alc883_acer_aspire_automute(codec);
7430}
7431
Kailang Yangd1a991a2007-08-15 16:21:59 +02007432static struct hda_verb alc883_acer_eapd_verbs[] = {
7433 /* HP Pin: output 0 (0x0c) */
7434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7436 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007440 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007441 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 /* eanable EAPD on medion laptop */
7443 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7444 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007445 /* enable unsolicited event */
7446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007447 { }
7448};
7449
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007450static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7451{
7452 unsigned int present;
7453
7454 present = snd_hda_codec_read(codec, 0x1b, 0,
7455 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7456 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7457 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7458 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7459 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7460 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7462 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7463 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7464}
7465
7466static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7467 unsigned int res)
7468{
7469 switch (res >> 26) {
7470 case ALC880_HP_EVENT:
7471 printk("hp_event\n");
7472 alc888_6st_dell_front_automute(codec);
7473 break;
7474 }
7475}
7476
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007477/*
7478 * generic initialization of ADC, input mixers and output mixers
7479 */
7480static struct hda_verb alc883_auto_init_verbs[] = {
7481 /*
7482 * Unmute ADC0-2 and set the default input to mic-in
7483 */
7484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7486 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488
Takashi Iwaicb53c622007-08-10 17:21:45 +02007489 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007490 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007491 * Note: PASD motherboards uses the Line In 2 as the input for
7492 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007493 */
7494 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007500
7501 /*
7502 * Set up output mixers (0x0c - 0x0f)
7503 */
7504 /* set vol=0 to output mixers */
7505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7508 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7509 /* set up input amps for analog loopback */
7510 /* Amp Indices: DAC = 0, mixer = 1 */
7511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7519 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7520 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7521
7522 /* FIXME: use matrix-type input source selection */
7523 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7524 /* Input mixer1 */
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007528 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7530 /* Input mixer2 */
7531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007534 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007536
7537 { }
7538};
7539
7540/* capture mixer elements */
7541static struct snd_kcontrol_new alc883_capture_mixer[] = {
7542 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7543 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7544 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7545 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7546 {
7547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7548 /* The multiple "Capture Source" controls confuse alsamixer
7549 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007550 */
7551 /* .name = "Capture Source", */
7552 .name = "Input Source",
7553 .count = 2,
7554 .info = alc882_mux_enum_info,
7555 .get = alc882_mux_enum_get,
7556 .put = alc882_mux_enum_put,
7557 },
7558 { } /* end */
7559};
7560
Takashi Iwaicb53c622007-08-10 17:21:45 +02007561#ifdef CONFIG_SND_HDA_POWER_SAVE
7562#define alc883_loopbacks alc880_loopbacks
7563#endif
7564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007565/* pcm configuration: identiacal with ALC880 */
7566#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7567#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007568#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007569#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7570#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7571
7572/*
7573 * configuration and preset
7574 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007575static const char *alc883_models[ALC883_MODEL_LAST] = {
7576 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7577 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7578 [ALC883_3ST_6ch] = "3stack-6ch",
7579 [ALC883_6ST_DIG] = "6stack-dig",
7580 [ALC883_TARGA_DIG] = "targa-dig",
7581 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007582 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007583 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007584 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007585 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007586 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007587 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007588 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7589 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007590 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007591 [ALC888_6ST_HP] = "6stack-hp",
7592 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007593 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007594 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007595 [ALC883_AUTO] = "auto",
7596};
7597
7598static struct snd_pci_quirk alc883_cfg_tbl[] = {
7599 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007600 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7601 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7602 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7603 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007604 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007605 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007606 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7607 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7608 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7609 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007610 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007611 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7612 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7613 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007614 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007615 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7621 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7622 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7625 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7627 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007628 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7629 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007630 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007631 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007632 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007633 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007634 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7635 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007636 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007637 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007638 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007639 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007640 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7641 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007642 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007643 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007644 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007645 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007646 {}
7647};
7648
7649static struct alc_config_preset alc883_presets[] = {
7650 [ALC883_3ST_2ch_DIG] = {
7651 .mixers = { alc883_3ST_2ch_mixer },
7652 .init_verbs = { alc883_init_verbs },
7653 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7654 .dac_nids = alc883_dac_nids,
7655 .dig_out_nid = ALC883_DIGOUT_NID,
7656 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7657 .adc_nids = alc883_adc_nids,
7658 .dig_in_nid = ALC883_DIGIN_NID,
7659 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7660 .channel_mode = alc883_3ST_2ch_modes,
7661 .input_mux = &alc883_capture_source,
7662 },
7663 [ALC883_3ST_6ch_DIG] = {
7664 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7665 .init_verbs = { alc883_init_verbs },
7666 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7667 .dac_nids = alc883_dac_nids,
7668 .dig_out_nid = ALC883_DIGOUT_NID,
7669 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7670 .adc_nids = alc883_adc_nids,
7671 .dig_in_nid = ALC883_DIGIN_NID,
7672 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7673 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007674 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007675 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007676 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007677 [ALC883_3ST_6ch] = {
7678 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7679 .init_verbs = { alc883_init_verbs },
7680 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7681 .dac_nids = alc883_dac_nids,
7682 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7683 .adc_nids = alc883_adc_nids,
7684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7685 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007686 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007687 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007688 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007689 [ALC883_6ST_DIG] = {
7690 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7691 .init_verbs = { alc883_init_verbs },
7692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7693 .dac_nids = alc883_dac_nids,
7694 .dig_out_nid = ALC883_DIGOUT_NID,
7695 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7696 .adc_nids = alc883_adc_nids,
7697 .dig_in_nid = ALC883_DIGIN_NID,
7698 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7699 .channel_mode = alc883_sixstack_modes,
7700 .input_mux = &alc883_capture_source,
7701 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007702 [ALC883_TARGA_DIG] = {
7703 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7704 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7705 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7706 .dac_nids = alc883_dac_nids,
7707 .dig_out_nid = ALC883_DIGOUT_NID,
7708 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7709 .adc_nids = alc883_adc_nids,
7710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7711 .channel_mode = alc883_3ST_6ch_modes,
7712 .need_dac_fix = 1,
7713 .input_mux = &alc883_capture_source,
7714 .unsol_event = alc883_tagra_unsol_event,
7715 .init_hook = alc883_tagra_automute,
7716 },
7717 [ALC883_TARGA_2ch_DIG] = {
7718 .mixers = { alc883_tagra_2ch_mixer},
7719 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7721 .dac_nids = alc883_dac_nids,
7722 .dig_out_nid = ALC883_DIGOUT_NID,
7723 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7724 .adc_nids = alc883_adc_nids,
7725 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7726 .channel_mode = alc883_3ST_2ch_modes,
7727 .input_mux = &alc883_capture_source,
7728 .unsol_event = alc883_tagra_unsol_event,
7729 .init_hook = alc883_tagra_automute,
7730 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007731 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007732 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007733 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7734 * and the headphone jack. Turn this on and rely on the
7735 * standard mute methods whenever the user wants to turn
7736 * these outputs off.
7737 */
7738 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7739 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7740 .dac_nids = alc883_dac_nids,
7741 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7742 .adc_nids = alc883_adc_nids,
7743 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7744 .channel_mode = alc883_3ST_2ch_modes,
7745 .input_mux = &alc883_capture_source,
7746 },
Tobin Davis2880a862007-08-07 11:50:26 +02007747 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007748 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007749 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007750 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7751 .dac_nids = alc883_dac_nids,
7752 .dig_out_nid = ALC883_DIGOUT_NID,
7753 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7754 .adc_nids = alc883_adc_nids,
7755 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7756 .channel_mode = alc883_3ST_2ch_modes,
7757 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007758 .unsol_event = alc883_acer_aspire_unsol_event,
7759 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007760 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007761 [ALC883_MEDION] = {
7762 .mixers = { alc883_fivestack_mixer,
7763 alc883_chmode_mixer },
7764 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007765 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7767 .dac_nids = alc883_dac_nids,
7768 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7769 .adc_nids = alc883_adc_nids,
7770 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7771 .channel_mode = alc883_sixstack_modes,
7772 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007773 },
Kailang Yang272a5272007-05-14 11:00:38 +02007774 [ALC883_MEDION_MD2] = {
7775 .mixers = { alc883_medion_md2_mixer},
7776 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7778 .dac_nids = alc883_dac_nids,
7779 .dig_out_nid = ALC883_DIGOUT_NID,
7780 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7781 .adc_nids = alc883_adc_nids,
7782 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7783 .channel_mode = alc883_3ST_2ch_modes,
7784 .input_mux = &alc883_capture_source,
7785 .unsol_event = alc883_medion_md2_unsol_event,
7786 .init_hook = alc883_medion_md2_automute,
7787 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007788 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007789 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007790 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7791 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7792 .dac_nids = alc883_dac_nids,
7793 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7794 .adc_nids = alc883_adc_nids,
7795 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7796 .channel_mode = alc883_3ST_2ch_modes,
7797 .input_mux = &alc883_capture_source,
7798 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007799 [ALC883_LENOVO_101E_2ch] = {
7800 .mixers = { alc883_lenovo_101e_2ch_mixer},
7801 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7802 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7803 .dac_nids = alc883_dac_nids,
7804 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7805 .adc_nids = alc883_adc_nids,
7806 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7807 .channel_mode = alc883_3ST_2ch_modes,
7808 .input_mux = &alc883_lenovo_101e_capture_source,
7809 .unsol_event = alc883_lenovo_101e_unsol_event,
7810 .init_hook = alc883_lenovo_101e_all_automute,
7811 },
Kailang Yang272a5272007-05-14 11:00:38 +02007812 [ALC883_LENOVO_NB0763] = {
7813 .mixers = { alc883_lenovo_nb0763_mixer },
7814 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7815 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7816 .dac_nids = alc883_dac_nids,
7817 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7818 .adc_nids = alc883_adc_nids,
7819 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7820 .channel_mode = alc883_3ST_2ch_modes,
7821 .need_dac_fix = 1,
7822 .input_mux = &alc883_lenovo_nb0763_capture_source,
7823 .unsol_event = alc883_medion_md2_unsol_event,
7824 .init_hook = alc883_medion_md2_automute,
7825 },
7826 [ALC888_LENOVO_MS7195_DIG] = {
7827 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7828 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7830 .dac_nids = alc883_dac_nids,
7831 .dig_out_nid = ALC883_DIGOUT_NID,
7832 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7833 .adc_nids = alc883_adc_nids,
7834 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7835 .channel_mode = alc883_3ST_6ch_modes,
7836 .need_dac_fix = 1,
7837 .input_mux = &alc883_capture_source,
7838 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7839 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007840 },
7841 [ALC883_HAIER_W66] = {
7842 .mixers = { alc883_tagra_2ch_mixer},
7843 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7845 .dac_nids = alc883_dac_nids,
7846 .dig_out_nid = ALC883_DIGOUT_NID,
7847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7848 .adc_nids = alc883_adc_nids,
7849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7850 .channel_mode = alc883_3ST_2ch_modes,
7851 .input_mux = &alc883_capture_source,
7852 .unsol_event = alc883_haier_w66_unsol_event,
7853 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007854 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007855 [ALC888_6ST_HP] = {
7856 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7857 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7859 .dac_nids = alc883_dac_nids,
7860 .dig_out_nid = ALC883_DIGOUT_NID,
7861 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7862 .adc_nids = alc883_adc_nids,
7863 .dig_in_nid = ALC883_DIGIN_NID,
7864 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7865 .channel_mode = alc883_sixstack_modes,
7866 .input_mux = &alc883_capture_source,
7867 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007868 [ALC888_3ST_HP] = {
7869 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7870 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007871 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7872 .dac_nids = alc883_dac_nids,
7873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7874 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007875 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7876 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007877 .need_dac_fix = 1,
7878 .input_mux = &alc883_capture_source,
7879 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007880 [ALC888_6ST_DELL] = {
7881 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7882 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7883 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7884 .dac_nids = alc883_dac_nids,
7885 .dig_out_nid = ALC883_DIGOUT_NID,
7886 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7887 .adc_nids = alc883_adc_nids,
7888 .dig_in_nid = ALC883_DIGIN_NID,
7889 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7890 .channel_mode = alc883_sixstack_modes,
7891 .input_mux = &alc883_capture_source,
7892 .unsol_event = alc888_6st_dell_unsol_event,
7893 .init_hook = alc888_6st_dell_front_automute,
7894 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007895 [ALC883_MITAC] = {
7896 .mixers = { alc883_mitac_mixer },
7897 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7899 .dac_nids = alc883_dac_nids,
7900 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7901 .adc_nids = alc883_adc_nids,
7902 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7903 .channel_mode = alc883_3ST_2ch_modes,
7904 .input_mux = &alc883_capture_source,
7905 .unsol_event = alc883_mitac_unsol_event,
7906 .init_hook = alc883_mitac_automute,
7907 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007908};
7909
7910
7911/*
7912 * BIOS auto configuration
7913 */
7914static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7915 hda_nid_t nid, int pin_type,
7916 int dac_idx)
7917{
7918 /* set as output */
7919 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007920 int idx;
7921
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007922 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7923 idx = 4;
7924 else
7925 idx = spec->multiout.dac_nids[dac_idx] - 2;
7926
7927 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7928 pin_type);
7929 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7930 AMP_OUT_UNMUTE);
7931 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7932
7933}
7934
7935static void alc883_auto_init_multi_out(struct hda_codec *codec)
7936{
7937 struct alc_spec *spec = codec->spec;
7938 int i;
7939
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007940 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007941 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007942 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007943 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007944 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007945 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007946 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007947 }
7948}
7949
7950static void alc883_auto_init_hp_out(struct hda_codec *codec)
7951{
7952 struct alc_spec *spec = codec->spec;
7953 hda_nid_t pin;
7954
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007955 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007956 if (pin) /* connect to front */
7957 /* use dac 0 */
7958 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7959}
7960
7961#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7962#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7963
7964static void alc883_auto_init_analog_input(struct hda_codec *codec)
7965{
7966 struct alc_spec *spec = codec->spec;
7967 int i;
7968
7969 for (i = 0; i < AUTO_PIN_LAST; i++) {
7970 hda_nid_t nid = spec->autocfg.input_pins[i];
7971 if (alc883_is_input_pin(nid)) {
7972 snd_hda_codec_write(codec, nid, 0,
7973 AC_VERB_SET_PIN_WIDGET_CONTROL,
7974 (i <= AUTO_PIN_FRONT_MIC ?
7975 PIN_VREF80 : PIN_IN));
7976 if (nid != ALC883_PIN_CD_NID)
7977 snd_hda_codec_write(codec, nid, 0,
7978 AC_VERB_SET_AMP_GAIN_MUTE,
7979 AMP_OUT_MUTE);
7980 }
7981 }
7982}
7983
7984/* almost identical with ALC880 parser... */
7985static int alc883_parse_auto_config(struct hda_codec *codec)
7986{
7987 struct alc_spec *spec = codec->spec;
7988 int err = alc880_parse_auto_config(codec);
7989
7990 if (err < 0)
7991 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007992 else if (!err)
7993 return 0; /* no config found */
7994
7995 err = alc_auto_add_mic_boost(codec);
7996 if (err < 0)
7997 return err;
7998
7999 /* hack - override the init verbs */
8000 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008001 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8002 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008003
8004 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008005}
8006
8007/* additional initialization for auto-configuration model */
8008static void alc883_auto_init(struct hda_codec *codec)
8009{
8010 alc883_auto_init_multi_out(codec);
8011 alc883_auto_init_hp_out(codec);
8012 alc883_auto_init_analog_input(codec);
8013}
8014
8015static int patch_alc883(struct hda_codec *codec)
8016{
8017 struct alc_spec *spec;
8018 int err, board_config;
8019
8020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8021 if (spec == NULL)
8022 return -ENOMEM;
8023
8024 codec->spec = spec;
8025
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008026 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8027 alc883_models,
8028 alc883_cfg_tbl);
8029 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008030 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8031 "trying auto-probe from BIOS...\n");
8032 board_config = ALC883_AUTO;
8033 }
8034
8035 if (board_config == ALC883_AUTO) {
8036 /* automatic parse from the BIOS config */
8037 err = alc883_parse_auto_config(codec);
8038 if (err < 0) {
8039 alc_free(codec);
8040 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008041 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008042 printk(KERN_INFO
8043 "hda_codec: Cannot set up configuration "
8044 "from BIOS. Using base mode...\n");
8045 board_config = ALC883_3ST_2ch_DIG;
8046 }
8047 }
8048
8049 if (board_config != ALC883_AUTO)
8050 setup_preset(spec, &alc883_presets[board_config]);
8051
8052 spec->stream_name_analog = "ALC883 Analog";
8053 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8054 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008055 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008056
8057 spec->stream_name_digital = "ALC883 Digital";
8058 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8059 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8060
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008061 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008062 spec->adc_nids = alc883_adc_nids;
8063 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8064 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008065
Takashi Iwai2134ea42008-01-10 16:53:55 +01008066 spec->vmaster_nid = 0x0c;
8067
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008068 codec->patch_ops = alc_patch_ops;
8069 if (board_config == ALC883_AUTO)
8070 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008071#ifdef CONFIG_SND_HDA_POWER_SAVE
8072 if (!spec->loopback.amplist)
8073 spec->loopback.amplist = alc883_loopbacks;
8074#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008075
8076 return 0;
8077}
8078
8079/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008080 * ALC262 support
8081 */
8082
8083#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8084#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8085
8086#define alc262_dac_nids alc260_dac_nids
8087#define alc262_adc_nids alc882_adc_nids
8088#define alc262_adc_nids_alt alc882_adc_nids_alt
8089
8090#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008091#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008092
8093static struct snd_kcontrol_new alc262_base_mixer[] = {
8094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008105 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008106 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008107 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008108 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8110 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008112 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008113};
8114
Kailang Yangccc656c2006-10-17 12:32:26 +02008115static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008124 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008127 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008128 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008129 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008130 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8132 { } /* end */
8133};
8134
Takashi Iwaice875f02008-01-28 18:17:43 +01008135/* update HP, line and mono-out pins according to the master switch */
8136static void alc262_hp_master_update(struct hda_codec *codec)
8137{
8138 struct alc_spec *spec = codec->spec;
8139 int val = spec->master_sw;
8140
8141 /* HP & line-out */
8142 snd_hda_codec_write_cache(codec, 0x1b, 0,
8143 AC_VERB_SET_PIN_WIDGET_CONTROL,
8144 val ? PIN_HP : 0);
8145 snd_hda_codec_write_cache(codec, 0x15, 0,
8146 AC_VERB_SET_PIN_WIDGET_CONTROL,
8147 val ? PIN_HP : 0);
8148 /* mono (speaker) depending on the HP jack sense */
8149 val = val && !spec->jack_present;
8150 snd_hda_codec_write_cache(codec, 0x16, 0,
8151 AC_VERB_SET_PIN_WIDGET_CONTROL,
8152 val ? PIN_OUT : 0);
8153}
8154
8155static void alc262_hp_bpc_automute(struct hda_codec *codec)
8156{
8157 struct alc_spec *spec = codec->spec;
8158 unsigned int presence;
8159 presence = snd_hda_codec_read(codec, 0x1b, 0,
8160 AC_VERB_GET_PIN_SENSE, 0);
8161 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8162 alc262_hp_master_update(codec);
8163}
8164
8165static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8166{
8167 if ((res >> 26) != ALC880_HP_EVENT)
8168 return;
8169 alc262_hp_bpc_automute(codec);
8170}
8171
8172static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8173{
8174 struct alc_spec *spec = codec->spec;
8175 unsigned int presence;
8176 presence = snd_hda_codec_read(codec, 0x15, 0,
8177 AC_VERB_GET_PIN_SENSE, 0);
8178 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8179 alc262_hp_master_update(codec);
8180}
8181
8182static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8183 unsigned int res)
8184{
8185 if ((res >> 26) != ALC880_HP_EVENT)
8186 return;
8187 alc262_hp_wildwest_automute(codec);
8188}
8189
8190static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8191 struct snd_ctl_elem_value *ucontrol)
8192{
8193 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8194 struct alc_spec *spec = codec->spec;
8195 *ucontrol->value.integer.value = spec->master_sw;
8196 return 0;
8197}
8198
8199static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8200 struct snd_ctl_elem_value *ucontrol)
8201{
8202 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8203 struct alc_spec *spec = codec->spec;
8204 int val = !!*ucontrol->value.integer.value;
8205
8206 if (val == spec->master_sw)
8207 return 0;
8208 spec->master_sw = val;
8209 alc262_hp_master_update(codec);
8210 return 1;
8211}
8212
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008213static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008214 {
8215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8216 .name = "Master Playback Switch",
8217 .info = snd_ctl_boolean_mono_info,
8218 .get = alc262_hp_master_sw_get,
8219 .put = alc262_hp_master_sw_put,
8220 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8222 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8223 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008224 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8225 HDA_OUTPUT),
8226 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8227 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8238 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8239 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8240 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8241 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8242 { } /* end */
8243};
8244
Kailang Yangcd7509a2007-01-26 18:33:17 +01008245static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008246 {
8247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8248 .name = "Master Playback Switch",
8249 .info = snd_ctl_boolean_mono_info,
8250 .get = alc262_hp_master_sw_get,
8251 .put = alc262_hp_master_sw_put,
8252 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8254 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008257 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8258 HDA_OUTPUT),
8259 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8260 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008263 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8266 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8267 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8268 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8269 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8270 { } /* end */
8271};
8272
8273static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8274 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8275 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008276 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008277 { } /* end */
8278};
8279
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008280/* mute/unmute internal speaker according to the hp jack and mute state */
8281static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8282{
8283 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008284
8285 if (force || !spec->sense_updated) {
8286 unsigned int present;
8287 present = snd_hda_codec_read(codec, 0x15, 0,
8288 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008289 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008290 spec->sense_updated = 1;
8291 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008292 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8293 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008294}
8295
8296static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8297 unsigned int res)
8298{
8299 if ((res >> 26) != ALC880_HP_EVENT)
8300 return;
8301 alc262_hp_t5735_automute(codec, 1);
8302}
8303
8304static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8305{
8306 alc262_hp_t5735_automute(codec, 1);
8307}
8308
8309static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008310 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8311 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008312 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8313 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8317 { } /* end */
8318};
8319
8320static struct hda_verb alc262_hp_t5735_verbs[] = {
8321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8323
8324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8325 { }
8326};
8327
Kailang Yang8c427222008-01-10 13:03:59 +01008328static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8330 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008331 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8332 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8335 { } /* end */
8336};
8337
8338static struct hda_verb alc262_hp_rp5700_verbs[] = {
8339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8340 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8341 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8343 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8344 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8349 {}
8350};
8351
8352static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8353 .num_items = 1,
8354 .items = {
8355 { "Line", 0x1 },
8356 },
8357};
8358
Takashi Iwai0724ea22007-08-23 00:31:43 +02008359/* bind hp and internal speaker mute (with plug check) */
8360static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8361 struct snd_ctl_elem_value *ucontrol)
8362{
8363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8364 long *valp = ucontrol->value.integer.value;
8365 int change;
8366
8367 /* change hp mute */
8368 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8369 HDA_AMP_MUTE,
8370 valp[0] ? 0 : HDA_AMP_MUTE);
8371 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8372 HDA_AMP_MUTE,
8373 valp[1] ? 0 : HDA_AMP_MUTE);
8374 if (change) {
8375 /* change speaker according to HP jack state */
8376 struct alc_spec *spec = codec->spec;
8377 unsigned int mute;
8378 if (spec->jack_present)
8379 mute = HDA_AMP_MUTE;
8380 else
8381 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8382 HDA_OUTPUT, 0);
8383 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8384 HDA_AMP_MUTE, mute);
8385 }
8386 return change;
8387}
Takashi Iwai5b319542007-07-26 11:49:22 +02008388
Kailang Yang272a5272007-05-14 11:00:38 +02008389static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008390 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8391 {
8392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8393 .name = "Master Playback Switch",
8394 .info = snd_hda_mixer_amp_switch_info,
8395 .get = snd_hda_mixer_amp_switch_get,
8396 .put = alc262_sony_master_sw_put,
8397 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8398 },
Kailang Yang272a5272007-05-14 11:00:38 +02008399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8401 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8402 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8403 { } /* end */
8404};
8405
Kailang Yang83c34212007-07-05 11:43:05 +02008406static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8408 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8411 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8412 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8413 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8414 { } /* end */
8415};
Kailang Yang272a5272007-05-14 11:00:38 +02008416
Kailang Yangdf694da2005-12-05 19:42:22 +01008417#define alc262_capture_mixer alc882_capture_mixer
8418#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8419
8420/*
8421 * generic initialization of ADC, input mixers and output mixers
8422 */
8423static struct hda_verb alc262_init_verbs[] = {
8424 /*
8425 * Unmute ADC0-2 and set the default input to mic-in
8426 */
8427 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8429 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8431 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8432 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8433
Takashi Iwaicb53c622007-08-10 17:21:45 +02008434 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008435 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008436 * Note: PASD motherboards uses the Line In 2 as the input for
8437 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008438 */
8439 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008445
8446 /*
8447 * Set up output mixers (0x0c - 0x0e)
8448 */
8449 /* set vol=0 to output mixers */
8450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8452 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8453 /* set up input amps for analog loopback */
8454 /* Amp Indices: DAC = 0, mixer = 1 */
8455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8461
8462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8464 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8465 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8466 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8467 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8468
8469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8474
8475 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8476 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8477
8478 /* FIXME: use matrix-type input source selection */
8479 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8480 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8485 /* Input mixer2 */
8486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8490 /* Input mixer3 */
8491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008495
8496 { }
8497};
8498
Kailang Yangccc656c2006-10-17 12:32:26 +02008499static struct hda_verb alc262_hippo_unsol_verbs[] = {
8500 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8502 {}
8503};
8504
8505static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8507 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8509
8510 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8512 {}
8513};
8514
Kailang Yang272a5272007-05-14 11:00:38 +02008515static struct hda_verb alc262_sony_unsol_verbs[] = {
8516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8519
8520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8522};
8523
Kailang Yangccc656c2006-10-17 12:32:26 +02008524/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008525static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008526{
8527 struct alc_spec *spec = codec->spec;
8528 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008529 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008530
Takashi Iwai5b319542007-07-26 11:49:22 +02008531 /* need to execute and sync at first */
8532 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8533 present = snd_hda_codec_read(codec, 0x15, 0,
8534 AC_VERB_GET_PIN_SENSE, 0);
8535 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008536 if (spec->jack_present) {
8537 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008538 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8539 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008540 } else {
8541 /* unmute internal speaker if necessary */
8542 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8544 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008545 }
8546}
8547
8548/* unsolicited event for HP jack sensing */
8549static void alc262_hippo_unsol_event(struct hda_codec *codec,
8550 unsigned int res)
8551{
8552 if ((res >> 26) != ALC880_HP_EVENT)
8553 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008554 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008555}
8556
Takashi Iwai5b319542007-07-26 11:49:22 +02008557static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008558{
Kailang Yangccc656c2006-10-17 12:32:26 +02008559 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008560 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008561
Takashi Iwai5b319542007-07-26 11:49:22 +02008562 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8563 present = snd_hda_codec_read(codec, 0x1b, 0,
8564 AC_VERB_GET_PIN_SENSE, 0);
8565 present = (present & 0x80000000) != 0;
8566 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008567 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008568 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8569 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008570 } else {
8571 /* unmute internal speaker if necessary */
8572 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008573 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8574 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008575 }
8576}
8577
8578/* unsolicited event for HP jack sensing */
8579static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8580 unsigned int res)
8581{
8582 if ((res >> 26) != ALC880_HP_EVENT)
8583 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008584 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008585}
8586
Takashi Iwai834be882006-03-01 14:16:17 +01008587/*
8588 * fujitsu model
8589 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8590 */
8591
8592#define ALC_HP_EVENT 0x37
8593
8594static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8595 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8597 {}
8598};
8599
8600static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008601 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008602 .items = {
8603 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008604 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008605 { "CD", 0x4 },
8606 },
8607};
8608
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008609static struct hda_input_mux alc262_HP_capture_source = {
8610 .num_items = 5,
8611 .items = {
8612 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008613 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008614 { "Line", 0x2 },
8615 { "CD", 0x4 },
8616 { "AUX IN", 0x6 },
8617 },
8618};
8619
zhejiangaccbe492007-08-31 12:36:05 +02008620static struct hda_input_mux alc262_HP_D7000_capture_source = {
8621 .num_items = 4,
8622 .items = {
8623 { "Mic", 0x0 },
8624 { "Front Mic", 0x2 },
8625 { "Line", 0x1 },
8626 { "CD", 0x4 },
8627 },
8628};
8629
Takashi Iwai834be882006-03-01 14:16:17 +01008630/* mute/unmute internal speaker according to the hp jack and mute state */
8631static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8632{
8633 struct alc_spec *spec = codec->spec;
8634 unsigned int mute;
8635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008636 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008637 unsigned int present;
8638 /* need to execute and sync at first */
8639 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8640 present = snd_hda_codec_read(codec, 0x14, 0,
8641 AC_VERB_GET_PIN_SENSE, 0);
8642 spec->jack_present = (present & 0x80000000) != 0;
8643 spec->sense_updated = 1;
8644 }
8645 if (spec->jack_present) {
8646 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8648 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008649 } else {
8650 /* unmute internal speaker if necessary */
8651 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008652 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8653 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008654 }
8655}
8656
8657/* unsolicited event for HP jack sensing */
8658static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8659 unsigned int res)
8660{
8661 if ((res >> 26) != ALC_HP_EVENT)
8662 return;
8663 alc262_fujitsu_automute(codec, 1);
8664}
8665
8666/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008667static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8668 .ops = &snd_hda_bind_vol,
8669 .values = {
8670 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8671 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8672 0
8673 },
8674};
Takashi Iwai834be882006-03-01 14:16:17 +01008675
8676/* bind hp and internal speaker mute (with plug check) */
8677static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8678 struct snd_ctl_elem_value *ucontrol)
8679{
8680 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8681 long *valp = ucontrol->value.integer.value;
8682 int change;
8683
8684 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008685 HDA_AMP_MUTE,
8686 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008687 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008688 HDA_AMP_MUTE,
8689 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008690 if (change)
8691 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008692 return change;
8693}
8694
8695static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008696 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008697 {
8698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8699 .name = "Master Playback Switch",
8700 .info = snd_hda_mixer_amp_switch_info,
8701 .get = snd_hda_mixer_amp_switch_get,
8702 .put = alc262_fujitsu_master_sw_put,
8703 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8704 },
8705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008710 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8711 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8712 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008713 { } /* end */
8714};
8715
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008716/* additional init verbs for Benq laptops */
8717static struct hda_verb alc262_EAPD_verbs[] = {
8718 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8719 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8720 {}
8721};
8722
Kailang Yang83c34212007-07-05 11:43:05 +02008723static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8724 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8726
8727 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8728 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8729 {}
8730};
8731
Tobin Davisf651b502007-10-26 12:40:47 +02008732/* Samsung Q1 Ultra Vista model setup */
8733static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8734 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8735 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8739 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8740 { } /* end */
8741};
8742
8743static struct hda_verb alc262_ultra_verbs[] = {
8744 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8746 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8747 /* Mic is on Node 0x19 */
8748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8749 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8751 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8753 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8755 {}
8756};
8757
8758static struct hda_input_mux alc262_ultra_capture_source = {
8759 .num_items = 1,
8760 .items = {
8761 { "Mic", 0x1 },
8762 },
8763};
8764
8765/* mute/unmute internal speaker according to the hp jack and mute state */
8766static void alc262_ultra_automute(struct hda_codec *codec)
8767{
8768 struct alc_spec *spec = codec->spec;
8769 unsigned int mute;
8770 unsigned int present;
8771
8772 /* need to execute and sync at first */
8773 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8774 present = snd_hda_codec_read(codec, 0x15, 0,
8775 AC_VERB_GET_PIN_SENSE, 0);
8776 spec->jack_present = (present & 0x80000000) != 0;
8777 if (spec->jack_present) {
8778 /* mute internal speaker */
8779 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8780 HDA_AMP_MUTE, HDA_AMP_MUTE);
8781 } else {
8782 /* unmute internal speaker if necessary */
8783 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8784 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8785 HDA_AMP_MUTE, mute);
8786 }
8787}
8788
8789/* unsolicited event for HP jack sensing */
8790static void alc262_ultra_unsol_event(struct hda_codec *codec,
8791 unsigned int res)
8792{
8793 if ((res >> 26) != ALC880_HP_EVENT)
8794 return;
8795 alc262_ultra_automute(codec);
8796}
8797
Kailang Yangdf694da2005-12-05 19:42:22 +01008798/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008799static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8800 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008801{
8802 hda_nid_t nid;
8803 int err;
8804
8805 spec->multiout.num_dacs = 1; /* only use one dac */
8806 spec->multiout.dac_nids = spec->private_dac_nids;
8807 spec->multiout.dac_nids[0] = 2;
8808
8809 nid = cfg->line_out_pins[0];
8810 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008811 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8812 "Front Playback Volume",
8813 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8814 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008815 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008816 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8817 "Front Playback Switch",
8818 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8819 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008820 return err;
8821 }
8822
Takashi Iwai82bc9552006-03-21 11:24:42 +01008823 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008824 if (nid) {
8825 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008826 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8827 "Speaker Playback Volume",
8828 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8829 HDA_OUTPUT));
8830 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008831 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008832 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8833 "Speaker Playback Switch",
8834 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8835 HDA_OUTPUT));
8836 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008837 return err;
8838 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008839 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8840 "Speaker Playback Switch",
8841 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8842 HDA_OUTPUT));
8843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008844 return err;
8845 }
8846 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008847 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008848 if (nid) {
8849 /* spec->multiout.hp_nid = 2; */
8850 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008851 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8852 "Headphone Playback Volume",
8853 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8854 HDA_OUTPUT));
8855 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008856 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008857 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8858 "Headphone Playback Switch",
8859 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8860 HDA_OUTPUT));
8861 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008862 return err;
8863 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008864 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8865 "Headphone Playback Switch",
8866 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8867 HDA_OUTPUT));
8868 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008869 return err;
8870 }
8871 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008872 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008873}
8874
8875/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008876#define alc262_auto_create_analog_input_ctls \
8877 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008878
8879/*
8880 * generic initialization of ADC, input mixers and output mixers
8881 */
8882static struct hda_verb alc262_volume_init_verbs[] = {
8883 /*
8884 * Unmute ADC0-2 and set the default input to mic-in
8885 */
8886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892
Takashi Iwaicb53c622007-08-10 17:21:45 +02008893 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008894 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008895 * Note: PASD motherboards uses the Line In 2 as the input for
8896 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008897 */
8898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008904
8905 /*
8906 * Set up output mixers (0x0c - 0x0f)
8907 */
8908 /* set vol=0 to output mixers */
8909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8912
8913 /* set up input amps for analog loopback */
8914 /* Amp Indices: DAC = 0, mixer = 1 */
8915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8921
8922 /* FIXME: use matrix-type input source selection */
8923 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8924 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8929 /* Input mixer2 */
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8934 /* Input mixer3 */
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8939
8940 { }
8941};
8942
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008943static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8944 /*
8945 * Unmute ADC0-2 and set the default input to mic-in
8946 */
8947 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8949 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8951 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8953
Takashi Iwaicb53c622007-08-10 17:21:45 +02008954 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008955 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008956 * Note: PASD motherboards uses the Line In 2 as the input for
8957 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008958 */
8959 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8962 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8963 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008967
8968 /*
8969 * Set up output mixers (0x0c - 0x0e)
8970 */
8971 /* set vol=0 to output mixers */
8972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8973 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8974 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8975
8976 /* set up input amps for analog loopback */
8977 /* Amp Indices: DAC = 0, mixer = 1 */
8978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8981 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8984
Takashi Iwaice875f02008-01-28 18:17:43 +01008985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8988
8989 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8991
8992 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8994
8995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9000
9001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9002 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9003 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9005 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9006 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9007
9008
9009 /* FIXME: use matrix-type input source selection */
9010 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9011 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9016 /* Input mixer2 */
9017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9018 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9019 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9020 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9021 /* Input mixer3 */
9022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9026
Takashi Iwaice875f02008-01-28 18:17:43 +01009027 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9028
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009029 { }
9030};
9031
Kailang Yangcd7509a2007-01-26 18:33:17 +01009032static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9033 /*
9034 * Unmute ADC0-2 and set the default input to mic-in
9035 */
9036 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9038 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9040 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9042
Takashi Iwaicb53c622007-08-10 17:21:45 +02009043 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009044 * mixer widget
9045 * Note: PASD motherboards uses the Line In 2 as the input for front
9046 * panel mic (mic 2)
9047 */
9048 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009057 /*
9058 * Set up output mixers (0x0c - 0x0e)
9059 */
9060 /* set vol=0 to output mixers */
9061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9064
9065 /* set up input amps for analog loopback */
9066 /* Amp Indices: DAC = 0, mixer = 1 */
9067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9073
9074
9075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9080 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9081 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9082
9083 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9085
9086 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9087 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9088
9089 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9093 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9094 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9095
9096 /* FIXME: use matrix-type input source selection */
9097 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9098 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9104 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9106 /* Input mixer2 */
9107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9112 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9114 /* Input mixer3 */
9115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9120 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9122
Takashi Iwaice875f02008-01-28 18:17:43 +01009123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9124
Kailang Yangcd7509a2007-01-26 18:33:17 +01009125 { }
9126};
9127
Takashi Iwaicb53c622007-08-10 17:21:45 +02009128#ifdef CONFIG_SND_HDA_POWER_SAVE
9129#define alc262_loopbacks alc880_loopbacks
9130#endif
9131
Kailang Yangdf694da2005-12-05 19:42:22 +01009132/* pcm configuration: identiacal with ALC880 */
9133#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9134#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9135#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9136#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9137
9138/*
9139 * BIOS auto configuration
9140 */
9141static int alc262_parse_auto_config(struct hda_codec *codec)
9142{
9143 struct alc_spec *spec = codec->spec;
9144 int err;
9145 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9146
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009147 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9148 alc262_ignore);
9149 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009150 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009151 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009152 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009153 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9154 if (err < 0)
9155 return err;
9156 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9157 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009158 return err;
9159
9160 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9161
9162 if (spec->autocfg.dig_out_pin)
9163 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9164 if (spec->autocfg.dig_in_pin)
9165 spec->dig_in_nid = ALC262_DIGIN_NID;
9166
9167 if (spec->kctl_alloc)
9168 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9169
9170 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009171 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009172 spec->input_mux = &spec->private_imux;
9173
Takashi Iwai776e1842007-08-29 15:07:11 +02009174 err = alc_auto_add_mic_boost(codec);
9175 if (err < 0)
9176 return err;
9177
Kailang Yangdf694da2005-12-05 19:42:22 +01009178 return 1;
9179}
9180
9181#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9182#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9183#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9184
9185
9186/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009187static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009188{
Kailang Yangdf694da2005-12-05 19:42:22 +01009189 alc262_auto_init_multi_out(codec);
9190 alc262_auto_init_hp_out(codec);
9191 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009192}
9193
9194/*
9195 * configuration and preset
9196 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009197static const char *alc262_models[ALC262_MODEL_LAST] = {
9198 [ALC262_BASIC] = "basic",
9199 [ALC262_HIPPO] = "hippo",
9200 [ALC262_HIPPO_1] = "hippo_1",
9201 [ALC262_FUJITSU] = "fujitsu",
9202 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009203 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009204 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009205 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009206 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009207 [ALC262_BENQ_T31] = "benq-t31",
9208 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009209 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009210 [ALC262_AUTO] = "auto",
9211};
9212
9213static struct snd_pci_quirk alc262_cfg_tbl[] = {
9214 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9215 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009216 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009217 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9218 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009219 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009220 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009221 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009222 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009223 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009224 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009225 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009226 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009227 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009228 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009229 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009230 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009231 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9232 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9233 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009234 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9235 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009236 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009237 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009238 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009239 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9240 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9241 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009242 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009243 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009244 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009245 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009246 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009247 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009248 {}
9249};
9250
9251static struct alc_config_preset alc262_presets[] = {
9252 [ALC262_BASIC] = {
9253 .mixers = { alc262_base_mixer },
9254 .init_verbs = { alc262_init_verbs },
9255 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9256 .dac_nids = alc262_dac_nids,
9257 .hp_nid = 0x03,
9258 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9259 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009260 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009261 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009262 [ALC262_HIPPO] = {
9263 .mixers = { alc262_base_mixer },
9264 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9265 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9266 .dac_nids = alc262_dac_nids,
9267 .hp_nid = 0x03,
9268 .dig_out_nid = ALC262_DIGOUT_NID,
9269 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9270 .channel_mode = alc262_modes,
9271 .input_mux = &alc262_capture_source,
9272 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009273 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009274 },
9275 [ALC262_HIPPO_1] = {
9276 .mixers = { alc262_hippo1_mixer },
9277 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9278 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9279 .dac_nids = alc262_dac_nids,
9280 .hp_nid = 0x02,
9281 .dig_out_nid = ALC262_DIGOUT_NID,
9282 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9283 .channel_mode = alc262_modes,
9284 .input_mux = &alc262_capture_source,
9285 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009286 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009287 },
Takashi Iwai834be882006-03-01 14:16:17 +01009288 [ALC262_FUJITSU] = {
9289 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009290 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9291 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009292 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9293 .dac_nids = alc262_dac_nids,
9294 .hp_nid = 0x03,
9295 .dig_out_nid = ALC262_DIGOUT_NID,
9296 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9297 .channel_mode = alc262_modes,
9298 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009299 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009300 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009301 [ALC262_HP_BPC] = {
9302 .mixers = { alc262_HP_BPC_mixer },
9303 .init_verbs = { alc262_HP_BPC_init_verbs },
9304 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9305 .dac_nids = alc262_dac_nids,
9306 .hp_nid = 0x03,
9307 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9308 .channel_mode = alc262_modes,
9309 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009310 .unsol_event = alc262_hp_bpc_unsol_event,
9311 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009312 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009313 [ALC262_HP_BPC_D7000_WF] = {
9314 .mixers = { alc262_HP_BPC_WildWest_mixer },
9315 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9316 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9317 .dac_nids = alc262_dac_nids,
9318 .hp_nid = 0x03,
9319 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9320 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009321 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009322 .unsol_event = alc262_hp_wildwest_unsol_event,
9323 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009324 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009325 [ALC262_HP_BPC_D7000_WL] = {
9326 .mixers = { alc262_HP_BPC_WildWest_mixer,
9327 alc262_HP_BPC_WildWest_option_mixer },
9328 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9329 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9330 .dac_nids = alc262_dac_nids,
9331 .hp_nid = 0x03,
9332 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9333 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009334 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009335 .unsol_event = alc262_hp_wildwest_unsol_event,
9336 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009337 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009338 [ALC262_HP_TC_T5735] = {
9339 .mixers = { alc262_hp_t5735_mixer },
9340 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9341 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9342 .dac_nids = alc262_dac_nids,
9343 .hp_nid = 0x03,
9344 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9345 .channel_mode = alc262_modes,
9346 .input_mux = &alc262_capture_source,
9347 .unsol_event = alc262_hp_t5735_unsol_event,
9348 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009349 },
9350 [ALC262_HP_RP5700] = {
9351 .mixers = { alc262_hp_rp5700_mixer },
9352 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9353 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9354 .dac_nids = alc262_dac_nids,
9355 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9356 .channel_mode = alc262_modes,
9357 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009358 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009359 [ALC262_BENQ_ED8] = {
9360 .mixers = { alc262_base_mixer },
9361 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9362 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9363 .dac_nids = alc262_dac_nids,
9364 .hp_nid = 0x03,
9365 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9366 .channel_mode = alc262_modes,
9367 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009368 },
Kailang Yang272a5272007-05-14 11:00:38 +02009369 [ALC262_SONY_ASSAMD] = {
9370 .mixers = { alc262_sony_mixer },
9371 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9372 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9373 .dac_nids = alc262_dac_nids,
9374 .hp_nid = 0x02,
9375 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9376 .channel_mode = alc262_modes,
9377 .input_mux = &alc262_capture_source,
9378 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009379 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009380 },
9381 [ALC262_BENQ_T31] = {
9382 .mixers = { alc262_benq_t31_mixer },
9383 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9384 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9385 .dac_nids = alc262_dac_nids,
9386 .hp_nid = 0x03,
9387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9388 .channel_mode = alc262_modes,
9389 .input_mux = &alc262_capture_source,
9390 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009391 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009392 },
Tobin Davisf651b502007-10-26 12:40:47 +02009393 [ALC262_ULTRA] = {
9394 .mixers = { alc262_ultra_mixer },
9395 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9397 .dac_nids = alc262_dac_nids,
9398 .hp_nid = 0x03,
9399 .dig_out_nid = ALC262_DIGOUT_NID,
9400 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9401 .channel_mode = alc262_modes,
9402 .input_mux = &alc262_ultra_capture_source,
9403 .unsol_event = alc262_ultra_unsol_event,
9404 .init_hook = alc262_ultra_automute,
9405 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009406};
9407
9408static int patch_alc262(struct hda_codec *codec)
9409{
9410 struct alc_spec *spec;
9411 int board_config;
9412 int err;
9413
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009414 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009415 if (spec == NULL)
9416 return -ENOMEM;
9417
9418 codec->spec = spec;
9419#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009420 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9421 * under-run
9422 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009423 {
9424 int tmp;
9425 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9426 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9427 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9428 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9429 }
9430#endif
9431
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009432 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9433 alc262_models,
9434 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009435
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009436 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009437 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9438 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009439 board_config = ALC262_AUTO;
9440 }
9441
9442 if (board_config == ALC262_AUTO) {
9443 /* automatic parse from the BIOS config */
9444 err = alc262_parse_auto_config(codec);
9445 if (err < 0) {
9446 alc_free(codec);
9447 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009448 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009449 printk(KERN_INFO
9450 "hda_codec: Cannot set up configuration "
9451 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009452 board_config = ALC262_BASIC;
9453 }
9454 }
9455
9456 if (board_config != ALC262_AUTO)
9457 setup_preset(spec, &alc262_presets[board_config]);
9458
9459 spec->stream_name_analog = "ALC262 Analog";
9460 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9461 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9462
9463 spec->stream_name_digital = "ALC262 Digital";
9464 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9465 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009467 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009468 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009469 unsigned int wcap = get_wcaps(codec, 0x07);
9470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009471 /* get type */
9472 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009473 if (wcap != AC_WID_AUD_IN) {
9474 spec->adc_nids = alc262_adc_nids_alt;
9475 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009476 spec->mixers[spec->num_mixers] =
9477 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009478 spec->num_mixers++;
9479 } else {
9480 spec->adc_nids = alc262_adc_nids;
9481 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9482 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9483 spec->num_mixers++;
9484 }
9485 }
9486
Takashi Iwai2134ea42008-01-10 16:53:55 +01009487 spec->vmaster_nid = 0x0c;
9488
Kailang Yangdf694da2005-12-05 19:42:22 +01009489 codec->patch_ops = alc_patch_ops;
9490 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009491 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009492#ifdef CONFIG_SND_HDA_POWER_SAVE
9493 if (!spec->loopback.amplist)
9494 spec->loopback.amplist = alc262_loopbacks;
9495#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009496
Kailang Yangdf694da2005-12-05 19:42:22 +01009497 return 0;
9498}
9499
Kailang Yangdf694da2005-12-05 19:42:22 +01009500/*
Kailang Yanga361d842007-06-05 12:30:55 +02009501 * ALC268 channel source setting (2 channel)
9502 */
9503#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9504#define alc268_modes alc260_modes
9505
9506static hda_nid_t alc268_dac_nids[2] = {
9507 /* front, hp */
9508 0x02, 0x03
9509};
9510
9511static hda_nid_t alc268_adc_nids[2] = {
9512 /* ADC0-1 */
9513 0x08, 0x07
9514};
9515
9516static hda_nid_t alc268_adc_nids_alt[1] = {
9517 /* ADC0 */
9518 0x08
9519};
9520
9521static struct snd_kcontrol_new alc268_base_mixer[] = {
9522 /* output mixer control */
9523 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9524 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9525 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009527 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9528 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9529 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009530 { }
9531};
9532
Kailang Yangd1a991a2007-08-15 16:21:59 +02009533static struct hda_verb alc268_eapd_verbs[] = {
9534 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9535 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9536 { }
9537};
9538
Takashi Iwaid2738092007-08-16 14:59:45 +02009539/* Toshiba specific */
9540#define alc268_toshiba_automute alc262_hippo_automute
9541
9542static struct hda_verb alc268_toshiba_verbs[] = {
9543 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9544 { } /* end */
9545};
9546
9547/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009548/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009549static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9550 .ops = &snd_hda_bind_vol,
9551 .values = {
9552 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9553 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9554 0
9555 },
9556};
9557
Takashi Iwai889c4392007-08-23 18:56:52 +02009558/* mute/unmute internal speaker according to the hp jack and mute state */
9559static void alc268_acer_automute(struct hda_codec *codec, int force)
9560{
9561 struct alc_spec *spec = codec->spec;
9562 unsigned int mute;
9563
9564 if (force || !spec->sense_updated) {
9565 unsigned int present;
9566 present = snd_hda_codec_read(codec, 0x14, 0,
9567 AC_VERB_GET_PIN_SENSE, 0);
9568 spec->jack_present = (present & 0x80000000) != 0;
9569 spec->sense_updated = 1;
9570 }
9571 if (spec->jack_present)
9572 mute = HDA_AMP_MUTE; /* mute internal speaker */
9573 else /* unmute internal speaker if necessary */
9574 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9575 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9576 HDA_AMP_MUTE, mute);
9577}
9578
9579
9580/* bind hp and internal speaker mute (with plug check) */
9581static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9582 struct snd_ctl_elem_value *ucontrol)
9583{
9584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9585 long *valp = ucontrol->value.integer.value;
9586 int change;
9587
9588 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9589 HDA_AMP_MUTE,
9590 valp[0] ? 0 : HDA_AMP_MUTE);
9591 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9592 HDA_AMP_MUTE,
9593 valp[1] ? 0 : HDA_AMP_MUTE);
9594 if (change)
9595 alc268_acer_automute(codec, 0);
9596 return change;
9597}
Takashi Iwaid2738092007-08-16 14:59:45 +02009598
9599static struct snd_kcontrol_new alc268_acer_mixer[] = {
9600 /* output mixer control */
9601 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9602 {
9603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9604 .name = "Master Playback Switch",
9605 .info = snd_hda_mixer_amp_switch_info,
9606 .get = snd_hda_mixer_amp_switch_get,
9607 .put = alc268_acer_master_sw_put,
9608 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9609 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009610 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9611 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9612 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009613 { }
9614};
9615
9616static struct hda_verb alc268_acer_verbs[] = {
9617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9619
9620 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9621 { }
9622};
9623
9624/* unsolicited event for HP jack sensing */
9625static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9626 unsigned int res)
9627{
Takashi Iwai889c4392007-08-23 18:56:52 +02009628 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009629 return;
9630 alc268_toshiba_automute(codec);
9631}
9632
9633static void alc268_acer_unsol_event(struct hda_codec *codec,
9634 unsigned int res)
9635{
Takashi Iwai889c4392007-08-23 18:56:52 +02009636 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009637 return;
9638 alc268_acer_automute(codec, 1);
9639}
9640
Takashi Iwai889c4392007-08-23 18:56:52 +02009641static void alc268_acer_init_hook(struct hda_codec *codec)
9642{
9643 alc268_acer_automute(codec, 1);
9644}
9645
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009646static struct snd_kcontrol_new alc268_dell_mixer[] = {
9647 /* output mixer control */
9648 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9649 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9652 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9653 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9654 { }
9655};
9656
9657static struct hda_verb alc268_dell_verbs[] = {
9658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9660 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9661 { }
9662};
9663
9664/* mute/unmute internal speaker according to the hp jack and mute state */
9665static void alc268_dell_automute(struct hda_codec *codec)
9666{
9667 unsigned int present;
9668 unsigned int mute;
9669
9670 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9671 if (present & 0x80000000)
9672 mute = HDA_AMP_MUTE;
9673 else
9674 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9675 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9676 HDA_AMP_MUTE, mute);
9677}
9678
9679static void alc268_dell_unsol_event(struct hda_codec *codec,
9680 unsigned int res)
9681{
9682 if ((res >> 26) != ALC880_HP_EVENT)
9683 return;
9684 alc268_dell_automute(codec);
9685}
9686
9687#define alc268_dell_init_hook alc268_dell_automute
9688
Kailang Yanga361d842007-06-05 12:30:55 +02009689/*
9690 * generic initialization of ADC, input mixers and output mixers
9691 */
9692static struct hda_verb alc268_base_init_verbs[] = {
9693 /* Unmute DAC0-1 and set vol = 0 */
9694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9695 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9696 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9699 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9700
9701 /*
9702 * Set up output mixers (0x0c - 0x0e)
9703 */
9704 /* set vol=0 to output mixers */
9705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9708 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9709
9710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9711 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9712
9713 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9716 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9717 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9720 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9721
9722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9728 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9729 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9730
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009731 /* Unmute Selector 23h,24h and set the default input to mic-in */
9732
9733 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9734 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9735 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009737
Kailang Yanga361d842007-06-05 12:30:55 +02009738 { }
9739};
9740
9741/*
9742 * generic initialization of ADC, input mixers and output mixers
9743 */
9744static struct hda_verb alc268_volume_init_verbs[] = {
9745 /* set output DAC */
9746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9747 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9748 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9749 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9750
9751 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9752 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9754 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9755 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9756
9757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9760 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9761 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9762
9763 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9764 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9765 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9766 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9767
9768 /* set PCBEEP vol = 0 */
9769 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9770
9771 { }
9772};
9773
9774#define alc268_mux_enum_info alc_mux_enum_info
9775#define alc268_mux_enum_get alc_mux_enum_get
9776
9777static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9778 struct snd_ctl_elem_value *ucontrol)
9779{
9780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9781 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009782
Kailang Yanga361d842007-06-05 12:30:55 +02009783 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9784 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9785 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009786
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009787 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9788 nid,
9789 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009790}
9791
9792static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9793 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9794 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9795 {
9796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9797 /* The multiple "Capture Source" controls confuse alsamixer
9798 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009799 */
9800 /* .name = "Capture Source", */
9801 .name = "Input Source",
9802 .count = 1,
9803 .info = alc268_mux_enum_info,
9804 .get = alc268_mux_enum_get,
9805 .put = alc268_mux_enum_put,
9806 },
9807 { } /* end */
9808};
9809
9810static struct snd_kcontrol_new alc268_capture_mixer[] = {
9811 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9812 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9813 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9814 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9815 {
9816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9817 /* The multiple "Capture Source" controls confuse alsamixer
9818 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009819 */
9820 /* .name = "Capture Source", */
9821 .name = "Input Source",
9822 .count = 2,
9823 .info = alc268_mux_enum_info,
9824 .get = alc268_mux_enum_get,
9825 .put = alc268_mux_enum_put,
9826 },
9827 { } /* end */
9828};
9829
9830static struct hda_input_mux alc268_capture_source = {
9831 .num_items = 4,
9832 .items = {
9833 { "Mic", 0x0 },
9834 { "Front Mic", 0x1 },
9835 { "Line", 0x2 },
9836 { "CD", 0x3 },
9837 },
9838};
9839
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009840#ifdef CONFIG_SND_DEBUG
9841static struct snd_kcontrol_new alc268_test_mixer[] = {
9842 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9843 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9844 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9846
9847 /* Volume widgets */
9848 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9849 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9850 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9851 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9852 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9853 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9854 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9855 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9856 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9857 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9858 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9859 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9860 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009861 /* The below appears problematic on some hardwares */
9862 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009863 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9864 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9865 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9866 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9867
9868 /* Modes for retasking pin widgets */
9869 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9870 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9871 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9872 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9873
9874 /* Controls for GPIO pins, assuming they are configured as outputs */
9875 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9876 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9877 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9878 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9879
9880 /* Switches to allow the digital SPDIF output pin to be enabled.
9881 * The ALC268 does not have an SPDIF input.
9882 */
9883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9884
9885 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9886 * this output to turn on an external amplifier.
9887 */
9888 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9889 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9890
9891 { } /* end */
9892};
9893#endif
9894
Kailang Yanga361d842007-06-05 12:30:55 +02009895/* create input playback/capture controls for the given pin */
9896static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9897 const char *ctlname, int idx)
9898{
9899 char name[32];
9900 int err;
9901
9902 sprintf(name, "%s Playback Volume", ctlname);
9903 if (nid == 0x14) {
9904 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9905 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9906 HDA_OUTPUT));
9907 if (err < 0)
9908 return err;
9909 } else if (nid == 0x15) {
9910 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9911 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9912 HDA_OUTPUT));
9913 if (err < 0)
9914 return err;
9915 } else
9916 return -1;
9917 sprintf(name, "%s Playback Switch", ctlname);
9918 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9919 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9920 if (err < 0)
9921 return err;
9922 return 0;
9923}
9924
9925/* add playback controls from the parsed DAC table */
9926static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9927 const struct auto_pin_cfg *cfg)
9928{
9929 hda_nid_t nid;
9930 int err;
9931
9932 spec->multiout.num_dacs = 2; /* only use one dac */
9933 spec->multiout.dac_nids = spec->private_dac_nids;
9934 spec->multiout.dac_nids[0] = 2;
9935 spec->multiout.dac_nids[1] = 3;
9936
9937 nid = cfg->line_out_pins[0];
9938 if (nid)
9939 alc268_new_analog_output(spec, nid, "Front", 0);
9940
9941 nid = cfg->speaker_pins[0];
9942 if (nid == 0x1d) {
9943 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9944 "Speaker Playback Volume",
9945 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9946 if (err < 0)
9947 return err;
9948 }
9949 nid = cfg->hp_pins[0];
9950 if (nid)
9951 alc268_new_analog_output(spec, nid, "Headphone", 0);
9952
9953 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9954 if (nid == 0x16) {
9955 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9956 "Mono Playback Switch",
9957 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9958 if (err < 0)
9959 return err;
9960 }
9961 return 0;
9962}
9963
9964/* create playback/capture controls for input pins */
9965static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9966 const struct auto_pin_cfg *cfg)
9967{
9968 struct hda_input_mux *imux = &spec->private_imux;
9969 int i, idx1;
9970
9971 for (i = 0; i < AUTO_PIN_LAST; i++) {
9972 switch(cfg->input_pins[i]) {
9973 case 0x18:
9974 idx1 = 0; /* Mic 1 */
9975 break;
9976 case 0x19:
9977 idx1 = 1; /* Mic 2 */
9978 break;
9979 case 0x1a:
9980 idx1 = 2; /* Line In */
9981 break;
9982 case 0x1c:
9983 idx1 = 3; /* CD */
9984 break;
9985 default:
9986 continue;
9987 }
9988 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9989 imux->items[imux->num_items].index = idx1;
9990 imux->num_items++;
9991 }
9992 return 0;
9993}
9994
9995static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9996{
9997 struct alc_spec *spec = codec->spec;
9998 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9999 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10000 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10001 unsigned int dac_vol1, dac_vol2;
10002
10003 if (speaker_nid) {
10004 snd_hda_codec_write(codec, speaker_nid, 0,
10005 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10006 snd_hda_codec_write(codec, 0x0f, 0,
10007 AC_VERB_SET_AMP_GAIN_MUTE,
10008 AMP_IN_UNMUTE(1));
10009 snd_hda_codec_write(codec, 0x10, 0,
10010 AC_VERB_SET_AMP_GAIN_MUTE,
10011 AMP_IN_UNMUTE(1));
10012 } else {
10013 snd_hda_codec_write(codec, 0x0f, 0,
10014 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10015 snd_hda_codec_write(codec, 0x10, 0,
10016 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10017 }
10018
10019 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10020 if (line_nid == 0x14)
10021 dac_vol2 = AMP_OUT_ZERO;
10022 else if (line_nid == 0x15)
10023 dac_vol1 = AMP_OUT_ZERO;
10024 if (hp_nid == 0x14)
10025 dac_vol2 = AMP_OUT_ZERO;
10026 else if (hp_nid == 0x15)
10027 dac_vol1 = AMP_OUT_ZERO;
10028 if (line_nid != 0x16 || hp_nid != 0x16 ||
10029 spec->autocfg.line_out_pins[1] != 0x16 ||
10030 spec->autocfg.line_out_pins[2] != 0x16)
10031 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10032
10033 snd_hda_codec_write(codec, 0x02, 0,
10034 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10035 snd_hda_codec_write(codec, 0x03, 0,
10036 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10037}
10038
10039/* pcm configuration: identiacal with ALC880 */
10040#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10041#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010042#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010043#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10044
10045/*
10046 * BIOS auto configuration
10047 */
10048static int alc268_parse_auto_config(struct hda_codec *codec)
10049{
10050 struct alc_spec *spec = codec->spec;
10051 int err;
10052 static hda_nid_t alc268_ignore[] = { 0 };
10053
10054 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10055 alc268_ignore);
10056 if (err < 0)
10057 return err;
10058 if (!spec->autocfg.line_outs)
10059 return 0; /* can't find valid BIOS pin config */
10060
10061 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10062 if (err < 0)
10063 return err;
10064 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10065 if (err < 0)
10066 return err;
10067
10068 spec->multiout.max_channels = 2;
10069
10070 /* digital only support output */
10071 if (spec->autocfg.dig_out_pin)
10072 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10073
10074 if (spec->kctl_alloc)
10075 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10076
10077 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10078 spec->num_mux_defs = 1;
10079 spec->input_mux = &spec->private_imux;
10080
Takashi Iwai776e1842007-08-29 15:07:11 +020010081 err = alc_auto_add_mic_boost(codec);
10082 if (err < 0)
10083 return err;
10084
Kailang Yanga361d842007-06-05 12:30:55 +020010085 return 1;
10086}
10087
10088#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10089#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10090#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10091
10092/* init callback for auto-configuration model -- overriding the default init */
10093static void alc268_auto_init(struct hda_codec *codec)
10094{
10095 alc268_auto_init_multi_out(codec);
10096 alc268_auto_init_hp_out(codec);
10097 alc268_auto_init_mono_speaker_out(codec);
10098 alc268_auto_init_analog_input(codec);
10099}
10100
10101/*
10102 * configuration and preset
10103 */
10104static const char *alc268_models[ALC268_MODEL_LAST] = {
10105 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010106 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010107 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010108 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010109 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010110#ifdef CONFIG_SND_DEBUG
10111 [ALC268_TEST] = "test",
10112#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010113 [ALC268_AUTO] = "auto",
10114};
10115
10116static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010117 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010118 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010119 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010120 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010121 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010122 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010123 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010124 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010125 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010126 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010127 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010128 {}
10129};
10130
10131static struct alc_config_preset alc268_presets[] = {
10132 [ALC268_3ST] = {
10133 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10134 .init_verbs = { alc268_base_init_verbs },
10135 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10136 .dac_nids = alc268_dac_nids,
10137 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10138 .adc_nids = alc268_adc_nids_alt,
10139 .hp_nid = 0x03,
10140 .dig_out_nid = ALC268_DIGOUT_NID,
10141 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10142 .channel_mode = alc268_modes,
10143 .input_mux = &alc268_capture_source,
10144 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010145 [ALC268_TOSHIBA] = {
10146 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010147 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10148 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010149 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10150 .dac_nids = alc268_dac_nids,
10151 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10152 .adc_nids = alc268_adc_nids_alt,
10153 .hp_nid = 0x03,
10154 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10155 .channel_mode = alc268_modes,
10156 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010157 .unsol_event = alc268_toshiba_unsol_event,
10158 .init_hook = alc268_toshiba_automute,
10159 },
10160 [ALC268_ACER] = {
10161 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10162 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10163 alc268_acer_verbs },
10164 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10165 .dac_nids = alc268_dac_nids,
10166 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10167 .adc_nids = alc268_adc_nids_alt,
10168 .hp_nid = 0x02,
10169 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10170 .channel_mode = alc268_modes,
10171 .input_mux = &alc268_capture_source,
10172 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010173 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010174 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010175 [ALC268_DELL] = {
10176 .mixers = { alc268_dell_mixer },
10177 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10178 alc268_dell_verbs },
10179 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10180 .dac_nids = alc268_dac_nids,
10181 .hp_nid = 0x02,
10182 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10183 .channel_mode = alc268_modes,
10184 .unsol_event = alc268_dell_unsol_event,
10185 .init_hook = alc268_dell_init_hook,
10186 .input_mux = &alc268_capture_source,
10187 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010188 [ALC268_ZEPTO] = {
10189 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10190 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10191 alc268_toshiba_verbs },
10192 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10193 .dac_nids = alc268_dac_nids,
10194 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10195 .adc_nids = alc268_adc_nids_alt,
10196 .hp_nid = 0x03,
10197 .dig_out_nid = ALC268_DIGOUT_NID,
10198 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10199 .channel_mode = alc268_modes,
10200 .input_mux = &alc268_capture_source,
10201 .unsol_event = alc268_toshiba_unsol_event,
10202 .init_hook = alc268_toshiba_automute
10203 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010204#ifdef CONFIG_SND_DEBUG
10205 [ALC268_TEST] = {
10206 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10207 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10208 alc268_volume_init_verbs },
10209 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10210 .dac_nids = alc268_dac_nids,
10211 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10212 .adc_nids = alc268_adc_nids_alt,
10213 .hp_nid = 0x03,
10214 .dig_out_nid = ALC268_DIGOUT_NID,
10215 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10216 .channel_mode = alc268_modes,
10217 .input_mux = &alc268_capture_source,
10218 },
10219#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010220};
10221
10222static int patch_alc268(struct hda_codec *codec)
10223{
10224 struct alc_spec *spec;
10225 int board_config;
10226 int err;
10227
10228 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10229 if (spec == NULL)
10230 return -ENOMEM;
10231
10232 codec->spec = spec;
10233
10234 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10235 alc268_models,
10236 alc268_cfg_tbl);
10237
10238 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10239 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10240 "trying auto-probe from BIOS...\n");
10241 board_config = ALC268_AUTO;
10242 }
10243
10244 if (board_config == ALC268_AUTO) {
10245 /* automatic parse from the BIOS config */
10246 err = alc268_parse_auto_config(codec);
10247 if (err < 0) {
10248 alc_free(codec);
10249 return err;
10250 } else if (!err) {
10251 printk(KERN_INFO
10252 "hda_codec: Cannot set up configuration "
10253 "from BIOS. Using base mode...\n");
10254 board_config = ALC268_3ST;
10255 }
10256 }
10257
10258 if (board_config != ALC268_AUTO)
10259 setup_preset(spec, &alc268_presets[board_config]);
10260
10261 spec->stream_name_analog = "ALC268 Analog";
10262 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10263 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010264 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010265
10266 spec->stream_name_digital = "ALC268 Digital";
10267 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10268
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010269 if (!spec->adc_nids && spec->input_mux) {
10270 /* check whether NID 0x07 is valid */
10271 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010272
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010273 /* get type */
10274 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10275 if (wcap != AC_WID_AUD_IN) {
10276 spec->adc_nids = alc268_adc_nids_alt;
10277 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10278 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010279 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010280 spec->num_mixers++;
10281 } else {
10282 spec->adc_nids = alc268_adc_nids;
10283 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10284 spec->mixers[spec->num_mixers] =
10285 alc268_capture_mixer;
10286 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010287 }
10288 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010289
10290 spec->vmaster_nid = 0x02;
10291
Kailang Yanga361d842007-06-05 12:30:55 +020010292 codec->patch_ops = alc_patch_ops;
10293 if (board_config == ALC268_AUTO)
10294 spec->init_hook = alc268_auto_init;
10295
10296 return 0;
10297}
10298
10299/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010300 * ALC269 channel source setting (2 channel)
10301 */
10302#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10303
10304#define alc269_dac_nids alc260_dac_nids
10305
10306static hda_nid_t alc269_adc_nids[1] = {
10307 /* ADC1 */
10308 0x07,
10309};
10310
10311#define alc269_modes alc260_modes
10312#define alc269_capture_source alc880_lg_lw_capture_source
10313
10314static struct snd_kcontrol_new alc269_base_mixer[] = {
10315 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10316 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10321 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10322 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10323 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10324 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10326 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10327 { } /* end */
10328};
10329
10330/* capture mixer elements */
10331static struct snd_kcontrol_new alc269_capture_mixer[] = {
10332 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10333 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10334 {
10335 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10336 /* The multiple "Capture Source" controls confuse alsamixer
10337 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010338 */
10339 /* .name = "Capture Source", */
10340 .name = "Input Source",
10341 .count = 1,
10342 .info = alc_mux_enum_info,
10343 .get = alc_mux_enum_get,
10344 .put = alc_mux_enum_put,
10345 },
10346 { } /* end */
10347};
10348
10349/*
10350 * generic initialization of ADC, input mixers and output mixers
10351 */
10352static struct hda_verb alc269_init_verbs[] = {
10353 /*
10354 * Unmute ADC0 and set the default input to mic-in
10355 */
10356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10357
10358 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10359 * analog-loopback mixer widget
10360 * Note: PASD motherboards uses the Line In 2 as the input for
10361 * front panel mic (mic 2)
10362 */
10363 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10369
10370 /*
10371 * Set up output mixers (0x0c - 0x0e)
10372 */
10373 /* set vol=0 to output mixers */
10374 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10375 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10376
10377 /* set up input amps for analog loopback */
10378 /* Amp Indices: DAC = 0, mixer = 1 */
10379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10381 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10382 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10385
10386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10388 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10389 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10392 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10393
10394 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10400 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10401
10402 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10403 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10404
10405 /* FIXME: use matrix-type input source selection */
10406 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10407 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10412
10413 /* set EAPD */
10414 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10415 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10416 { }
10417};
10418
10419/* add playback controls from the parsed DAC table */
10420static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10421 const struct auto_pin_cfg *cfg)
10422{
10423 hda_nid_t nid;
10424 int err;
10425
10426 spec->multiout.num_dacs = 1; /* only use one dac */
10427 spec->multiout.dac_nids = spec->private_dac_nids;
10428 spec->multiout.dac_nids[0] = 2;
10429
10430 nid = cfg->line_out_pins[0];
10431 if (nid) {
10432 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10433 "Front Playback Volume",
10434 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10435 if (err < 0)
10436 return err;
10437 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10438 "Front Playback Switch",
10439 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10440 if (err < 0)
10441 return err;
10442 }
10443
10444 nid = cfg->speaker_pins[0];
10445 if (nid) {
10446 if (!cfg->line_out_pins[0]) {
10447 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10448 "Speaker Playback Volume",
10449 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10450 HDA_OUTPUT));
10451 if (err < 0)
10452 return err;
10453 }
10454 if (nid == 0x16) {
10455 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10456 "Speaker Playback Switch",
10457 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10458 HDA_OUTPUT));
10459 if (err < 0)
10460 return err;
10461 } else {
10462 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10463 "Speaker Playback Switch",
10464 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10465 HDA_OUTPUT));
10466 if (err < 0)
10467 return err;
10468 }
10469 }
10470 nid = cfg->hp_pins[0];
10471 if (nid) {
10472 /* spec->multiout.hp_nid = 2; */
10473 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10474 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10475 "Headphone Playback Volume",
10476 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10477 HDA_OUTPUT));
10478 if (err < 0)
10479 return err;
10480 }
10481 if (nid == 0x16) {
10482 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10483 "Headphone Playback Switch",
10484 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10485 HDA_OUTPUT));
10486 if (err < 0)
10487 return err;
10488 } else {
10489 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10490 "Headphone Playback Switch",
10491 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10492 HDA_OUTPUT));
10493 if (err < 0)
10494 return err;
10495 }
10496 }
10497 return 0;
10498}
10499
10500#define alc269_auto_create_analog_input_ctls \
10501 alc880_auto_create_analog_input_ctls
10502
10503#ifdef CONFIG_SND_HDA_POWER_SAVE
10504#define alc269_loopbacks alc880_loopbacks
10505#endif
10506
10507/* pcm configuration: identiacal with ALC880 */
10508#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10509#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10510#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10511#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10512
10513/*
10514 * BIOS auto configuration
10515 */
10516static int alc269_parse_auto_config(struct hda_codec *codec)
10517{
10518 struct alc_spec *spec = codec->spec;
10519 int err;
10520 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10521
10522 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10523 alc269_ignore);
10524 if (err < 0)
10525 return err;
10526
10527 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10528 if (err < 0)
10529 return err;
10530 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10531 if (err < 0)
10532 return err;
10533
10534 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10535
10536 if (spec->autocfg.dig_out_pin)
10537 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10538
10539 if (spec->kctl_alloc)
10540 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10541
10542 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10543 spec->num_mux_defs = 1;
10544 spec->input_mux = &spec->private_imux;
10545
10546 err = alc_auto_add_mic_boost(codec);
10547 if (err < 0)
10548 return err;
10549
10550 return 1;
10551}
10552
10553#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10554#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10555#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10556
10557
10558/* init callback for auto-configuration model -- overriding the default init */
10559static void alc269_auto_init(struct hda_codec *codec)
10560{
10561 alc269_auto_init_multi_out(codec);
10562 alc269_auto_init_hp_out(codec);
10563 alc269_auto_init_analog_input(codec);
10564}
10565
10566/*
10567 * configuration and preset
10568 */
10569static const char *alc269_models[ALC269_MODEL_LAST] = {
10570 [ALC269_BASIC] = "basic",
10571};
10572
10573static struct snd_pci_quirk alc269_cfg_tbl[] = {
10574 {}
10575};
10576
10577static struct alc_config_preset alc269_presets[] = {
10578 [ALC269_BASIC] = {
10579 .mixers = { alc269_base_mixer },
10580 .init_verbs = { alc269_init_verbs },
10581 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10582 .dac_nids = alc269_dac_nids,
10583 .hp_nid = 0x03,
10584 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10585 .channel_mode = alc269_modes,
10586 .input_mux = &alc269_capture_source,
10587 },
10588};
10589
10590static int patch_alc269(struct hda_codec *codec)
10591{
10592 struct alc_spec *spec;
10593 int board_config;
10594 int err;
10595
10596 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10597 if (spec == NULL)
10598 return -ENOMEM;
10599
10600 codec->spec = spec;
10601
10602 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10603 alc269_models,
10604 alc269_cfg_tbl);
10605
10606 if (board_config < 0) {
10607 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10608 "trying auto-probe from BIOS...\n");
10609 board_config = ALC269_AUTO;
10610 }
10611
10612 if (board_config == ALC269_AUTO) {
10613 /* automatic parse from the BIOS config */
10614 err = alc269_parse_auto_config(codec);
10615 if (err < 0) {
10616 alc_free(codec);
10617 return err;
10618 } else if (!err) {
10619 printk(KERN_INFO
10620 "hda_codec: Cannot set up configuration "
10621 "from BIOS. Using base mode...\n");
10622 board_config = ALC269_BASIC;
10623 }
10624 }
10625
10626 if (board_config != ALC269_AUTO)
10627 setup_preset(spec, &alc269_presets[board_config]);
10628
10629 spec->stream_name_analog = "ALC269 Analog";
10630 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10631 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10632
10633 spec->stream_name_digital = "ALC269 Digital";
10634 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10635 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10636
10637 spec->adc_nids = alc269_adc_nids;
10638 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10639 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10640 spec->num_mixers++;
10641
10642 codec->patch_ops = alc_patch_ops;
10643 if (board_config == ALC269_AUTO)
10644 spec->init_hook = alc269_auto_init;
10645#ifdef CONFIG_SND_HDA_POWER_SAVE
10646 if (!spec->loopback.amplist)
10647 spec->loopback.amplist = alc269_loopbacks;
10648#endif
10649
10650 return 0;
10651}
10652
10653/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010654 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10655 */
10656
10657/*
10658 * set the path ways for 2 channel output
10659 * need to set the codec line out and mic 1 pin widgets to inputs
10660 */
10661static struct hda_verb alc861_threestack_ch2_init[] = {
10662 /* set pin widget 1Ah (line in) for input */
10663 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010664 /* set pin widget 18h (mic1/2) for input, for mic also enable
10665 * the vref
10666 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010667 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10668
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10670#if 0
10671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10673#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 { } /* end */
10675};
10676/*
10677 * 6ch mode
10678 * need to set the codec line out and mic 1 pin widgets to outputs
10679 */
10680static struct hda_verb alc861_threestack_ch6_init[] = {
10681 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10682 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10683 /* set pin widget 18h (mic1) for output (CLFE)*/
10684 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10685
10686 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010687 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010688
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010689 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10690#if 0
10691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10692 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10693#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010694 { } /* end */
10695};
10696
10697static struct hda_channel_mode alc861_threestack_modes[2] = {
10698 { 2, alc861_threestack_ch2_init },
10699 { 6, alc861_threestack_ch6_init },
10700};
Takashi Iwai22309c32006-08-09 16:57:28 +020010701/* Set mic1 as input and unmute the mixer */
10702static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10703 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10704 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10705 { } /* end */
10706};
10707/* Set mic1 as output and mute mixer */
10708static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10709 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10710 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10711 { } /* end */
10712};
10713
10714static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10715 { 2, alc861_uniwill_m31_ch2_init },
10716 { 4, alc861_uniwill_m31_ch4_init },
10717};
Kailang Yangdf694da2005-12-05 19:42:22 +010010718
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010719/* Set mic1 and line-in as input and unmute the mixer */
10720static struct hda_verb alc861_asus_ch2_init[] = {
10721 /* set pin widget 1Ah (line in) for input */
10722 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010723 /* set pin widget 18h (mic1/2) for input, for mic also enable
10724 * the vref
10725 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010726 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10727
10728 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10729#if 0
10730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10731 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10732#endif
10733 { } /* end */
10734};
10735/* Set mic1 nad line-in as output and mute mixer */
10736static struct hda_verb alc861_asus_ch6_init[] = {
10737 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10738 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10739 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10740 /* set pin widget 18h (mic1) for output (CLFE)*/
10741 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10742 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10743 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10744 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10745
10746 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10747#if 0
10748 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10749 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10750#endif
10751 { } /* end */
10752};
10753
10754static struct hda_channel_mode alc861_asus_modes[2] = {
10755 { 2, alc861_asus_ch2_init },
10756 { 6, alc861_asus_ch6_init },
10757};
10758
Kailang Yangdf694da2005-12-05 19:42:22 +010010759/* patch-ALC861 */
10760
10761static struct snd_kcontrol_new alc861_base_mixer[] = {
10762 /* output mixer control */
10763 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10764 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10765 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10766 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10767 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10768
10769 /*Input mixer control */
10770 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10771 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10772 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10773 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10774 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10775 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10777 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010780
Kailang Yangdf694da2005-12-05 19:42:22 +010010781 /* Capture mixer control */
10782 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10783 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10784 {
10785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10786 .name = "Capture Source",
10787 .count = 1,
10788 .info = alc_mux_enum_info,
10789 .get = alc_mux_enum_get,
10790 .put = alc_mux_enum_put,
10791 },
10792 { } /* end */
10793};
10794
10795static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10796 /* output mixer control */
10797 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10798 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10799 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10800 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10801 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10802
10803 /* Input mixer control */
10804 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10805 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10806 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10807 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10808 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10809 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10811 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010814
Kailang Yangdf694da2005-12-05 19:42:22 +010010815 /* Capture mixer control */
10816 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10817 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10818 {
10819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10820 .name = "Capture Source",
10821 .count = 1,
10822 .info = alc_mux_enum_info,
10823 .get = alc_mux_enum_get,
10824 .put = alc_mux_enum_put,
10825 },
10826 {
10827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10828 .name = "Channel Mode",
10829 .info = alc_ch_mode_info,
10830 .get = alc_ch_mode_get,
10831 .put = alc_ch_mode_put,
10832 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10833 },
10834 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010835};
10836
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010837static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010838 /* output mixer control */
10839 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10841 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10842
10843 /*Capture mixer control */
10844 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10845 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10846 {
10847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10848 .name = "Capture Source",
10849 .count = 1,
10850 .info = alc_mux_enum_info,
10851 .get = alc_mux_enum_get,
10852 .put = alc_mux_enum_put,
10853 },
10854
10855 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010856};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010857
Takashi Iwai22309c32006-08-09 16:57:28 +020010858static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10859 /* output mixer control */
10860 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10861 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10862 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10863 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10864 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10865
10866 /* Input mixer control */
10867 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10868 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10869 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10870 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10871 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10872 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10874 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10875 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010877
Takashi Iwai22309c32006-08-09 16:57:28 +020010878 /* Capture mixer control */
10879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10881 {
10882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10883 .name = "Capture Source",
10884 .count = 1,
10885 .info = alc_mux_enum_info,
10886 .get = alc_mux_enum_get,
10887 .put = alc_mux_enum_put,
10888 },
10889 {
10890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10891 .name = "Channel Mode",
10892 .info = alc_ch_mode_info,
10893 .get = alc_ch_mode_get,
10894 .put = alc_ch_mode_put,
10895 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10896 },
10897 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010898};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010899
10900static struct snd_kcontrol_new alc861_asus_mixer[] = {
10901 /* output mixer control */
10902 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10903 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10904 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10905 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10906 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10907
10908 /* Input mixer control */
10909 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10910 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10912 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10913 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10914 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10916 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10919
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010920 /* Capture mixer control */
10921 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10922 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10923 {
10924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10925 .name = "Capture Source",
10926 .count = 1,
10927 .info = alc_mux_enum_info,
10928 .get = alc_mux_enum_get,
10929 .put = alc_mux_enum_put,
10930 },
10931 {
10932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10933 .name = "Channel Mode",
10934 .info = alc_ch_mode_info,
10935 .get = alc_ch_mode_get,
10936 .put = alc_ch_mode_put,
10937 .private_value = ARRAY_SIZE(alc861_asus_modes),
10938 },
10939 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010940};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010941
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010942/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010943static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010944 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10945 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10946 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10947 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10948 { }
10949};
10950
Kailang Yangdf694da2005-12-05 19:42:22 +010010951/*
10952 * generic initialization of ADC, input mixers and output mixers
10953 */
10954static struct hda_verb alc861_base_init_verbs[] = {
10955 /*
10956 * Unmute ADC0 and set the default input to mic-in
10957 */
10958 /* port-A for surround (rear panel) */
10959 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10960 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10961 /* port-B for mic-in (rear panel) with vref */
10962 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10963 /* port-C for line-in (rear panel) */
10964 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10965 /* port-D for Front */
10966 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10967 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10968 /* port-E for HP out (front panel) */
10969 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10970 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010971 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010972 /* port-F for mic-in (front panel) with vref */
10973 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10974 /* port-G for CLFE (rear panel) */
10975 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10976 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10977 /* port-H for side (rear panel) */
10978 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10979 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10980 /* CD-in */
10981 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10982 /* route front mic to ADC1*/
10983 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10985
10986 /* Unmute DAC0~3 & spdif out*/
10987 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10988 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10989 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10990 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10992
10993 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10994 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10995 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10996 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10997 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10998
10999 /* Unmute Stereo Mixer 15 */
11000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011004
11005 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11006 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11009 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011013 /* hp used DAC 3 (Front) */
11014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11016
11017 { }
11018};
11019
11020static struct hda_verb alc861_threestack_init_verbs[] = {
11021 /*
11022 * Unmute ADC0 and set the default input to mic-in
11023 */
11024 /* port-A for surround (rear panel) */
11025 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11026 /* port-B for mic-in (rear panel) with vref */
11027 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11028 /* port-C for line-in (rear panel) */
11029 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11030 /* port-D for Front */
11031 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11032 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11033 /* port-E for HP out (front panel) */
11034 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11035 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011036 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011037 /* port-F for mic-in (front panel) with vref */
11038 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11039 /* port-G for CLFE (rear panel) */
11040 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11041 /* port-H for side (rear panel) */
11042 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11043 /* CD-in */
11044 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11045 /* route front mic to ADC1*/
11046 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11048 /* Unmute DAC0~3 & spdif out*/
11049 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11050 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11051 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11052 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054
11055 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11056 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11058 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11059 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11060
11061 /* Unmute Stereo Mixer 15 */
11062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011066
11067 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11069 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11071 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11072 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011075 /* hp used DAC 3 (Front) */
11076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11078 { }
11079};
Takashi Iwai22309c32006-08-09 16:57:28 +020011080
11081static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11082 /*
11083 * Unmute ADC0 and set the default input to mic-in
11084 */
11085 /* port-A for surround (rear panel) */
11086 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11087 /* port-B for mic-in (rear panel) with vref */
11088 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11089 /* port-C for line-in (rear panel) */
11090 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11091 /* port-D for Front */
11092 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11093 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11094 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011095 /* this has to be set to VREF80 */
11096 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011097 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011098 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011099 /* port-F for mic-in (front panel) with vref */
11100 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11101 /* port-G for CLFE (rear panel) */
11102 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11103 /* port-H for side (rear panel) */
11104 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11105 /* CD-in */
11106 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11107 /* route front mic to ADC1*/
11108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11110 /* Unmute DAC0~3 & spdif out*/
11111 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11112 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11114 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11116
11117 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11118 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11119 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11120 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11121 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11122
11123 /* Unmute Stereo Mixer 15 */
11124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011128
11129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011137 /* hp used DAC 3 (Front) */
11138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11140 { }
11141};
11142
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011143static struct hda_verb alc861_asus_init_verbs[] = {
11144 /*
11145 * Unmute ADC0 and set the default input to mic-in
11146 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011147 /* port-A for surround (rear panel)
11148 * according to codec#0 this is the HP jack
11149 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011150 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11151 /* route front PCM to HP */
11152 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11153 /* port-B for mic-in (rear panel) with vref */
11154 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11155 /* port-C for line-in (rear panel) */
11156 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11157 /* port-D for Front */
11158 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11159 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11160 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011161 /* this has to be set to VREF80 */
11162 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011163 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011164 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011165 /* port-F for mic-in (front panel) with vref */
11166 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11167 /* port-G for CLFE (rear panel) */
11168 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11169 /* port-H for side (rear panel) */
11170 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11171 /* CD-in */
11172 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11173 /* route front mic to ADC1*/
11174 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11176 /* Unmute DAC0~3 & spdif out*/
11177 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11178 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11179 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11180 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11181 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11182 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11183 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11184 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11185 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11186 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11187
11188 /* Unmute Stereo Mixer 15 */
11189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011193
11194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11195 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11196 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11197 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011202 /* hp used DAC 3 (Front) */
11203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11205 { }
11206};
11207
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011208/* additional init verbs for ASUS laptops */
11209static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11210 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11211 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11212 { }
11213};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011214
Kailang Yangdf694da2005-12-05 19:42:22 +010011215/*
11216 * generic initialization of ADC, input mixers and output mixers
11217 */
11218static struct hda_verb alc861_auto_init_verbs[] = {
11219 /*
11220 * Unmute ADC0 and set the default input to mic-in
11221 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011222 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224
11225 /* Unmute DAC0~3 & spdif out*/
11226 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11227 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11228 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11229 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11231
11232 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11233 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11234 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11235 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11236 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11237
11238 /* Unmute Stereo Mixer 15 */
11239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11243
11244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11246 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11252
11253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011263
11264 { }
11265};
11266
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011267static struct hda_verb alc861_toshiba_init_verbs[] = {
11268 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011269
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011270 { }
11271};
11272
11273/* toggle speaker-output according to the hp-jack state */
11274static void alc861_toshiba_automute(struct hda_codec *codec)
11275{
11276 unsigned int present;
11277
11278 present = snd_hda_codec_read(codec, 0x0f, 0,
11279 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011280 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11281 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11282 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11283 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011284}
11285
11286static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11287 unsigned int res)
11288{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011289 if ((res >> 26) == ALC880_HP_EVENT)
11290 alc861_toshiba_automute(codec);
11291}
11292
Kailang Yangdf694da2005-12-05 19:42:22 +010011293/* pcm configuration: identiacal with ALC880 */
11294#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11295#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11296#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11297#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11298
11299
11300#define ALC861_DIGOUT_NID 0x07
11301
11302static struct hda_channel_mode alc861_8ch_modes[1] = {
11303 { 8, NULL }
11304};
11305
11306static hda_nid_t alc861_dac_nids[4] = {
11307 /* front, surround, clfe, side */
11308 0x03, 0x06, 0x05, 0x04
11309};
11310
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011311static hda_nid_t alc660_dac_nids[3] = {
11312 /* front, clfe, surround */
11313 0x03, 0x05, 0x06
11314};
11315
Kailang Yangdf694da2005-12-05 19:42:22 +010011316static hda_nid_t alc861_adc_nids[1] = {
11317 /* ADC0-2 */
11318 0x08,
11319};
11320
11321static struct hda_input_mux alc861_capture_source = {
11322 .num_items = 5,
11323 .items = {
11324 { "Mic", 0x0 },
11325 { "Front Mic", 0x3 },
11326 { "Line", 0x1 },
11327 { "CD", 0x4 },
11328 { "Mixer", 0x5 },
11329 },
11330};
11331
11332/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011333static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11334 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011335{
11336 int i;
11337 hda_nid_t nid;
11338
11339 spec->multiout.dac_nids = spec->private_dac_nids;
11340 for (i = 0; i < cfg->line_outs; i++) {
11341 nid = cfg->line_out_pins[i];
11342 if (nid) {
11343 if (i >= ARRAY_SIZE(alc861_dac_nids))
11344 continue;
11345 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11346 }
11347 }
11348 spec->multiout.num_dacs = cfg->line_outs;
11349 return 0;
11350}
11351
11352/* add playback controls from the parsed DAC table */
11353static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11354 const struct auto_pin_cfg *cfg)
11355{
11356 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 static const char *chname[4] = {
11358 "Front", "Surround", NULL /*CLFE*/, "Side"
11359 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011360 hda_nid_t nid;
11361 int i, idx, err;
11362
11363 for (i = 0; i < cfg->line_outs; i++) {
11364 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011365 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011366 continue;
11367 if (nid == 0x05) {
11368 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011369 err = add_control(spec, ALC_CTL_BIND_MUTE,
11370 "Center Playback Switch",
11371 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11372 HDA_OUTPUT));
11373 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011374 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011375 err = add_control(spec, ALC_CTL_BIND_MUTE,
11376 "LFE Playback Switch",
11377 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11378 HDA_OUTPUT));
11379 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011380 return err;
11381 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011382 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11383 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 if (nid == alc861_dac_nids[idx])
11385 break;
11386 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11388 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11389 HDA_OUTPUT));
11390 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011391 return err;
11392 }
11393 }
11394 return 0;
11395}
11396
11397static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11398{
11399 int err;
11400 hda_nid_t nid;
11401
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011402 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011403 return 0;
11404
11405 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11406 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011407 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11408 "Headphone Playback Switch",
11409 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11410 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011411 return err;
11412 spec->multiout.hp_nid = nid;
11413 }
11414 return 0;
11415}
11416
11417/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011418static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11419 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011420{
Kailang Yangdf694da2005-12-05 19:42:22 +010011421 struct hda_input_mux *imux = &spec->private_imux;
11422 int i, err, idx, idx1;
11423
11424 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011425 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011426 case 0x0c:
11427 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011428 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011429 break;
11430 case 0x0f:
11431 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011432 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011433 break;
11434 case 0x0d:
11435 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011436 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011437 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011438 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011439 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011440 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011441 break;
11442 case 0x11:
11443 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011444 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011445 break;
11446 default:
11447 continue;
11448 }
11449
Takashi Iwai4a471b72005-12-07 13:56:29 +010011450 err = new_analog_input(spec, cfg->input_pins[i],
11451 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011452 if (err < 0)
11453 return err;
11454
Takashi Iwai4a471b72005-12-07 13:56:29 +010011455 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011456 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011457 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011458 }
11459 return 0;
11460}
11461
11462static struct snd_kcontrol_new alc861_capture_mixer[] = {
11463 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11464 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11465
11466 {
11467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11468 /* The multiple "Capture Source" controls confuse alsamixer
11469 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011470 */
11471 /* .name = "Capture Source", */
11472 .name = "Input Source",
11473 .count = 1,
11474 .info = alc_mux_enum_info,
11475 .get = alc_mux_enum_get,
11476 .put = alc_mux_enum_put,
11477 },
11478 { } /* end */
11479};
11480
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011481static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11482 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011483 int pin_type, int dac_idx)
11484{
11485 /* set as output */
11486
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011487 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11488 pin_type);
11489 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11490 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011491
11492}
11493
11494static void alc861_auto_init_multi_out(struct hda_codec *codec)
11495{
11496 struct alc_spec *spec = codec->spec;
11497 int i;
11498
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011499 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011500 for (i = 0; i < spec->autocfg.line_outs; i++) {
11501 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011502 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011503 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011504 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011505 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011506 }
11507}
11508
11509static void alc861_auto_init_hp_out(struct hda_codec *codec)
11510{
11511 struct alc_spec *spec = codec->spec;
11512 hda_nid_t pin;
11513
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011514 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011515 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11517 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011518}
11519
11520static void alc861_auto_init_analog_input(struct hda_codec *codec)
11521{
11522 struct alc_spec *spec = codec->spec;
11523 int i;
11524
11525 for (i = 0; i < AUTO_PIN_LAST; i++) {
11526 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011527 if (nid >= 0x0c && nid <= 0x11) {
11528 snd_hda_codec_write(codec, nid, 0,
11529 AC_VERB_SET_PIN_WIDGET_CONTROL,
11530 i <= AUTO_PIN_FRONT_MIC ?
11531 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011532 }
11533 }
11534}
11535
11536/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011537/* return 1 if successful, 0 if the proper config is not found,
11538 * or a negative error code
11539 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011540static int alc861_parse_auto_config(struct hda_codec *codec)
11541{
11542 struct alc_spec *spec = codec->spec;
11543 int err;
11544 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11545
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011546 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11547 alc861_ignore);
11548 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011549 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011550 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011551 return 0; /* can't find valid BIOS pin config */
11552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011553 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11554 if (err < 0)
11555 return err;
11556 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11557 if (err < 0)
11558 return err;
11559 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11560 if (err < 0)
11561 return err;
11562 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11563 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011564 return err;
11565
11566 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11567
11568 if (spec->autocfg.dig_out_pin)
11569 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11570
11571 if (spec->kctl_alloc)
11572 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11573
11574 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11575
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011576 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011577 spec->input_mux = &spec->private_imux;
11578
11579 spec->adc_nids = alc861_adc_nids;
11580 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11581 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11582 spec->num_mixers++;
11583
11584 return 1;
11585}
11586
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011587/* additional initialization for auto-configuration model */
11588static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011589{
Kailang Yangdf694da2005-12-05 19:42:22 +010011590 alc861_auto_init_multi_out(codec);
11591 alc861_auto_init_hp_out(codec);
11592 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011593}
11594
Takashi Iwaicb53c622007-08-10 17:21:45 +020011595#ifdef CONFIG_SND_HDA_POWER_SAVE
11596static struct hda_amp_list alc861_loopbacks[] = {
11597 { 0x15, HDA_INPUT, 0 },
11598 { 0x15, HDA_INPUT, 1 },
11599 { 0x15, HDA_INPUT, 2 },
11600 { 0x15, HDA_INPUT, 3 },
11601 { } /* end */
11602};
11603#endif
11604
Kailang Yangdf694da2005-12-05 19:42:22 +010011605
11606/*
11607 * configuration and preset
11608 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011609static const char *alc861_models[ALC861_MODEL_LAST] = {
11610 [ALC861_3ST] = "3stack",
11611 [ALC660_3ST] = "3stack-660",
11612 [ALC861_3ST_DIG] = "3stack-dig",
11613 [ALC861_6ST_DIG] = "6stack-dig",
11614 [ALC861_UNIWILL_M31] = "uniwill-m31",
11615 [ALC861_TOSHIBA] = "toshiba",
11616 [ALC861_ASUS] = "asus",
11617 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11618 [ALC861_AUTO] = "auto",
11619};
11620
11621static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011622 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011623 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11624 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11625 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011626 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011627 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011628 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011629 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11630 * Any other models that need this preset?
11631 */
11632 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011633 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11634 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011635 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11636 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11637 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11638 /* FIXME: the below seems conflict */
11639 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11640 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11641 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011642 {}
11643};
11644
11645static struct alc_config_preset alc861_presets[] = {
11646 [ALC861_3ST] = {
11647 .mixers = { alc861_3ST_mixer },
11648 .init_verbs = { alc861_threestack_init_verbs },
11649 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11650 .dac_nids = alc861_dac_nids,
11651 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11652 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011653 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011654 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11655 .adc_nids = alc861_adc_nids,
11656 .input_mux = &alc861_capture_source,
11657 },
11658 [ALC861_3ST_DIG] = {
11659 .mixers = { alc861_base_mixer },
11660 .init_verbs = { alc861_threestack_init_verbs },
11661 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11662 .dac_nids = alc861_dac_nids,
11663 .dig_out_nid = ALC861_DIGOUT_NID,
11664 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11665 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011666 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011667 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11668 .adc_nids = alc861_adc_nids,
11669 .input_mux = &alc861_capture_source,
11670 },
11671 [ALC861_6ST_DIG] = {
11672 .mixers = { alc861_base_mixer },
11673 .init_verbs = { alc861_base_init_verbs },
11674 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11675 .dac_nids = alc861_dac_nids,
11676 .dig_out_nid = ALC861_DIGOUT_NID,
11677 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11678 .channel_mode = alc861_8ch_modes,
11679 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11680 .adc_nids = alc861_adc_nids,
11681 .input_mux = &alc861_capture_source,
11682 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011683 [ALC660_3ST] = {
11684 .mixers = { alc861_3ST_mixer },
11685 .init_verbs = { alc861_threestack_init_verbs },
11686 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11687 .dac_nids = alc660_dac_nids,
11688 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11689 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011690 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011691 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11692 .adc_nids = alc861_adc_nids,
11693 .input_mux = &alc861_capture_source,
11694 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011695 [ALC861_UNIWILL_M31] = {
11696 .mixers = { alc861_uniwill_m31_mixer },
11697 .init_verbs = { alc861_uniwill_m31_init_verbs },
11698 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11699 .dac_nids = alc861_dac_nids,
11700 .dig_out_nid = ALC861_DIGOUT_NID,
11701 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11702 .channel_mode = alc861_uniwill_m31_modes,
11703 .need_dac_fix = 1,
11704 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11705 .adc_nids = alc861_adc_nids,
11706 .input_mux = &alc861_capture_source,
11707 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011708 [ALC861_TOSHIBA] = {
11709 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011710 .init_verbs = { alc861_base_init_verbs,
11711 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011712 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11713 .dac_nids = alc861_dac_nids,
11714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11715 .channel_mode = alc883_3ST_2ch_modes,
11716 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11717 .adc_nids = alc861_adc_nids,
11718 .input_mux = &alc861_capture_source,
11719 .unsol_event = alc861_toshiba_unsol_event,
11720 .init_hook = alc861_toshiba_automute,
11721 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011722 [ALC861_ASUS] = {
11723 .mixers = { alc861_asus_mixer },
11724 .init_verbs = { alc861_asus_init_verbs },
11725 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11726 .dac_nids = alc861_dac_nids,
11727 .dig_out_nid = ALC861_DIGOUT_NID,
11728 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11729 .channel_mode = alc861_asus_modes,
11730 .need_dac_fix = 1,
11731 .hp_nid = 0x06,
11732 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11733 .adc_nids = alc861_adc_nids,
11734 .input_mux = &alc861_capture_source,
11735 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011736 [ALC861_ASUS_LAPTOP] = {
11737 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11738 .init_verbs = { alc861_asus_init_verbs,
11739 alc861_asus_laptop_init_verbs },
11740 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11741 .dac_nids = alc861_dac_nids,
11742 .dig_out_nid = ALC861_DIGOUT_NID,
11743 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11744 .channel_mode = alc883_3ST_2ch_modes,
11745 .need_dac_fix = 1,
11746 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11747 .adc_nids = alc861_adc_nids,
11748 .input_mux = &alc861_capture_source,
11749 },
11750};
Kailang Yangdf694da2005-12-05 19:42:22 +010011751
11752
11753static int patch_alc861(struct hda_codec *codec)
11754{
11755 struct alc_spec *spec;
11756 int board_config;
11757 int err;
11758
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011759 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011760 if (spec == NULL)
11761 return -ENOMEM;
11762
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011763 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011764
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011765 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11766 alc861_models,
11767 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011768
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011769 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011770 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11771 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011772 board_config = ALC861_AUTO;
11773 }
11774
11775 if (board_config == ALC861_AUTO) {
11776 /* automatic parse from the BIOS config */
11777 err = alc861_parse_auto_config(codec);
11778 if (err < 0) {
11779 alc_free(codec);
11780 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011781 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011782 printk(KERN_INFO
11783 "hda_codec: Cannot set up configuration "
11784 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011785 board_config = ALC861_3ST_DIG;
11786 }
11787 }
11788
11789 if (board_config != ALC861_AUTO)
11790 setup_preset(spec, &alc861_presets[board_config]);
11791
11792 spec->stream_name_analog = "ALC861 Analog";
11793 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11794 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11795
11796 spec->stream_name_digital = "ALC861 Digital";
11797 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11798 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11799
Takashi Iwai2134ea42008-01-10 16:53:55 +010011800 spec->vmaster_nid = 0x03;
11801
Kailang Yangdf694da2005-12-05 19:42:22 +010011802 codec->patch_ops = alc_patch_ops;
11803 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011804 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011805#ifdef CONFIG_SND_HDA_POWER_SAVE
11806 if (!spec->loopback.amplist)
11807 spec->loopback.amplist = alc861_loopbacks;
11808#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011809
11810 return 0;
11811}
11812
11813/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011814 * ALC861-VD support
11815 *
11816 * Based on ALC882
11817 *
11818 * In addition, an independent DAC
11819 */
11820#define ALC861VD_DIGOUT_NID 0x06
11821
11822static hda_nid_t alc861vd_dac_nids[4] = {
11823 /* front, surr, clfe, side surr */
11824 0x02, 0x03, 0x04, 0x05
11825};
11826
11827/* dac_nids for ALC660vd are in a different order - according to
11828 * Realtek's driver.
11829 * This should probably tesult in a different mixer for 6stack models
11830 * of ALC660vd codecs, but for now there is only 3stack mixer
11831 * - and it is the same as in 861vd.
11832 * adc_nids in ALC660vd are (is) the same as in 861vd
11833 */
11834static hda_nid_t alc660vd_dac_nids[3] = {
11835 /* front, rear, clfe, rear_surr */
11836 0x02, 0x04, 0x03
11837};
11838
11839static hda_nid_t alc861vd_adc_nids[1] = {
11840 /* ADC0 */
11841 0x09,
11842};
11843
11844/* input MUX */
11845/* FIXME: should be a matrix-type input source selection */
11846static struct hda_input_mux alc861vd_capture_source = {
11847 .num_items = 4,
11848 .items = {
11849 { "Mic", 0x0 },
11850 { "Front Mic", 0x1 },
11851 { "Line", 0x2 },
11852 { "CD", 0x4 },
11853 },
11854};
11855
Kailang Yang272a5272007-05-14 11:00:38 +020011856static struct hda_input_mux alc861vd_dallas_capture_source = {
11857 .num_items = 3,
11858 .items = {
11859 { "Front Mic", 0x0 },
11860 { "ATAPI Mic", 0x1 },
11861 { "Line In", 0x5 },
11862 },
11863};
11864
Kailang Yangd1a991a2007-08-15 16:21:59 +020011865static struct hda_input_mux alc861vd_hp_capture_source = {
11866 .num_items = 2,
11867 .items = {
11868 { "Front Mic", 0x0 },
11869 { "ATAPI Mic", 0x1 },
11870 },
11871};
11872
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011873#define alc861vd_mux_enum_info alc_mux_enum_info
11874#define alc861vd_mux_enum_get alc_mux_enum_get
11875
11876static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11877 struct snd_ctl_elem_value *ucontrol)
11878{
11879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11880 struct alc_spec *spec = codec->spec;
11881 const struct hda_input_mux *imux = spec->input_mux;
11882 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11883 static hda_nid_t capture_mixers[1] = { 0x22 };
11884 hda_nid_t nid = capture_mixers[adc_idx];
11885 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11886 unsigned int i, idx;
11887
11888 idx = ucontrol->value.enumerated.item[0];
11889 if (idx >= imux->num_items)
11890 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011891 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011892 return 0;
11893 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011894 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11895 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11896 imux->items[i].index,
11897 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011898 }
11899 *cur_val = idx;
11900 return 1;
11901}
11902
11903/*
11904 * 2ch mode
11905 */
11906static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11907 { 2, NULL }
11908};
11909
11910/*
11911 * 6ch mode
11912 */
11913static struct hda_verb alc861vd_6stack_ch6_init[] = {
11914 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11915 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11916 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11917 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11918 { } /* end */
11919};
11920
11921/*
11922 * 8ch mode
11923 */
11924static struct hda_verb alc861vd_6stack_ch8_init[] = {
11925 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11926 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11927 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11928 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11929 { } /* end */
11930};
11931
11932static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11933 { 6, alc861vd_6stack_ch6_init },
11934 { 8, alc861vd_6stack_ch8_init },
11935};
11936
11937static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11938 {
11939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11940 .name = "Channel Mode",
11941 .info = alc_ch_mode_info,
11942 .get = alc_ch_mode_get,
11943 .put = alc_ch_mode_put,
11944 },
11945 { } /* end */
11946};
11947
11948static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11949 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11950 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11951
11952 {
11953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11954 /* The multiple "Capture Source" controls confuse alsamixer
11955 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011956 */
11957 /* .name = "Capture Source", */
11958 .name = "Input Source",
11959 .count = 1,
11960 .info = alc861vd_mux_enum_info,
11961 .get = alc861vd_mux_enum_get,
11962 .put = alc861vd_mux_enum_put,
11963 },
11964 { } /* end */
11965};
11966
11967/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11968 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11969 */
11970static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11971 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11973
11974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11976
11977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11978 HDA_OUTPUT),
11979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11980 HDA_OUTPUT),
11981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11983
11984 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11985 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11986
11987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11988
11989 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11992
11993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11996
11997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11999
12000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12002
12003 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12004 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12005
12006 { } /* end */
12007};
12008
12009static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12010 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12011 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12012
12013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12014
12015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12017 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12018
12019 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12020 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12021 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12022
12023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12025
12026 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12027 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12028
12029 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12030 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12031
12032 { } /* end */
12033};
12034
Kailang Yangbdd148a2007-05-08 15:19:08 +020012035static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12036 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12037 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12038 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12039
12040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12041
12042 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12045
12046 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12048 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12049
12050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12052
12053 { } /* end */
12054};
12055
Kailang Yang272a5272007-05-14 11:00:38 +020012056/* Pin assignment: Front=0x14, HP = 0x15,
12057 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12058 */
12059static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12060 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12061 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12063 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12064 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12065 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12066 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12067 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012070 { } /* end */
12071};
12072
Kailang Yangd1a991a2007-08-15 16:21:59 +020012073/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12074 * Front Mic=0x18, ATAPI Mic = 0x19,
12075 */
12076static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12077 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12079 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12080 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12081 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12082 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12083 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12084 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12085
12086 { } /* end */
12087};
12088
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012089/*
12090 * generic initialization of ADC, input mixers and output mixers
12091 */
12092static struct hda_verb alc861vd_volume_init_verbs[] = {
12093 /*
12094 * Unmute ADC0 and set the default input to mic-in
12095 */
12096 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12098
12099 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12100 * the analog-loopback mixer widget
12101 */
12102 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012108
12109 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012114
12115 /*
12116 * Set up output mixers (0x02 - 0x05)
12117 */
12118 /* set vol=0 to output mixers */
12119 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12120 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12121 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12122 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12123
12124 /* set up input amps for analog loopback */
12125 /* Amp Indices: DAC = 0, mixer = 1 */
12126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12129 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12130 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12132 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12134
12135 { }
12136};
12137
12138/*
12139 * 3-stack pin configuration:
12140 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12141 */
12142static struct hda_verb alc861vd_3stack_init_verbs[] = {
12143 /*
12144 * Set pin mode and muting
12145 */
12146 /* set front pin widgets 0x14 for output */
12147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12150
12151 /* Mic (rear) pin: input vref at 80% */
12152 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12153 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12154 /* Front Mic pin: input vref at 80% */
12155 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12156 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12157 /* Line In pin: input */
12158 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12159 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12160 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12162 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12163 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12164 /* CD pin widget for input */
12165 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12166
12167 { }
12168};
12169
12170/*
12171 * 6-stack pin configuration:
12172 */
12173static struct hda_verb alc861vd_6stack_init_verbs[] = {
12174 /*
12175 * Set pin mode and muting
12176 */
12177 /* set front pin widgets 0x14 for output */
12178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12180 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12181
12182 /* Rear Pin: output 1 (0x0d) */
12183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12185 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12186 /* CLFE Pin: output 2 (0x0e) */
12187 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12189 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12190 /* Side Pin: output 3 (0x0f) */
12191 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12192 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12193 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12194
12195 /* Mic (rear) pin: input vref at 80% */
12196 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12197 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12198 /* Front Mic pin: input vref at 80% */
12199 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12201 /* Line In pin: input */
12202 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12204 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12207 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12208 /* CD pin widget for input */
12209 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12210
12211 { }
12212};
12213
Kailang Yangbdd148a2007-05-08 15:19:08 +020012214static struct hda_verb alc861vd_eapd_verbs[] = {
12215 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12216 { }
12217};
12218
12219static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12225 {}
12226};
12227
12228/* toggle speaker-output according to the hp-jack state */
12229static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12230{
12231 unsigned int present;
12232 unsigned char bits;
12233
12234 present = snd_hda_codec_read(codec, 0x1b, 0,
12235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012236 bits = present ? HDA_AMP_MUTE : 0;
12237 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12238 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012239}
12240
12241static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12242{
12243 unsigned int present;
12244 unsigned char bits;
12245
12246 present = snd_hda_codec_read(codec, 0x18, 0,
12247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012248 bits = present ? HDA_AMP_MUTE : 0;
12249 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12250 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012251}
12252
12253static void alc861vd_lenovo_automute(struct hda_codec *codec)
12254{
12255 alc861vd_lenovo_hp_automute(codec);
12256 alc861vd_lenovo_mic_automute(codec);
12257}
12258
12259static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12260 unsigned int res)
12261{
12262 switch (res >> 26) {
12263 case ALC880_HP_EVENT:
12264 alc861vd_lenovo_hp_automute(codec);
12265 break;
12266 case ALC880_MIC_EVENT:
12267 alc861vd_lenovo_mic_automute(codec);
12268 break;
12269 }
12270}
12271
Kailang Yang272a5272007-05-14 11:00:38 +020012272static struct hda_verb alc861vd_dallas_verbs[] = {
12273 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12274 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12276 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12277
12278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12286
12287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12288 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12295
12296 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12300 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12303 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12304
12305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12309
12310 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12311 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12312 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12313
12314 { } /* end */
12315};
12316
12317/* toggle speaker-output according to the hp-jack state */
12318static void alc861vd_dallas_automute(struct hda_codec *codec)
12319{
12320 unsigned int present;
12321
12322 present = snd_hda_codec_read(codec, 0x15, 0,
12323 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012324 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12325 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012326}
12327
12328static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12329{
12330 if ((res >> 26) == ALC880_HP_EVENT)
12331 alc861vd_dallas_automute(codec);
12332}
12333
Takashi Iwaicb53c622007-08-10 17:21:45 +020012334#ifdef CONFIG_SND_HDA_POWER_SAVE
12335#define alc861vd_loopbacks alc880_loopbacks
12336#endif
12337
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012338/* pcm configuration: identiacal with ALC880 */
12339#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12340#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12341#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12342#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12343
12344/*
12345 * configuration and preset
12346 */
12347static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12348 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012349 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012350 [ALC861VD_3ST] = "3stack",
12351 [ALC861VD_3ST_DIG] = "3stack-digout",
12352 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012353 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012354 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012355 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012356 [ALC861VD_AUTO] = "auto",
12357};
12358
12359static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012360 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12361 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012362 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012363 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012364 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012365 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012366 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012367 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012368 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012369 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012370 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012371 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12372 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012373 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012374 {}
12375};
12376
12377static struct alc_config_preset alc861vd_presets[] = {
12378 [ALC660VD_3ST] = {
12379 .mixers = { alc861vd_3st_mixer },
12380 .init_verbs = { alc861vd_volume_init_verbs,
12381 alc861vd_3stack_init_verbs },
12382 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12383 .dac_nids = alc660vd_dac_nids,
12384 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12385 .adc_nids = alc861vd_adc_nids,
12386 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12387 .channel_mode = alc861vd_3stack_2ch_modes,
12388 .input_mux = &alc861vd_capture_source,
12389 },
Mike Crash6963f842007-06-25 12:12:51 +020012390 [ALC660VD_3ST_DIG] = {
12391 .mixers = { alc861vd_3st_mixer },
12392 .init_verbs = { alc861vd_volume_init_verbs,
12393 alc861vd_3stack_init_verbs },
12394 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12395 .dac_nids = alc660vd_dac_nids,
12396 .dig_out_nid = ALC861VD_DIGOUT_NID,
12397 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12398 .adc_nids = alc861vd_adc_nids,
12399 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12400 .channel_mode = alc861vd_3stack_2ch_modes,
12401 .input_mux = &alc861vd_capture_source,
12402 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012403 [ALC861VD_3ST] = {
12404 .mixers = { alc861vd_3st_mixer },
12405 .init_verbs = { alc861vd_volume_init_verbs,
12406 alc861vd_3stack_init_verbs },
12407 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12408 .dac_nids = alc861vd_dac_nids,
12409 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12410 .channel_mode = alc861vd_3stack_2ch_modes,
12411 .input_mux = &alc861vd_capture_source,
12412 },
12413 [ALC861VD_3ST_DIG] = {
12414 .mixers = { alc861vd_3st_mixer },
12415 .init_verbs = { alc861vd_volume_init_verbs,
12416 alc861vd_3stack_init_verbs },
12417 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12418 .dac_nids = alc861vd_dac_nids,
12419 .dig_out_nid = ALC861VD_DIGOUT_NID,
12420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12421 .channel_mode = alc861vd_3stack_2ch_modes,
12422 .input_mux = &alc861vd_capture_source,
12423 },
12424 [ALC861VD_6ST_DIG] = {
12425 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12426 .init_verbs = { alc861vd_volume_init_verbs,
12427 alc861vd_6stack_init_verbs },
12428 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12429 .dac_nids = alc861vd_dac_nids,
12430 .dig_out_nid = ALC861VD_DIGOUT_NID,
12431 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12432 .channel_mode = alc861vd_6stack_modes,
12433 .input_mux = &alc861vd_capture_source,
12434 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012435 [ALC861VD_LENOVO] = {
12436 .mixers = { alc861vd_lenovo_mixer },
12437 .init_verbs = { alc861vd_volume_init_verbs,
12438 alc861vd_3stack_init_verbs,
12439 alc861vd_eapd_verbs,
12440 alc861vd_lenovo_unsol_verbs },
12441 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12442 .dac_nids = alc660vd_dac_nids,
12443 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12444 .adc_nids = alc861vd_adc_nids,
12445 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12446 .channel_mode = alc861vd_3stack_2ch_modes,
12447 .input_mux = &alc861vd_capture_source,
12448 .unsol_event = alc861vd_lenovo_unsol_event,
12449 .init_hook = alc861vd_lenovo_automute,
12450 },
Kailang Yang272a5272007-05-14 11:00:38 +020012451 [ALC861VD_DALLAS] = {
12452 .mixers = { alc861vd_dallas_mixer },
12453 .init_verbs = { alc861vd_dallas_verbs },
12454 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12455 .dac_nids = alc861vd_dac_nids,
12456 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12457 .adc_nids = alc861vd_adc_nids,
12458 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12459 .channel_mode = alc861vd_3stack_2ch_modes,
12460 .input_mux = &alc861vd_dallas_capture_source,
12461 .unsol_event = alc861vd_dallas_unsol_event,
12462 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012463 },
12464 [ALC861VD_HP] = {
12465 .mixers = { alc861vd_hp_mixer },
12466 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12467 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12468 .dac_nids = alc861vd_dac_nids,
12469 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12470 .dig_out_nid = ALC861VD_DIGOUT_NID,
12471 .adc_nids = alc861vd_adc_nids,
12472 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12473 .channel_mode = alc861vd_3stack_2ch_modes,
12474 .input_mux = &alc861vd_hp_capture_source,
12475 .unsol_event = alc861vd_dallas_unsol_event,
12476 .init_hook = alc861vd_dallas_automute,
12477 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012478};
12479
12480/*
12481 * BIOS auto configuration
12482 */
12483static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12484 hda_nid_t nid, int pin_type, int dac_idx)
12485{
12486 /* set as output */
12487 snd_hda_codec_write(codec, nid, 0,
12488 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12489 snd_hda_codec_write(codec, nid, 0,
12490 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12491}
12492
12493static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12494{
12495 struct alc_spec *spec = codec->spec;
12496 int i;
12497
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012498 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012499 for (i = 0; i <= HDA_SIDE; i++) {
12500 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012501 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012502 if (nid)
12503 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012504 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012505 }
12506}
12507
12508
12509static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12510{
12511 struct alc_spec *spec = codec->spec;
12512 hda_nid_t pin;
12513
12514 pin = spec->autocfg.hp_pins[0];
12515 if (pin) /* connect to front and use dac 0 */
12516 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12517}
12518
12519#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12520#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12521
12522static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12523{
12524 struct alc_spec *spec = codec->spec;
12525 int i;
12526
12527 for (i = 0; i < AUTO_PIN_LAST; i++) {
12528 hda_nid_t nid = spec->autocfg.input_pins[i];
12529 if (alc861vd_is_input_pin(nid)) {
12530 snd_hda_codec_write(codec, nid, 0,
12531 AC_VERB_SET_PIN_WIDGET_CONTROL,
12532 i <= AUTO_PIN_FRONT_MIC ?
12533 PIN_VREF80 : PIN_IN);
12534 if (nid != ALC861VD_PIN_CD_NID)
12535 snd_hda_codec_write(codec, nid, 0,
12536 AC_VERB_SET_AMP_GAIN_MUTE,
12537 AMP_OUT_MUTE);
12538 }
12539 }
12540}
12541
12542#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12543#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12544
12545/* add playback controls from the parsed DAC table */
12546/* Based on ALC880 version. But ALC861VD has separate,
12547 * different NIDs for mute/unmute switch and volume control */
12548static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12549 const struct auto_pin_cfg *cfg)
12550{
12551 char name[32];
12552 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12553 hda_nid_t nid_v, nid_s;
12554 int i, err;
12555
12556 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012557 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012558 continue;
12559 nid_v = alc861vd_idx_to_mixer_vol(
12560 alc880_dac_to_idx(
12561 spec->multiout.dac_nids[i]));
12562 nid_s = alc861vd_idx_to_mixer_switch(
12563 alc880_dac_to_idx(
12564 spec->multiout.dac_nids[i]));
12565
12566 if (i == 2) {
12567 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012568 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12569 "Center Playback Volume",
12570 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12571 HDA_OUTPUT));
12572 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012574 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12575 "LFE Playback Volume",
12576 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12577 HDA_OUTPUT));
12578 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012579 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012580 err = add_control(spec, ALC_CTL_BIND_MUTE,
12581 "Center Playback Switch",
12582 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12583 HDA_INPUT));
12584 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012585 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012586 err = add_control(spec, ALC_CTL_BIND_MUTE,
12587 "LFE Playback Switch",
12588 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12589 HDA_INPUT));
12590 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012591 return err;
12592 } else {
12593 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012594 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12595 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12596 HDA_OUTPUT));
12597 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012598 return err;
12599 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012600 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012601 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012602 HDA_INPUT));
12603 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012604 return err;
12605 }
12606 }
12607 return 0;
12608}
12609
12610/* add playback controls for speaker and HP outputs */
12611/* Based on ALC880 version. But ALC861VD has separate,
12612 * different NIDs for mute/unmute switch and volume control */
12613static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12614 hda_nid_t pin, const char *pfx)
12615{
12616 hda_nid_t nid_v, nid_s;
12617 int err;
12618 char name[32];
12619
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012620 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012621 return 0;
12622
12623 if (alc880_is_fixed_pin(pin)) {
12624 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12625 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012626 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012627 spec->multiout.hp_nid = nid_v;
12628 else
12629 spec->multiout.extra_out_nid[0] = nid_v;
12630 /* control HP volume/switch on the output mixer amp */
12631 nid_v = alc861vd_idx_to_mixer_vol(
12632 alc880_fixed_pin_idx(pin));
12633 nid_s = alc861vd_idx_to_mixer_switch(
12634 alc880_fixed_pin_idx(pin));
12635
12636 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012637 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12638 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12639 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012640 return err;
12641 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012642 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12643 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12644 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012645 return err;
12646 } else if (alc880_is_multi_pin(pin)) {
12647 /* set manual connection */
12648 /* we have only a switch on HP-out PIN */
12649 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012650 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12651 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12652 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012653 return err;
12654 }
12655 return 0;
12656}
12657
12658/* parse the BIOS configuration and set up the alc_spec
12659 * return 1 if successful, 0 if the proper config is not found,
12660 * or a negative error code
12661 * Based on ALC880 version - had to change it to override
12662 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12663static int alc861vd_parse_auto_config(struct hda_codec *codec)
12664{
12665 struct alc_spec *spec = codec->spec;
12666 int err;
12667 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12668
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012669 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12670 alc861vd_ignore);
12671 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012672 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012673 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012674 return 0; /* can't find valid BIOS pin config */
12675
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012676 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12677 if (err < 0)
12678 return err;
12679 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12680 if (err < 0)
12681 return err;
12682 err = alc861vd_auto_create_extra_out(spec,
12683 spec->autocfg.speaker_pins[0],
12684 "Speaker");
12685 if (err < 0)
12686 return err;
12687 err = alc861vd_auto_create_extra_out(spec,
12688 spec->autocfg.hp_pins[0],
12689 "Headphone");
12690 if (err < 0)
12691 return err;
12692 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12693 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012694 return err;
12695
12696 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12697
12698 if (spec->autocfg.dig_out_pin)
12699 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12700
12701 if (spec->kctl_alloc)
12702 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12703
12704 spec->init_verbs[spec->num_init_verbs++]
12705 = alc861vd_volume_init_verbs;
12706
12707 spec->num_mux_defs = 1;
12708 spec->input_mux = &spec->private_imux;
12709
Takashi Iwai776e1842007-08-29 15:07:11 +020012710 err = alc_auto_add_mic_boost(codec);
12711 if (err < 0)
12712 return err;
12713
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012714 return 1;
12715}
12716
12717/* additional initialization for auto-configuration model */
12718static void alc861vd_auto_init(struct hda_codec *codec)
12719{
12720 alc861vd_auto_init_multi_out(codec);
12721 alc861vd_auto_init_hp_out(codec);
12722 alc861vd_auto_init_analog_input(codec);
12723}
12724
12725static int patch_alc861vd(struct hda_codec *codec)
12726{
12727 struct alc_spec *spec;
12728 int err, board_config;
12729
12730 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12731 if (spec == NULL)
12732 return -ENOMEM;
12733
12734 codec->spec = spec;
12735
12736 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12737 alc861vd_models,
12738 alc861vd_cfg_tbl);
12739
12740 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12741 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12742 "ALC861VD, trying auto-probe from BIOS...\n");
12743 board_config = ALC861VD_AUTO;
12744 }
12745
12746 if (board_config == ALC861VD_AUTO) {
12747 /* automatic parse from the BIOS config */
12748 err = alc861vd_parse_auto_config(codec);
12749 if (err < 0) {
12750 alc_free(codec);
12751 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012752 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012753 printk(KERN_INFO
12754 "hda_codec: Cannot set up configuration "
12755 "from BIOS. Using base mode...\n");
12756 board_config = ALC861VD_3ST;
12757 }
12758 }
12759
12760 if (board_config != ALC861VD_AUTO)
12761 setup_preset(spec, &alc861vd_presets[board_config]);
12762
12763 spec->stream_name_analog = "ALC861VD Analog";
12764 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12765 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12766
12767 spec->stream_name_digital = "ALC861VD Digital";
12768 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12769 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12770
12771 spec->adc_nids = alc861vd_adc_nids;
12772 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12773
12774 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12775 spec->num_mixers++;
12776
Takashi Iwai2134ea42008-01-10 16:53:55 +010012777 spec->vmaster_nid = 0x02;
12778
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012779 codec->patch_ops = alc_patch_ops;
12780
12781 if (board_config == ALC861VD_AUTO)
12782 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012783#ifdef CONFIG_SND_HDA_POWER_SAVE
12784 if (!spec->loopback.amplist)
12785 spec->loopback.amplist = alc861vd_loopbacks;
12786#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012787
12788 return 0;
12789}
12790
12791/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012792 * ALC662 support
12793 *
12794 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12795 * configuration. Each pin widget can choose any input DACs and a mixer.
12796 * Each ADC is connected from a mixer of all inputs. This makes possible
12797 * 6-channel independent captures.
12798 *
12799 * In addition, an independent DAC for the multi-playback (not used in this
12800 * driver yet).
12801 */
12802#define ALC662_DIGOUT_NID 0x06
12803#define ALC662_DIGIN_NID 0x0a
12804
12805static hda_nid_t alc662_dac_nids[4] = {
12806 /* front, rear, clfe, rear_surr */
12807 0x02, 0x03, 0x04
12808};
12809
12810static hda_nid_t alc662_adc_nids[1] = {
12811 /* ADC1-2 */
12812 0x09,
12813};
12814/* input MUX */
12815/* FIXME: should be a matrix-type input source selection */
12816
12817static struct hda_input_mux alc662_capture_source = {
12818 .num_items = 4,
12819 .items = {
12820 { "Mic", 0x0 },
12821 { "Front Mic", 0x1 },
12822 { "Line", 0x2 },
12823 { "CD", 0x4 },
12824 },
12825};
12826
12827static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12828 .num_items = 2,
12829 .items = {
12830 { "Mic", 0x1 },
12831 { "Line", 0x2 },
12832 },
12833};
Kailang Yang291702f2007-10-16 14:28:03 +020012834
12835static struct hda_input_mux alc662_eeepc_capture_source = {
12836 .num_items = 2,
12837 .items = {
12838 { "i-Mic", 0x1 },
12839 { "e-Mic", 0x0 },
12840 },
12841};
12842
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012843#define alc662_mux_enum_info alc_mux_enum_info
12844#define alc662_mux_enum_get alc_mux_enum_get
12845
12846static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12847 struct snd_ctl_elem_value *ucontrol)
12848{
12849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12850 struct alc_spec *spec = codec->spec;
12851 const struct hda_input_mux *imux = spec->input_mux;
12852 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012853 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012854 hda_nid_t nid = capture_mixers[adc_idx];
12855 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12856 unsigned int i, idx;
12857
12858 idx = ucontrol->value.enumerated.item[0];
12859 if (idx >= imux->num_items)
12860 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012861 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012862 return 0;
12863 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012864 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12865 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12866 imux->items[i].index,
12867 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012868 }
12869 *cur_val = idx;
12870 return 1;
12871}
12872/*
12873 * 2ch mode
12874 */
12875static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12876 { 2, NULL }
12877};
12878
12879/*
12880 * 2ch mode
12881 */
12882static struct hda_verb alc662_3ST_ch2_init[] = {
12883 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12884 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12887 { } /* end */
12888};
12889
12890/*
12891 * 6ch mode
12892 */
12893static struct hda_verb alc662_3ST_ch6_init[] = {
12894 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12895 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12896 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12899 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12900 { } /* end */
12901};
12902
12903static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12904 { 2, alc662_3ST_ch2_init },
12905 { 6, alc662_3ST_ch6_init },
12906};
12907
12908/*
12909 * 2ch mode
12910 */
12911static struct hda_verb alc662_sixstack_ch6_init[] = {
12912 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12913 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12914 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12915 { } /* end */
12916};
12917
12918/*
12919 * 6ch mode
12920 */
12921static struct hda_verb alc662_sixstack_ch8_init[] = {
12922 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12923 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12924 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12925 { } /* end */
12926};
12927
12928static struct hda_channel_mode alc662_5stack_modes[2] = {
12929 { 2, alc662_sixstack_ch6_init },
12930 { 6, alc662_sixstack_ch8_init },
12931};
12932
12933/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12934 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12935 */
12936
12937static struct snd_kcontrol_new alc662_base_mixer[] = {
12938 /* output mixer control */
12939 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12940 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12942 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12943 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12944 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12945 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12946 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12948
12949 /*Input mixer control */
12950 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12951 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12952 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12953 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12954 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12955 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12957 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012958 { } /* end */
12959};
12960
12961static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12962 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12973 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12974 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012975 { } /* end */
12976};
12977
12978static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12979 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12980 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12982 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012998 { } /* end */
12999};
13000
13001static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13002 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13003 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13005 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013011 { } /* end */
13012};
13013
Kailang Yang291702f2007-10-16 14:28:03 +020013014static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013015 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013016
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013017 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13018 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013019
13020 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13021 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13022 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13023
13024 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13025 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13026 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13027 { } /* end */
13028};
13029
Kailang Yang8c427222008-01-10 13:03:59 +010013030static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013031 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13032 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13034 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13037 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13038 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013039 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013040 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13045 { } /* end */
13046};
13047
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013048static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13049 {
13050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13051 .name = "Channel Mode",
13052 .info = alc_ch_mode_info,
13053 .get = alc_ch_mode_get,
13054 .put = alc_ch_mode_put,
13055 },
13056 { } /* end */
13057};
13058
13059static struct hda_verb alc662_init_verbs[] = {
13060 /* ADC: mute amp left and right */
13061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13062 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13063 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13064
Takashi Iwaicb53c622007-08-10 17:21:45 +020013065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013070
Kailang Yangb60dd392007-09-20 12:50:29 +020013071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013077
13078 /* Front Pin: output 0 (0x0c) */
13079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13081
13082 /* Rear Pin: output 1 (0x0d) */
13083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13085
13086 /* CLFE Pin: output 2 (0x0e) */
13087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13088 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13089
13090 /* Mic (rear) pin: input vref at 80% */
13091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13092 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13093 /* Front Mic pin: input vref at 80% */
13094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13096 /* Line In pin: input */
13097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13098 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13099 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13103 /* CD pin widget for input */
13104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13105
13106 /* FIXME: use matrix-type input source selection */
13107 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13108 /* Input mixer */
13109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013113
13114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013118 { }
13119};
13120
13121static struct hda_verb alc662_sue_init_verbs[] = {
13122 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13123 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013124 {}
13125};
13126
13127static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13128 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13129 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13130 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013131};
13132
Kailang Yang8c427222008-01-10 13:03:59 +010013133/* Set Unsolicited Event*/
13134static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13136 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13137 {}
13138};
13139
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013140/*
13141 * generic initialization of ADC, input mixers and output mixers
13142 */
13143static struct hda_verb alc662_auto_init_verbs[] = {
13144 /*
13145 * Unmute ADC and set the default input to mic-in
13146 */
13147 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13149
13150 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13151 * mixer widget
13152 * Note: PASD motherboards uses the Line In 2 as the input for front
13153 * panel mic (mic 2)
13154 */
13155 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013161
13162 /*
13163 * Set up output mixers (0x0c - 0x0f)
13164 */
13165 /* set vol=0 to output mixers */
13166 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13167 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13168 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13169
13170 /* set up input amps for analog loopback */
13171 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013178
13179
13180 /* FIXME: use matrix-type input source selection */
13181 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13182 /* Input mixer */
13183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013185 { }
13186};
13187
13188/* capture mixer elements */
13189static struct snd_kcontrol_new alc662_capture_mixer[] = {
13190 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13191 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13192 {
13193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13194 /* The multiple "Capture Source" controls confuse alsamixer
13195 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013196 */
13197 /* .name = "Capture Source", */
13198 .name = "Input Source",
13199 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013200 .info = alc662_mux_enum_info,
13201 .get = alc662_mux_enum_get,
13202 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013203 },
13204 { } /* end */
13205};
13206
13207static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13208{
13209 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013211
13212 present = snd_hda_codec_read(codec, 0x14, 0,
13213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013214 bits = present ? HDA_AMP_MUTE : 0;
13215 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13216 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013217}
13218
13219static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13220{
13221 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013223
13224 present = snd_hda_codec_read(codec, 0x1b, 0,
13225 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013226 bits = present ? HDA_AMP_MUTE : 0;
13227 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13228 HDA_AMP_MUTE, bits);
13229 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13230 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013231}
13232
13233static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13234 unsigned int res)
13235{
13236 if ((res >> 26) == ALC880_HP_EVENT)
13237 alc662_lenovo_101e_all_automute(codec);
13238 if ((res >> 26) == ALC880_FRONT_EVENT)
13239 alc662_lenovo_101e_ispeaker_automute(codec);
13240}
13241
Kailang Yang291702f2007-10-16 14:28:03 +020013242static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13243{
13244 unsigned int present;
13245
13246 present = snd_hda_codec_read(codec, 0x18, 0,
13247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13248 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13249 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13250 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13251 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13252 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13253 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13254 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13255 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13256}
13257
13258/* unsolicited event for HP jack sensing */
13259static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13260 unsigned int res)
13261{
13262 if ((res >> 26) == ALC880_HP_EVENT)
13263 alc262_hippo1_automute( codec );
13264
13265 if ((res >> 26) == ALC880_MIC_EVENT)
13266 alc662_eeepc_mic_automute(codec);
13267}
13268
13269static void alc662_eeepc_inithook(struct hda_codec *codec)
13270{
13271 alc262_hippo1_automute( codec );
13272 alc662_eeepc_mic_automute(codec);
13273}
13274
Kailang Yang8c427222008-01-10 13:03:59 +010013275static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13276{
13277 unsigned int mute;
13278 unsigned int present;
13279
13280 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13281 present = snd_hda_codec_read(codec, 0x14, 0,
13282 AC_VERB_GET_PIN_SENSE, 0);
13283 present = (present & 0x80000000) != 0;
13284 if (present) {
13285 /* mute internal speaker */
13286 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13287 HDA_AMP_MUTE, HDA_AMP_MUTE);
13288 } else {
13289 /* unmute internal speaker if necessary */
13290 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13291 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13292 HDA_AMP_MUTE, mute);
13293 }
13294}
13295
13296/* unsolicited event for HP jack sensing */
13297static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13298 unsigned int res)
13299{
13300 if ((res >> 26) == ALC880_HP_EVENT)
13301 alc662_eeepc_ep20_automute(codec);
13302}
13303
13304static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13305{
13306 alc662_eeepc_ep20_automute(codec);
13307}
13308
Takashi Iwaicb53c622007-08-10 17:21:45 +020013309#ifdef CONFIG_SND_HDA_POWER_SAVE
13310#define alc662_loopbacks alc880_loopbacks
13311#endif
13312
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013313
13314/* pcm configuration: identiacal with ALC880 */
13315#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13316#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13317#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13318#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13319
13320/*
13321 * configuration and preset
13322 */
13323static const char *alc662_models[ALC662_MODEL_LAST] = {
13324 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13325 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13326 [ALC662_3ST_6ch] = "3stack-6ch",
13327 [ALC662_5ST_DIG] = "6stack-dig",
13328 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013329 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013330 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013331 [ALC662_AUTO] = "auto",
13332};
13333
13334static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013335 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013336 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013337 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013338 {}
13339};
13340
13341static struct alc_config_preset alc662_presets[] = {
13342 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013343 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013344 .init_verbs = { alc662_init_verbs },
13345 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13346 .dac_nids = alc662_dac_nids,
13347 .dig_out_nid = ALC662_DIGOUT_NID,
13348 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13349 .adc_nids = alc662_adc_nids,
13350 .dig_in_nid = ALC662_DIGIN_NID,
13351 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13352 .channel_mode = alc662_3ST_2ch_modes,
13353 .input_mux = &alc662_capture_source,
13354 },
13355 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013356 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13357 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013358 .init_verbs = { alc662_init_verbs },
13359 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13360 .dac_nids = alc662_dac_nids,
13361 .dig_out_nid = ALC662_DIGOUT_NID,
13362 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13363 .adc_nids = alc662_adc_nids,
13364 .dig_in_nid = ALC662_DIGIN_NID,
13365 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13366 .channel_mode = alc662_3ST_6ch_modes,
13367 .need_dac_fix = 1,
13368 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013369 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013370 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013371 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13372 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013373 .init_verbs = { alc662_init_verbs },
13374 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13375 .dac_nids = alc662_dac_nids,
13376 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13377 .adc_nids = alc662_adc_nids,
13378 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13379 .channel_mode = alc662_3ST_6ch_modes,
13380 .need_dac_fix = 1,
13381 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013382 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013383 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013384 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13385 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013386 .init_verbs = { alc662_init_verbs },
13387 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13388 .dac_nids = alc662_dac_nids,
13389 .dig_out_nid = ALC662_DIGOUT_NID,
13390 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13391 .adc_nids = alc662_adc_nids,
13392 .dig_in_nid = ALC662_DIGIN_NID,
13393 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13394 .channel_mode = alc662_5stack_modes,
13395 .input_mux = &alc662_capture_source,
13396 },
13397 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013398 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013399 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13400 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13401 .dac_nids = alc662_dac_nids,
13402 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13403 .adc_nids = alc662_adc_nids,
13404 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13405 .channel_mode = alc662_3ST_2ch_modes,
13406 .input_mux = &alc662_lenovo_101e_capture_source,
13407 .unsol_event = alc662_lenovo_101e_unsol_event,
13408 .init_hook = alc662_lenovo_101e_all_automute,
13409 },
Kailang Yang291702f2007-10-16 14:28:03 +020013410 [ALC662_ASUS_EEEPC_P701] = {
13411 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13412 .init_verbs = { alc662_init_verbs,
13413 alc662_eeepc_sue_init_verbs },
13414 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13415 .dac_nids = alc662_dac_nids,
13416 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13417 .adc_nids = alc662_adc_nids,
13418 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13419 .channel_mode = alc662_3ST_2ch_modes,
13420 .input_mux = &alc662_eeepc_capture_source,
13421 .unsol_event = alc662_eeepc_unsol_event,
13422 .init_hook = alc662_eeepc_inithook,
13423 },
Kailang Yang8c427222008-01-10 13:03:59 +010013424 [ALC662_ASUS_EEEPC_EP20] = {
13425 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13426 alc662_chmode_mixer },
13427 .init_verbs = { alc662_init_verbs,
13428 alc662_eeepc_ep20_sue_init_verbs },
13429 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13430 .dac_nids = alc662_dac_nids,
13431 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13432 .adc_nids = alc662_adc_nids,
13433 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13434 .channel_mode = alc662_3ST_6ch_modes,
13435 .input_mux = &alc662_lenovo_101e_capture_source,
13436 .unsol_event = alc662_eeepc_ep20_unsol_event,
13437 .init_hook = alc662_eeepc_ep20_inithook,
13438 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013439
13440};
13441
13442
13443/*
13444 * BIOS auto configuration
13445 */
13446
13447/* add playback controls from the parsed DAC table */
13448static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13449 const struct auto_pin_cfg *cfg)
13450{
13451 char name[32];
13452 static const char *chname[4] = {
13453 "Front", "Surround", NULL /*CLFE*/, "Side"
13454 };
13455 hda_nid_t nid;
13456 int i, err;
13457
13458 for (i = 0; i < cfg->line_outs; i++) {
13459 if (!spec->multiout.dac_nids[i])
13460 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013461 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013462 if (i == 2) {
13463 /* Center/LFE */
13464 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13465 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013466 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13467 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013468 if (err < 0)
13469 return err;
13470 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13471 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013472 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13473 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013474 if (err < 0)
13475 return err;
13476 err = add_control(spec, ALC_CTL_BIND_MUTE,
13477 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013478 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13479 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013480 if (err < 0)
13481 return err;
13482 err = add_control(spec, ALC_CTL_BIND_MUTE,
13483 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013484 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13485 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013486 if (err < 0)
13487 return err;
13488 } else {
13489 sprintf(name, "%s Playback Volume", chname[i]);
13490 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013491 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13492 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013493 if (err < 0)
13494 return err;
13495 sprintf(name, "%s Playback Switch", chname[i]);
13496 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013497 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13498 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013499 if (err < 0)
13500 return err;
13501 }
13502 }
13503 return 0;
13504}
13505
13506/* add playback controls for speaker and HP outputs */
13507static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13508 const char *pfx)
13509{
13510 hda_nid_t nid;
13511 int err;
13512 char name[32];
13513
13514 if (!pin)
13515 return 0;
13516
13517 if (alc880_is_fixed_pin(pin)) {
13518 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13519 /* printk("DAC nid=%x\n",nid); */
13520 /* specify the DAC as the extra output */
13521 if (!spec->multiout.hp_nid)
13522 spec->multiout.hp_nid = nid;
13523 else
13524 spec->multiout.extra_out_nid[0] = nid;
13525 /* control HP volume/switch on the output mixer amp */
13526 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13527 sprintf(name, "%s Playback Volume", pfx);
13528 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13529 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13530 if (err < 0)
13531 return err;
13532 sprintf(name, "%s Playback Switch", pfx);
13533 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13534 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13535 if (err < 0)
13536 return err;
13537 } else if (alc880_is_multi_pin(pin)) {
13538 /* set manual connection */
13539 /* we have only a switch on HP-out PIN */
13540 sprintf(name, "%s Playback Switch", pfx);
13541 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13542 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13543 if (err < 0)
13544 return err;
13545 }
13546 return 0;
13547}
13548
13549/* create playback/capture controls for input pins */
13550static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13551 const struct auto_pin_cfg *cfg)
13552{
13553 struct hda_input_mux *imux = &spec->private_imux;
13554 int i, err, idx;
13555
13556 for (i = 0; i < AUTO_PIN_LAST; i++) {
13557 if (alc880_is_input_pin(cfg->input_pins[i])) {
13558 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13559 err = new_analog_input(spec, cfg->input_pins[i],
13560 auto_pin_cfg_labels[i],
13561 idx, 0x0b);
13562 if (err < 0)
13563 return err;
13564 imux->items[imux->num_items].label =
13565 auto_pin_cfg_labels[i];
13566 imux->items[imux->num_items].index =
13567 alc880_input_pin_idx(cfg->input_pins[i]);
13568 imux->num_items++;
13569 }
13570 }
13571 return 0;
13572}
13573
13574static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13575 hda_nid_t nid, int pin_type,
13576 int dac_idx)
13577{
13578 /* set as output */
13579 snd_hda_codec_write(codec, nid, 0,
13580 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13581 snd_hda_codec_write(codec, nid, 0,
13582 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13583 /* need the manual connection? */
13584 if (alc880_is_multi_pin(nid)) {
13585 struct alc_spec *spec = codec->spec;
13586 int idx = alc880_multi_pin_idx(nid);
13587 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13588 AC_VERB_SET_CONNECT_SEL,
13589 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13590 }
13591}
13592
13593static void alc662_auto_init_multi_out(struct hda_codec *codec)
13594{
13595 struct alc_spec *spec = codec->spec;
13596 int i;
13597
Kailang Yang8c427222008-01-10 13:03:59 +010013598 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013599 for (i = 0; i <= HDA_SIDE; i++) {
13600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013601 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013602 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013603 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013604 i);
13605 }
13606}
13607
13608static void alc662_auto_init_hp_out(struct hda_codec *codec)
13609{
13610 struct alc_spec *spec = codec->spec;
13611 hda_nid_t pin;
13612
13613 pin = spec->autocfg.hp_pins[0];
13614 if (pin) /* connect to front */
13615 /* use dac 0 */
13616 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13617}
13618
13619#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13620#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13621
13622static void alc662_auto_init_analog_input(struct hda_codec *codec)
13623{
13624 struct alc_spec *spec = codec->spec;
13625 int i;
13626
13627 for (i = 0; i < AUTO_PIN_LAST; i++) {
13628 hda_nid_t nid = spec->autocfg.input_pins[i];
13629 if (alc662_is_input_pin(nid)) {
13630 snd_hda_codec_write(codec, nid, 0,
13631 AC_VERB_SET_PIN_WIDGET_CONTROL,
13632 (i <= AUTO_PIN_FRONT_MIC ?
13633 PIN_VREF80 : PIN_IN));
13634 if (nid != ALC662_PIN_CD_NID)
13635 snd_hda_codec_write(codec, nid, 0,
13636 AC_VERB_SET_AMP_GAIN_MUTE,
13637 AMP_OUT_MUTE);
13638 }
13639 }
13640}
13641
13642static int alc662_parse_auto_config(struct hda_codec *codec)
13643{
13644 struct alc_spec *spec = codec->spec;
13645 int err;
13646 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13647
13648 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13649 alc662_ignore);
13650 if (err < 0)
13651 return err;
13652 if (!spec->autocfg.line_outs)
13653 return 0; /* can't find valid BIOS pin config */
13654
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013655 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13656 if (err < 0)
13657 return err;
13658 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13659 if (err < 0)
13660 return err;
13661 err = alc662_auto_create_extra_out(spec,
13662 spec->autocfg.speaker_pins[0],
13663 "Speaker");
13664 if (err < 0)
13665 return err;
13666 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13667 "Headphone");
13668 if (err < 0)
13669 return err;
13670 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13671 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013672 return err;
13673
13674 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13675
13676 if (spec->autocfg.dig_out_pin)
13677 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13678
13679 if (spec->kctl_alloc)
13680 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13681
13682 spec->num_mux_defs = 1;
13683 spec->input_mux = &spec->private_imux;
13684
Takashi Iwai8c872862007-06-19 12:11:16 +020013685 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013686 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13687 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020013688 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013689}
13690
13691/* additional initialization for auto-configuration model */
13692static void alc662_auto_init(struct hda_codec *codec)
13693{
13694 alc662_auto_init_multi_out(codec);
13695 alc662_auto_init_hp_out(codec);
13696 alc662_auto_init_analog_input(codec);
13697}
13698
13699static int patch_alc662(struct hda_codec *codec)
13700{
13701 struct alc_spec *spec;
13702 int err, board_config;
13703
13704 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13705 if (!spec)
13706 return -ENOMEM;
13707
13708 codec->spec = spec;
13709
13710 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13711 alc662_models,
13712 alc662_cfg_tbl);
13713 if (board_config < 0) {
13714 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13715 "trying auto-probe from BIOS...\n");
13716 board_config = ALC662_AUTO;
13717 }
13718
13719 if (board_config == ALC662_AUTO) {
13720 /* automatic parse from the BIOS config */
13721 err = alc662_parse_auto_config(codec);
13722 if (err < 0) {
13723 alc_free(codec);
13724 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020013725 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013726 printk(KERN_INFO
13727 "hda_codec: Cannot set up configuration "
13728 "from BIOS. Using base mode...\n");
13729 board_config = ALC662_3ST_2ch_DIG;
13730 }
13731 }
13732
13733 if (board_config != ALC662_AUTO)
13734 setup_preset(spec, &alc662_presets[board_config]);
13735
13736 spec->stream_name_analog = "ALC662 Analog";
13737 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13738 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13739
13740 spec->stream_name_digital = "ALC662 Digital";
13741 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13742 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13743
13744 if (!spec->adc_nids && spec->input_mux) {
13745 spec->adc_nids = alc662_adc_nids;
13746 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13747 }
13748
Takashi Iwai2134ea42008-01-10 16:53:55 +010013749 spec->vmaster_nid = 0x02;
13750
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013751 codec->patch_ops = alc_patch_ops;
13752 if (board_config == ALC662_AUTO)
13753 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013754#ifdef CONFIG_SND_HDA_POWER_SAVE
13755 if (!spec->loopback.amplist)
13756 spec->loopback.amplist = alc662_loopbacks;
13757#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013758
13759 return 0;
13760}
13761
13762/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013763 * patch entries
13764 */
13765struct hda_codec_preset snd_hda_preset_realtek[] = {
13766 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013767 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013768 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013769 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013770 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013771 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013772 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013773 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13774 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13775 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013776 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13777 .patch = patch_alc883 },
13778 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13779 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013780 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013781 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013782 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013783 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013784 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013785 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013786 {} /* terminator */
13787};