blob: e8ce525d297b376ab04e7a9b8ddd1e3ceb05af82 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
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 Avdoninbab282b92006-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 Iwaie1406342008-02-11 18:32:32 +0100241 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200242 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200245 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 const struct hda_input_mux *input_mux;
247 unsigned int cur_mux[3];
248
249 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100250 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200252 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100255 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200256
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200257 /* dynamic controls, init_verbs and input_mux */
258 struct auto_pin_cfg autocfg;
259 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100260 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200261 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200262 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100263
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100264 /* hooks */
265 void (*init_hook)(struct hda_codec *codec);
266 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
267
Takashi Iwai834be882006-03-01 14:16:17 +0100268 /* for pin sensing */
269 unsigned int sense_updated: 1;
270 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100271 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200272
Takashi Iwai2134ea42008-01-10 16:53:55 +0100273 /* for virtual master */
274 hda_nid_t vmaster_nid;
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;
Takashi Iwaie1406342008-02-11 18:32:32 +0100294 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100295 hda_nid_t dig_in_nid;
296 unsigned int num_channel_mode;
297 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200298 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200299 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100300 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100301 void (*unsol_event)(struct hda_codec *, unsigned int);
302 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200303#ifdef CONFIG_SND_HDA_POWER_SAVE
304 struct hda_amp_list *loopbacks;
305#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306};
307
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309/*
310 * input MUX handling
311 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200312static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
315 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
316 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
318 if (mux_idx >= spec->num_mux_defs)
319 mux_idx = 0;
320 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321}
322
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200323static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
324 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct alc_spec *spec = codec->spec;
328 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
329
330 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
331 return 0;
332}
333
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200334static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
335 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336{
337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
338 struct alc_spec *spec = codec->spec;
339 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200340 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t nid = spec->capsrc_nids ?
342 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200343 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100344 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345}
346
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200347
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348/*
349 * channel mode setting
350 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200351static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353{
354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
355 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100356 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
357 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358}
359
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200360static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
361 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
364 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100365 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366 spec->num_channel_mode,
367 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200370static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200375 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
376 spec->num_channel_mode,
377 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200378 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200379 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
380 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381}
382
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100384 * Control the mode of pin widget settings via the mixer. "pc" is used
385 * instead of "%" to avoid consequences of accidently treating the % as
386 * being part of a format specifier. Maximum allowed length of a value is
387 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100388 *
389 * Note: some retasking pin complexes seem to ignore requests for input
390 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
391 * are requested. Therefore order this list so that this behaviour will not
392 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200393 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
394 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200395 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100396static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100397 "Mic 50pc bias", "Mic 80pc bias",
398 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100399};
400static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100401 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100402};
403/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200404 * in the pin being assumed to be exclusively an input or an output pin. In
405 * addition, "input" pins may or may not process the mic bias option
406 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
407 * accept requests for bias as of chip versions up to March 2006) and/or
408 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200410#define ALC_PIN_DIR_IN 0x00
411#define ALC_PIN_DIR_OUT 0x01
412#define ALC_PIN_DIR_INOUT 0x02
413#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
414#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100415
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417 * For each direction the minimum and maximum values are given.
418 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200419static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420 { 0, 2 }, /* ALC_PIN_DIR_IN */
421 { 3, 4 }, /* ALC_PIN_DIR_OUT */
422 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200423 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
424 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100425};
426#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
427#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
428#define alc_pin_mode_n_items(_dir) \
429 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
430
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200431static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
432 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200433{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 unsigned int item_num = uinfo->value.enumerated.item;
435 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
436
437 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200438 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
440
441 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
442 item_num = alc_pin_mode_min(dir);
443 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200444 return 0;
445}
446
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200449{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100450 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200454 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
456 AC_VERB_GET_PIN_WIDGET_CONTROL,
457 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200458
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 /* Find enumerated value for current pinctl setting */
460 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100464 return 0;
465}
466
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469{
470 signed int change;
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 hda_nid_t nid = kcontrol->private_value & 0xffff;
473 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
474 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
476 AC_VERB_GET_PIN_WIDGET_CONTROL,
477 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200479 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100480 val = alc_pin_mode_min(dir);
481
482 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100483 if (change) {
484 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200485 snd_hda_codec_write_cache(codec, nid, 0,
486 AC_VERB_SET_PIN_WIDGET_CONTROL,
487 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100488
489 /* Also enable the retasking pin's input/output as required
490 * for the requested pin mode. Enum values of 2 or less are
491 * input modes.
492 *
493 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200494 * reduces noise slightly (particularly on input) so we'll
495 * do it. However, having both input and output buffers
496 * enabled simultaneously doesn't seem to be problematic if
497 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100498 */
499 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200500 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
501 HDA_AMP_MUTE, HDA_AMP_MUTE);
502 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
503 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100504 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200505 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
506 HDA_AMP_MUTE, HDA_AMP_MUTE);
507 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
508 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100509 }
510 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 return change;
512}
513
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200515 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516 .info = alc_pin_mode_info, \
517 .get = alc_pin_mode_get, \
518 .put = alc_pin_mode_put, \
519 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100520
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100521/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
522 * together using a mask with more than one bit set. This control is
523 * currently used only by the ALC260 test model. At this stage they are not
524 * needed for any "production" models.
525 */
526#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200527#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200528
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100531{
532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
533 hda_nid_t nid = kcontrol->private_value & 0xffff;
534 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
535 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536 unsigned int val = snd_hda_codec_read(codec, nid, 0,
537 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100538
539 *valp = (val & mask) != 0;
540 return 0;
541}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100544{
545 signed int change;
546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
547 hda_nid_t nid = kcontrol->private_value & 0xffff;
548 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
549 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
551 AC_VERB_GET_GPIO_DATA,
552 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100553
554 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
556 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100557 gpio_data &= ~mask;
558 else
559 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200560 snd_hda_codec_write_cache(codec, nid, 0,
561 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100562
563 return change;
564}
565#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
566 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
567 .info = alc_gpio_data_info, \
568 .get = alc_gpio_data_get, \
569 .put = alc_gpio_data_put, \
570 .private_value = nid | (mask<<16) }
571#endif /* CONFIG_SND_DEBUG */
572
Jonathan Woithe92621f12006-02-28 11:47:47 +0100573/* A switch control to allow the enabling of the digital IO pins on the
574 * ALC260. This is incredibly simplistic; the intention of this control is
575 * to provide something in the test model allowing digital outputs to be
576 * identified if present. If models are found which can utilise these
577 * outputs a more complete mixer control can be devised for those models if
578 * necessary.
579 */
580#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200581#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200582
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100585{
586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
587 hda_nid_t nid = kcontrol->private_value & 0xffff;
588 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
589 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200590 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100591 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100592
593 *valp = (val & mask) != 0;
594 return 0;
595}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100598{
599 signed int change;
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 hda_nid_t nid = kcontrol->private_value & 0xffff;
602 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
603 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100605 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200606 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100607
608 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100610 if (val==0)
611 ctrl_data &= ~mask;
612 else
613 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200614 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
615 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100616
617 return change;
618}
619#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
620 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
621 .info = alc_spdif_ctrl_info, \
622 .get = alc_spdif_ctrl_get, \
623 .put = alc_spdif_ctrl_put, \
624 .private_value = nid | (mask<<16) }
625#endif /* CONFIG_SND_DEBUG */
626
Jonathan Woithef8225f62008-01-08 12:16:54 +0100627/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
628 * Again, this is only used in the ALC26x test models to help identify when
629 * the EAPD line must be asserted for features to work.
630 */
631#ifdef CONFIG_SND_DEBUG
632#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
633
634static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
636{
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 hda_nid_t nid = kcontrol->private_value & 0xffff;
639 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
640 long *valp = ucontrol->value.integer.value;
641 unsigned int val = snd_hda_codec_read(codec, nid, 0,
642 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
643
644 *valp = (val & mask) != 0;
645 return 0;
646}
647
648static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
650{
651 int change;
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 hda_nid_t nid = kcontrol->private_value & 0xffff;
654 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
655 long val = *ucontrol->value.integer.value;
656 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
657 AC_VERB_GET_EAPD_BTLENABLE,
658 0x00);
659
660 /* Set/unset the masked control bit(s) as needed */
661 change = (!val ? 0 : mask) != (ctrl_data & mask);
662 if (!val)
663 ctrl_data &= ~mask;
664 else
665 ctrl_data |= mask;
666 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
667 ctrl_data);
668
669 return change;
670}
671
672#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
673 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
674 .info = alc_eapd_ctrl_info, \
675 .get = alc_eapd_ctrl_get, \
676 .put = alc_eapd_ctrl_put, \
677 .private_value = nid | (mask<<16) }
678#endif /* CONFIG_SND_DEBUG */
679
Kailang Yangdf694da2005-12-05 19:42:22 +0100680/*
681 * set up from the preset table
682 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200683static void setup_preset(struct alc_spec *spec,
684 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100685{
686 int i;
687
688 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
689 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200690 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
691 i++)
692 spec->init_verbs[spec->num_init_verbs++] =
693 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100694
695 spec->channel_mode = preset->channel_mode;
696 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200697 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100698
699 spec->multiout.max_channels = spec->channel_mode[0].channels;
700
701 spec->multiout.num_dacs = preset->num_dacs;
702 spec->multiout.dac_nids = preset->dac_nids;
703 spec->multiout.dig_out_nid = preset->dig_out_nid;
704 spec->multiout.hp_nid = preset->hp_nid;
705
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200706 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200707 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200708 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100709 spec->input_mux = preset->input_mux;
710
711 spec->num_adc_nids = preset->num_adc_nids;
712 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100713 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100714 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100715
716 spec->unsol_event = preset->unsol_event;
717 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200718#ifdef CONFIG_SND_HDA_POWER_SAVE
719 spec->loopback.amplist = preset->loopbacks;
720#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100721}
722
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200723/* Enable GPIO mask and set output */
724static struct hda_verb alc_gpio1_init_verbs[] = {
725 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
726 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
727 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
728 { }
729};
730
731static struct hda_verb alc_gpio2_init_verbs[] = {
732 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
733 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
734 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
735 { }
736};
737
Kailang Yangbdd148a2007-05-08 15:19:08 +0200738static struct hda_verb alc_gpio3_init_verbs[] = {
739 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
740 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
741 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
742 { }
743};
744
Kailang Yangc9b58002007-10-16 14:30:01 +0200745static void alc_sku_automute(struct hda_codec *codec)
746{
747 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200748 unsigned int present;
749 unsigned int hp_nid = spec->autocfg.hp_pins[0];
750 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
751
752 /* need to execute and sync at first */
753 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
754 present = snd_hda_codec_read(codec, hp_nid, 0,
755 AC_VERB_GET_PIN_SENSE, 0);
756 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100757 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
758 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200759}
760
761/* unsolicited event for HP jack sensing */
762static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
763{
764 if (codec->vendor_id == 0x10ec0880)
765 res >>= 28;
766 else
767 res >>= 26;
768 if (res != ALC880_HP_EVENT)
769 return;
770
771 alc_sku_automute(codec);
772}
773
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200774/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
775 * 31 ~ 16 : Manufacture ID
776 * 15 ~ 8 : SKU ID
777 * 7 ~ 0 : Assembly ID
778 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
779 */
780static void alc_subsystem_id(struct hda_codec *codec,
781 unsigned int porta, unsigned int porte,
782 unsigned int portd)
783{
Kailang Yangc9b58002007-10-16 14:30:01 +0200784 unsigned int ass, tmp, i;
785 unsigned nid;
786 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200787
Kailang Yangc9b58002007-10-16 14:30:01 +0200788 ass = codec->subsystem_id & 0xffff;
789 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
790 goto do_sku;
791
792 /*
793 * 31~30 : port conetcivity
794 * 29~21 : reserve
795 * 20 : PCBEEP input
796 * 19~16 : Check sum (15:1)
797 * 15~1 : Custom
798 * 0 : override
799 */
800 nid = 0x1d;
801 if (codec->vendor_id == 0x10ec0260)
802 nid = 0x17;
803 ass = snd_hda_codec_read(codec, nid, 0,
804 AC_VERB_GET_CONFIG_DEFAULT, 0);
805 if (!(ass & 1) && !(ass & 0x100000))
806 return;
807 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200808 return;
809
Kailang Yangc9b58002007-10-16 14:30:01 +0200810 /* check sum */
811 tmp = 0;
812 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100813 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200814 tmp++;
815 }
816 if (((ass >> 16) & 0xf) != tmp)
817 return;
818do_sku:
819 /*
820 * 0 : override
821 * 1 : Swap Jack
822 * 2 : 0 --> Desktop, 1 --> Laptop
823 * 3~5 : External Amplifier control
824 * 7~6 : Reserved
825 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200826 tmp = (ass & 0x38) >> 3; /* external Amp control */
827 switch (tmp) {
828 case 1:
829 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
830 break;
831 case 3:
832 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
833 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200834 case 7:
835 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
836 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200837 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200838 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200839 case 0x10ec0260:
840 snd_hda_codec_write(codec, 0x0f, 0,
841 AC_VERB_SET_EAPD_BTLENABLE, 2);
842 snd_hda_codec_write(codec, 0x10, 0,
843 AC_VERB_SET_EAPD_BTLENABLE, 2);
844 break;
845 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200846 case 0x10ec0267:
847 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200848 case 0x10ec0269:
849 case 0x10ec0862:
850 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200851 snd_hda_codec_write(codec, 0x14, 0,
852 AC_VERB_SET_EAPD_BTLENABLE, 2);
853 snd_hda_codec_write(codec, 0x15, 0,
854 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200855 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200856 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200857 switch (codec->vendor_id) {
858 case 0x10ec0260:
859 snd_hda_codec_write(codec, 0x1a, 0,
860 AC_VERB_SET_COEF_INDEX, 7);
861 tmp = snd_hda_codec_read(codec, 0x1a, 0,
862 AC_VERB_GET_PROC_COEF, 0);
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 snd_hda_codec_write(codec, 0x1a, 0,
866 AC_VERB_SET_PROC_COEF,
867 tmp | 0x2010);
868 break;
869 case 0x10ec0262:
870 case 0x10ec0880:
871 case 0x10ec0882:
872 case 0x10ec0883:
873 case 0x10ec0885:
874 case 0x10ec0888:
875 snd_hda_codec_write(codec, 0x20, 0,
876 AC_VERB_SET_COEF_INDEX, 7);
877 tmp = snd_hda_codec_read(codec, 0x20, 0,
878 AC_VERB_GET_PROC_COEF, 0);
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 snd_hda_codec_write(codec, 0x20, 0,
882 AC_VERB_SET_PROC_COEF,
883 tmp | 0x2010);
884 break;
885 case 0x10ec0267:
886 case 0x10ec0268:
887 snd_hda_codec_write(codec, 0x20, 0,
888 AC_VERB_SET_COEF_INDEX, 7);
889 tmp = snd_hda_codec_read(codec, 0x20, 0,
890 AC_VERB_GET_PROC_COEF, 0);
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 snd_hda_codec_write(codec, 0x20, 0,
894 AC_VERB_SET_PROC_COEF,
895 tmp | 0x3000);
896 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200897 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200898 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200899 break;
900 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200901
Kailang Yang8c427222008-01-10 13:03:59 +0100902 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200903 * when the external headphone out jack is plugged"
904 */
Kailang Yang8c427222008-01-10 13:03:59 +0100905 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 return;
907 /*
908 * 10~8 : Jack location
909 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
910 * 14~13: Resvered
911 * 15 : 1 --> enable the function "Mute internal speaker
912 * when the external headphone out jack is plugged"
913 */
914 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100915 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200916 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100917 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200918 else
919 return;
920 }
921
922 if (!spec->autocfg.hp_pins[0]) {
923 tmp = (ass >> 11) & 0x3; /* HP to chassis */
924 if (tmp == 0)
925 spec->autocfg.hp_pins[0] = porta;
926 else if (tmp == 1)
927 spec->autocfg.hp_pins[0] = porte;
928 else if (tmp == 2)
929 spec->autocfg.hp_pins[0] = portd;
930 else
931 return;
932 }
933
934 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
935 AC_VERB_SET_UNSOLICITED_ENABLE,
936 AC_USRSP_EN | ALC880_HP_EVENT);
937 spec->unsol_event = alc_sku_unsol_event;
938 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200939}
940
Takashi Iwai41e41f12005-06-08 14:48:49 +0200941/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200942 * Fix-up pin default configurations
943 */
944
945struct alc_pincfg {
946 hda_nid_t nid;
947 u32 val;
948};
949
950static void alc_fix_pincfg(struct hda_codec *codec,
951 const struct snd_pci_quirk *quirk,
952 const struct alc_pincfg **pinfix)
953{
954 const struct alc_pincfg *cfg;
955
956 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
957 if (!quirk)
958 return;
959
960 cfg = pinfix[quirk->value];
961 for (; cfg->nid; cfg++) {
962 int i;
963 u32 val = cfg->val;
964 for (i = 0; i < 4; i++) {
965 snd_hda_codec_write(codec, cfg->nid, 0,
966 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
967 val & 0xff);
968 val >>= 8;
969 }
970 }
971}
972
973/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200974 * ALC880 3-stack model
975 *
976 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200977 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
978 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 */
980
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200981static hda_nid_t alc880_dac_nids[4] = {
982 /* front, rear, clfe, rear_surr */
983 0x02, 0x05, 0x04, 0x03
984};
985
986static hda_nid_t alc880_adc_nids[3] = {
987 /* ADC0-2 */
988 0x07, 0x08, 0x09,
989};
990
991/* The datasheet says the node 0x07 is connected from inputs,
992 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100993 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200995static hda_nid_t alc880_adc_nids_alt[2] = {
996 /* ADC1-2 */
997 0x08, 0x09,
998};
999
1000#define ALC880_DIGOUT_NID 0x06
1001#define ALC880_DIGIN_NID 0x0a
1002
1003static struct hda_input_mux alc880_capture_source = {
1004 .num_items = 4,
1005 .items = {
1006 { "Mic", 0x0 },
1007 { "Front Mic", 0x3 },
1008 { "Line", 0x2 },
1009 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001011};
1012
1013/* channel source setting (2/6 channel selection for 3-stack) */
1014/* 2ch mode */
1015static struct hda_verb alc880_threestack_ch2_init[] = {
1016 /* set line-in to input, mute it */
1017 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1018 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1019 /* set mic-in to input vref 80%, mute it */
1020 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1021 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 { } /* end */
1023};
1024
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001025/* 6ch mode */
1026static struct hda_verb alc880_threestack_ch6_init[] = {
1027 /* set line-in to output, unmute it */
1028 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1029 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1030 /* set mic-in to output, unmute it */
1031 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1032 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1033 { } /* end */
1034};
1035
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001036static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 { 2, alc880_threestack_ch2_init },
1038 { 6, alc880_threestack_ch6_init },
1039};
1040
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001041static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001045 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001048 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1049 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1053 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1058 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1059 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 {
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1063 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001064 .info = alc_ch_mode_info,
1065 .get = alc_ch_mode_get,
1066 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067 },
1068 { } /* end */
1069};
1070
1071/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001072static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1074 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1079 {
1080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1081 /* The multiple "Capture Source" controls confuse alsamixer
1082 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083 */
1084 /* .name = "Capture Source", */
1085 .name = "Input Source",
1086 .count = 3,
1087 .info = alc_mux_enum_info,
1088 .get = alc_mux_enum_get,
1089 .put = alc_mux_enum_put,
1090 },
1091 { } /* end */
1092};
1093
1094/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001095static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001096 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1097 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 {
1101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1102 /* The multiple "Capture Source" controls confuse alsamixer
1103 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 */
1105 /* .name = "Capture Source", */
1106 .name = "Input Source",
1107 .count = 2,
1108 .info = alc_mux_enum_info,
1109 .get = alc_mux_enum_get,
1110 .put = alc_mux_enum_put,
1111 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 { } /* end */
1113};
1114
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001115
1116
1117/*
1118 * ALC880 5-stack model
1119 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001120 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1121 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001122 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1123 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1124 */
1125
1126/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001127static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001128 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001129 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 { } /* end */
1131};
1132
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133/* channel source setting (6/8 channel selection for 5-stack) */
1134/* 6ch mode */
1135static struct hda_verb alc880_fivestack_ch6_init[] = {
1136 /* set line-in to input, mute it */
1137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001139 { } /* end */
1140};
1141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001142/* 8ch mode */
1143static struct hda_verb alc880_fivestack_ch8_init[] = {
1144 /* set line-in to output, unmute it */
1145 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1146 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1147 { } /* end */
1148};
1149
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001150static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001151 { 6, alc880_fivestack_ch6_init },
1152 { 8, alc880_fivestack_ch8_init },
1153};
1154
1155
1156/*
1157 * ALC880 6-stack model
1158 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001159 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1160 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1162 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1163 */
1164
1165static hda_nid_t alc880_6st_dac_nids[4] = {
1166 /* front, rear, clfe, rear_surr */
1167 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001168};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001169
1170static struct hda_input_mux alc880_6stack_capture_source = {
1171 .num_items = 4,
1172 .items = {
1173 { "Mic", 0x0 },
1174 { "Front Mic", 0x1 },
1175 { "Line", 0x2 },
1176 { "CD", 0x4 },
1177 },
1178};
1179
1180/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001181static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001182 { 8, NULL },
1183};
1184
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001185static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001189 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001195 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001206 {
1207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1208 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001209 .info = alc_ch_mode_info,
1210 .get = alc_ch_mode_get,
1211 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001212 },
1213 { } /* end */
1214};
1215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216
1217/*
1218 * ALC880 W810 model
1219 *
1220 * W810 has rear IO for:
1221 * Front (DAC 02)
1222 * Surround (DAC 03)
1223 * Center/LFE (DAC 04)
1224 * Digital out (06)
1225 *
1226 * The system also has a pair of internal speakers, and a headphone jack.
1227 * These are both connected to Line2 on the codec, hence to DAC 02.
1228 *
1229 * There is a variable resistor to control the speaker or headphone
1230 * volume. This is a hardware-only device without a software API.
1231 *
1232 * Plugging headphones in will disable the internal speakers. This is
1233 * implemented in hardware, not via the driver using jack sense. In
1234 * a similar fashion, plugging into the rear socket marked "front" will
1235 * disable both the speakers and headphones.
1236 *
1237 * For input, there's a microphone jack, and an "audio in" jack.
1238 * These may not do anything useful with this driver yet, because I
1239 * haven't setup any initialization verbs for these yet...
1240 */
1241
1242static hda_nid_t alc880_w810_dac_nids[3] = {
1243 /* front, rear/surround, clfe */
1244 0x02, 0x03, 0x04
1245};
1246
1247/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001248static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249 { 6, NULL }
1250};
1251
1252/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001253static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001255 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001257 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1259 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001260 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1261 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1263 { } /* end */
1264};
1265
1266
1267/*
1268 * Z710V model
1269 *
1270 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001271 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1272 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001273 */
1274
1275static hda_nid_t alc880_z71v_dac_nids[1] = {
1276 0x02
1277};
1278#define ALC880_Z71V_HP_DAC 0x03
1279
1280/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001281static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001282 { 2, NULL }
1283};
1284
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001285static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001289 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1293 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1294 { } /* end */
1295};
1296
1297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298/*
1299 * ALC880 F1734 model
1300 *
1301 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1302 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1303 */
1304
1305static hda_nid_t alc880_f1734_dac_nids[1] = {
1306 0x03
1307};
1308#define ALC880_F1734_HP_DAC 0x02
1309
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001310static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001311 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001312 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001313 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1314 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001319 { } /* end */
1320};
1321
Takashi Iwai937b4162008-02-11 14:52:36 +01001322static struct hda_input_mux alc880_f1734_capture_source = {
1323 .num_items = 2,
1324 .items = {
1325 { "Mic", 0x1 },
1326 { "CD", 0x4 },
1327 },
1328};
1329
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001331/*
1332 * ALC880 ASUS model
1333 *
1334 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1335 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1336 * Mic = 0x18, Line = 0x1a
1337 */
1338
1339#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1340#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1341
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001342static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001345 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001346 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001347 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1348 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001349 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1350 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001357 {
1358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1359 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001360 .info = alc_ch_mode_info,
1361 .get = alc_ch_mode_get,
1362 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001363 },
1364 { } /* end */
1365};
1366
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001367/*
1368 * ALC880 ASUS W1V model
1369 *
1370 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1371 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1372 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1373 */
1374
1375/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001376static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001377 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1378 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001379 { } /* end */
1380};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001382/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001383static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001384 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1385 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1386 { } /* end */
1387};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001388
Kailang Yangdf694da2005-12-05 19:42:22 +01001389/* TCL S700 */
1390static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1391 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1392 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1395 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1398 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1399 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1400 {
1401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1402 /* The multiple "Capture Source" controls confuse alsamixer
1403 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001404 */
1405 /* .name = "Capture Source", */
1406 .name = "Input Source",
1407 .count = 1,
1408 .info = alc_mux_enum_info,
1409 .get = alc_mux_enum_get,
1410 .put = alc_mux_enum_put,
1411 },
1412 { } /* end */
1413};
1414
Kailang Yangccc656c2006-10-17 12:32:26 +02001415/* Uniwill */
1416static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001417 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1418 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1419 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1420 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001421 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1423 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1424 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1430 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1431 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1432 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1433 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1434 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1435 {
1436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1437 .name = "Channel Mode",
1438 .info = alc_ch_mode_info,
1439 .get = alc_ch_mode_get,
1440 .put = alc_ch_mode_put,
1441 },
1442 { } /* end */
1443};
1444
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001445static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1446 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1447 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1449 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1453 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1454 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1455 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1456 { } /* end */
1457};
1458
Kailang Yangccc656c2006-10-17 12:32:26 +02001459static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001460 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1461 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1463 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1466 { } /* end */
1467};
1468
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001470 * virtual master controls
1471 */
1472
1473/*
1474 * slave controls for virtual master
1475 */
1476static const char *alc_slave_vols[] = {
1477 "Front Playback Volume",
1478 "Surround Playback Volume",
1479 "Center Playback Volume",
1480 "LFE Playback Volume",
1481 "Side Playback Volume",
1482 "Headphone Playback Volume",
1483 "Speaker Playback Volume",
1484 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001485 "Line-Out Playback Volume",
1486 NULL,
1487};
1488
1489static const char *alc_slave_sws[] = {
1490 "Front Playback Switch",
1491 "Surround Playback Switch",
1492 "Center Playback Switch",
1493 "LFE Playback Switch",
1494 "Side Playback Switch",
1495 "Headphone Playback Switch",
1496 "Speaker Playback Switch",
1497 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001498 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001499 NULL,
1500};
1501
1502/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001503 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 */
1505static int alc_build_controls(struct hda_codec *codec)
1506{
1507 struct alc_spec *spec = codec->spec;
1508 int err;
1509 int i;
1510
1511 for (i = 0; i < spec->num_mixers; i++) {
1512 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1513 if (err < 0)
1514 return err;
1515 }
1516
1517 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001518 err = snd_hda_create_spdif_out_ctls(codec,
1519 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 if (err < 0)
1521 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001522 err = snd_hda_create_spdif_share_sw(codec,
1523 &spec->multiout);
1524 if (err < 0)
1525 return err;
1526 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 }
1528 if (spec->dig_in_nid) {
1529 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1530 if (err < 0)
1531 return err;
1532 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001533
1534 /* if we have no master control, let's create it */
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001536 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001537 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001538 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001539 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001540 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001541 if (err < 0)
1542 return err;
1543 }
1544 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1545 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1546 NULL, alc_slave_sws);
1547 if (err < 0)
1548 return err;
1549 }
1550
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 return 0;
1552}
1553
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001554
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555/*
1556 * initialize the codec volumes, etc
1557 */
1558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001559/*
1560 * generic initialization of ADC, input mixers and output mixers
1561 */
1562static struct hda_verb alc880_volume_init_verbs[] = {
1563 /*
1564 * Unmute ADC0-2 and set the default input to mic-in
1565 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001570 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001573 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1574 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001575 * Note: PASD motherboards uses the Line In 2 as the input for front
1576 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001587 /*
1588 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001590 /* set vol=0 to output mixers */
1591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1595 /* set up input amps for analog loopback */
1596 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605
1606 { }
1607};
1608
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001609/*
1610 * 3-stack pin configuration:
1611 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1612 */
1613static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1614 /*
1615 * preset connection lists of input pins
1616 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1617 */
1618 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1619 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1620 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1621
1622 /*
1623 * Set pin mode and muting
1624 */
1625 /* set front pin widgets 0x14 for output */
1626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1629 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* Mic2 (as headphone out) for HP output */
1632 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1634 /* Line In pin widget for input */
1635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1636 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1637 /* Line2 (as front mic) pin widget for input and vref at 80% */
1638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1639 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1640 /* CD pin widget for input */
1641 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1642
1643 { }
1644};
1645
1646/*
1647 * 5-stack pin configuration:
1648 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1649 * line-in/side = 0x1a, f-mic = 0x1b
1650 */
1651static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1652 /*
1653 * preset connection lists of input pins
1654 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1655 */
1656 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1657 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1658
1659 /*
1660 * Set pin mode and muting
1661 */
1662 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001667 /* unmute pins for output (no gain on this amp) */
1668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001674 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* Mic2 (as headphone out) for HP output */
1677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001678 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679 /* Line In pin widget for input */
1680 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1681 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1682 /* Line2 (as front mic) pin widget for input and vref at 80% */
1683 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1684 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1685 /* CD pin widget for input */
1686 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687
1688 { }
1689};
1690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691/*
1692 * W810 pin configuration:
1693 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1694 */
1695static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 /* hphone/speaker input selector: front DAC */
1697 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1698
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705
1706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 { }
1710};
1711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712/*
1713 * Z71V pin configuration:
1714 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1715 */
1716static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001721
Takashi Iwai16ded522005-06-10 19:58:24 +02001722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001726
1727 { }
1728};
1729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730/*
1731 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001732 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1733 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734 */
1735static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1736 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1737
Takashi Iwai16ded522005-06-10 19:58:24 +02001738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001744 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746
Takashi Iwai16ded522005-06-10 19:58:24 +02001747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001757 { }
1758};
Takashi Iwai16ded522005-06-10 19:58:24 +02001759
Kailang Yangccc656c2006-10-17 12:32:26 +02001760/*
1761 * Uniwill pin configuration:
1762 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1763 * line = 0x1a
1764 */
1765static struct hda_verb alc880_uniwill_init_verbs[] = {
1766 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1767
1768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1782
1783 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1787 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1788 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1789 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1790 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1792
1793 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1794 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1795
1796 { }
1797};
1798
1799/*
1800* Uniwill P53
1801* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1802 */
1803static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1804 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1805
1806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1818
1819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1824 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1825
1826 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1827 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1828
1829 { }
1830};
1831
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001832static struct hda_verb alc880_beep_init_verbs[] = {
1833 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1834 { }
1835};
1836
Kailang Yangccc656c2006-10-17 12:32:26 +02001837/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001838static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001839{
1840 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001841 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001842
1843 present = snd_hda_codec_read(codec, 0x14, 0,
1844 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001845 bits = present ? HDA_AMP_MUTE : 0;
1846 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1847 HDA_AMP_MUTE, bits);
1848 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1849 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001850}
1851
1852/* auto-toggle front mic */
1853static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1854{
1855 unsigned int present;
1856 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001857
1858 present = snd_hda_codec_read(codec, 0x18, 0,
1859 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001860 bits = present ? HDA_AMP_MUTE : 0;
1861 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001862}
1863
1864static void alc880_uniwill_automute(struct hda_codec *codec)
1865{
1866 alc880_uniwill_hp_automute(codec);
1867 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001868}
1869
1870static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1871 unsigned int res)
1872{
1873 /* Looks like the unsol event is incompatible with the standard
1874 * definition. 4bit tag is placed at 28 bit!
1875 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001876 switch (res >> 28) {
1877 case ALC880_HP_EVENT:
1878 alc880_uniwill_hp_automute(codec);
1879 break;
1880 case ALC880_MIC_EVENT:
1881 alc880_uniwill_mic_automute(codec);
1882 break;
1883 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001884}
1885
1886static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1887{
1888 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001889 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001890
1891 present = snd_hda_codec_read(codec, 0x14, 0,
1892 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001893 bits = present ? HDA_AMP_MUTE : 0;
1894 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001895}
1896
1897static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1898{
1899 unsigned int present;
1900
1901 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001902 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1903 present &= HDA_AMP_VOLMASK;
1904 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1905 HDA_AMP_VOLMASK, present);
1906 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1907 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001908}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001909
Kailang Yangccc656c2006-10-17 12:32:26 +02001910static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1911 unsigned int res)
1912{
1913 /* Looks like the unsol event is incompatible with the standard
1914 * definition. 4bit tag is placed at 28 bit!
1915 */
1916 if ((res >> 28) == ALC880_HP_EVENT)
1917 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001918 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001919 alc880_uniwill_p53_dcvol_automute(codec);
1920}
1921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001922/*
1923 * F1734 pin configuration:
1924 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1925 */
1926static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1927 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1928 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1929 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1930 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1931
1932 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1933 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936
1937 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1941 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001946
Takashi Iwai937b4162008-02-11 14:52:36 +01001947 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1948 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1949
Takashi Iwai16ded522005-06-10 19:58:24 +02001950 { }
1951};
1952
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001953/*
1954 * ASUS pin configuration:
1955 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1956 */
1957static struct hda_verb alc880_pin_asus_init_verbs[] = {
1958 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1959 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1960 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1961 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1962
1963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1967 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1969 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971
1972 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1976 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1980 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1981
1982 { }
1983};
1984
1985/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001986#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1987#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001988
Kailang Yangdf694da2005-12-05 19:42:22 +01001989/* Clevo m520g init */
1990static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1991 /* headphone output */
1992 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1993 /* line-out */
1994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1995 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* Line-in */
1997 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1998 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* CD */
2000 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2001 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002 /* Mic1 (rear panel) */
2003 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2004 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2005 /* Mic2 (front panel) */
2006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2007 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2008 /* headphone */
2009 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2010 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011 /* change to EAPD mode */
2012 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2013 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2014
2015 { }
2016};
2017
2018static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002019 /* change to EAPD mode */
2020 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2021 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2022
Kailang Yangdf694da2005-12-05 19:42:22 +01002023 /* Headphone output */
2024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2025 /* Front output*/
2026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2027 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2028
2029 /* Line In pin widget for input */
2030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2031 /* CD pin widget for input */
2032 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2033 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2034 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2035
2036 /* change to EAPD mode */
2037 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2038 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2039
2040 { }
2041};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042
2043/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002044 * LG m1 express dual
2045 *
2046 * Pin assignment:
2047 * Rear Line-In/Out (blue): 0x14
2048 * Build-in Mic-In: 0x15
2049 * Speaker-out: 0x17
2050 * HP-Out (green): 0x1b
2051 * Mic-In/Out (red): 0x19
2052 * SPDIF-Out: 0x1e
2053 */
2054
2055/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2056static hda_nid_t alc880_lg_dac_nids[3] = {
2057 0x05, 0x02, 0x03
2058};
2059
2060/* seems analog CD is not working */
2061static struct hda_input_mux alc880_lg_capture_source = {
2062 .num_items = 3,
2063 .items = {
2064 { "Mic", 0x1 },
2065 { "Line", 0x5 },
2066 { "Internal Mic", 0x6 },
2067 },
2068};
2069
2070/* 2,4,6 channel modes */
2071static struct hda_verb alc880_lg_ch2_init[] = {
2072 /* set line-in and mic-in to input */
2073 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2074 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2075 { }
2076};
2077
2078static struct hda_verb alc880_lg_ch4_init[] = {
2079 /* set line-in to out and mic-in to input */
2080 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2081 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2082 { }
2083};
2084
2085static struct hda_verb alc880_lg_ch6_init[] = {
2086 /* set line-in and mic-in to output */
2087 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2088 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2089 { }
2090};
2091
2092static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2093 { 2, alc880_lg_ch2_init },
2094 { 4, alc880_lg_ch4_init },
2095 { 6, alc880_lg_ch6_init },
2096};
2097
2098static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002099 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2100 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002101 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2102 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2103 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2104 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2106 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2112 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2113 {
2114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2115 .name = "Channel Mode",
2116 .info = alc_ch_mode_info,
2117 .get = alc_ch_mode_get,
2118 .put = alc_ch_mode_put,
2119 },
2120 { } /* end */
2121};
2122
2123static struct hda_verb alc880_lg_init_verbs[] = {
2124 /* set capture source to mic-in */
2125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2128 /* mute all amp mixer inputs */
2129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002132 /* line-in to input */
2133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2135 /* built-in mic */
2136 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2138 /* speaker-out */
2139 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2140 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2141 /* mic-in to input */
2142 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2143 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2144 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2145 /* HP-out */
2146 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2147 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2148 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2149 /* jack sense */
2150 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2151 { }
2152};
2153
2154/* toggle speaker-output according to the hp-jack state */
2155static void alc880_lg_automute(struct hda_codec *codec)
2156{
2157 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002158 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002159
2160 present = snd_hda_codec_read(codec, 0x1b, 0,
2161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002162 bits = present ? HDA_AMP_MUTE : 0;
2163 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2164 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002165}
2166
2167static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2168{
2169 /* Looks like the unsol event is incompatible with the standard
2170 * definition. 4bit tag is placed at 28 bit!
2171 */
2172 if ((res >> 28) == 0x01)
2173 alc880_lg_automute(codec);
2174}
2175
2176/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002177 * LG LW20
2178 *
2179 * Pin assignment:
2180 * Speaker-out: 0x14
2181 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002182 * Built-in Mic-In: 0x19
2183 * Line-In: 0x1b
2184 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002185 * SPDIF-Out: 0x1e
2186 */
2187
Takashi Iwaid6815182006-03-23 16:06:23 +01002188static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002189 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002190 .items = {
2191 { "Mic", 0x0 },
2192 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002193 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002194 },
2195};
2196
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002197#define alc880_lg_lw_modes alc880_threestack_modes
2198
Takashi Iwaid6815182006-03-23 16:06:23 +01002199static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2203 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2209 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2213 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002214 {
2215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2216 .name = "Channel Mode",
2217 .info = alc_ch_mode_info,
2218 .get = alc_ch_mode_get,
2219 .put = alc_ch_mode_put,
2220 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002221 { } /* end */
2222};
2223
2224static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002225 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2226 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2227 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2228
Takashi Iwaid6815182006-03-23 16:06:23 +01002229 /* set capture source to mic-in */
2230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002234 /* speaker-out */
2235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2240 /* mic-in to input */
2241 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2243 /* built-in mic */
2244 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2245 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2246 /* jack sense */
2247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2248 { }
2249};
2250
2251/* toggle speaker-output according to the hp-jack state */
2252static void alc880_lg_lw_automute(struct hda_codec *codec)
2253{
2254 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002255 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002256
2257 present = snd_hda_codec_read(codec, 0x1b, 0,
2258 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002259 bits = present ? HDA_AMP_MUTE : 0;
2260 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2261 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002262}
2263
2264static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2265{
2266 /* Looks like the unsol event is incompatible with the standard
2267 * definition. 4bit tag is placed at 28 bit!
2268 */
2269 if ((res >> 28) == 0x01)
2270 alc880_lg_lw_automute(codec);
2271}
2272
Takashi Iwaicb53c622007-08-10 17:21:45 +02002273#ifdef CONFIG_SND_HDA_POWER_SAVE
2274static struct hda_amp_list alc880_loopbacks[] = {
2275 { 0x0b, HDA_INPUT, 0 },
2276 { 0x0b, HDA_INPUT, 1 },
2277 { 0x0b, HDA_INPUT, 2 },
2278 { 0x0b, HDA_INPUT, 3 },
2279 { 0x0b, HDA_INPUT, 4 },
2280 { } /* end */
2281};
2282
2283static struct hda_amp_list alc880_lg_loopbacks[] = {
2284 { 0x0b, HDA_INPUT, 1 },
2285 { 0x0b, HDA_INPUT, 6 },
2286 { 0x0b, HDA_INPUT, 7 },
2287 { } /* end */
2288};
2289#endif
2290
Takashi Iwaid6815182006-03-23 16:06:23 +01002291/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002292 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002293 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002294
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295static int alc_init(struct hda_codec *codec)
2296{
2297 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002298 unsigned int i;
2299
2300 for (i = 0; i < spec->num_init_verbs; i++)
2301 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002302
2303 if (spec->init_hook)
2304 spec->init_hook(codec);
2305
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 return 0;
2307}
2308
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002309static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2310{
2311 struct alc_spec *spec = codec->spec;
2312
2313 if (spec->unsol_event)
2314 spec->unsol_event(codec, res);
2315}
2316
Takashi Iwaicb53c622007-08-10 17:21:45 +02002317#ifdef CONFIG_SND_HDA_POWER_SAVE
2318static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2319{
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2322}
2323#endif
2324
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325/*
2326 * Analog playback callbacks
2327 */
2328static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2329 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002330 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331{
2332 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002333 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2334 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335}
2336
2337static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2338 struct hda_codec *codec,
2339 unsigned int stream_tag,
2340 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002341 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342{
2343 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002344 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2345 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346}
2347
2348static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002350 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351{
2352 struct alc_spec *spec = codec->spec;
2353 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2354}
2355
2356/*
2357 * Digital out
2358 */
2359static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2360 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002361 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362{
2363 struct alc_spec *spec = codec->spec;
2364 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2365}
2366
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002367static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 unsigned int stream_tag,
2370 unsigned int format,
2371 struct snd_pcm_substream *substream)
2372{
2373 struct alc_spec *spec = codec->spec;
2374 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2375 stream_tag, format, substream);
2376}
2377
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2379 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002380 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381{
2382 struct alc_spec *spec = codec->spec;
2383 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2384}
2385
2386/*
2387 * Analog capture
2388 */
Takashi Iwai63300792008-01-24 15:31:36 +01002389static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 struct hda_codec *codec,
2391 unsigned int stream_tag,
2392 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002393 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394{
2395 struct alc_spec *spec = codec->spec;
2396
Takashi Iwai63300792008-01-24 15:31:36 +01002397 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 stream_tag, 0, format);
2399 return 0;
2400}
2401
Takashi Iwai63300792008-01-24 15:31:36 +01002402static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002404 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405{
2406 struct alc_spec *spec = codec->spec;
2407
Takashi Iwai63300792008-01-24 15:31:36 +01002408 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002409 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 return 0;
2411}
2412
2413
2414/*
2415 */
2416static struct hda_pcm_stream alc880_pcm_analog_playback = {
2417 .substreams = 1,
2418 .channels_min = 2,
2419 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002420 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 .ops = {
2422 .open = alc880_playback_pcm_open,
2423 .prepare = alc880_playback_pcm_prepare,
2424 .cleanup = alc880_playback_pcm_cleanup
2425 },
2426};
2427
2428static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002429 .substreams = 1,
2430 .channels_min = 2,
2431 .channels_max = 2,
2432 /* NID is set in alc_build_pcms */
2433};
2434
2435static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2436 .substreams = 1,
2437 .channels_min = 2,
2438 .channels_max = 2,
2439 /* NID is set in alc_build_pcms */
2440};
2441
2442static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2443 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 .channels_min = 2,
2445 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002446 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002448 .prepare = alc880_alt_capture_pcm_prepare,
2449 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 },
2451};
2452
2453static struct hda_pcm_stream alc880_pcm_digital_playback = {
2454 .substreams = 1,
2455 .channels_min = 2,
2456 .channels_max = 2,
2457 /* NID is set in alc_build_pcms */
2458 .ops = {
2459 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002460 .close = alc880_dig_playback_pcm_close,
2461 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 },
2463};
2464
2465static struct hda_pcm_stream alc880_pcm_digital_capture = {
2466 .substreams = 1,
2467 .channels_min = 2,
2468 .channels_max = 2,
2469 /* NID is set in alc_build_pcms */
2470};
2471
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002472/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002473static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002474 .substreams = 0,
2475 .channels_min = 0,
2476 .channels_max = 0,
2477};
2478
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479static int alc_build_pcms(struct hda_codec *codec)
2480{
2481 struct alc_spec *spec = codec->spec;
2482 struct hda_pcm *info = spec->pcm_rec;
2483 int i;
2484
2485 codec->num_pcms = 1;
2486 codec->pcm_info = info;
2487
2488 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002489 if (spec->stream_analog_playback) {
2490 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2493 }
2494 if (spec->stream_analog_capture) {
2495 snd_assert(spec->adc_nids, return -EINVAL);
2496 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2497 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2498 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499
Takashi Iwai4a471b72005-12-07 13:56:29 +01002500 if (spec->channel_mode) {
2501 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2502 for (i = 0; i < spec->num_channel_mode; i++) {
2503 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2505 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506 }
2507 }
2508
Takashi Iwaie08a0072006-09-07 17:52:14 +02002509 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002511 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002512 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002514 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002515 if (spec->multiout.dig_out_nid &&
2516 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2518 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2519 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002520 if (spec->dig_in_nid &&
2521 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2523 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2524 }
2525 }
2526
Takashi Iwaie08a0072006-09-07 17:52:14 +02002527 /* If the use of more than one ADC is requested for the current
2528 * model, configure a second analog capture-only PCM.
2529 */
2530 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002531 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2532 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002533 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002534 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002535 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002536 if (spec->alt_dac_nid) {
2537 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2538 *spec->stream_analog_alt_playback;
2539 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2540 spec->alt_dac_nid;
2541 } else {
2542 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2543 alc_pcm_null_stream;
2544 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2545 }
2546 if (spec->num_adc_nids > 1) {
2547 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2548 *spec->stream_analog_alt_capture;
2549 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2550 spec->adc_nids[1];
2551 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2552 spec->num_adc_nids - 1;
2553 } else {
2554 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2555 alc_pcm_null_stream;
2556 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002557 }
2558 }
2559
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 return 0;
2561}
2562
2563static void alc_free(struct hda_codec *codec)
2564{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002565 struct alc_spec *spec = codec->spec;
2566 unsigned int i;
2567
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002568 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 return;
2570
2571 if (spec->kctl_alloc) {
2572 for (i = 0; i < spec->num_kctl_used; i++)
2573 kfree(spec->kctl_alloc[i].name);
2574 kfree(spec->kctl_alloc);
2575 }
2576 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577}
2578
2579/*
2580 */
2581static struct hda_codec_ops alc_patch_ops = {
2582 .build_controls = alc_build_controls,
2583 .build_pcms = alc_build_pcms,
2584 .init = alc_init,
2585 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002586 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002587#ifdef CONFIG_SND_HDA_POWER_SAVE
2588 .check_power_status = alc_check_power_status,
2589#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590};
2591
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002592
2593/*
2594 * Test configuration for debugging
2595 *
2596 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2597 * enum controls.
2598 */
2599#ifdef CONFIG_SND_DEBUG
2600static hda_nid_t alc880_test_dac_nids[4] = {
2601 0x02, 0x03, 0x04, 0x05
2602};
2603
2604static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002605 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002606 .items = {
2607 { "In-1", 0x0 },
2608 { "In-2", 0x1 },
2609 { "In-3", 0x2 },
2610 { "In-4", 0x3 },
2611 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002612 { "Front", 0x5 },
2613 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002614 },
2615};
2616
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002617static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002618 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002619 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002620 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002621 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002622};
2623
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002624static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002626{
2627 static char *texts[] = {
2628 "N/A", "Line Out", "HP Out",
2629 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2630 };
2631 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2632 uinfo->count = 1;
2633 uinfo->value.enumerated.items = 8;
2634 if (uinfo->value.enumerated.item >= 8)
2635 uinfo->value.enumerated.item = 7;
2636 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2637 return 0;
2638}
2639
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002640static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2641 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002642{
2643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2644 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2645 unsigned int pin_ctl, item = 0;
2646
2647 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2648 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2649 if (pin_ctl & AC_PINCTL_OUT_EN) {
2650 if (pin_ctl & AC_PINCTL_HP_EN)
2651 item = 2;
2652 else
2653 item = 1;
2654 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2655 switch (pin_ctl & AC_PINCTL_VREFEN) {
2656 case AC_PINCTL_VREF_HIZ: item = 3; break;
2657 case AC_PINCTL_VREF_50: item = 4; break;
2658 case AC_PINCTL_VREF_GRD: item = 5; break;
2659 case AC_PINCTL_VREF_80: item = 6; break;
2660 case AC_PINCTL_VREF_100: item = 7; break;
2661 }
2662 }
2663 ucontrol->value.enumerated.item[0] = item;
2664 return 0;
2665}
2666
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002667static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2668 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002669{
2670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2671 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2672 static unsigned int ctls[] = {
2673 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2674 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2675 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2676 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2677 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2678 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2679 };
2680 unsigned int old_ctl, new_ctl;
2681
2682 old_ctl = snd_hda_codec_read(codec, nid, 0,
2683 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2684 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2685 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002686 int val;
2687 snd_hda_codec_write_cache(codec, nid, 0,
2688 AC_VERB_SET_PIN_WIDGET_CONTROL,
2689 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002690 val = ucontrol->value.enumerated.item[0] >= 3 ?
2691 HDA_AMP_MUTE : 0;
2692 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2693 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002694 return 1;
2695 }
2696 return 0;
2697}
2698
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002699static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2700 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002701{
2702 static char *texts[] = {
2703 "Front", "Surround", "CLFE", "Side"
2704 };
2705 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2706 uinfo->count = 1;
2707 uinfo->value.enumerated.items = 4;
2708 if (uinfo->value.enumerated.item >= 4)
2709 uinfo->value.enumerated.item = 3;
2710 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2711 return 0;
2712}
2713
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002714static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2715 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002716{
2717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2718 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2719 unsigned int sel;
2720
2721 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2722 ucontrol->value.enumerated.item[0] = sel & 3;
2723 return 0;
2724}
2725
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002726static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2727 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002728{
2729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2730 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2731 unsigned int sel;
2732
2733 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2734 if (ucontrol->value.enumerated.item[0] != sel) {
2735 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002736 snd_hda_codec_write_cache(codec, nid, 0,
2737 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002738 return 1;
2739 }
2740 return 0;
2741}
2742
2743#define PIN_CTL_TEST(xname,nid) { \
2744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2745 .name = xname, \
2746 .info = alc_test_pin_ctl_info, \
2747 .get = alc_test_pin_ctl_get, \
2748 .put = alc_test_pin_ctl_put, \
2749 .private_value = nid \
2750 }
2751
2752#define PIN_SRC_TEST(xname,nid) { \
2753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2754 .name = xname, \
2755 .info = alc_test_pin_src_info, \
2756 .get = alc_test_pin_src_get, \
2757 .put = alc_test_pin_src_put, \
2758 .private_value = nid \
2759 }
2760
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002761static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2764 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2765 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002766 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2767 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2768 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2769 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002770 PIN_CTL_TEST("Front Pin Mode", 0x14),
2771 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2772 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2773 PIN_CTL_TEST("Side Pin Mode", 0x17),
2774 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2775 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2776 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2777 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2778 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2779 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2780 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2781 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2782 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2783 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2784 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2785 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2786 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2787 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2788 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2789 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2790 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2791 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002792 {
2793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2794 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002795 .info = alc_ch_mode_info,
2796 .get = alc_ch_mode_get,
2797 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002798 },
2799 { } /* end */
2800};
2801
2802static struct hda_verb alc880_test_init_verbs[] = {
2803 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002812 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2816 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002817 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2820 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2821 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002822 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2826 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002827 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2829 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2832 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002833 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002838 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002842 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002844 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002845 /* Analog input/passthru */
2846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002851 { }
2852};
2853#endif
2854
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855/*
2856 */
2857
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002858static const char *alc880_models[ALC880_MODEL_LAST] = {
2859 [ALC880_3ST] = "3stack",
2860 [ALC880_TCL_S700] = "tcl",
2861 [ALC880_3ST_DIG] = "3stack-digout",
2862 [ALC880_CLEVO] = "clevo",
2863 [ALC880_5ST] = "5stack",
2864 [ALC880_5ST_DIG] = "5stack-digout",
2865 [ALC880_W810] = "w810",
2866 [ALC880_Z71V] = "z71v",
2867 [ALC880_6ST] = "6stack",
2868 [ALC880_6ST_DIG] = "6stack-digout",
2869 [ALC880_ASUS] = "asus",
2870 [ALC880_ASUS_W1V] = "asus-w1v",
2871 [ALC880_ASUS_DIG] = "asus-dig",
2872 [ALC880_ASUS_DIG2] = "asus-dig2",
2873 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002874 [ALC880_UNIWILL_P53] = "uniwill-p53",
2875 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002876 [ALC880_F1734] = "F1734",
2877 [ALC880_LG] = "lg",
2878 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002879#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002880 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002881#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002882 [ALC880_AUTO] = "auto",
2883};
2884
2885static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002886 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002887 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2888 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2889 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2890 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2891 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2892 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2893 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2894 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002895 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2896 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002897 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2898 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2899 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2900 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2901 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2902 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2903 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2904 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2905 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2906 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002907 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002908 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2909 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2910 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002911 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002912 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002913 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2914 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002915 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2916 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002917 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2918 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2919 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2920 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002921 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2922 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002923 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002924 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002925 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002926 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002927 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2928 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002929 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2930 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002931 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002932 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002933 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002934 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002935 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002936 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2937 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002938 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002939 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2940 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2941 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2942 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002943 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2944 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002945 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002946 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002947 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2948 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002949 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2950 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2951 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002952 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2953 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2954 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 {}
2956};
2957
Takashi Iwai16ded522005-06-10 19:58:24 +02002958/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002959 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002960 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002961static struct alc_config_preset alc880_presets[] = {
2962 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002964 .init_verbs = { alc880_volume_init_verbs,
2965 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002966 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002967 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002968 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2969 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002970 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002971 .input_mux = &alc880_capture_source,
2972 },
2973 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002975 .init_verbs = { alc880_volume_init_verbs,
2976 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002977 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002978 .dac_nids = alc880_dac_nids,
2979 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002980 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2981 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002982 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 .input_mux = &alc880_capture_source,
2984 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002985 [ALC880_TCL_S700] = {
2986 .mixers = { alc880_tcl_s700_mixer },
2987 .init_verbs = { alc880_volume_init_verbs,
2988 alc880_pin_tcl_S700_init_verbs,
2989 alc880_gpio2_init_verbs },
2990 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2991 .dac_nids = alc880_dac_nids,
2992 .hp_nid = 0x03,
2993 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2994 .channel_mode = alc880_2_jack_modes,
2995 .input_mux = &alc880_capture_source,
2996 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002997 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002998 .mixers = { alc880_three_stack_mixer,
2999 alc880_five_stack_mixer},
3000 .init_verbs = { alc880_volume_init_verbs,
3001 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3003 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003004 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3005 .channel_mode = alc880_fivestack_modes,
3006 .input_mux = &alc880_capture_source,
3007 },
3008 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003009 .mixers = { alc880_three_stack_mixer,
3010 alc880_five_stack_mixer },
3011 .init_verbs = { alc880_volume_init_verbs,
3012 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003013 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3014 .dac_nids = alc880_dac_nids,
3015 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3017 .channel_mode = alc880_fivestack_modes,
3018 .input_mux = &alc880_capture_source,
3019 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003020 [ALC880_6ST] = {
3021 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003022 .init_verbs = { alc880_volume_init_verbs,
3023 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003024 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3025 .dac_nids = alc880_6st_dac_nids,
3026 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3027 .channel_mode = alc880_sixstack_modes,
3028 .input_mux = &alc880_6stack_capture_source,
3029 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003030 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003032 .init_verbs = { alc880_volume_init_verbs,
3033 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003034 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3035 .dac_nids = alc880_6st_dac_nids,
3036 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003037 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3038 .channel_mode = alc880_sixstack_modes,
3039 .input_mux = &alc880_6stack_capture_source,
3040 },
3041 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003043 .init_verbs = { alc880_volume_init_verbs,
3044 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003045 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003046 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3047 .dac_nids = alc880_w810_dac_nids,
3048 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3050 .channel_mode = alc880_w810_modes,
3051 .input_mux = &alc880_capture_source,
3052 },
3053 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003055 .init_verbs = { alc880_volume_init_verbs,
3056 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003057 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3058 .dac_nids = alc880_z71v_dac_nids,
3059 .dig_out_nid = ALC880_DIGOUT_NID,
3060 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3062 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003063 .input_mux = &alc880_capture_source,
3064 },
3065 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003067 .init_verbs = { alc880_volume_init_verbs,
3068 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3070 .dac_nids = alc880_f1734_dac_nids,
3071 .hp_nid = 0x02,
3072 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3073 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003074 .input_mux = &alc880_f1734_capture_source,
3075 .unsol_event = alc880_uniwill_p53_unsol_event,
3076 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003077 },
3078 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003080 .init_verbs = { alc880_volume_init_verbs,
3081 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 alc880_gpio1_init_verbs },
3083 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3084 .dac_nids = alc880_asus_dac_nids,
3085 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3086 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003087 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003088 .input_mux = &alc880_capture_source,
3089 },
3090 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003092 .init_verbs = { alc880_volume_init_verbs,
3093 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 alc880_gpio1_init_verbs },
3095 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3096 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003097 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3099 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003100 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003101 .input_mux = &alc880_capture_source,
3102 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003103 [ALC880_ASUS_DIG2] = {
3104 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003105 .init_verbs = { alc880_volume_init_verbs,
3106 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003107 alc880_gpio2_init_verbs }, /* use GPIO2 */
3108 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3109 .dac_nids = alc880_asus_dac_nids,
3110 .dig_out_nid = ALC880_DIGOUT_NID,
3111 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3112 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003113 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003114 .input_mux = &alc880_capture_source,
3115 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003116 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003118 .init_verbs = { alc880_volume_init_verbs,
3119 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 alc880_gpio1_init_verbs },
3121 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3122 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3125 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .input_mux = &alc880_capture_source,
3128 },
3129 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003130 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003131 .init_verbs = { alc880_volume_init_verbs,
3132 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3134 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3137 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003138 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 .input_mux = &alc880_capture_source,
3140 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003141 [ALC880_UNIWILL] = {
3142 .mixers = { alc880_uniwill_mixer },
3143 .init_verbs = { alc880_volume_init_verbs,
3144 alc880_uniwill_init_verbs },
3145 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3146 .dac_nids = alc880_asus_dac_nids,
3147 .dig_out_nid = ALC880_DIGOUT_NID,
3148 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3149 .channel_mode = alc880_threestack_modes,
3150 .need_dac_fix = 1,
3151 .input_mux = &alc880_capture_source,
3152 .unsol_event = alc880_uniwill_unsol_event,
3153 .init_hook = alc880_uniwill_automute,
3154 },
3155 [ALC880_UNIWILL_P53] = {
3156 .mixers = { alc880_uniwill_p53_mixer },
3157 .init_verbs = { alc880_volume_init_verbs,
3158 alc880_uniwill_p53_init_verbs },
3159 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3160 .dac_nids = alc880_asus_dac_nids,
3161 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003162 .channel_mode = alc880_threestack_modes,
3163 .input_mux = &alc880_capture_source,
3164 .unsol_event = alc880_uniwill_p53_unsol_event,
3165 .init_hook = alc880_uniwill_p53_hp_automute,
3166 },
3167 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003168 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003169 alc880_pcbeep_mixer, },
3170 .init_verbs = { alc880_volume_init_verbs,
3171 alc880_uniwill_p53_init_verbs,
3172 alc880_beep_init_verbs },
3173 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3174 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003175 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003176 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3177 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003178 .input_mux = &alc880_capture_source,
3179 .unsol_event = alc880_uniwill_p53_unsol_event,
3180 .init_hook = alc880_uniwill_p53_hp_automute,
3181 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003182 [ALC880_CLEVO] = {
3183 .mixers = { alc880_three_stack_mixer },
3184 .init_verbs = { alc880_volume_init_verbs,
3185 alc880_pin_clevo_init_verbs },
3186 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3187 .dac_nids = alc880_dac_nids,
3188 .hp_nid = 0x03,
3189 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3190 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003191 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003192 .input_mux = &alc880_capture_source,
3193 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003194 [ALC880_LG] = {
3195 .mixers = { alc880_lg_mixer },
3196 .init_verbs = { alc880_volume_init_verbs,
3197 alc880_lg_init_verbs },
3198 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3199 .dac_nids = alc880_lg_dac_nids,
3200 .dig_out_nid = ALC880_DIGOUT_NID,
3201 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3202 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003203 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003204 .input_mux = &alc880_lg_capture_source,
3205 .unsol_event = alc880_lg_unsol_event,
3206 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003207#ifdef CONFIG_SND_HDA_POWER_SAVE
3208 .loopbacks = alc880_lg_loopbacks,
3209#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003210 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003211 [ALC880_LG_LW] = {
3212 .mixers = { alc880_lg_lw_mixer },
3213 .init_verbs = { alc880_volume_init_verbs,
3214 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003215 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003216 .dac_nids = alc880_dac_nids,
3217 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003218 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3219 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003220 .input_mux = &alc880_lg_lw_capture_source,
3221 .unsol_event = alc880_lg_lw_unsol_event,
3222 .init_hook = alc880_lg_lw_automute,
3223 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003224#ifdef CONFIG_SND_DEBUG
3225 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 .mixers = { alc880_test_mixer },
3227 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003228 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3229 .dac_nids = alc880_test_dac_nids,
3230 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003231 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3232 .channel_mode = alc880_test_modes,
3233 .input_mux = &alc880_test_capture_source,
3234 },
3235#endif
3236};
3237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238/*
3239 * Automatic parse of I/O pins from the BIOS configuration
3240 */
3241
3242#define NUM_CONTROL_ALLOC 32
3243#define NUM_VERB_ALLOC 32
3244
3245enum {
3246 ALC_CTL_WIDGET_VOL,
3247 ALC_CTL_WIDGET_MUTE,
3248 ALC_CTL_BIND_MUTE,
3249};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003250static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3252 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003253 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254};
3255
3256/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003257static int add_control(struct alc_spec *spec, int type, const char *name,
3258 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003260 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261
3262 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3263 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3264
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003265 /* array + terminator */
3266 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3267 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 return -ENOMEM;
3269 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003270 memcpy(knew, spec->kctl_alloc,
3271 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 kfree(spec->kctl_alloc);
3273 }
3274 spec->kctl_alloc = knew;
3275 spec->num_kctl_alloc = num;
3276 }
3277
3278 knew = &spec->kctl_alloc[spec->num_kctl_used];
3279 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003280 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003281 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 return -ENOMEM;
3283 knew->private_value = val;
3284 spec->num_kctl_used++;
3285 return 0;
3286}
3287
3288#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3289#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3290#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3291#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3292#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3293#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3294#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3295#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3296#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3297#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3298#define ALC880_PIN_CD_NID 0x1c
3299
3300/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003301static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3302 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003303{
3304 hda_nid_t nid;
3305 int assigned[4];
3306 int i, j;
3307
3308 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003309 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003310
3311 /* check the pins hardwired to audio widget */
3312 for (i = 0; i < cfg->line_outs; i++) {
3313 nid = cfg->line_out_pins[i];
3314 if (alc880_is_fixed_pin(nid)) {
3315 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003316 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 assigned[idx] = 1;
3318 }
3319 }
3320 /* left pins can be connect to any audio widget */
3321 for (i = 0; i < cfg->line_outs; i++) {
3322 nid = cfg->line_out_pins[i];
3323 if (alc880_is_fixed_pin(nid))
3324 continue;
3325 /* search for an empty channel */
3326 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003327 if (!assigned[j]) {
3328 spec->multiout.dac_nids[i] =
3329 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330 assigned[j] = 1;
3331 break;
3332 }
3333 }
3334 }
3335 spec->multiout.num_dacs = cfg->line_outs;
3336 return 0;
3337}
3338
3339/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003340static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3341 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003342{
3343 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003344 static const char *chname[4] = {
3345 "Front", "Surround", NULL /*CLFE*/, "Side"
3346 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003347 hda_nid_t nid;
3348 int i, err;
3349
3350 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003351 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 continue;
3353 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3354 if (i == 2) {
3355 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003356 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3357 "Center Playback Volume",
3358 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3359 HDA_OUTPUT));
3360 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003361 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003362 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3363 "LFE Playback Volume",
3364 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3365 HDA_OUTPUT));
3366 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003368 err = add_control(spec, ALC_CTL_BIND_MUTE,
3369 "Center Playback Switch",
3370 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3371 HDA_INPUT));
3372 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003373 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003374 err = add_control(spec, ALC_CTL_BIND_MUTE,
3375 "LFE Playback Switch",
3376 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3377 HDA_INPUT));
3378 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 return err;
3380 } else {
3381 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003382 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3383 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3384 HDA_OUTPUT));
3385 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003386 return err;
3387 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003388 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3389 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3390 HDA_INPUT));
3391 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003392 return err;
3393 }
3394 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 return 0;
3396}
3397
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003398/* add playback controls for speaker and HP outputs */
3399static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3400 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003401{
3402 hda_nid_t nid;
3403 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003404 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003405
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003406 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407 return 0;
3408
3409 if (alc880_is_fixed_pin(pin)) {
3410 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003411 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003412 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003413 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003414 else
3415 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 /* control HP volume/switch on the output mixer amp */
3417 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003418 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003419 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3420 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3421 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003422 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003423 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3425 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3426 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427 return err;
3428 } else if (alc880_is_multi_pin(pin)) {
3429 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003431 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003432 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3433 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3434 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003435 return err;
3436 }
3437 return 0;
3438}
3439
3440/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3442 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003443 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003444{
3445 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003446 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447
3448 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003449 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3450 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3451 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452 return err;
3453 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003454 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3455 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3456 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003457 return err;
3458 return 0;
3459}
3460
3461/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003462static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3463 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003466 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003467
3468 for (i = 0; i < AUTO_PIN_LAST; i++) {
3469 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003470 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003471 err = new_analog_input(spec, cfg->input_pins[i],
3472 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003473 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 if (err < 0)
3475 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003476 imux->items[imux->num_items].label =
3477 auto_pin_cfg_labels[i];
3478 imux->items[imux->num_items].index =
3479 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480 imux->num_items++;
3481 }
3482 }
3483 return 0;
3484}
3485
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003486static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3487 unsigned int pin_type)
3488{
3489 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3490 pin_type);
3491 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003492 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3493 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003494}
3495
Kailang Yangdf694da2005-12-05 19:42:22 +01003496static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3497 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498 int dac_idx)
3499{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003500 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 /* need the manual connection? */
3502 if (alc880_is_multi_pin(nid)) {
3503 struct alc_spec *spec = codec->spec;
3504 int idx = alc880_multi_pin_idx(nid);
3505 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3506 AC_VERB_SET_CONNECT_SEL,
3507 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3508 }
3509}
3510
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003511static int get_pin_type(int line_out_type)
3512{
3513 if (line_out_type == AUTO_PIN_HP_OUT)
3514 return PIN_HP;
3515 else
3516 return PIN_OUT;
3517}
3518
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519static void alc880_auto_init_multi_out(struct hda_codec *codec)
3520{
3521 struct alc_spec *spec = codec->spec;
3522 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003523
3524 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 for (i = 0; i < spec->autocfg.line_outs; i++) {
3526 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003527 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3528 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003529 }
3530}
3531
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003532static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533{
3534 struct alc_spec *spec = codec->spec;
3535 hda_nid_t pin;
3536
Takashi Iwai82bc9552006-03-21 11:24:42 +01003537 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003538 if (pin) /* connect to front */
3539 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003540 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003541 if (pin) /* connect to front */
3542 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3543}
3544
3545static void alc880_auto_init_analog_input(struct hda_codec *codec)
3546{
3547 struct alc_spec *spec = codec->spec;
3548 int i;
3549
3550 for (i = 0; i < AUTO_PIN_LAST; i++) {
3551 hda_nid_t nid = spec->autocfg.input_pins[i];
3552 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003553 snd_hda_codec_write(codec, nid, 0,
3554 AC_VERB_SET_PIN_WIDGET_CONTROL,
3555 i <= AUTO_PIN_FRONT_MIC ?
3556 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003558 snd_hda_codec_write(codec, nid, 0,
3559 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003560 AMP_OUT_MUTE);
3561 }
3562 }
3563}
3564
3565/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003566/* return 1 if successful, 0 if the proper config is not found,
3567 * or a negative error code
3568 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569static int alc880_parse_auto_config(struct hda_codec *codec)
3570{
3571 struct alc_spec *spec = codec->spec;
3572 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003573 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003575 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3576 alc880_ignore);
3577 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003579 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003581
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003582 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3583 if (err < 0)
3584 return err;
3585 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3586 if (err < 0)
3587 return err;
3588 err = alc880_auto_create_extra_out(spec,
3589 spec->autocfg.speaker_pins[0],
3590 "Speaker");
3591 if (err < 0)
3592 return err;
3593 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3594 "Headphone");
3595 if (err < 0)
3596 return err;
3597 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3598 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 return err;
3600
3601 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3602
3603 if (spec->autocfg.dig_out_pin)
3604 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3605 if (spec->autocfg.dig_in_pin)
3606 spec->dig_in_nid = ALC880_DIGIN_NID;
3607
3608 if (spec->kctl_alloc)
3609 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3610
3611 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3612
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003613 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003614 spec->input_mux = &spec->private_imux;
3615
3616 return 1;
3617}
3618
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003619/* additional initialization for auto-configuration model */
3620static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003621{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003622 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003624 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003626 if (spec->unsol_event)
3627 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628}
3629
3630/*
3631 * OK, here we have finally the patch for ALC880
3632 */
3633
Linus Torvalds1da177e2005-04-16 15:20:36 -07003634static int patch_alc880(struct hda_codec *codec)
3635{
3636 struct alc_spec *spec;
3637 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003638 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003639
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003640 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641 if (spec == NULL)
3642 return -ENOMEM;
3643
3644 codec->spec = spec;
3645
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003646 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3647 alc880_models,
3648 alc880_cfg_tbl);
3649 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003650 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3651 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003652 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003653 }
3654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003655 if (board_config == ALC880_AUTO) {
3656 /* automatic parse from the BIOS config */
3657 err = alc880_parse_auto_config(codec);
3658 if (err < 0) {
3659 alc_free(codec);
3660 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003661 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003662 printk(KERN_INFO
3663 "hda_codec: Cannot set up configuration "
3664 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003665 board_config = ALC880_3ST;
3666 }
3667 }
3668
Kailang Yangdf694da2005-12-05 19:42:22 +01003669 if (board_config != ALC880_AUTO)
3670 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003671
3672 spec->stream_name_analog = "ALC880 Analog";
3673 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3674 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003675 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003676
3677 spec->stream_name_digital = "ALC880 Digital";
3678 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3679 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3680
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003681 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003682 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003683 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003684 /* get type */
3685 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003686 if (wcap != AC_WID_AUD_IN) {
3687 spec->adc_nids = alc880_adc_nids_alt;
3688 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003689 spec->mixers[spec->num_mixers] =
3690 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 spec->num_mixers++;
3692 } else {
3693 spec->adc_nids = alc880_adc_nids;
3694 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3695 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3696 spec->num_mixers++;
3697 }
3698 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003699
Takashi Iwai2134ea42008-01-10 16:53:55 +01003700 spec->vmaster_nid = 0x0c;
3701
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003704 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003705#ifdef CONFIG_SND_HDA_POWER_SAVE
3706 if (!spec->loopback.amplist)
3707 spec->loopback.amplist = alc880_loopbacks;
3708#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709
3710 return 0;
3711}
3712
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003713
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714/*
3715 * ALC260 support
3716 */
3717
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003718static hda_nid_t alc260_dac_nids[1] = {
3719 /* front */
3720 0x02,
3721};
3722
3723static hda_nid_t alc260_adc_nids[1] = {
3724 /* ADC0 */
3725 0x04,
3726};
3727
Kailang Yangdf694da2005-12-05 19:42:22 +01003728static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003729 /* ADC1 */
3730 0x05,
3731};
3732
Kailang Yangdf694da2005-12-05 19:42:22 +01003733static hda_nid_t alc260_hp_adc_nids[2] = {
3734 /* ADC1, 0 */
3735 0x05, 0x04
3736};
3737
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003738/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3739 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3740 */
3741static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003742 /* ADC0, ADC1 */
3743 0x04, 0x05
3744};
3745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003746#define ALC260_DIGOUT_NID 0x03
3747#define ALC260_DIGIN_NID 0x06
3748
3749static struct hda_input_mux alc260_capture_source = {
3750 .num_items = 4,
3751 .items = {
3752 { "Mic", 0x0 },
3753 { "Front Mic", 0x1 },
3754 { "Line", 0x2 },
3755 { "CD", 0x4 },
3756 },
3757};
3758
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003759/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003760 * headphone jack and the internal CD lines since these are the only pins at
3761 * which audio can appear. For flexibility, also allow the option of
3762 * recording the mixer output on the second ADC (ADC0 doesn't have a
3763 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003764 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003765static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3766 {
3767 .num_items = 3,
3768 .items = {
3769 { "Mic/Line", 0x0 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x2 },
3772 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003773 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003774 {
3775 .num_items = 4,
3776 .items = {
3777 { "Mic/Line", 0x0 },
3778 { "CD", 0x4 },
3779 { "Headphone", 0x2 },
3780 { "Mixer", 0x5 },
3781 },
3782 },
3783
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003784};
3785
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003786/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3787 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003788 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003789static struct hda_input_mux alc260_acer_capture_sources[2] = {
3790 {
3791 .num_items = 4,
3792 .items = {
3793 { "Mic", 0x0 },
3794 { "Line", 0x2 },
3795 { "CD", 0x4 },
3796 { "Headphone", 0x5 },
3797 },
3798 },
3799 {
3800 .num_items = 5,
3801 .items = {
3802 { "Mic", 0x0 },
3803 { "Line", 0x2 },
3804 { "CD", 0x4 },
3805 { "Headphone", 0x6 },
3806 { "Mixer", 0x5 },
3807 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003808 },
3809};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003810/*
3811 * This is just place-holder, so there's something for alc_build_pcms to look
3812 * at when it calculates the maximum number of channels. ALC260 has no mixer
3813 * element which allows changing the channel mode, so the verb list is
3814 * never used.
3815 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003816static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817 { 2, NULL },
3818};
3819
Kailang Yangdf694da2005-12-05 19:42:22 +01003820
3821/* Mixer combinations
3822 *
3823 * basic: base_output + input + pc_beep + capture
3824 * HP: base_output + input + capture_alt
3825 * HP_3013: hp_3013 + input + capture
3826 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003827 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003828 */
3829
3830static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003831 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003832 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003833 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3834 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3835 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3836 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3837 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003838};
Kailang Yangdf694da2005-12-05 19:42:22 +01003839
3840static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003841 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3842 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3843 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3844 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3846 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3848 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849 { } /* end */
3850};
3851
Kailang Yangdf694da2005-12-05 19:42:22 +01003852static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3853 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3854 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3855 { } /* end */
3856};
3857
Takashi Iwaibec15c32008-01-28 18:16:30 +01003858/* update HP, line and mono out pins according to the master switch */
3859static void alc260_hp_master_update(struct hda_codec *codec,
3860 hda_nid_t hp, hda_nid_t line,
3861 hda_nid_t mono)
3862{
3863 struct alc_spec *spec = codec->spec;
3864 unsigned int val = spec->master_sw ? PIN_HP : 0;
3865 /* change HP and line-out pins */
3866 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3867 val);
3868 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3869 val);
3870 /* mono (speaker) depending on the HP jack sense */
3871 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3872 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3873 val);
3874}
3875
3876static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3877 struct snd_ctl_elem_value *ucontrol)
3878{
3879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3880 struct alc_spec *spec = codec->spec;
3881 *ucontrol->value.integer.value = spec->master_sw;
3882 return 0;
3883}
3884
3885static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3886 struct snd_ctl_elem_value *ucontrol)
3887{
3888 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3889 struct alc_spec *spec = codec->spec;
3890 int val = !!*ucontrol->value.integer.value;
3891 hda_nid_t hp, line, mono;
3892
3893 if (val == spec->master_sw)
3894 return 0;
3895 spec->master_sw = val;
3896 hp = (kcontrol->private_value >> 16) & 0xff;
3897 line = (kcontrol->private_value >> 8) & 0xff;
3898 mono = kcontrol->private_value & 0xff;
3899 alc260_hp_master_update(codec, hp, line, mono);
3900 return 1;
3901}
3902
3903static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3904 {
3905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3906 .name = "Master Playback Switch",
3907 .info = snd_ctl_boolean_mono_info,
3908 .get = alc260_hp_master_sw_get,
3909 .put = alc260_hp_master_sw_put,
3910 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3911 },
3912 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3913 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3915 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3916 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3917 HDA_OUTPUT),
3918 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3919 { } /* end */
3920};
3921
3922static struct hda_verb alc260_hp_unsol_verbs[] = {
3923 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3924 {},
3925};
3926
3927static void alc260_hp_automute(struct hda_codec *codec)
3928{
3929 struct alc_spec *spec = codec->spec;
3930 unsigned int present;
3931
3932 present = snd_hda_codec_read(codec, 0x10, 0,
3933 AC_VERB_GET_PIN_SENSE, 0);
3934 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3935 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3936}
3937
3938static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3939{
3940 if ((res >> 26) == ALC880_HP_EVENT)
3941 alc260_hp_automute(codec);
3942}
3943
Kailang Yangdf694da2005-12-05 19:42:22 +01003944static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003945 {
3946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3947 .name = "Master Playback Switch",
3948 .info = snd_ctl_boolean_mono_info,
3949 .get = alc260_hp_master_sw_get,
3950 .put = alc260_hp_master_sw_put,
3951 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3952 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003953 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3954 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3955 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3956 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003959 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3960 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003961 { } /* end */
3962};
3963
Takashi Iwaibec15c32008-01-28 18:16:30 +01003964static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3965 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3966 {},
3967};
3968
3969static void alc260_hp_3013_automute(struct hda_codec *codec)
3970{
3971 struct alc_spec *spec = codec->spec;
3972 unsigned int present;
3973
3974 present = snd_hda_codec_read(codec, 0x15, 0,
3975 AC_VERB_GET_PIN_SENSE, 0);
3976 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3977 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3978}
3979
3980static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3981 unsigned int res)
3982{
3983 if ((res >> 26) == ALC880_HP_EVENT)
3984 alc260_hp_3013_automute(codec);
3985}
3986
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003987/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3988 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3989 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003990static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003992 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003993 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003994 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3995 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3996 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3997 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003998 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003999 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4000 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004001 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4002 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 { } /* end */
4004};
4005
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004006/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4007 * versions of the ALC260 don't act on requests to enable mic bias from NID
4008 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4009 * datasheet doesn't mention this restriction. At this stage it's not clear
4010 * whether this behaviour is intentional or is a hardware bug in chip
4011 * revisions available in early 2006. Therefore for now allow the
4012 * "Headphone Jack Mode" control to span all choices, but if it turns out
4013 * that the lack of mic bias for this NID is intentional we could change the
4014 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4015 *
4016 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4017 * don't appear to make the mic bias available from the "line" jack, even
4018 * though the NID used for this jack (0x14) can supply it. The theory is
4019 * that perhaps Acer have included blocking capacitors between the ALC260
4020 * and the output jack. If this turns out to be the case for all such
4021 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4022 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004023 *
4024 * The C20x Tablet series have a mono internal speaker which is controlled
4025 * via the chip's Mono sum widget and pin complex, so include the necessary
4026 * controls for such models. On models without a "mono speaker" the control
4027 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004028 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004029static struct snd_kcontrol_new alc260_acer_mixer[] = {
4030 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4031 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004032 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004033 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004034 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004035 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004036 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004037 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4038 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4040 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4041 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4042 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4043 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4044 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4045 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4046 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4047 { } /* end */
4048};
4049
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004050/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4051 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4052 */
4053static struct snd_kcontrol_new alc260_will_mixer[] = {
4054 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4055 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4057 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4058 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4059 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4060 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4061 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4062 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4063 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4064 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4065 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4066 { } /* end */
4067};
4068
4069/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4070 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4071 */
4072static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4073 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4074 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4076 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4077 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4078 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4079 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4080 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4081 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4082 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4083 { } /* end */
4084};
4085
Kailang Yangdf694da2005-12-05 19:42:22 +01004086/* capture mixer elements */
4087static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004088 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4089 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004090 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4091 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004092 {
4093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004094 /* The multiple "Capture Source" controls confuse alsamixer
4095 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004096 */
4097 /* .name = "Capture Source", */
4098 .name = "Input Source",
4099 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004100 .info = alc_mux_enum_info,
4101 .get = alc_mux_enum_get,
4102 .put = alc_mux_enum_put,
4103 },
4104 { } /* end */
4105};
4106
Kailang Yangdf694da2005-12-05 19:42:22 +01004107static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4108 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4109 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4110 {
4111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4112 /* The multiple "Capture Source" controls confuse alsamixer
4113 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004114 */
4115 /* .name = "Capture Source", */
4116 .name = "Input Source",
4117 .count = 1,
4118 .info = alc_mux_enum_info,
4119 .get = alc_mux_enum_get,
4120 .put = alc_mux_enum_put,
4121 },
4122 { } /* end */
4123};
4124
4125/*
4126 * initialization verbs
4127 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128static struct hda_verb alc260_init_verbs[] = {
4129 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004130 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004132 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004133 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004134 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004137 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004140 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004141 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004142 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004144 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004145 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004146 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4147 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004149 /* set connection select to line in (default select for this ADC) */
4150 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 /* mute capture amp left and right */
4152 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4153 /* set connection select to line in (default select for this ADC) */
4154 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004155 /* set vol=0 Line-Out mixer amp left and right */
4156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4157 /* unmute pin widget amp left and right (no gain on this amp) */
4158 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4159 /* set vol=0 HP mixer amp left and right */
4160 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4161 /* unmute pin widget amp left and right (no gain on this amp) */
4162 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4163 /* set vol=0 Mono mixer amp left and right */
4164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4165 /* unmute pin widget amp left and right (no gain on this amp) */
4166 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4167 /* unmute LINE-2 out pin */
4168 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004169 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4170 * Line In 2 = 0x03
4171 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004172 /* mute analog inputs */
4173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004178 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004179 /* mute Front out path */
4180 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4181 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4182 /* mute Headphone out path */
4183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4185 /* mute Mono out path */
4186 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4187 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004188 { }
4189};
4190
Takashi Iwai474167d2006-05-17 17:17:43 +02004191#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004192static struct hda_verb alc260_hp_init_verbs[] = {
4193 /* Headphone and output */
4194 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4195 /* mono output */
4196 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4197 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4198 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4199 /* Mic2 (front panel) pin widget for input and vref at 80% */
4200 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4201 /* Line In pin widget for input */
4202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4203 /* Line-2 pin widget for output */
4204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4205 /* CD pin widget for input */
4206 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4207 /* unmute amp left and right */
4208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4209 /* set connection select to line in (default select for this ADC) */
4210 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4211 /* unmute Line-Out mixer amp left and right (volume = 0) */
4212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4213 /* mute pin widget amp left and right (no gain on this amp) */
4214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4215 /* unmute HP mixer amp left and right (volume = 0) */
4216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4217 /* mute pin widget amp left and right (no gain on this amp) */
4218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004219 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4220 * Line In 2 = 0x03
4221 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004222 /* mute analog inputs */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004228 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4229 /* Unmute Front out path */
4230 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4232 /* Unmute Headphone out path */
4233 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4235 /* Unmute Mono out path */
4236 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4237 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4238 { }
4239};
Takashi Iwai474167d2006-05-17 17:17:43 +02004240#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004241
4242static struct hda_verb alc260_hp_3013_init_verbs[] = {
4243 /* Line out and output */
4244 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4245 /* mono output */
4246 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4247 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4248 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4249 /* Mic2 (front panel) pin widget for input and vref at 80% */
4250 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4251 /* Line In pin widget for input */
4252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4253 /* Headphone pin widget for output */
4254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4255 /* CD pin widget for input */
4256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4257 /* unmute amp left and right */
4258 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4259 /* set connection select to line in (default select for this ADC) */
4260 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4261 /* unmute Line-Out mixer amp left and right (volume = 0) */
4262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4263 /* mute pin widget amp left and right (no gain on this amp) */
4264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4265 /* unmute HP mixer amp left and right (volume = 0) */
4266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4267 /* mute pin widget amp left and right (no gain on this amp) */
4268 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004269 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4270 * Line In 2 = 0x03
4271 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004272 /* mute analog inputs */
4273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004278 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4279 /* Unmute Front out path */
4280 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4282 /* Unmute Headphone out path */
4283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4285 /* Unmute Mono out path */
4286 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4287 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4288 { }
4289};
4290
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004291/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004292 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4293 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004294 */
4295static struct hda_verb alc260_fujitsu_init_verbs[] = {
4296 /* Disable all GPIOs */
4297 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4298 /* Internal speaker is connected to headphone pin */
4299 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4300 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004302 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4303 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4304 /* Ensure all other unused pins are disabled and muted. */
4305 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004307 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004308 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004309 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004310 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004313
Jonathan Woithef7ace402006-02-28 11:46:14 +01004314 /* Disable digital (SPDIF) pins */
4315 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4316 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004317
Jonathan Woithef7ace402006-02-28 11:46:14 +01004318 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4319 * when acting as an output.
4320 */
4321 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4322
4323 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4328 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4329 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4330 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4331 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4332 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004333
Jonathan Woithef7ace402006-02-28 11:46:14 +01004334 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4335 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4336 /* Unmute Line1 pin widget output buffer since it starts as an output.
4337 * If the pin mode is changed by the user the pin mode control will
4338 * take care of enabling the pin's input/output buffers as needed.
4339 * Therefore there's no need to enable the input buffer at this
4340 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004341 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004342 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004343 /* Unmute input buffer of pin widget used for Line-in (no equiv
4344 * mixer ctrl)
4345 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004346 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004347
Jonathan Woithef7ace402006-02-28 11:46:14 +01004348 /* Mute capture amp left and right */
4349 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4350 /* Set ADC connection select to match default mixer setting - line
4351 * in (on mic1 pin)
4352 */
4353 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004354
Jonathan Woithef7ace402006-02-28 11:46:14 +01004355 /* Do the same for the second ADC: mute capture input amp and
4356 * set ADC connection to line in (on mic1 pin)
4357 */
4358 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4359 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004360
Jonathan Woithef7ace402006-02-28 11:46:14 +01004361 /* Mute all inputs to mixer widget (even unconnected ones) */
4362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004370
4371 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004372};
4373
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004374/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4375 * similar laptops (adapted from Fujitsu init verbs).
4376 */
4377static struct hda_verb alc260_acer_init_verbs[] = {
4378 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4379 * the headphone jack. Turn this on and rely on the standard mute
4380 * methods whenever the user wants to turn these outputs off.
4381 */
4382 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4383 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4384 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4385 /* Internal speaker/Headphone jack is connected to Line-out pin */
4386 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4387 /* Internal microphone/Mic jack is connected to Mic1 pin */
4388 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4389 /* Line In jack is connected to Line1 pin */
4390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004391 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4392 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004393 /* Ensure all other unused pins are disabled and muted. */
4394 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004396 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4397 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4400 /* Disable digital (SPDIF) pins */
4401 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4402 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4403
4404 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4405 * bus when acting as outputs.
4406 */
4407 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4408 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4409
4410 /* Start with output sum widgets muted and their output gains at min */
4411 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4412 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4414 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4415 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4417 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4418 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4419 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4420
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004421 /* Unmute Line-out pin widget amp left and right
4422 * (no equiv mixer ctrl)
4423 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004424 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004425 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4426 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004427 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4428 * inputs. If the pin mode is changed by the user the pin mode control
4429 * will take care of enabling the pin's input/output buffers as needed.
4430 * Therefore there's no need to enable the input buffer at this
4431 * stage.
4432 */
4433 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4435
4436 /* Mute capture amp left and right */
4437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4438 /* Set ADC connection select to match default mixer setting - mic
4439 * (on mic1 pin)
4440 */
4441 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4442
4443 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004444 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004445 */
4446 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004447 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004448
4449 /* Mute all inputs to mixer widget (even unconnected ones) */
4450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4458
4459 { }
4460};
4461
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004462static struct hda_verb alc260_will_verbs[] = {
4463 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4464 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4465 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4466 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4467 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4468 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4469 {}
4470};
4471
4472static struct hda_verb alc260_replacer_672v_verbs[] = {
4473 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4474 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4475 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4476
4477 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4478 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4479 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4480
4481 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4482 {}
4483};
4484
4485/* toggle speaker-output according to the hp-jack state */
4486static void alc260_replacer_672v_automute(struct hda_codec *codec)
4487{
4488 unsigned int present;
4489
4490 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4491 present = snd_hda_codec_read(codec, 0x0f, 0,
4492 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4493 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004494 snd_hda_codec_write_cache(codec, 0x01, 0,
4495 AC_VERB_SET_GPIO_DATA, 1);
4496 snd_hda_codec_write_cache(codec, 0x0f, 0,
4497 AC_VERB_SET_PIN_WIDGET_CONTROL,
4498 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004499 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004500 snd_hda_codec_write_cache(codec, 0x01, 0,
4501 AC_VERB_SET_GPIO_DATA, 0);
4502 snd_hda_codec_write_cache(codec, 0x0f, 0,
4503 AC_VERB_SET_PIN_WIDGET_CONTROL,
4504 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004505 }
4506}
4507
4508static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4509 unsigned int res)
4510{
4511 if ((res >> 26) == ALC880_HP_EVENT)
4512 alc260_replacer_672v_automute(codec);
4513}
4514
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004515/* Test configuration for debugging, modelled after the ALC880 test
4516 * configuration.
4517 */
4518#ifdef CONFIG_SND_DEBUG
4519static hda_nid_t alc260_test_dac_nids[1] = {
4520 0x02,
4521};
4522static hda_nid_t alc260_test_adc_nids[2] = {
4523 0x04, 0x05,
4524};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525/* For testing the ALC260, each input MUX needs its own definition since
4526 * the signal assignments are different. This assumes that the first ADC
4527 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004528 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004529static struct hda_input_mux alc260_test_capture_sources[2] = {
4530 {
4531 .num_items = 7,
4532 .items = {
4533 { "MIC1 pin", 0x0 },
4534 { "MIC2 pin", 0x1 },
4535 { "LINE1 pin", 0x2 },
4536 { "LINE2 pin", 0x3 },
4537 { "CD pin", 0x4 },
4538 { "LINE-OUT pin", 0x5 },
4539 { "HP-OUT pin", 0x6 },
4540 },
4541 },
4542 {
4543 .num_items = 8,
4544 .items = {
4545 { "MIC1 pin", 0x0 },
4546 { "MIC2 pin", 0x1 },
4547 { "LINE1 pin", 0x2 },
4548 { "LINE2 pin", 0x3 },
4549 { "CD pin", 0x4 },
4550 { "Mixer", 0x5 },
4551 { "LINE-OUT pin", 0x6 },
4552 { "HP-OUT pin", 0x7 },
4553 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004554 },
4555};
4556static struct snd_kcontrol_new alc260_test_mixer[] = {
4557 /* Output driver widgets */
4558 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4559 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4560 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4561 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4562 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4563 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4564
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004565 /* Modes for retasking pin widgets
4566 * Note: the ALC260 doesn't seem to act on requests to enable mic
4567 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4568 * mention this restriction. At this stage it's not clear whether
4569 * this behaviour is intentional or is a hardware bug in chip
4570 * revisions available at least up until early 2006. Therefore for
4571 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4572 * choices, but if it turns out that the lack of mic bias for these
4573 * NIDs is intentional we could change their modes from
4574 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4575 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004576 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4577 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4578 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4579 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4580 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4581 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4582
4583 /* Loopback mixer controls */
4584 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4585 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4586 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4587 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4588 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4589 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4590 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4591 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4592 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4593 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4594 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4595 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4596 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4597 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4598 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4599 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004600
4601 /* Controls for GPIO pins, assuming they are configured as outputs */
4602 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4603 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4604 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4605 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4606
Jonathan Woithe92621f12006-02-28 11:47:47 +01004607 /* Switches to allow the digital IO pins to be enabled. The datasheet
4608 * is ambigious as to which NID is which; testing on laptops which
4609 * make this output available should provide clarification.
4610 */
4611 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4612 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4613
Jonathan Woithef8225f62008-01-08 12:16:54 +01004614 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4615 * this output to turn on an external amplifier.
4616 */
4617 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4618 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4619
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004620 { } /* end */
4621};
4622static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004623 /* Enable all GPIOs as outputs with an initial value of 0 */
4624 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4625 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4626 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4627
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004628 /* Enable retasking pins as output, initially without power amp */
4629 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4630 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4632 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4633 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4634 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4635
Jonathan Woithe92621f12006-02-28 11:47:47 +01004636 /* Disable digital (SPDIF) pins initially, but users can enable
4637 * them via a mixer switch. In the case of SPDIF-out, this initverb
4638 * payload also sets the generation to 0, output to be in "consumer"
4639 * PCM format, copyright asserted, no pre-emphasis and no validity
4640 * control.
4641 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004642 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4643 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4644
Jonathan Woithef7ace402006-02-28 11:46:14 +01004645 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004646 * OUT1 sum bus when acting as an output.
4647 */
4648 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4649 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4650 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4651 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4652
4653 /* Start with output sum widgets muted and their output gains at min */
4654 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4660 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4661 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4662 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4663
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004664 /* Unmute retasking pin widget output buffers since the default
4665 * state appears to be output. As the pin mode is changed by the
4666 * user the pin mode control will take care of enabling the pin's
4667 * input/output buffers as needed.
4668 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004669 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4673 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4674 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4675 /* Also unmute the mono-out pin widget */
4676 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4677
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004678 /* Mute capture amp left and right */
4679 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004680 /* Set ADC connection select to match default mixer setting (mic1
4681 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004682 */
4683 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4684
4685 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004686 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004687 */
4688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4689 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4690
4691 /* Mute all inputs to mixer widget (even unconnected ones) */
4692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4700
4701 { }
4702};
4703#endif
4704
Takashi Iwai63300792008-01-24 15:31:36 +01004705#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4706#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004707
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004708#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4709#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4710
Kailang Yangdf694da2005-12-05 19:42:22 +01004711/*
4712 * for BIOS auto-configuration
4713 */
4714
4715static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4716 const char *pfx)
4717{
4718 hda_nid_t nid_vol;
4719 unsigned long vol_val, sw_val;
4720 char name[32];
4721 int err;
4722
4723 if (nid >= 0x0f && nid < 0x11) {
4724 nid_vol = nid - 0x7;
4725 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4726 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4727 } else if (nid == 0x11) {
4728 nid_vol = nid - 0x7;
4729 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4730 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4731 } else if (nid >= 0x12 && nid <= 0x15) {
4732 nid_vol = 0x08;
4733 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4734 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4735 } else
4736 return 0; /* N/A */
4737
4738 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004739 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4740 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004741 return err;
4742 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004743 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4744 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004745 return err;
4746 return 1;
4747}
4748
4749/* add playback controls from the parsed DAC table */
4750static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4751 const struct auto_pin_cfg *cfg)
4752{
4753 hda_nid_t nid;
4754 int err;
4755
4756 spec->multiout.num_dacs = 1;
4757 spec->multiout.dac_nids = spec->private_dac_nids;
4758 spec->multiout.dac_nids[0] = 0x02;
4759
4760 nid = cfg->line_out_pins[0];
4761 if (nid) {
4762 err = alc260_add_playback_controls(spec, nid, "Front");
4763 if (err < 0)
4764 return err;
4765 }
4766
Takashi Iwai82bc9552006-03-21 11:24:42 +01004767 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004768 if (nid) {
4769 err = alc260_add_playback_controls(spec, nid, "Speaker");
4770 if (err < 0)
4771 return err;
4772 }
4773
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004774 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004775 if (nid) {
4776 err = alc260_add_playback_controls(spec, nid, "Headphone");
4777 if (err < 0)
4778 return err;
4779 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004780 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004781}
4782
4783/* create playback/capture controls for input pins */
4784static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4785 const struct auto_pin_cfg *cfg)
4786{
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 struct hda_input_mux *imux = &spec->private_imux;
4788 int i, err, idx;
4789
4790 for (i = 0; i < AUTO_PIN_LAST; i++) {
4791 if (cfg->input_pins[i] >= 0x12) {
4792 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004793 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004794 auto_pin_cfg_labels[i], idx,
4795 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004796 if (err < 0)
4797 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004798 imux->items[imux->num_items].label =
4799 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004800 imux->items[imux->num_items].index = idx;
4801 imux->num_items++;
4802 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004803 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004805 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004806 auto_pin_cfg_labels[i], idx,
4807 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 if (err < 0)
4809 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 imux->items[imux->num_items].label =
4811 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 imux->items[imux->num_items].index = idx;
4813 imux->num_items++;
4814 }
4815 }
4816 return 0;
4817}
4818
4819static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4820 hda_nid_t nid, int pin_type,
4821 int sel_idx)
4822{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004823 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 /* need the manual connection? */
4825 if (nid >= 0x12) {
4826 int idx = nid - 0x12;
4827 snd_hda_codec_write(codec, idx + 0x0b, 0,
4828 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004829 }
4830}
4831
4832static void alc260_auto_init_multi_out(struct hda_codec *codec)
4833{
4834 struct alc_spec *spec = codec->spec;
4835 hda_nid_t nid;
4836
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004837 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004838 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004839 if (nid) {
4840 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4841 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4842 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004843
Takashi Iwai82bc9552006-03-21 11:24:42 +01004844 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004845 if (nid)
4846 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4847
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004848 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004849 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004850 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004851}
Kailang Yangdf694da2005-12-05 19:42:22 +01004852
4853#define ALC260_PIN_CD_NID 0x16
4854static void alc260_auto_init_analog_input(struct hda_codec *codec)
4855{
4856 struct alc_spec *spec = codec->spec;
4857 int i;
4858
4859 for (i = 0; i < AUTO_PIN_LAST; i++) {
4860 hda_nid_t nid = spec->autocfg.input_pins[i];
4861 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004862 snd_hda_codec_write(codec, nid, 0,
4863 AC_VERB_SET_PIN_WIDGET_CONTROL,
4864 i <= AUTO_PIN_FRONT_MIC ?
4865 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004866 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004867 snd_hda_codec_write(codec, nid, 0,
4868 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004869 AMP_OUT_MUTE);
4870 }
4871 }
4872}
4873
4874/*
4875 * generic initialization of ADC, input mixers and output mixers
4876 */
4877static struct hda_verb alc260_volume_init_verbs[] = {
4878 /*
4879 * Unmute ADC0-1 and set the default input to mic-in
4880 */
4881 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4882 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4883 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4884 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4885
4886 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4887 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004888 * Note: PASD motherboards uses the Line In 2 as the input for
4889 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004890 */
4891 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004892 /* mute analog inputs */
4893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004898
4899 /*
4900 * Set up output mixers (0x08 - 0x0a)
4901 */
4902 /* set vol=0 to output mixers */
4903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4906 /* set up input amps for analog loopback */
4907 /* Amp Indices: DAC = 0, mixer = 1 */
4908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4912 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4913 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4914
4915 { }
4916};
4917
4918static int alc260_parse_auto_config(struct hda_codec *codec)
4919{
4920 struct alc_spec *spec = codec->spec;
4921 unsigned int wcap;
4922 int err;
4923 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4924
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004925 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4926 alc260_ignore);
4927 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004928 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004929 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4930 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004931 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004933 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004934 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4935 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004936 return err;
4937
4938 spec->multiout.max_channels = 2;
4939
4940 if (spec->autocfg.dig_out_pin)
4941 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4942 if (spec->kctl_alloc)
4943 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4944
4945 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4946
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004947 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004948 spec->input_mux = &spec->private_imux;
4949
4950 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004951 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004952 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4953 if (wcap != AC_WID_AUD_IN) {
4954 spec->adc_nids = alc260_adc_nids_alt;
4955 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4956 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004957 } else {
4958 spec->adc_nids = alc260_adc_nids;
4959 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4960 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004961 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004962 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004963
4964 return 1;
4965}
4966
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004967/* additional initialization for auto-configuration model */
4968static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004969{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004970 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004971 alc260_auto_init_multi_out(codec);
4972 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004973 if (spec->unsol_event)
4974 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004975}
4976
Takashi Iwaicb53c622007-08-10 17:21:45 +02004977#ifdef CONFIG_SND_HDA_POWER_SAVE
4978static struct hda_amp_list alc260_loopbacks[] = {
4979 { 0x07, HDA_INPUT, 0 },
4980 { 0x07, HDA_INPUT, 1 },
4981 { 0x07, HDA_INPUT, 2 },
4982 { 0x07, HDA_INPUT, 3 },
4983 { 0x07, HDA_INPUT, 4 },
4984 { } /* end */
4985};
4986#endif
4987
Kailang Yangdf694da2005-12-05 19:42:22 +01004988/*
4989 * ALC260 configurations
4990 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004991static const char *alc260_models[ALC260_MODEL_LAST] = {
4992 [ALC260_BASIC] = "basic",
4993 [ALC260_HP] = "hp",
4994 [ALC260_HP_3013] = "hp-3013",
4995 [ALC260_FUJITSU_S702X] = "fujitsu",
4996 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004997 [ALC260_WILL] = "will",
4998 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004999#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005000 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005001#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005002 [ALC260_AUTO] = "auto",
5003};
5004
5005static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005006 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005007 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005008 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005009 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005010 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5011 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5012 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5013 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5014 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5015 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5016 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5017 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5018 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5019 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5020 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5021 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005022 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005023 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005024 {}
5025};
5026
Kailang Yangdf694da2005-12-05 19:42:22 +01005027static struct alc_config_preset alc260_presets[] = {
5028 [ALC260_BASIC] = {
5029 .mixers = { alc260_base_output_mixer,
5030 alc260_input_mixer,
5031 alc260_pc_beep_mixer,
5032 alc260_capture_mixer },
5033 .init_verbs = { alc260_init_verbs },
5034 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5035 .dac_nids = alc260_dac_nids,
5036 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5037 .adc_nids = alc260_adc_nids,
5038 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5039 .channel_mode = alc260_modes,
5040 .input_mux = &alc260_capture_source,
5041 },
5042 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005043 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005044 alc260_input_mixer,
5045 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005046 .init_verbs = { alc260_init_verbs,
5047 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5049 .dac_nids = alc260_dac_nids,
5050 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5051 .adc_nids = alc260_hp_adc_nids,
5052 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5053 .channel_mode = alc260_modes,
5054 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005055 .unsol_event = alc260_hp_unsol_event,
5056 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005057 },
5058 [ALC260_HP_3013] = {
5059 .mixers = { alc260_hp_3013_mixer,
5060 alc260_input_mixer,
5061 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005062 .init_verbs = { alc260_hp_3013_init_verbs,
5063 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005064 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5065 .dac_nids = alc260_dac_nids,
5066 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5067 .adc_nids = alc260_hp_adc_nids,
5068 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5069 .channel_mode = alc260_modes,
5070 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005071 .unsol_event = alc260_hp_3013_unsol_event,
5072 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005073 },
5074 [ALC260_FUJITSU_S702X] = {
5075 .mixers = { alc260_fujitsu_mixer,
5076 alc260_capture_mixer },
5077 .init_verbs = { alc260_fujitsu_init_verbs },
5078 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5079 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005080 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5081 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005082 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5083 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005084 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5085 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005086 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005087 [ALC260_ACER] = {
5088 .mixers = { alc260_acer_mixer,
5089 alc260_capture_mixer },
5090 .init_verbs = { alc260_acer_init_verbs },
5091 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5092 .dac_nids = alc260_dac_nids,
5093 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5094 .adc_nids = alc260_dual_adc_nids,
5095 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5096 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005097 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5098 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005099 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005100 [ALC260_WILL] = {
5101 .mixers = { alc260_will_mixer,
5102 alc260_capture_mixer },
5103 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5104 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5105 .dac_nids = alc260_dac_nids,
5106 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5107 .adc_nids = alc260_adc_nids,
5108 .dig_out_nid = ALC260_DIGOUT_NID,
5109 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5110 .channel_mode = alc260_modes,
5111 .input_mux = &alc260_capture_source,
5112 },
5113 [ALC260_REPLACER_672V] = {
5114 .mixers = { alc260_replacer_672v_mixer,
5115 alc260_capture_mixer },
5116 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5117 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5118 .dac_nids = alc260_dac_nids,
5119 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5120 .adc_nids = alc260_adc_nids,
5121 .dig_out_nid = ALC260_DIGOUT_NID,
5122 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5123 .channel_mode = alc260_modes,
5124 .input_mux = &alc260_capture_source,
5125 .unsol_event = alc260_replacer_672v_unsol_event,
5126 .init_hook = alc260_replacer_672v_automute,
5127 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005128#ifdef CONFIG_SND_DEBUG
5129 [ALC260_TEST] = {
5130 .mixers = { alc260_test_mixer,
5131 alc260_capture_mixer },
5132 .init_verbs = { alc260_test_init_verbs },
5133 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5134 .dac_nids = alc260_test_dac_nids,
5135 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5136 .adc_nids = alc260_test_adc_nids,
5137 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5138 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005139 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5140 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005141 },
5142#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005143};
5144
Linus Torvalds1da177e2005-04-16 15:20:36 -07005145static int patch_alc260(struct hda_codec *codec)
5146{
5147 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005148 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005149
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005150 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005151 if (spec == NULL)
5152 return -ENOMEM;
5153
5154 codec->spec = spec;
5155
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005156 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5157 alc260_models,
5158 alc260_cfg_tbl);
5159 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005160 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5161 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005162 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005163 }
5164
Kailang Yangdf694da2005-12-05 19:42:22 +01005165 if (board_config == ALC260_AUTO) {
5166 /* automatic parse from the BIOS config */
5167 err = alc260_parse_auto_config(codec);
5168 if (err < 0) {
5169 alc_free(codec);
5170 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005171 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005172 printk(KERN_INFO
5173 "hda_codec: Cannot set up configuration "
5174 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005175 board_config = ALC260_BASIC;
5176 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005177 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005178
Kailang Yangdf694da2005-12-05 19:42:22 +01005179 if (board_config != ALC260_AUTO)
5180 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005181
5182 spec->stream_name_analog = "ALC260 Analog";
5183 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5184 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5185
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005186 spec->stream_name_digital = "ALC260 Digital";
5187 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5188 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5189
Takashi Iwai2134ea42008-01-10 16:53:55 +01005190 spec->vmaster_nid = 0x08;
5191
Linus Torvalds1da177e2005-04-16 15:20:36 -07005192 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005194 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005195#ifdef CONFIG_SND_HDA_POWER_SAVE
5196 if (!spec->loopback.amplist)
5197 spec->loopback.amplist = alc260_loopbacks;
5198#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005199
5200 return 0;
5201}
5202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005203
Linus Torvalds1da177e2005-04-16 15:20:36 -07005204/*
5205 * ALC882 support
5206 *
5207 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5208 * configuration. Each pin widget can choose any input DACs and a mixer.
5209 * Each ADC is connected from a mixer of all inputs. This makes possible
5210 * 6-channel independent captures.
5211 *
5212 * In addition, an independent DAC for the multi-playback (not used in this
5213 * driver yet).
5214 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005215#define ALC882_DIGOUT_NID 0x06
5216#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005217
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005218static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005219 { 8, NULL }
5220};
5221
5222static hda_nid_t alc882_dac_nids[4] = {
5223 /* front, rear, clfe, rear_surr */
5224 0x02, 0x03, 0x04, 0x05
5225};
5226
Kailang Yangdf694da2005-12-05 19:42:22 +01005227/* identical with ALC880 */
5228#define alc882_adc_nids alc880_adc_nids
5229#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005230
Takashi Iwaie1406342008-02-11 18:32:32 +01005231static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5232static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5233
Linus Torvalds1da177e2005-04-16 15:20:36 -07005234/* input MUX */
5235/* FIXME: should be a matrix-type input source selection */
5236
5237static struct hda_input_mux alc882_capture_source = {
5238 .num_items = 4,
5239 .items = {
5240 { "Mic", 0x0 },
5241 { "Front Mic", 0x1 },
5242 { "Line", 0x2 },
5243 { "CD", 0x4 },
5244 },
5245};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005246#define alc882_mux_enum_info alc_mux_enum_info
5247#define alc882_mux_enum_get alc_mux_enum_get
5248
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005249static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5250 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005251{
5252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5253 struct alc_spec *spec = codec->spec;
5254 const struct hda_input_mux *imux = spec->input_mux;
5255 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005256 hda_nid_t nid = spec->capsrc_nids ?
5257 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005258 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5259 unsigned int i, idx;
5260
5261 idx = ucontrol->value.enumerated.item[0];
5262 if (idx >= imux->num_items)
5263 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005264 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005265 return 0;
5266 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005267 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5268 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005269 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005270 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005271 }
5272 *cur_val = idx;
5273 return 1;
5274}
5275
Kailang Yangdf694da2005-12-05 19:42:22 +01005276/*
Kailang Yang272a5272007-05-14 11:00:38 +02005277 * 2ch mode
5278 */
5279static struct hda_verb alc882_3ST_ch2_init[] = {
5280 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5281 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5282 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5283 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5284 { } /* end */
5285};
5286
5287/*
5288 * 6ch mode
5289 */
5290static struct hda_verb alc882_3ST_ch6_init[] = {
5291 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5292 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5293 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5296 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5297 { } /* end */
5298};
5299
5300static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5301 { 2, alc882_3ST_ch2_init },
5302 { 6, alc882_3ST_ch6_init },
5303};
5304
5305/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 * 6ch mode
5307 */
5308static struct hda_verb alc882_sixstack_ch6_init[] = {
5309 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5310 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5311 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5312 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5313 { } /* end */
5314};
5315
5316/*
5317 * 8ch mode
5318 */
5319static struct hda_verb alc882_sixstack_ch8_init[] = {
5320 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5321 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5322 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5323 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5324 { } /* end */
5325};
5326
5327static struct hda_channel_mode alc882_sixstack_modes[2] = {
5328 { 6, alc882_sixstack_ch6_init },
5329 { 8, alc882_sixstack_ch8_init },
5330};
5331
Takashi Iwai87350ad2007-08-16 18:19:38 +02005332/*
5333 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5334 */
5335
5336/*
5337 * 2ch mode
5338 */
5339static struct hda_verb alc885_mbp_ch2_init[] = {
5340 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5341 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5342 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5343 { } /* end */
5344};
5345
5346/*
5347 * 6ch mode
5348 */
5349static struct hda_verb alc885_mbp_ch6_init[] = {
5350 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5351 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5352 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5353 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5354 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5355 { } /* end */
5356};
5357
5358static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5359 { 2, alc885_mbp_ch2_init },
5360 { 6, alc885_mbp_ch6_init },
5361};
5362
5363
Linus Torvalds1da177e2005-04-16 15:20:36 -07005364/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5365 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5366 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005367static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005370 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005371 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005372 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5373 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005374 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5375 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005376 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005377 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005384 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5386 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005387 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5389 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5390 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005391 { } /* end */
5392};
5393
Takashi Iwai87350ad2007-08-16 18:19:38 +02005394static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005395 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5396 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5397 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5398 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5400 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5402 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005403 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5405 { } /* end */
5406};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005407static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5408 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5409 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5410 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5411 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5412 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5413 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5415 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5416 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5417 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5418 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5419 { } /* end */
5420};
5421
Kailang Yang272a5272007-05-14 11:00:38 +02005422static struct snd_kcontrol_new alc882_targa_mixer[] = {
5423 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005435 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005436 { } /* end */
5437};
5438
5439/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5440 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5441 */
5442static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5444 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5446 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5449 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5450 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5451 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5452 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005456 { } /* end */
5457};
5458
Takashi Iwai914759b2007-09-06 14:52:04 +02005459static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5470 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5471 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5472 { } /* end */
5473};
5474
Kailang Yangdf694da2005-12-05 19:42:22 +01005475static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5476 {
5477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5478 .name = "Channel Mode",
5479 .info = alc_ch_mode_info,
5480 .get = alc_ch_mode_get,
5481 .put = alc_ch_mode_put,
5482 },
5483 { } /* end */
5484};
5485
Linus Torvalds1da177e2005-04-16 15:20:36 -07005486static struct hda_verb alc882_init_verbs[] = {
5487 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005491 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005495 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005504 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005507 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005508 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005510 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005512 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005516 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005518 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005519 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005520 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005522 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5523 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005524 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005525 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5526 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5529 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5530 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5531 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5532 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005533 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005534 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005535
5536 /* FIXME: use matrix-type input source selection */
5537 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5538 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005548 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5553 /* ADC1: mute amp left and right */
5554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005555 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005556 /* ADC2: mute amp left and right */
5557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005558 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005559 /* ADC3: mute amp left and right */
5560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005562
5563 { }
5564};
5565
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005566static struct hda_verb alc882_eapd_verbs[] = {
5567 /* change to EAPD mode */
5568 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005569 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005570 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005571};
5572
Tobin Davis9102cd12006-12-15 10:02:12 +01005573/* Mac Pro test */
5574static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5575 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5576 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5580 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5581 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5582 { } /* end */
5583};
5584
5585static struct hda_verb alc882_macpro_init_verbs[] = {
5586 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5590 /* Front Pin: output 0 (0x0c) */
5591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5594 /* Front Mic pin: input vref at 80% */
5595 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5597 /* Speaker: output */
5598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5599 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5600 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5601 /* Headphone output (output 0 - 0x0c) */
5602 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5603 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5604 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5605
5606 /* FIXME: use matrix-type input source selection */
5607 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5613 /* Input mixer2 */
5614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5618 /* Input mixer3 */
5619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5623 /* ADC1: mute amp left and right */
5624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5625 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5626 /* ADC2: mute amp left and right */
5627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5629 /* ADC3: mute amp left and right */
5630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5632
5633 { }
5634};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005635
Takashi Iwai87350ad2007-08-16 18:19:38 +02005636/* Macbook Pro rev3 */
5637static struct hda_verb alc885_mbp3_init_verbs[] = {
5638 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5642 /* Rear mixer */
5643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5644 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5646 /* Front Pin: output 0 (0x0c) */
5647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5649 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5650 /* HP Pin: output 0 (0x0d) */
5651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5654 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5655 /* Mic (rear) pin: input vref at 80% */
5656 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5658 /* Front Mic pin: input vref at 80% */
5659 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5660 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5661 /* Line In pin: use output 1 when in LineOut mode */
5662 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5663 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5664 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5665
5666 /* FIXME: use matrix-type input source selection */
5667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5673 /* Input mixer2 */
5674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5678 /* Input mixer3 */
5679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5683 /* ADC1: mute amp left and right */
5684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5686 /* ADC2: mute amp left and right */
5687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5688 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5689 /* ADC3: mute amp left and right */
5690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5691 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5692
5693 { }
5694};
5695
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005696/* iMac 24 mixer. */
5697static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5698 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5699 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5700 { } /* end */
5701};
5702
5703/* iMac 24 init verbs. */
5704static struct hda_verb alc885_imac24_init_verbs[] = {
5705 /* Internal speakers: output 0 (0x0c) */
5706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5708 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5709 /* Internal speakers: output 0 (0x0c) */
5710 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5712 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5713 /* Headphone: output 0 (0x0c) */
5714 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5716 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5718 /* Front Mic: input vref at 80% */
5719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5721 { }
5722};
5723
5724/* Toggle speaker-output according to the hp-jack state */
5725static void alc885_imac24_automute(struct hda_codec *codec)
5726{
5727 unsigned int present;
5728
5729 present = snd_hda_codec_read(codec, 0x14, 0,
5730 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005731 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5732 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5733 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5734 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005735}
5736
5737/* Processes unsolicited events. */
5738static void alc885_imac24_unsol_event(struct hda_codec *codec,
5739 unsigned int res)
5740{
5741 /* Headphone insertion or removal. */
5742 if ((res >> 26) == ALC880_HP_EVENT)
5743 alc885_imac24_automute(codec);
5744}
5745
Takashi Iwai87350ad2007-08-16 18:19:38 +02005746static void alc885_mbp3_automute(struct hda_codec *codec)
5747{
5748 unsigned int present;
5749
5750 present = snd_hda_codec_read(codec, 0x15, 0,
5751 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5752 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5753 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5754 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5755 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5756
5757}
5758static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5759 unsigned int res)
5760{
5761 /* Headphone insertion or removal. */
5762 if ((res >> 26) == ALC880_HP_EVENT)
5763 alc885_mbp3_automute(codec);
5764}
5765
5766
Kailang Yang272a5272007-05-14 11:00:38 +02005767static struct hda_verb alc882_targa_verbs[] = {
5768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5770
5771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5773
5774 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5775 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5776 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5777
5778 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5779 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5780 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5781 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5782 { } /* end */
5783};
5784
5785/* toggle speaker-output according to the hp-jack state */
5786static void alc882_targa_automute(struct hda_codec *codec)
5787{
5788 unsigned int present;
5789
5790 present = snd_hda_codec_read(codec, 0x14, 0,
5791 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005792 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5793 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005794 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5795 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005796}
5797
5798static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5799{
5800 /* Looks like the unsol event is incompatible with the standard
5801 * definition. 4bit tag is placed at 26 bit!
5802 */
5803 if (((res >> 26) == ALC880_HP_EVENT)) {
5804 alc882_targa_automute(codec);
5805 }
5806}
5807
5808static struct hda_verb alc882_asus_a7j_verbs[] = {
5809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5811
5812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5815
5816 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5818 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5819
5820 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5821 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5822 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5823 { } /* end */
5824};
5825
Takashi Iwai914759b2007-09-06 14:52:04 +02005826static struct hda_verb alc882_asus_a7m_verbs[] = {
5827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5829
5830 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5832 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5833
5834 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5836 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5837
5838 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5839 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5840 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5841 { } /* end */
5842};
5843
Tobin Davis9102cd12006-12-15 10:02:12 +01005844static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5845{
5846 unsigned int gpiostate, gpiomask, gpiodir;
5847
5848 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5849 AC_VERB_GET_GPIO_DATA, 0);
5850
5851 if (!muted)
5852 gpiostate |= (1 << pin);
5853 else
5854 gpiostate &= ~(1 << pin);
5855
5856 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5857 AC_VERB_GET_GPIO_MASK, 0);
5858 gpiomask |= (1 << pin);
5859
5860 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5861 AC_VERB_GET_GPIO_DIRECTION, 0);
5862 gpiodir |= (1 << pin);
5863
5864
5865 snd_hda_codec_write(codec, codec->afg, 0,
5866 AC_VERB_SET_GPIO_MASK, gpiomask);
5867 snd_hda_codec_write(codec, codec->afg, 0,
5868 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5869
5870 msleep(1);
5871
5872 snd_hda_codec_write(codec, codec->afg, 0,
5873 AC_VERB_SET_GPIO_DATA, gpiostate);
5874}
5875
Takashi Iwai7debbe52007-08-16 15:01:03 +02005876/* set up GPIO at initialization */
5877static void alc885_macpro_init_hook(struct hda_codec *codec)
5878{
5879 alc882_gpio_mute(codec, 0, 0);
5880 alc882_gpio_mute(codec, 1, 0);
5881}
5882
5883/* set up GPIO and update auto-muting at initialization */
5884static void alc885_imac24_init_hook(struct hda_codec *codec)
5885{
5886 alc885_macpro_init_hook(codec);
5887 alc885_imac24_automute(codec);
5888}
5889
Kailang Yangdf694da2005-12-05 19:42:22 +01005890/*
5891 * generic initialization of ADC, input mixers and output mixers
5892 */
5893static struct hda_verb alc882_auto_init_verbs[] = {
5894 /*
5895 * Unmute ADC0-2 and set the default input to mic-in
5896 */
5897 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5899 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5901 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5903
Takashi Iwaicb53c622007-08-10 17:21:45 +02005904 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005905 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005906 * Note: PASD motherboards uses the Line In 2 as the input for
5907 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 */
5909 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005915
5916 /*
5917 * Set up output mixers (0x0c - 0x0f)
5918 */
5919 /* set vol=0 to output mixers */
5920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5924 /* set up input amps for analog loopback */
5925 /* Amp Indices: DAC = 0, mixer = 1 */
5926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5928 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5929 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5930 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5932 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5933 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5934 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5935 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5936
5937 /* FIXME: use matrix-type input source selection */
5938 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5939 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5944 /* Input mixer2 */
5945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5949 /* Input mixer3 */
5950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5954
5955 { }
5956};
5957
5958/* capture mixer elements */
5959static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5960 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5962 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5963 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 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 = 2,
5972 .info = alc882_mux_enum_info,
5973 .get = alc882_mux_enum_get,
5974 .put = alc882_mux_enum_put,
5975 },
5976 { } /* end */
5977};
5978
5979static struct snd_kcontrol_new alc882_capture_mixer[] = {
5980 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5981 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5982 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5983 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5984 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5985 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5986 {
5987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5988 /* The multiple "Capture Source" controls confuse alsamixer
5989 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 */
5991 /* .name = "Capture Source", */
5992 .name = "Input Source",
5993 .count = 3,
5994 .info = alc882_mux_enum_info,
5995 .get = alc882_mux_enum_get,
5996 .put = alc882_mux_enum_put,
5997 },
5998 { } /* end */
5999};
6000
Takashi Iwaicb53c622007-08-10 17:21:45 +02006001#ifdef CONFIG_SND_HDA_POWER_SAVE
6002#define alc882_loopbacks alc880_loopbacks
6003#endif
6004
Kailang Yangdf694da2005-12-05 19:42:22 +01006005/* pcm configuration: identiacal with ALC880 */
6006#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6007#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6008#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6009#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6010
6011/*
6012 * configuration and preset
6013 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006014static const char *alc882_models[ALC882_MODEL_LAST] = {
6015 [ALC882_3ST_DIG] = "3stack-dig",
6016 [ALC882_6ST_DIG] = "6stack-dig",
6017 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006018 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006019 [ALC882_TARGA] = "targa",
6020 [ALC882_ASUS_A7J] = "asus-a7j",
6021 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006022 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006023 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006024 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006025 [ALC882_AUTO] = "auto",
6026};
6027
6028static struct snd_pci_quirk alc882_cfg_tbl[] = {
6029 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006030 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006031 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006032 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006033 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006034 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006035 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006036 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006037 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006038 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6039 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6040 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 {}
6042};
6043
6044static struct alc_config_preset alc882_presets[] = {
6045 [ALC882_3ST_DIG] = {
6046 .mixers = { alc882_base_mixer },
6047 .init_verbs = { alc882_init_verbs },
6048 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6049 .dac_nids = alc882_dac_nids,
6050 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 .dig_in_nid = ALC882_DIGIN_NID,
6052 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6053 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006054 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 .input_mux = &alc882_capture_source,
6056 },
6057 [ALC882_6ST_DIG] = {
6058 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6059 .init_verbs = { alc882_init_verbs },
6060 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6061 .dac_nids = alc882_dac_nids,
6062 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 .dig_in_nid = ALC882_DIGIN_NID,
6064 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6065 .channel_mode = alc882_sixstack_modes,
6066 .input_mux = &alc882_capture_source,
6067 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006068 [ALC882_ARIMA] = {
6069 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6070 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6071 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6072 .dac_nids = alc882_dac_nids,
6073 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6074 .channel_mode = alc882_sixstack_modes,
6075 .input_mux = &alc882_capture_source,
6076 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006077 [ALC882_W2JC] = {
6078 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6079 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6080 alc880_gpio1_init_verbs },
6081 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6082 .dac_nids = alc882_dac_nids,
6083 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6084 .channel_mode = alc880_threestack_modes,
6085 .need_dac_fix = 1,
6086 .input_mux = &alc882_capture_source,
6087 .dig_out_nid = ALC882_DIGOUT_NID,
6088 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006089 [ALC885_MBP3] = {
6090 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6091 .init_verbs = { alc885_mbp3_init_verbs,
6092 alc880_gpio1_init_verbs },
6093 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6094 .dac_nids = alc882_dac_nids,
6095 .channel_mode = alc885_mbp_6ch_modes,
6096 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6097 .input_mux = &alc882_capture_source,
6098 .dig_out_nid = ALC882_DIGOUT_NID,
6099 .dig_in_nid = ALC882_DIGIN_NID,
6100 .unsol_event = alc885_mbp3_unsol_event,
6101 .init_hook = alc885_mbp3_automute,
6102 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006103 [ALC885_MACPRO] = {
6104 .mixers = { alc882_macpro_mixer },
6105 .init_verbs = { alc882_macpro_init_verbs },
6106 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6107 .dac_nids = alc882_dac_nids,
6108 .dig_out_nid = ALC882_DIGOUT_NID,
6109 .dig_in_nid = ALC882_DIGIN_NID,
6110 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6111 .channel_mode = alc882_ch_modes,
6112 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006113 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006114 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006115 [ALC885_IMAC24] = {
6116 .mixers = { alc885_imac24_mixer },
6117 .init_verbs = { alc885_imac24_init_verbs },
6118 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6119 .dac_nids = alc882_dac_nids,
6120 .dig_out_nid = ALC882_DIGOUT_NID,
6121 .dig_in_nid = ALC882_DIGIN_NID,
6122 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6123 .channel_mode = alc882_ch_modes,
6124 .input_mux = &alc882_capture_source,
6125 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006126 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006127 },
Kailang Yang272a5272007-05-14 11:00:38 +02006128 [ALC882_TARGA] = {
6129 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6130 alc882_capture_mixer },
6131 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6132 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6133 .dac_nids = alc882_dac_nids,
6134 .dig_out_nid = ALC882_DIGOUT_NID,
6135 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6136 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006137 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006138 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6139 .channel_mode = alc882_3ST_6ch_modes,
6140 .need_dac_fix = 1,
6141 .input_mux = &alc882_capture_source,
6142 .unsol_event = alc882_targa_unsol_event,
6143 .init_hook = alc882_targa_automute,
6144 },
6145 [ALC882_ASUS_A7J] = {
6146 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6147 alc882_capture_mixer },
6148 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6149 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6150 .dac_nids = alc882_dac_nids,
6151 .dig_out_nid = ALC882_DIGOUT_NID,
6152 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6153 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006154 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006155 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6156 .channel_mode = alc882_3ST_6ch_modes,
6157 .need_dac_fix = 1,
6158 .input_mux = &alc882_capture_source,
6159 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006160 [ALC882_ASUS_A7M] = {
6161 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6162 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6163 alc880_gpio1_init_verbs,
6164 alc882_asus_a7m_verbs },
6165 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6166 .dac_nids = alc882_dac_nids,
6167 .dig_out_nid = ALC882_DIGOUT_NID,
6168 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6169 .channel_mode = alc880_threestack_modes,
6170 .need_dac_fix = 1,
6171 .input_mux = &alc882_capture_source,
6172 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006173};
6174
6175
6176/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006177 * Pin config fixes
6178 */
6179enum {
6180 PINFIX_ABIT_AW9D_MAX
6181};
6182
6183static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6184 { 0x15, 0x01080104 }, /* side */
6185 { 0x16, 0x01011012 }, /* rear */
6186 { 0x17, 0x01016011 }, /* clfe */
6187 { }
6188};
6189
6190static const struct alc_pincfg *alc882_pin_fixes[] = {
6191 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6192};
6193
6194static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6195 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6196 {}
6197};
6198
6199/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006200 * BIOS auto configuration
6201 */
6202static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6203 hda_nid_t nid, int pin_type,
6204 int dac_idx)
6205{
6206 /* set as output */
6207 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006208 int idx;
6209
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006210 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6212 idx = 4;
6213 else
6214 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6216
6217}
6218
6219static void alc882_auto_init_multi_out(struct hda_codec *codec)
6220{
6221 struct alc_spec *spec = codec->spec;
6222 int i;
6223
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006224 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006225 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006226 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006227 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006228 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006229 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006230 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006231 }
6232}
6233
6234static void alc882_auto_init_hp_out(struct hda_codec *codec)
6235{
6236 struct alc_spec *spec = codec->spec;
6237 hda_nid_t pin;
6238
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006239 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006241 /* use dac 0 */
6242 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006243 pin = spec->autocfg.speaker_pins[0];
6244 if (pin)
6245 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006246}
6247
6248#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6249#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6250
6251static void alc882_auto_init_analog_input(struct hda_codec *codec)
6252{
6253 struct alc_spec *spec = codec->spec;
6254 int i;
6255
6256 for (i = 0; i < AUTO_PIN_LAST; i++) {
6257 hda_nid_t nid = spec->autocfg.input_pins[i];
6258 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 snd_hda_codec_write(codec, nid, 0,
6260 AC_VERB_SET_PIN_WIDGET_CONTROL,
6261 i <= AUTO_PIN_FRONT_MIC ?
6262 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006264 snd_hda_codec_write(codec, nid, 0,
6265 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006266 AMP_OUT_MUTE);
6267 }
6268 }
6269}
6270
Takashi Iwai776e1842007-08-29 15:07:11 +02006271/* add mic boosts if needed */
6272static int alc_auto_add_mic_boost(struct hda_codec *codec)
6273{
6274 struct alc_spec *spec = codec->spec;
6275 int err;
6276 hda_nid_t nid;
6277
6278 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006279 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006280 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6281 "Mic Boost",
6282 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6283 if (err < 0)
6284 return err;
6285 }
6286 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006287 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006288 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6289 "Front Mic Boost",
6290 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6291 if (err < 0)
6292 return err;
6293 }
6294 return 0;
6295}
6296
Kailang Yangdf694da2005-12-05 19:42:22 +01006297/* almost identical with ALC880 parser... */
6298static int alc882_parse_auto_config(struct hda_codec *codec)
6299{
6300 struct alc_spec *spec = codec->spec;
6301 int err = alc880_parse_auto_config(codec);
6302
6303 if (err < 0)
6304 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006305 else if (!err)
6306 return 0; /* no config found */
6307
6308 err = alc_auto_add_mic_boost(codec);
6309 if (err < 0)
6310 return err;
6311
6312 /* hack - override the init verbs */
6313 spec->init_verbs[0] = alc882_auto_init_verbs;
6314
6315 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006316}
6317
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006318/* additional initialization for auto-configuration model */
6319static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006320{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006321 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 alc882_auto_init_multi_out(codec);
6323 alc882_auto_init_hp_out(codec);
6324 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006325 if (spec->unsol_event)
6326 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006327}
6328
Linus Torvalds1da177e2005-04-16 15:20:36 -07006329static int patch_alc882(struct hda_codec *codec)
6330{
6331 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006332 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006333
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006334 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006335 if (spec == NULL)
6336 return -ENOMEM;
6337
Linus Torvalds1da177e2005-04-16 15:20:36 -07006338 codec->spec = spec;
6339
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006340 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6341 alc882_models,
6342 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006343
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006345 /* Pick up systems that don't supply PCI SSID */
6346 switch (codec->subsystem_id) {
6347 case 0x106b0c00: /* Mac Pro */
6348 board_config = ALC885_MACPRO;
6349 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006350 case 0x106b1000: /* iMac 24 */
6351 board_config = ALC885_IMAC24;
6352 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006353 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006354 case 0x106b2c00: /* Macbook Pro rev3 */
6355 board_config = ALC885_MBP3;
6356 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006357 default:
6358 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6359 "trying auto-probe from BIOS...\n");
6360 board_config = ALC882_AUTO;
6361 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006362 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006363
Takashi Iwaif95474e2007-07-10 00:47:43 +02006364 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6365
Kailang Yangdf694da2005-12-05 19:42:22 +01006366 if (board_config == ALC882_AUTO) {
6367 /* automatic parse from the BIOS config */
6368 err = alc882_parse_auto_config(codec);
6369 if (err < 0) {
6370 alc_free(codec);
6371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006372 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006373 printk(KERN_INFO
6374 "hda_codec: Cannot set up configuration "
6375 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006376 board_config = ALC882_3ST_DIG;
6377 }
6378 }
6379
6380 if (board_config != ALC882_AUTO)
6381 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006382
6383 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006384 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6385 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006386 /* FIXME: setup DAC5 */
6387 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6388 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006389
6390 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006391 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6392 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006394 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006395 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006396 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006397 /* get type */
6398 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006399 if (wcap != AC_WID_AUD_IN) {
6400 spec->adc_nids = alc882_adc_nids_alt;
6401 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006402 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006403 spec->mixers[spec->num_mixers] =
6404 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 spec->num_mixers++;
6406 } else {
6407 spec->adc_nids = alc882_adc_nids;
6408 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006409 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006410 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6411 spec->num_mixers++;
6412 }
6413 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006414
Takashi Iwai2134ea42008-01-10 16:53:55 +01006415 spec->vmaster_nid = 0x0c;
6416
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006418 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006419 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006420#ifdef CONFIG_SND_HDA_POWER_SAVE
6421 if (!spec->loopback.amplist)
6422 spec->loopback.amplist = alc882_loopbacks;
6423#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006424
6425 return 0;
6426}
6427
6428/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006429 * ALC883 support
6430 *
6431 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6432 * configuration. Each pin widget can choose any input DACs and a mixer.
6433 * Each ADC is connected from a mixer of all inputs. This makes possible
6434 * 6-channel independent captures.
6435 *
6436 * In addition, an independent DAC for the multi-playback (not used in this
6437 * driver yet).
6438 */
6439#define ALC883_DIGOUT_NID 0x06
6440#define ALC883_DIGIN_NID 0x0a
6441
6442static hda_nid_t alc883_dac_nids[4] = {
6443 /* front, rear, clfe, rear_surr */
6444 0x02, 0x04, 0x03, 0x05
6445};
6446
6447static hda_nid_t alc883_adc_nids[2] = {
6448 /* ADC1-2 */
6449 0x08, 0x09,
6450};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006451
Takashi Iwaie1406342008-02-11 18:32:32 +01006452static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6453
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006454/* input MUX */
6455/* FIXME: should be a matrix-type input source selection */
6456
6457static struct hda_input_mux alc883_capture_source = {
6458 .num_items = 4,
6459 .items = {
6460 { "Mic", 0x0 },
6461 { "Front Mic", 0x1 },
6462 { "Line", 0x2 },
6463 { "CD", 0x4 },
6464 },
6465};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006466
6467static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6468 .num_items = 2,
6469 .items = {
6470 { "Mic", 0x1 },
6471 { "Line", 0x2 },
6472 },
6473};
6474
Kailang Yang272a5272007-05-14 11:00:38 +02006475static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6476 .num_items = 4,
6477 .items = {
6478 { "Mic", 0x0 },
6479 { "iMic", 0x1 },
6480 { "Line", 0x2 },
6481 { "CD", 0x4 },
6482 },
6483};
6484
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006485#define alc883_mux_enum_info alc_mux_enum_info
6486#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006487/* ALC883 has the ALC882-type input selection */
6488#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006489
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006490/*
6491 * 2ch mode
6492 */
6493static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6494 { 2, NULL }
6495};
6496
6497/*
6498 * 2ch mode
6499 */
6500static struct hda_verb alc883_3ST_ch2_init[] = {
6501 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6502 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6503 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6504 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6505 { } /* end */
6506};
6507
6508/*
Tobin Davisb2011312007-09-17 12:45:11 +02006509 * 4ch mode
6510 */
6511static struct hda_verb alc883_3ST_ch4_init[] = {
6512 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6513 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6514 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6515 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6516 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6517 { } /* end */
6518};
6519
6520/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006521 * 6ch mode
6522 */
6523static struct hda_verb alc883_3ST_ch6_init[] = {
6524 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6525 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6526 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6527 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6528 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6529 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6530 { } /* end */
6531};
6532
Tobin Davisb2011312007-09-17 12:45:11 +02006533static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006534 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006535 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006536 { 6, alc883_3ST_ch6_init },
6537};
6538
6539/*
6540 * 6ch mode
6541 */
6542static struct hda_verb alc883_sixstack_ch6_init[] = {
6543 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6544 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6545 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6546 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6547 { } /* end */
6548};
6549
6550/*
6551 * 8ch mode
6552 */
6553static struct hda_verb alc883_sixstack_ch8_init[] = {
6554 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6555 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6556 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6557 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6558 { } /* end */
6559};
6560
6561static struct hda_channel_mode alc883_sixstack_modes[2] = {
6562 { 6, alc883_sixstack_ch6_init },
6563 { 8, alc883_sixstack_ch8_init },
6564};
6565
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006566static struct hda_verb alc883_medion_eapd_verbs[] = {
6567 /* eanable EAPD on medion laptop */
6568 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6569 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6570 { }
6571};
6572
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006573/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6574 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6575 */
6576
6577static struct snd_kcontrol_new alc883_base_mixer[] = {
6578 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6579 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6580 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6581 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6582 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6583 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6584 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6585 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6586 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6587 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006594 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006597 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6599 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6600 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6601 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6602 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6603 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6604 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6605 {
6606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6607 /* .name = "Capture Source", */
6608 .name = "Input Source",
6609 .count = 2,
6610 .info = alc883_mux_enum_info,
6611 .get = alc883_mux_enum_get,
6612 .put = alc883_mux_enum_put,
6613 },
6614 { } /* end */
6615};
6616
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006617static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6619 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6620 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6621 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6622 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6623 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6624 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6626 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6629 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6631 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6632 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6633 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6634 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6635 {
6636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6637 /* .name = "Capture Source", */
6638 .name = "Input Source",
6639 .count = 2,
6640 .info = alc883_mux_enum_info,
6641 .get = alc883_mux_enum_get,
6642 .put = alc883_mux_enum_put,
6643 },
6644 { } /* end */
6645};
6646
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006647static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6651 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6652 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006656 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6658 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6661 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6662 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6663 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6664 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6665 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6666 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6667 {
6668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6669 /* .name = "Capture Source", */
6670 .name = "Input Source",
6671 .count = 2,
6672 .info = alc883_mux_enum_info,
6673 .get = alc883_mux_enum_get,
6674 .put = alc883_mux_enum_put,
6675 },
6676 { } /* end */
6677};
6678
6679static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6680 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6681 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6682 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6683 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6684 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6685 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6686 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6687 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6689 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6690 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6692 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006694 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006697 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6699 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6700 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6701 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6702 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6703 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6704 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6705 {
6706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6707 /* .name = "Capture Source", */
6708 .name = "Input Source",
6709 .count = 2,
6710 .info = alc883_mux_enum_info,
6711 .get = alc883_mux_enum_get,
6712 .put = alc883_mux_enum_put,
6713 },
6714 { } /* end */
6715};
6716
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006717static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6719 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6720 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6722 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6723 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6724 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6725 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6727 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6728 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006732 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006735 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006736 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6737 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6738 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6739 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6740 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6741
6742 {
6743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6744 /* .name = "Capture Source", */
6745 .name = "Input Source",
6746 .count = 1,
6747 .info = alc883_mux_enum_info,
6748 .get = alc883_mux_enum_get,
6749 .put = alc883_mux_enum_put,
6750 },
6751 { } /* end */
6752};
6753
Kailang Yangccc656c2006-10-17 12:32:26 +02006754static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6757 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6772 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6773 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6774 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6775 {
6776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6777 /* .name = "Capture Source", */
6778 .name = "Input Source",
6779 .count = 2,
6780 .info = alc883_mux_enum_info,
6781 .get = alc883_mux_enum_get,
6782 .put = alc883_mux_enum_put,
6783 },
6784 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006785};
Kailang Yangccc656c2006-10-17 12:32:26 +02006786
6787static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6790 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6792 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6797 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6798 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6799 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6800 {
6801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6802 /* .name = "Capture Source", */
6803 .name = "Input Source",
6804 .count = 2,
6805 .info = alc883_mux_enum_info,
6806 .get = alc883_mux_enum_get,
6807 .put = alc883_mux_enum_put,
6808 },
6809 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006810};
Kailang Yangccc656c2006-10-17 12:32:26 +02006811
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006812static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006815 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6816 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6821 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6822 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6823 {
6824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6825 /* .name = "Capture Source", */
6826 .name = "Input Source",
6827 .count = 1,
6828 .info = alc883_mux_enum_info,
6829 .get = alc883_mux_enum_get,
6830 .put = alc883_mux_enum_put,
6831 },
6832 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006833};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006834
Kailang Yang272a5272007-05-14 11:00:38 +02006835static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6836 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6837 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6838 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6843 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6844 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6845 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6846 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6847 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6848 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6849 {
6850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6851 /* .name = "Capture Source", */
6852 .name = "Input Source",
6853 .count = 2,
6854 .info = alc883_mux_enum_info,
6855 .get = alc883_mux_enum_get,
6856 .put = alc883_mux_enum_put,
6857 },
6858 { } /* end */
6859};
6860
6861static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6863 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6864 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6871 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6872 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6873 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6874 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6875 {
6876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6877 /* .name = "Capture Source", */
6878 .name = "Input Source",
6879 .count = 2,
6880 .info = alc883_mux_enum_info,
6881 .get = alc883_mux_enum_get,
6882 .put = alc883_mux_enum_put,
6883 },
6884 { } /* end */
6885};
6886
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006887static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6892 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6894 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6895 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6897 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6899 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6900 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6902 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6906 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6908 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6909 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6910 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6911 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6912 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6913 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6914 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6915 {
6916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6917 /* .name = "Capture Source", */
6918 .name = "Input Source",
6919 .count = 2,
6920 .info = alc883_mux_enum_info,
6921 .get = alc883_mux_enum_get,
6922 .put = alc883_mux_enum_put,
6923 },
6924 { } /* end */
6925};
6926
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006927static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6930 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6931 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6932 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6933 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6934 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6935 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6946 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6947 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6948 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6949 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6950 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6951 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6952 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6953 {
6954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6955 /* .name = "Capture Source", */
6956 .name = "Input Source",
6957 .count = 2,
6958 .info = alc883_mux_enum_info,
6959 .get = alc883_mux_enum_get,
6960 .put = alc883_mux_enum_put,
6961 },
6962 { } /* end */
6963};
6964
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006965static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6969 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6970 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6971 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6972 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6987 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6988 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6989 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6990 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6991 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6992 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6993 {
6994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6995 /* .name = "Capture Source", */
6996 .name = "Input Source",
6997 .count = 2,
6998 .info = alc883_mux_enum_info,
6999 .get = alc883_mux_enum_get,
7000 .put = alc883_mux_enum_put,
7001 },
7002 { } /* end */
7003};
7004
Tobin Davis2880a862007-08-07 11:50:26 +02007005static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007014 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7015 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7016 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7017 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7018 {
7019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7020 /* .name = "Capture Source", */
7021 .name = "Input Source",
7022 .count = 2,
7023 .info = alc883_mux_enum_info,
7024 .get = alc883_mux_enum_get,
7025 .put = alc883_mux_enum_put,
7026 },
7027 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007028};
Tobin Davis2880a862007-08-07 11:50:26 +02007029
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007030static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7031 {
7032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7033 .name = "Channel Mode",
7034 .info = alc_ch_mode_info,
7035 .get = alc_ch_mode_get,
7036 .put = alc_ch_mode_put,
7037 },
7038 { } /* end */
7039};
7040
7041static struct hda_verb alc883_init_verbs[] = {
7042 /* ADC1: mute amp left and right */
7043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7044 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7045 /* ADC2: mute amp left and right */
7046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7047 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7048 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7052 /* Rear mixer */
7053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7056 /* CLFE mixer */
7057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7060 /* Side mixer */
7061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7062 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7064
Takashi Iwaicb53c622007-08-10 17:21:45 +02007065 /* mute analog input loopbacks */
7066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007071
7072 /* Front Pin: output 0 (0x0c) */
7073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7074 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7075 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7076 /* Rear Pin: output 1 (0x0d) */
7077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7080 /* CLFE Pin: output 2 (0x0e) */
7081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7082 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7083 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7084 /* Side Pin: output 3 (0x0f) */
7085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7087 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7088 /* Mic (rear) pin: input vref at 80% */
7089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7091 /* Front Mic pin: input vref at 80% */
7092 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7094 /* Line In pin: input */
7095 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7097 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7099 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7100 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7101 /* CD pin widget for input */
7102 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7103
7104 /* FIXME: use matrix-type input source selection */
7105 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7106 /* Input mixer2 */
7107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7111 /* Input mixer3 */
7112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7116 { }
7117};
7118
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007119/* toggle speaker-output according to the hp-jack state */
7120static void alc883_mitac_hp_automute(struct hda_codec *codec)
7121{
7122 unsigned int present;
7123
7124 present = snd_hda_codec_read(codec, 0x15, 0,
7125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7126 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7128 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7129 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7130}
7131
7132/* auto-toggle front mic */
7133/*
7134static void alc883_mitac_mic_automute(struct hda_codec *codec)
7135{
7136 unsigned int present;
7137 unsigned char bits;
7138
7139 present = snd_hda_codec_read(codec, 0x18, 0,
7140 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7141 bits = present ? HDA_AMP_MUTE : 0;
7142 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7143}
7144*/
7145
7146static void alc883_mitac_automute(struct hda_codec *codec)
7147{
7148 alc883_mitac_hp_automute(codec);
7149 /* alc883_mitac_mic_automute(codec); */
7150}
7151
7152static void alc883_mitac_unsol_event(struct hda_codec *codec,
7153 unsigned int res)
7154{
7155 switch (res >> 26) {
7156 case ALC880_HP_EVENT:
7157 alc883_mitac_hp_automute(codec);
7158 break;
7159 case ALC880_MIC_EVENT:
7160 /* alc883_mitac_mic_automute(codec); */
7161 break;
7162 }
7163}
7164
7165static struct hda_verb alc883_mitac_verbs[] = {
7166 /* HP */
7167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7169 /* Subwoofer */
7170 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7171 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7172
7173 /* enable unsolicited event */
7174 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7175 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7176
7177 { } /* end */
7178};
7179
Kailang Yangccc656c2006-10-17 12:32:26 +02007180static struct hda_verb alc883_tagra_verbs[] = {
7181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7183
7184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7186
7187 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7188 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7189 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7190
7191 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007192 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7193 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7194 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007195
7196 { } /* end */
7197};
7198
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007199static struct hda_verb alc883_lenovo_101e_verbs[] = {
7200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7201 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7202 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7203 { } /* end */
7204};
7205
Kailang Yang272a5272007-05-14 11:00:38 +02007206static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7209 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7211 { } /* end */
7212};
7213
7214static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7217 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7218 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7219 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7220 { } /* end */
7221};
7222
Kailang Yang189609a2007-08-20 11:31:23 +02007223static struct hda_verb alc883_haier_w66_verbs[] = {
7224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7226
7227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7228
7229 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7230 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7231 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7233 { } /* end */
7234};
7235
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007236static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7239 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7240 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7241 { }
7242};
7243
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007244static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007245 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7246 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7247 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7248 { }
7249};
7250
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007251static struct hda_verb alc888_6st_dell_verbs[] = {
7252 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7254 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7255 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7257 { }
7258};
7259
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007260static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007261 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7262 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7263 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7264 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7265 { }
7266};
7267
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007268static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007269 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7270 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7271 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7272 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7273 { }
7274};
7275
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007276static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7277 { 2, alc888_3st_hp_2ch_init },
7278 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007279};
7280
Kailang Yang272a5272007-05-14 11:00:38 +02007281/* toggle front-jack and RCA according to the hp-jack state */
7282static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7283{
7284 unsigned int present;
7285
7286 present = snd_hda_codec_read(codec, 0x1b, 0,
7287 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007288 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7289 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7290 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7291 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007292}
7293
7294/* toggle RCA according to the front-jack state */
7295static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7296{
7297 unsigned int present;
7298
7299 present = snd_hda_codec_read(codec, 0x14, 0,
7300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007301 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7302 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007303}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007304
Kailang Yang272a5272007-05-14 11:00:38 +02007305static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7306 unsigned int res)
7307{
7308 if ((res >> 26) == ALC880_HP_EVENT)
7309 alc888_lenovo_ms7195_front_automute(codec);
7310 if ((res >> 26) == ALC880_FRONT_EVENT)
7311 alc888_lenovo_ms7195_rca_automute(codec);
7312}
7313
7314static struct hda_verb alc883_medion_md2_verbs[] = {
7315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7317
7318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7319
7320 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7321 { } /* end */
7322};
7323
7324/* toggle speaker-output according to the hp-jack state */
7325static void alc883_medion_md2_automute(struct hda_codec *codec)
7326{
7327 unsigned int present;
7328
7329 present = snd_hda_codec_read(codec, 0x14, 0,
7330 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007331 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7332 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007333}
7334
7335static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7336 unsigned int res)
7337{
7338 if ((res >> 26) == ALC880_HP_EVENT)
7339 alc883_medion_md2_automute(codec);
7340}
7341
Kailang Yangccc656c2006-10-17 12:32:26 +02007342/* toggle speaker-output according to the hp-jack state */
7343static void alc883_tagra_automute(struct hda_codec *codec)
7344{
7345 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007346 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007347
7348 present = snd_hda_codec_read(codec, 0x14, 0,
7349 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007350 bits = present ? HDA_AMP_MUTE : 0;
7351 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7352 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007353 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7354 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007355}
7356
7357static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7358{
7359 if ((res >> 26) == ALC880_HP_EVENT)
7360 alc883_tagra_automute(codec);
7361}
7362
Kailang Yang189609a2007-08-20 11:31:23 +02007363static void alc883_haier_w66_automute(struct hda_codec *codec)
7364{
7365 unsigned int present;
7366 unsigned char bits;
7367
7368 present = snd_hda_codec_read(codec, 0x1b, 0,
7369 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7370 bits = present ? 0x80 : 0;
7371 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7372 0x80, bits);
7373}
7374
7375static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7376 unsigned int res)
7377{
7378 if ((res >> 26) == ALC880_HP_EVENT)
7379 alc883_haier_w66_automute(codec);
7380}
7381
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007382static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7383{
7384 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007385 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007386
7387 present = snd_hda_codec_read(codec, 0x14, 0,
7388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007389 bits = present ? HDA_AMP_MUTE : 0;
7390 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7391 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007392}
7393
7394static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7395{
7396 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007397 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007398
7399 present = snd_hda_codec_read(codec, 0x1b, 0,
7400 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007401 bits = present ? HDA_AMP_MUTE : 0;
7402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7403 HDA_AMP_MUTE, bits);
7404 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7405 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007406}
7407
7408static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7409 unsigned int res)
7410{
7411 if ((res >> 26) == ALC880_HP_EVENT)
7412 alc883_lenovo_101e_all_automute(codec);
7413 if ((res >> 26) == ALC880_FRONT_EVENT)
7414 alc883_lenovo_101e_ispeaker_automute(codec);
7415}
7416
Takashi Iwai676a9b52007-08-16 15:23:35 +02007417/* toggle speaker-output according to the hp-jack state */
7418static void alc883_acer_aspire_automute(struct hda_codec *codec)
7419{
7420 unsigned int present;
7421
7422 present = snd_hda_codec_read(codec, 0x14, 0,
7423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7424 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7425 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7426 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7427 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7428}
7429
7430static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7431 unsigned int res)
7432{
7433 if ((res >> 26) == ALC880_HP_EVENT)
7434 alc883_acer_aspire_automute(codec);
7435}
7436
Kailang Yangd1a991a2007-08-15 16:21:59 +02007437static struct hda_verb alc883_acer_eapd_verbs[] = {
7438 /* HP Pin: output 0 (0x0c) */
7439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7441 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7444 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007445 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007446 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7447 /* eanable EAPD on medion laptop */
7448 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7449 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007450 /* enable unsolicited event */
7451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007452 { }
7453};
7454
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007455static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7456{
7457 unsigned int present;
7458
7459 present = snd_hda_codec_read(codec, 0x1b, 0,
7460 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7461 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7463 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7464 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7465 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7466 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7467 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7468 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7469}
7470
7471static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7472 unsigned int res)
7473{
7474 switch (res >> 26) {
7475 case ALC880_HP_EVENT:
7476 printk("hp_event\n");
7477 alc888_6st_dell_front_automute(codec);
7478 break;
7479 }
7480}
7481
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007482/*
7483 * generic initialization of ADC, input mixers and output mixers
7484 */
7485static struct hda_verb alc883_auto_init_verbs[] = {
7486 /*
7487 * Unmute ADC0-2 and set the default input to mic-in
7488 */
7489 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493
Takashi Iwaicb53c622007-08-10 17:21:45 +02007494 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007495 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007496 * Note: PASD motherboards uses the Line In 2 as the input for
7497 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007498 */
7499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007505
7506 /*
7507 * Set up output mixers (0x0c - 0x0f)
7508 */
7509 /* set vol=0 to output mixers */
7510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7514 /* set up input amps for analog loopback */
7515 /* Amp Indices: DAC = 0, mixer = 1 */
7516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7522 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7524 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7525 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7526
7527 /* FIXME: use matrix-type input source selection */
7528 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7529 /* Input mixer1 */
7530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007533 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7535 /* Input mixer2 */
7536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007539 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007541
7542 { }
7543};
7544
7545/* capture mixer elements */
7546static struct snd_kcontrol_new alc883_capture_mixer[] = {
7547 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7548 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7549 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7550 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7551 {
7552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7553 /* The multiple "Capture Source" controls confuse alsamixer
7554 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007555 */
7556 /* .name = "Capture Source", */
7557 .name = "Input Source",
7558 .count = 2,
7559 .info = alc882_mux_enum_info,
7560 .get = alc882_mux_enum_get,
7561 .put = alc882_mux_enum_put,
7562 },
7563 { } /* end */
7564};
7565
Takashi Iwaicb53c622007-08-10 17:21:45 +02007566#ifdef CONFIG_SND_HDA_POWER_SAVE
7567#define alc883_loopbacks alc880_loopbacks
7568#endif
7569
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007570/* pcm configuration: identiacal with ALC880 */
7571#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7572#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007573#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007574#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7575#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7576
7577/*
7578 * configuration and preset
7579 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007580static const char *alc883_models[ALC883_MODEL_LAST] = {
7581 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7582 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7583 [ALC883_3ST_6ch] = "3stack-6ch",
7584 [ALC883_6ST_DIG] = "6stack-dig",
7585 [ALC883_TARGA_DIG] = "targa-dig",
7586 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007587 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007588 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007589 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007590 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007591 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007592 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007593 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7594 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007595 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007596 [ALC888_6ST_HP] = "6stack-hp",
7597 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007598 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007599 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007600 [ALC883_AUTO] = "auto",
7601};
7602
7603static struct snd_pci_quirk alc883_cfg_tbl[] = {
7604 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007605 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7606 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7607 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7608 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007609 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007610 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007611 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7612 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7613 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7614 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007615 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007616 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7617 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7618 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007619 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007620 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7621 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7622 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7625 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7627 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7628 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7629 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7630 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7631 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7632 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007633 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7634 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007635 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007636 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007637 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007638 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007639 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7640 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007641 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007642 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007643 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007644 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007645 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7646 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007647 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007648 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007649 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007650 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007651 {}
7652};
7653
7654static struct alc_config_preset alc883_presets[] = {
7655 [ALC883_3ST_2ch_DIG] = {
7656 .mixers = { alc883_3ST_2ch_mixer },
7657 .init_verbs = { alc883_init_verbs },
7658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7659 .dac_nids = alc883_dac_nids,
7660 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007661 .dig_in_nid = ALC883_DIGIN_NID,
7662 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7663 .channel_mode = alc883_3ST_2ch_modes,
7664 .input_mux = &alc883_capture_source,
7665 },
7666 [ALC883_3ST_6ch_DIG] = {
7667 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7668 .init_verbs = { alc883_init_verbs },
7669 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7670 .dac_nids = alc883_dac_nids,
7671 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007672 .dig_in_nid = ALC883_DIGIN_NID,
7673 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7674 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007675 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007676 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007677 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007678 [ALC883_3ST_6ch] = {
7679 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7680 .init_verbs = { alc883_init_verbs },
7681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7682 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007683 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7684 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007685 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007686 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007687 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007688 [ALC883_6ST_DIG] = {
7689 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7690 .init_verbs = { alc883_init_verbs },
7691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7692 .dac_nids = alc883_dac_nids,
7693 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007694 .dig_in_nid = ALC883_DIGIN_NID,
7695 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7696 .channel_mode = alc883_sixstack_modes,
7697 .input_mux = &alc883_capture_source,
7698 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007699 [ALC883_TARGA_DIG] = {
7700 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7701 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7702 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7703 .dac_nids = alc883_dac_nids,
7704 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007705 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7706 .channel_mode = alc883_3ST_6ch_modes,
7707 .need_dac_fix = 1,
7708 .input_mux = &alc883_capture_source,
7709 .unsol_event = alc883_tagra_unsol_event,
7710 .init_hook = alc883_tagra_automute,
7711 },
7712 [ALC883_TARGA_2ch_DIG] = {
7713 .mixers = { alc883_tagra_2ch_mixer},
7714 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7715 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7716 .dac_nids = alc883_dac_nids,
7717 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007718 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7719 .channel_mode = alc883_3ST_2ch_modes,
7720 .input_mux = &alc883_capture_source,
7721 .unsol_event = alc883_tagra_unsol_event,
7722 .init_hook = alc883_tagra_automute,
7723 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007724 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007725 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007726 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7727 * and the headphone jack. Turn this on and rely on the
7728 * standard mute methods whenever the user wants to turn
7729 * these outputs off.
7730 */
7731 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7733 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7735 .channel_mode = alc883_3ST_2ch_modes,
7736 .input_mux = &alc883_capture_source,
7737 },
Tobin Davis2880a862007-08-07 11:50:26 +02007738 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007739 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007740 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007741 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7742 .dac_nids = alc883_dac_nids,
7743 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02007744 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7745 .channel_mode = alc883_3ST_2ch_modes,
7746 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007747 .unsol_event = alc883_acer_aspire_unsol_event,
7748 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007749 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007750 [ALC883_MEDION] = {
7751 .mixers = { alc883_fivestack_mixer,
7752 alc883_chmode_mixer },
7753 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007754 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7756 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02007757 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7758 .channel_mode = alc883_sixstack_modes,
7759 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007760 },
Kailang Yang272a5272007-05-14 11:00:38 +02007761 [ALC883_MEDION_MD2] = {
7762 .mixers = { alc883_medion_md2_mixer},
7763 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7764 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7765 .dac_nids = alc883_dac_nids,
7766 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007767 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7768 .channel_mode = alc883_3ST_2ch_modes,
7769 .input_mux = &alc883_capture_source,
7770 .unsol_event = alc883_medion_md2_unsol_event,
7771 .init_hook = alc883_medion_md2_automute,
7772 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007773 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007774 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007775 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7776 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7777 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007778 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7779 .channel_mode = alc883_3ST_2ch_modes,
7780 .input_mux = &alc883_capture_source,
7781 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007782 [ALC883_LENOVO_101E_2ch] = {
7783 .mixers = { alc883_lenovo_101e_2ch_mixer},
7784 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7786 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7788 .channel_mode = alc883_3ST_2ch_modes,
7789 .input_mux = &alc883_lenovo_101e_capture_source,
7790 .unsol_event = alc883_lenovo_101e_unsol_event,
7791 .init_hook = alc883_lenovo_101e_all_automute,
7792 },
Kailang Yang272a5272007-05-14 11:00:38 +02007793 [ALC883_LENOVO_NB0763] = {
7794 .mixers = { alc883_lenovo_nb0763_mixer },
7795 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7796 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7797 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7799 .channel_mode = alc883_3ST_2ch_modes,
7800 .need_dac_fix = 1,
7801 .input_mux = &alc883_lenovo_nb0763_capture_source,
7802 .unsol_event = alc883_medion_md2_unsol_event,
7803 .init_hook = alc883_medion_md2_automute,
7804 },
7805 [ALC888_LENOVO_MS7195_DIG] = {
7806 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7807 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7809 .dac_nids = alc883_dac_nids,
7810 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7812 .channel_mode = alc883_3ST_6ch_modes,
7813 .need_dac_fix = 1,
7814 .input_mux = &alc883_capture_source,
7815 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7816 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007817 },
7818 [ALC883_HAIER_W66] = {
7819 .mixers = { alc883_tagra_2ch_mixer},
7820 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7821 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7822 .dac_nids = alc883_dac_nids,
7823 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02007824 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7825 .channel_mode = alc883_3ST_2ch_modes,
7826 .input_mux = &alc883_capture_source,
7827 .unsol_event = alc883_haier_w66_unsol_event,
7828 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007829 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007830 [ALC888_6ST_HP] = {
7831 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7832 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007833 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7834 .dac_nids = alc883_dac_nids,
7835 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007836 .dig_in_nid = ALC883_DIGIN_NID,
7837 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7838 .channel_mode = alc883_sixstack_modes,
7839 .input_mux = &alc883_capture_source,
7840 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007841 [ALC888_3ST_HP] = {
7842 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7843 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7845 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007846 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7847 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007848 .need_dac_fix = 1,
7849 .input_mux = &alc883_capture_source,
7850 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007851 [ALC888_6ST_DELL] = {
7852 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7853 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7854 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7855 .dac_nids = alc883_dac_nids,
7856 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007857 .dig_in_nid = ALC883_DIGIN_NID,
7858 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7859 .channel_mode = alc883_sixstack_modes,
7860 .input_mux = &alc883_capture_source,
7861 .unsol_event = alc888_6st_dell_unsol_event,
7862 .init_hook = alc888_6st_dell_front_automute,
7863 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007864 [ALC883_MITAC] = {
7865 .mixers = { alc883_mitac_mixer },
7866 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7867 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7868 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007869 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7870 .channel_mode = alc883_3ST_2ch_modes,
7871 .input_mux = &alc883_capture_source,
7872 .unsol_event = alc883_mitac_unsol_event,
7873 .init_hook = alc883_mitac_automute,
7874 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007875};
7876
7877
7878/*
7879 * BIOS auto configuration
7880 */
7881static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7882 hda_nid_t nid, int pin_type,
7883 int dac_idx)
7884{
7885 /* set as output */
7886 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007887 int idx;
7888
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007889 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007890 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7891 idx = 4;
7892 else
7893 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007894 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7895
7896}
7897
7898static void alc883_auto_init_multi_out(struct hda_codec *codec)
7899{
7900 struct alc_spec *spec = codec->spec;
7901 int i;
7902
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007903 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007904 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007905 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007906 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007907 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007908 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007909 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007910 }
7911}
7912
7913static void alc883_auto_init_hp_out(struct hda_codec *codec)
7914{
7915 struct alc_spec *spec = codec->spec;
7916 hda_nid_t pin;
7917
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007918 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007919 if (pin) /* connect to front */
7920 /* use dac 0 */
7921 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007922 pin = spec->autocfg.speaker_pins[0];
7923 if (pin)
7924 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007925}
7926
7927#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7928#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7929
7930static void alc883_auto_init_analog_input(struct hda_codec *codec)
7931{
7932 struct alc_spec *spec = codec->spec;
7933 int i;
7934
7935 for (i = 0; i < AUTO_PIN_LAST; i++) {
7936 hda_nid_t nid = spec->autocfg.input_pins[i];
7937 if (alc883_is_input_pin(nid)) {
7938 snd_hda_codec_write(codec, nid, 0,
7939 AC_VERB_SET_PIN_WIDGET_CONTROL,
7940 (i <= AUTO_PIN_FRONT_MIC ?
7941 PIN_VREF80 : PIN_IN));
7942 if (nid != ALC883_PIN_CD_NID)
7943 snd_hda_codec_write(codec, nid, 0,
7944 AC_VERB_SET_AMP_GAIN_MUTE,
7945 AMP_OUT_MUTE);
7946 }
7947 }
7948}
7949
7950/* almost identical with ALC880 parser... */
7951static int alc883_parse_auto_config(struct hda_codec *codec)
7952{
7953 struct alc_spec *spec = codec->spec;
7954 int err = alc880_parse_auto_config(codec);
7955
7956 if (err < 0)
7957 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007958 else if (!err)
7959 return 0; /* no config found */
7960
7961 err = alc_auto_add_mic_boost(codec);
7962 if (err < 0)
7963 return err;
7964
7965 /* hack - override the init verbs */
7966 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007967 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7968 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007969
7970 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007971}
7972
7973/* additional initialization for auto-configuration model */
7974static void alc883_auto_init(struct hda_codec *codec)
7975{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007976 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007977 alc883_auto_init_multi_out(codec);
7978 alc883_auto_init_hp_out(codec);
7979 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007980 if (spec->unsol_event)
7981 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007982}
7983
7984static int patch_alc883(struct hda_codec *codec)
7985{
7986 struct alc_spec *spec;
7987 int err, board_config;
7988
7989 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7990 if (spec == NULL)
7991 return -ENOMEM;
7992
7993 codec->spec = spec;
7994
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007995 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7996 alc883_models,
7997 alc883_cfg_tbl);
7998 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007999 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8000 "trying auto-probe from BIOS...\n");
8001 board_config = ALC883_AUTO;
8002 }
8003
8004 if (board_config == ALC883_AUTO) {
8005 /* automatic parse from the BIOS config */
8006 err = alc883_parse_auto_config(codec);
8007 if (err < 0) {
8008 alc_free(codec);
8009 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008010 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008011 printk(KERN_INFO
8012 "hda_codec: Cannot set up configuration "
8013 "from BIOS. Using base mode...\n");
8014 board_config = ALC883_3ST_2ch_DIG;
8015 }
8016 }
8017
8018 if (board_config != ALC883_AUTO)
8019 setup_preset(spec, &alc883_presets[board_config]);
8020
8021 spec->stream_name_analog = "ALC883 Analog";
8022 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8023 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008024 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008025
8026 spec->stream_name_digital = "ALC883 Digital";
8027 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8028 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8029
Takashi Iwaie1406342008-02-11 18:32:32 +01008030 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8031 spec->adc_nids = alc883_adc_nids;
8032 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008033
Takashi Iwai2134ea42008-01-10 16:53:55 +01008034 spec->vmaster_nid = 0x0c;
8035
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008036 codec->patch_ops = alc_patch_ops;
8037 if (board_config == ALC883_AUTO)
8038 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008039#ifdef CONFIG_SND_HDA_POWER_SAVE
8040 if (!spec->loopback.amplist)
8041 spec->loopback.amplist = alc883_loopbacks;
8042#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008043
8044 return 0;
8045}
8046
8047/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008048 * ALC262 support
8049 */
8050
8051#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8052#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8053
8054#define alc262_dac_nids alc260_dac_nids
8055#define alc262_adc_nids alc882_adc_nids
8056#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008057#define alc262_capsrc_nids alc882_capsrc_nids
8058#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008059
8060#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008061#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008062
8063static struct snd_kcontrol_new alc262_base_mixer[] = {
8064 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8065 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8074 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008075 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008076 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008077 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8080 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8081 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008082 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008083};
8084
Kailang Yangccc656c2006-10-17 12:32:26 +02008085static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8087 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8088 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8089 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8090 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8091 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008097 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008098 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008099 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008100 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8102 { } /* end */
8103};
8104
Takashi Iwaice875f02008-01-28 18:17:43 +01008105/* update HP, line and mono-out pins according to the master switch */
8106static void alc262_hp_master_update(struct hda_codec *codec)
8107{
8108 struct alc_spec *spec = codec->spec;
8109 int val = spec->master_sw;
8110
8111 /* HP & line-out */
8112 snd_hda_codec_write_cache(codec, 0x1b, 0,
8113 AC_VERB_SET_PIN_WIDGET_CONTROL,
8114 val ? PIN_HP : 0);
8115 snd_hda_codec_write_cache(codec, 0x15, 0,
8116 AC_VERB_SET_PIN_WIDGET_CONTROL,
8117 val ? PIN_HP : 0);
8118 /* mono (speaker) depending on the HP jack sense */
8119 val = val && !spec->jack_present;
8120 snd_hda_codec_write_cache(codec, 0x16, 0,
8121 AC_VERB_SET_PIN_WIDGET_CONTROL,
8122 val ? PIN_OUT : 0);
8123}
8124
8125static void alc262_hp_bpc_automute(struct hda_codec *codec)
8126{
8127 struct alc_spec *spec = codec->spec;
8128 unsigned int presence;
8129 presence = snd_hda_codec_read(codec, 0x1b, 0,
8130 AC_VERB_GET_PIN_SENSE, 0);
8131 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8132 alc262_hp_master_update(codec);
8133}
8134
8135static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8136{
8137 if ((res >> 26) != ALC880_HP_EVENT)
8138 return;
8139 alc262_hp_bpc_automute(codec);
8140}
8141
8142static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8143{
8144 struct alc_spec *spec = codec->spec;
8145 unsigned int presence;
8146 presence = snd_hda_codec_read(codec, 0x15, 0,
8147 AC_VERB_GET_PIN_SENSE, 0);
8148 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8149 alc262_hp_master_update(codec);
8150}
8151
8152static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8153 unsigned int res)
8154{
8155 if ((res >> 26) != ALC880_HP_EVENT)
8156 return;
8157 alc262_hp_wildwest_automute(codec);
8158}
8159
8160static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8161 struct snd_ctl_elem_value *ucontrol)
8162{
8163 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8164 struct alc_spec *spec = codec->spec;
8165 *ucontrol->value.integer.value = spec->master_sw;
8166 return 0;
8167}
8168
8169static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8170 struct snd_ctl_elem_value *ucontrol)
8171{
8172 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8173 struct alc_spec *spec = codec->spec;
8174 int val = !!*ucontrol->value.integer.value;
8175
8176 if (val == spec->master_sw)
8177 return 0;
8178 spec->master_sw = val;
8179 alc262_hp_master_update(codec);
8180 return 1;
8181}
8182
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008183static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008184 {
8185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8186 .name = "Master Playback Switch",
8187 .info = snd_ctl_boolean_mono_info,
8188 .get = alc262_hp_master_sw_get,
8189 .put = alc262_hp_master_sw_put,
8190 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8192 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8193 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008194 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8195 HDA_OUTPUT),
8196 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8197 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008201 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8202 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8208 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8209 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8210 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8211 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8212 { } /* end */
8213};
8214
Kailang Yangcd7509a2007-01-26 18:33:17 +01008215static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008216 {
8217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8218 .name = "Master Playback Switch",
8219 .info = snd_ctl_boolean_mono_info,
8220 .get = alc262_hp_master_sw_get,
8221 .put = alc262_hp_master_sw_put,
8222 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8224 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008227 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8228 HDA_OUTPUT),
8229 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8230 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008233 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, 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 { } /* end */
8241};
8242
8243static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8244 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8245 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008246 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008247 { } /* end */
8248};
8249
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008250/* mute/unmute internal speaker according to the hp jack and mute state */
8251static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8252{
8253 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008254
8255 if (force || !spec->sense_updated) {
8256 unsigned int present;
8257 present = snd_hda_codec_read(codec, 0x15, 0,
8258 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008259 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008260 spec->sense_updated = 1;
8261 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8263 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008264}
8265
8266static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8267 unsigned int res)
8268{
8269 if ((res >> 26) != ALC880_HP_EVENT)
8270 return;
8271 alc262_hp_t5735_automute(codec, 1);
8272}
8273
8274static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8275{
8276 alc262_hp_t5735_automute(codec, 1);
8277}
8278
8279static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008280 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8281 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8287 { } /* end */
8288};
8289
8290static struct hda_verb alc262_hp_t5735_verbs[] = {
8291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8293
8294 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8295 { }
8296};
8297
Kailang Yang8c427222008-01-10 13:03:59 +01008298static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008299 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008301 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8302 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008303 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8304 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8305 { } /* end */
8306};
8307
8308static struct hda_verb alc262_hp_rp5700_verbs[] = {
8309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8312 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8314 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8319 {}
8320};
8321
8322static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8323 .num_items = 1,
8324 .items = {
8325 { "Line", 0x1 },
8326 },
8327};
8328
Takashi Iwai0724ea22007-08-23 00:31:43 +02008329/* bind hp and internal speaker mute (with plug check) */
8330static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8331 struct snd_ctl_elem_value *ucontrol)
8332{
8333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8334 long *valp = ucontrol->value.integer.value;
8335 int change;
8336
8337 /* change hp mute */
8338 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8339 HDA_AMP_MUTE,
8340 valp[0] ? 0 : HDA_AMP_MUTE);
8341 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8342 HDA_AMP_MUTE,
8343 valp[1] ? 0 : HDA_AMP_MUTE);
8344 if (change) {
8345 /* change speaker according to HP jack state */
8346 struct alc_spec *spec = codec->spec;
8347 unsigned int mute;
8348 if (spec->jack_present)
8349 mute = HDA_AMP_MUTE;
8350 else
8351 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8352 HDA_OUTPUT, 0);
8353 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8354 HDA_AMP_MUTE, mute);
8355 }
8356 return change;
8357}
Takashi Iwai5b319542007-07-26 11:49:22 +02008358
Kailang Yang272a5272007-05-14 11:00:38 +02008359static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008360 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8361 {
8362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8363 .name = "Master Playback Switch",
8364 .info = snd_hda_mixer_amp_switch_info,
8365 .get = snd_hda_mixer_amp_switch_get,
8366 .put = alc262_sony_master_sw_put,
8367 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8368 },
Kailang Yang272a5272007-05-14 11:00:38 +02008369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8371 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8372 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8373 { } /* end */
8374};
8375
Kailang Yang83c34212007-07-05 11:43:05 +02008376static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8377 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8378 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8379 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8382 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8383 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8384 { } /* end */
8385};
Kailang Yang272a5272007-05-14 11:00:38 +02008386
Kailang Yangdf694da2005-12-05 19:42:22 +01008387#define alc262_capture_mixer alc882_capture_mixer
8388#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8389
8390/*
8391 * generic initialization of ADC, input mixers and output mixers
8392 */
8393static struct hda_verb alc262_init_verbs[] = {
8394 /*
8395 * Unmute ADC0-2 and set the default input to mic-in
8396 */
8397 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8399 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8401 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8402 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8403
Takashi Iwaicb53c622007-08-10 17:21:45 +02008404 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008405 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008406 * Note: PASD motherboards uses the Line In 2 as the input for
8407 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008408 */
8409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008415
8416 /*
8417 * Set up output mixers (0x0c - 0x0e)
8418 */
8419 /* set vol=0 to output mixers */
8420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8423 /* set up input amps for analog loopback */
8424 /* Amp Indices: DAC = 0, mixer = 1 */
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8429 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8431
8432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8434 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8437 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8438
8439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8441 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8442 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8443 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8444
8445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8446 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8447
8448 /* FIXME: use matrix-type input source selection */
8449 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8450 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8455 /* Input mixer2 */
8456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8460 /* Input mixer3 */
8461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008465
8466 { }
8467};
8468
Kailang Yangccc656c2006-10-17 12:32:26 +02008469static struct hda_verb alc262_hippo_unsol_verbs[] = {
8470 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8472 {}
8473};
8474
8475static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8479
8480 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8482 {}
8483};
8484
Kailang Yang272a5272007-05-14 11:00:38 +02008485static struct hda_verb alc262_sony_unsol_verbs[] = {
8486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8487 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8489
8490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8491 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8492};
8493
Kailang Yangccc656c2006-10-17 12:32:26 +02008494/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008495static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008496{
8497 struct alc_spec *spec = codec->spec;
8498 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008499 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008500
Takashi Iwai5b319542007-07-26 11:49:22 +02008501 /* need to execute and sync at first */
8502 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8503 present = snd_hda_codec_read(codec, 0x15, 0,
8504 AC_VERB_GET_PIN_SENSE, 0);
8505 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008506 if (spec->jack_present) {
8507 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008508 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8509 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008510 } else {
8511 /* unmute internal speaker if necessary */
8512 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008513 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8514 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008515 }
8516}
8517
8518/* unsolicited event for HP jack sensing */
8519static void alc262_hippo_unsol_event(struct hda_codec *codec,
8520 unsigned int res)
8521{
8522 if ((res >> 26) != ALC880_HP_EVENT)
8523 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008524 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008525}
8526
Takashi Iwai5b319542007-07-26 11:49:22 +02008527static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008528{
Kailang Yangccc656c2006-10-17 12:32:26 +02008529 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008530 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008531
Takashi Iwai5b319542007-07-26 11:49:22 +02008532 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8533 present = snd_hda_codec_read(codec, 0x1b, 0,
8534 AC_VERB_GET_PIN_SENSE, 0);
8535 present = (present & 0x80000000) != 0;
8536 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008537 /* 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, 0x1b, 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_hippo1_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_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008555}
8556
Takashi Iwai834be882006-03-01 14:16:17 +01008557/*
8558 * fujitsu model
8559 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8560 */
8561
8562#define ALC_HP_EVENT 0x37
8563
8564static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8567 {}
8568};
8569
8570static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008571 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008572 .items = {
8573 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008574 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008575 { "CD", 0x4 },
8576 },
8577};
8578
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008579static struct hda_input_mux alc262_HP_capture_source = {
8580 .num_items = 5,
8581 .items = {
8582 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008583 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008584 { "Line", 0x2 },
8585 { "CD", 0x4 },
8586 { "AUX IN", 0x6 },
8587 },
8588};
8589
zhejiangaccbe492007-08-31 12:36:05 +02008590static struct hda_input_mux alc262_HP_D7000_capture_source = {
8591 .num_items = 4,
8592 .items = {
8593 { "Mic", 0x0 },
8594 { "Front Mic", 0x2 },
8595 { "Line", 0x1 },
8596 { "CD", 0x4 },
8597 },
8598};
8599
Takashi Iwai834be882006-03-01 14:16:17 +01008600/* mute/unmute internal speaker according to the hp jack and mute state */
8601static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8602{
8603 struct alc_spec *spec = codec->spec;
8604 unsigned int mute;
8605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008606 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008607 unsigned int present;
8608 /* need to execute and sync at first */
8609 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8610 present = snd_hda_codec_read(codec, 0x14, 0,
8611 AC_VERB_GET_PIN_SENSE, 0);
8612 spec->jack_present = (present & 0x80000000) != 0;
8613 spec->sense_updated = 1;
8614 }
8615 if (spec->jack_present) {
8616 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008617 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8618 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008619 } else {
8620 /* unmute internal speaker if necessary */
8621 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008622 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8623 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008624 }
8625}
8626
8627/* unsolicited event for HP jack sensing */
8628static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8629 unsigned int res)
8630{
8631 if ((res >> 26) != ALC_HP_EVENT)
8632 return;
8633 alc262_fujitsu_automute(codec, 1);
8634}
8635
8636/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008637static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8638 .ops = &snd_hda_bind_vol,
8639 .values = {
8640 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8641 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8642 0
8643 },
8644};
Takashi Iwai834be882006-03-01 14:16:17 +01008645
8646/* bind hp and internal speaker mute (with plug check) */
8647static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8648 struct snd_ctl_elem_value *ucontrol)
8649{
8650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8651 long *valp = ucontrol->value.integer.value;
8652 int change;
8653
8654 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008655 HDA_AMP_MUTE,
8656 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008657 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008658 HDA_AMP_MUTE,
8659 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008660 if (change)
8661 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008662 return change;
8663}
8664
8665static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008666 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008667 {
8668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8669 .name = "Master Playback Switch",
8670 .info = snd_hda_mixer_amp_switch_info,
8671 .get = snd_hda_mixer_amp_switch_get,
8672 .put = alc262_fujitsu_master_sw_put,
8673 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8674 },
8675 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8676 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8677 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008680 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8681 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8682 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008683 { } /* end */
8684};
8685
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008686/* additional init verbs for Benq laptops */
8687static struct hda_verb alc262_EAPD_verbs[] = {
8688 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8689 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8690 {}
8691};
8692
Kailang Yang83c34212007-07-05 11:43:05 +02008693static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8696
8697 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8698 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8699 {}
8700};
8701
Tobin Davisf651b502007-10-26 12:40:47 +02008702/* Samsung Q1 Ultra Vista model setup */
8703static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8704 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8705 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8709 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8710 { } /* end */
8711};
8712
8713static struct hda_verb alc262_ultra_verbs[] = {
8714 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8716 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8717 /* Mic is on Node 0x19 */
8718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8719 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8720 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8721 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8723 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8725 {}
8726};
8727
8728static struct hda_input_mux alc262_ultra_capture_source = {
8729 .num_items = 1,
8730 .items = {
8731 { "Mic", 0x1 },
8732 },
8733};
8734
8735/* mute/unmute internal speaker according to the hp jack and mute state */
8736static void alc262_ultra_automute(struct hda_codec *codec)
8737{
8738 struct alc_spec *spec = codec->spec;
8739 unsigned int mute;
8740 unsigned int present;
8741
8742 /* need to execute and sync at first */
8743 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8744 present = snd_hda_codec_read(codec, 0x15, 0,
8745 AC_VERB_GET_PIN_SENSE, 0);
8746 spec->jack_present = (present & 0x80000000) != 0;
8747 if (spec->jack_present) {
8748 /* mute internal speaker */
8749 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8750 HDA_AMP_MUTE, HDA_AMP_MUTE);
8751 } else {
8752 /* unmute internal speaker if necessary */
8753 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8754 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8755 HDA_AMP_MUTE, mute);
8756 }
8757}
8758
8759/* unsolicited event for HP jack sensing */
8760static void alc262_ultra_unsol_event(struct hda_codec *codec,
8761 unsigned int res)
8762{
8763 if ((res >> 26) != ALC880_HP_EVENT)
8764 return;
8765 alc262_ultra_automute(codec);
8766}
8767
Kailang Yangdf694da2005-12-05 19:42:22 +01008768/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008769static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8770 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008771{
8772 hda_nid_t nid;
8773 int err;
8774
8775 spec->multiout.num_dacs = 1; /* only use one dac */
8776 spec->multiout.dac_nids = spec->private_dac_nids;
8777 spec->multiout.dac_nids[0] = 2;
8778
8779 nid = cfg->line_out_pins[0];
8780 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008781 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8782 "Front Playback Volume",
8783 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008786 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8787 "Front Playback Switch",
8788 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008790 return err;
8791 }
8792
Takashi Iwai82bc9552006-03-21 11:24:42 +01008793 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008794 if (nid) {
8795 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008796 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8797 "Speaker Playback Volume",
8798 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8799 HDA_OUTPUT));
8800 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008802 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8803 "Speaker Playback Switch",
8804 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8805 HDA_OUTPUT));
8806 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008807 return err;
8808 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008809 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8810 "Speaker Playback Switch",
8811 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8812 HDA_OUTPUT));
8813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008814 return err;
8815 }
8816 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008817 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008818 if (nid) {
8819 /* spec->multiout.hp_nid = 2; */
8820 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008821 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8822 "Headphone Playback Volume",
8823 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8824 HDA_OUTPUT));
8825 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008826 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008827 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8828 "Headphone Playback Switch",
8829 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8830 HDA_OUTPUT));
8831 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008832 return err;
8833 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008834 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8835 "Headphone Playback Switch",
8836 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8837 HDA_OUTPUT));
8838 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008839 return err;
8840 }
8841 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008842 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008843}
8844
8845/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008846#define alc262_auto_create_analog_input_ctls \
8847 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008848
8849/*
8850 * generic initialization of ADC, input mixers and output mixers
8851 */
8852static struct hda_verb alc262_volume_init_verbs[] = {
8853 /*
8854 * Unmute ADC0-2 and set the default input to mic-in
8855 */
8856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8858 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862
Takashi Iwaicb53c622007-08-10 17:21:45 +02008863 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008864 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008865 * Note: PASD motherboards uses the Line In 2 as the input for
8866 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008867 */
8868 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008874
8875 /*
8876 * Set up output mixers (0x0c - 0x0f)
8877 */
8878 /* set vol=0 to output mixers */
8879 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8880 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8882
8883 /* set up input amps for analog loopback */
8884 /* Amp Indices: DAC = 0, mixer = 1 */
8885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891
8892 /* FIXME: use matrix-type input source selection */
8893 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8894 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8899 /* Input mixer2 */
8900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8904 /* Input mixer3 */
8905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8909
8910 { }
8911};
8912
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008913static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8914 /*
8915 * Unmute ADC0-2 and set the default input to mic-in
8916 */
8917 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8920 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8921 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8923
Takashi Iwaicb53c622007-08-10 17:21:45 +02008924 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008925 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008926 * Note: PASD motherboards uses the Line In 2 as the input for
8927 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008928 */
8929 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008937
8938 /*
8939 * Set up output mixers (0x0c - 0x0e)
8940 */
8941 /* set vol=0 to output mixers */
8942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8945
8946 /* set up input amps for analog loopback */
8947 /* Amp Indices: DAC = 0, mixer = 1 */
8948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8954
Takashi Iwaice875f02008-01-28 18:17:43 +01008955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8958
8959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8961
8962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8964
8965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8967 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8968 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8970
8971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8975 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8976 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8977
8978
8979 /* FIXME: use matrix-type input source selection */
8980 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8981 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8986 /* Input mixer2 */
8987 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8988 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8989 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8991 /* Input mixer3 */
8992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8996
Takashi Iwaice875f02008-01-28 18:17:43 +01008997 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8998
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008999 { }
9000};
9001
Kailang Yangcd7509a2007-01-26 18:33:17 +01009002static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9003 /*
9004 * Unmute ADC0-2 and set the default input to mic-in
9005 */
9006 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9007 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9012
Takashi Iwaicb53c622007-08-10 17:21:45 +02009013 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009014 * mixer widget
9015 * Note: PASD motherboards uses the Line In 2 as the input for front
9016 * panel mic (mic 2)
9017 */
9018 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009027 /*
9028 * Set up output mixers (0x0c - 0x0e)
9029 */
9030 /* set vol=0 to output mixers */
9031 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9034
9035 /* set up input amps for analog loopback */
9036 /* Amp Indices: DAC = 0, mixer = 1 */
9037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9041 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9043
9044
9045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9046 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9051 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9052
9053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9055
9056 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9058
9059 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9061 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9063 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9064 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9065
9066 /* FIXME: use matrix-type input source selection */
9067 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9068 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9074 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9076 /* Input mixer2 */
9077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9079 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9082 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9084 /* Input mixer3 */
9085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9090 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9092
Takashi Iwaice875f02008-01-28 18:17:43 +01009093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9094
Kailang Yangcd7509a2007-01-26 18:33:17 +01009095 { }
9096};
9097
Takashi Iwaicb53c622007-08-10 17:21:45 +02009098#ifdef CONFIG_SND_HDA_POWER_SAVE
9099#define alc262_loopbacks alc880_loopbacks
9100#endif
9101
Kailang Yangdf694da2005-12-05 19:42:22 +01009102/* pcm configuration: identiacal with ALC880 */
9103#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9104#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9105#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9106#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9107
9108/*
9109 * BIOS auto configuration
9110 */
9111static int alc262_parse_auto_config(struct hda_codec *codec)
9112{
9113 struct alc_spec *spec = codec->spec;
9114 int err;
9115 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9116
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009117 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9118 alc262_ignore);
9119 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009120 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009121 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009122 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009123 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9124 if (err < 0)
9125 return err;
9126 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9127 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009128 return err;
9129
9130 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9131
9132 if (spec->autocfg.dig_out_pin)
9133 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9134 if (spec->autocfg.dig_in_pin)
9135 spec->dig_in_nid = ALC262_DIGIN_NID;
9136
9137 if (spec->kctl_alloc)
9138 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9139
9140 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009141 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009142 spec->input_mux = &spec->private_imux;
9143
Takashi Iwai776e1842007-08-29 15:07:11 +02009144 err = alc_auto_add_mic_boost(codec);
9145 if (err < 0)
9146 return err;
9147
Kailang Yangdf694da2005-12-05 19:42:22 +01009148 return 1;
9149}
9150
9151#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9152#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9153#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9154
9155
9156/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009157static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009158{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009159 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009160 alc262_auto_init_multi_out(codec);
9161 alc262_auto_init_hp_out(codec);
9162 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009163 if (spec->unsol_event)
9164 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009165}
9166
9167/*
9168 * configuration and preset
9169 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009170static const char *alc262_models[ALC262_MODEL_LAST] = {
9171 [ALC262_BASIC] = "basic",
9172 [ALC262_HIPPO] = "hippo",
9173 [ALC262_HIPPO_1] = "hippo_1",
9174 [ALC262_FUJITSU] = "fujitsu",
9175 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009176 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009177 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009178 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009179 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009180 [ALC262_BENQ_T31] = "benq-t31",
9181 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009182 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009183 [ALC262_AUTO] = "auto",
9184};
9185
9186static struct snd_pci_quirk alc262_cfg_tbl[] = {
9187 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9188 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009189 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009190 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9191 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009192 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009193 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009194 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009195 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009196 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009197 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009198 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009199 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009200 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009201 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009202 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009203 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009204 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9205 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9206 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009207 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9208 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009209 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009210 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009211 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009212 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9213 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9214 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009215 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009216 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009217 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009218 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009219 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009220 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009221 {}
9222};
9223
9224static struct alc_config_preset alc262_presets[] = {
9225 [ALC262_BASIC] = {
9226 .mixers = { alc262_base_mixer },
9227 .init_verbs = { alc262_init_verbs },
9228 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9229 .dac_nids = alc262_dac_nids,
9230 .hp_nid = 0x03,
9231 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9232 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009233 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009234 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009235 [ALC262_HIPPO] = {
9236 .mixers = { alc262_base_mixer },
9237 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9238 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9239 .dac_nids = alc262_dac_nids,
9240 .hp_nid = 0x03,
9241 .dig_out_nid = ALC262_DIGOUT_NID,
9242 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9243 .channel_mode = alc262_modes,
9244 .input_mux = &alc262_capture_source,
9245 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009246 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009247 },
9248 [ALC262_HIPPO_1] = {
9249 .mixers = { alc262_hippo1_mixer },
9250 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9251 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9252 .dac_nids = alc262_dac_nids,
9253 .hp_nid = 0x02,
9254 .dig_out_nid = ALC262_DIGOUT_NID,
9255 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9256 .channel_mode = alc262_modes,
9257 .input_mux = &alc262_capture_source,
9258 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009259 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009260 },
Takashi Iwai834be882006-03-01 14:16:17 +01009261 [ALC262_FUJITSU] = {
9262 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009263 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9264 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009265 .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_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009272 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009273 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009274 [ALC262_HP_BPC] = {
9275 .mixers = { alc262_HP_BPC_mixer },
9276 .init_verbs = { alc262_HP_BPC_init_verbs },
9277 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9278 .dac_nids = alc262_dac_nids,
9279 .hp_nid = 0x03,
9280 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9281 .channel_mode = alc262_modes,
9282 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009283 .unsol_event = alc262_hp_bpc_unsol_event,
9284 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009285 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009286 [ALC262_HP_BPC_D7000_WF] = {
9287 .mixers = { alc262_HP_BPC_WildWest_mixer },
9288 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9289 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9290 .dac_nids = alc262_dac_nids,
9291 .hp_nid = 0x03,
9292 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9293 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009294 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009295 .unsol_event = alc262_hp_wildwest_unsol_event,
9296 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009297 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009298 [ALC262_HP_BPC_D7000_WL] = {
9299 .mixers = { alc262_HP_BPC_WildWest_mixer,
9300 alc262_HP_BPC_WildWest_option_mixer },
9301 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9302 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9303 .dac_nids = alc262_dac_nids,
9304 .hp_nid = 0x03,
9305 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9306 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009307 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009308 .unsol_event = alc262_hp_wildwest_unsol_event,
9309 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009310 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009311 [ALC262_HP_TC_T5735] = {
9312 .mixers = { alc262_hp_t5735_mixer },
9313 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9314 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9315 .dac_nids = alc262_dac_nids,
9316 .hp_nid = 0x03,
9317 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9318 .channel_mode = alc262_modes,
9319 .input_mux = &alc262_capture_source,
9320 .unsol_event = alc262_hp_t5735_unsol_event,
9321 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009322 },
9323 [ALC262_HP_RP5700] = {
9324 .mixers = { alc262_hp_rp5700_mixer },
9325 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9326 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9327 .dac_nids = alc262_dac_nids,
9328 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9329 .channel_mode = alc262_modes,
9330 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009331 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009332 [ALC262_BENQ_ED8] = {
9333 .mixers = { alc262_base_mixer },
9334 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9335 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9336 .dac_nids = alc262_dac_nids,
9337 .hp_nid = 0x03,
9338 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9339 .channel_mode = alc262_modes,
9340 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009341 },
Kailang Yang272a5272007-05-14 11:00:38 +02009342 [ALC262_SONY_ASSAMD] = {
9343 .mixers = { alc262_sony_mixer },
9344 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9345 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9346 .dac_nids = alc262_dac_nids,
9347 .hp_nid = 0x02,
9348 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9349 .channel_mode = alc262_modes,
9350 .input_mux = &alc262_capture_source,
9351 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009352 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009353 },
9354 [ALC262_BENQ_T31] = {
9355 .mixers = { alc262_benq_t31_mixer },
9356 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9357 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9358 .dac_nids = alc262_dac_nids,
9359 .hp_nid = 0x03,
9360 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9361 .channel_mode = alc262_modes,
9362 .input_mux = &alc262_capture_source,
9363 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009364 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009365 },
Tobin Davisf651b502007-10-26 12:40:47 +02009366 [ALC262_ULTRA] = {
9367 .mixers = { alc262_ultra_mixer },
9368 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9369 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9370 .dac_nids = alc262_dac_nids,
9371 .hp_nid = 0x03,
9372 .dig_out_nid = ALC262_DIGOUT_NID,
9373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9374 .channel_mode = alc262_modes,
9375 .input_mux = &alc262_ultra_capture_source,
9376 .unsol_event = alc262_ultra_unsol_event,
9377 .init_hook = alc262_ultra_automute,
9378 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009379};
9380
9381static int patch_alc262(struct hda_codec *codec)
9382{
9383 struct alc_spec *spec;
9384 int board_config;
9385 int err;
9386
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009387 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009388 if (spec == NULL)
9389 return -ENOMEM;
9390
9391 codec->spec = spec;
9392#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009393 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9394 * under-run
9395 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009396 {
9397 int tmp;
9398 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9399 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9400 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9401 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9402 }
9403#endif
9404
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009405 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9406 alc262_models,
9407 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009408
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009409 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009410 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9411 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009412 board_config = ALC262_AUTO;
9413 }
9414
9415 if (board_config == ALC262_AUTO) {
9416 /* automatic parse from the BIOS config */
9417 err = alc262_parse_auto_config(codec);
9418 if (err < 0) {
9419 alc_free(codec);
9420 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009421 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009422 printk(KERN_INFO
9423 "hda_codec: Cannot set up configuration "
9424 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009425 board_config = ALC262_BASIC;
9426 }
9427 }
9428
9429 if (board_config != ALC262_AUTO)
9430 setup_preset(spec, &alc262_presets[board_config]);
9431
9432 spec->stream_name_analog = "ALC262 Analog";
9433 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9434 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9435
9436 spec->stream_name_digital = "ALC262 Digital";
9437 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9438 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9439
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009440 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009441 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009442 unsigned int wcap = get_wcaps(codec, 0x07);
9443
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009444 /* get type */
9445 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009446 if (wcap != AC_WID_AUD_IN) {
9447 spec->adc_nids = alc262_adc_nids_alt;
9448 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009449 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009450 spec->mixers[spec->num_mixers] =
9451 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009452 spec->num_mixers++;
9453 } else {
9454 spec->adc_nids = alc262_adc_nids;
9455 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009456 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009457 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9458 spec->num_mixers++;
9459 }
9460 }
9461
Takashi Iwai2134ea42008-01-10 16:53:55 +01009462 spec->vmaster_nid = 0x0c;
9463
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 codec->patch_ops = alc_patch_ops;
9465 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009466 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009467#ifdef CONFIG_SND_HDA_POWER_SAVE
9468 if (!spec->loopback.amplist)
9469 spec->loopback.amplist = alc262_loopbacks;
9470#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009471
Kailang Yangdf694da2005-12-05 19:42:22 +01009472 return 0;
9473}
9474
Kailang Yangdf694da2005-12-05 19:42:22 +01009475/*
Kailang Yanga361d842007-06-05 12:30:55 +02009476 * ALC268 channel source setting (2 channel)
9477 */
9478#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9479#define alc268_modes alc260_modes
9480
9481static hda_nid_t alc268_dac_nids[2] = {
9482 /* front, hp */
9483 0x02, 0x03
9484};
9485
9486static hda_nid_t alc268_adc_nids[2] = {
9487 /* ADC0-1 */
9488 0x08, 0x07
9489};
9490
9491static hda_nid_t alc268_adc_nids_alt[1] = {
9492 /* ADC0 */
9493 0x08
9494};
9495
Takashi Iwaie1406342008-02-11 18:32:32 +01009496static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9497
Kailang Yanga361d842007-06-05 12:30:55 +02009498static struct snd_kcontrol_new alc268_base_mixer[] = {
9499 /* output mixer control */
9500 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9501 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009504 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9505 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9506 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009507 { }
9508};
9509
Kailang Yangd1a991a2007-08-15 16:21:59 +02009510static struct hda_verb alc268_eapd_verbs[] = {
9511 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9512 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9513 { }
9514};
9515
Takashi Iwaid2738092007-08-16 14:59:45 +02009516/* Toshiba specific */
9517#define alc268_toshiba_automute alc262_hippo_automute
9518
9519static struct hda_verb alc268_toshiba_verbs[] = {
9520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9521 { } /* end */
9522};
9523
9524/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009525/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009526static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9527 .ops = &snd_hda_bind_vol,
9528 .values = {
9529 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9530 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9531 0
9532 },
9533};
9534
Takashi Iwai889c4392007-08-23 18:56:52 +02009535/* mute/unmute internal speaker according to the hp jack and mute state */
9536static void alc268_acer_automute(struct hda_codec *codec, int force)
9537{
9538 struct alc_spec *spec = codec->spec;
9539 unsigned int mute;
9540
9541 if (force || !spec->sense_updated) {
9542 unsigned int present;
9543 present = snd_hda_codec_read(codec, 0x14, 0,
9544 AC_VERB_GET_PIN_SENSE, 0);
9545 spec->jack_present = (present & 0x80000000) != 0;
9546 spec->sense_updated = 1;
9547 }
9548 if (spec->jack_present)
9549 mute = HDA_AMP_MUTE; /* mute internal speaker */
9550 else /* unmute internal speaker if necessary */
9551 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9552 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9553 HDA_AMP_MUTE, mute);
9554}
9555
9556
9557/* bind hp and internal speaker mute (with plug check) */
9558static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9559 struct snd_ctl_elem_value *ucontrol)
9560{
9561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9562 long *valp = ucontrol->value.integer.value;
9563 int change;
9564
9565 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9566 HDA_AMP_MUTE,
9567 valp[0] ? 0 : HDA_AMP_MUTE);
9568 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9569 HDA_AMP_MUTE,
9570 valp[1] ? 0 : HDA_AMP_MUTE);
9571 if (change)
9572 alc268_acer_automute(codec, 0);
9573 return change;
9574}
Takashi Iwaid2738092007-08-16 14:59:45 +02009575
9576static struct snd_kcontrol_new alc268_acer_mixer[] = {
9577 /* output mixer control */
9578 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9579 {
9580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9581 .name = "Master Playback Switch",
9582 .info = snd_hda_mixer_amp_switch_info,
9583 .get = snd_hda_mixer_amp_switch_get,
9584 .put = alc268_acer_master_sw_put,
9585 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9586 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009587 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9588 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9589 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009590 { }
9591};
9592
9593static struct hda_verb alc268_acer_verbs[] = {
9594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9596
9597 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9598 { }
9599};
9600
9601/* unsolicited event for HP jack sensing */
9602static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9603 unsigned int res)
9604{
Takashi Iwai889c4392007-08-23 18:56:52 +02009605 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009606 return;
9607 alc268_toshiba_automute(codec);
9608}
9609
9610static void alc268_acer_unsol_event(struct hda_codec *codec,
9611 unsigned int res)
9612{
Takashi Iwai889c4392007-08-23 18:56:52 +02009613 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009614 return;
9615 alc268_acer_automute(codec, 1);
9616}
9617
Takashi Iwai889c4392007-08-23 18:56:52 +02009618static void alc268_acer_init_hook(struct hda_codec *codec)
9619{
9620 alc268_acer_automute(codec, 1);
9621}
9622
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009623static struct snd_kcontrol_new alc268_dell_mixer[] = {
9624 /* output mixer control */
9625 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9626 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9627 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9629 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9630 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9631 { }
9632};
9633
9634static struct hda_verb alc268_dell_verbs[] = {
9635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9637 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9638 { }
9639};
9640
9641/* mute/unmute internal speaker according to the hp jack and mute state */
9642static void alc268_dell_automute(struct hda_codec *codec)
9643{
9644 unsigned int present;
9645 unsigned int mute;
9646
9647 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9648 if (present & 0x80000000)
9649 mute = HDA_AMP_MUTE;
9650 else
9651 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9652 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9653 HDA_AMP_MUTE, mute);
9654}
9655
9656static void alc268_dell_unsol_event(struct hda_codec *codec,
9657 unsigned int res)
9658{
9659 if ((res >> 26) != ALC880_HP_EVENT)
9660 return;
9661 alc268_dell_automute(codec);
9662}
9663
9664#define alc268_dell_init_hook alc268_dell_automute
9665
Kailang Yanga361d842007-06-05 12:30:55 +02009666/*
9667 * generic initialization of ADC, input mixers and output mixers
9668 */
9669static struct hda_verb alc268_base_init_verbs[] = {
9670 /* Unmute DAC0-1 and set vol = 0 */
9671 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9672 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9673 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9674 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9675 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9676 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9677
9678 /*
9679 * Set up output mixers (0x0c - 0x0e)
9680 */
9681 /* set vol=0 to output mixers */
9682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9685 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9686
9687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9688 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9689
9690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9693 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9695 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9697 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9698
9699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9705 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9706 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9707
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009708 /* Unmute Selector 23h,24h and set the default input to mic-in */
9709
9710 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9711 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9712 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009714
Kailang Yanga361d842007-06-05 12:30:55 +02009715 { }
9716};
9717
9718/*
9719 * generic initialization of ADC, input mixers and output mixers
9720 */
9721static struct hda_verb alc268_volume_init_verbs[] = {
9722 /* set output DAC */
9723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9724 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9725 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9726 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9727
9728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9730 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9731 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9732 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9733
9734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9739
9740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9743 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9744
9745 /* set PCBEEP vol = 0 */
9746 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9747
9748 { }
9749};
9750
9751#define alc268_mux_enum_info alc_mux_enum_info
9752#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01009753#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +02009754
9755static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9756 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9757 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9758 {
9759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9760 /* The multiple "Capture Source" controls confuse alsamixer
9761 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009762 */
9763 /* .name = "Capture Source", */
9764 .name = "Input Source",
9765 .count = 1,
9766 .info = alc268_mux_enum_info,
9767 .get = alc268_mux_enum_get,
9768 .put = alc268_mux_enum_put,
9769 },
9770 { } /* end */
9771};
9772
9773static struct snd_kcontrol_new alc268_capture_mixer[] = {
9774 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9775 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9776 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9777 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9778 {
9779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9780 /* The multiple "Capture Source" controls confuse alsamixer
9781 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009782 */
9783 /* .name = "Capture Source", */
9784 .name = "Input Source",
9785 .count = 2,
9786 .info = alc268_mux_enum_info,
9787 .get = alc268_mux_enum_get,
9788 .put = alc268_mux_enum_put,
9789 },
9790 { } /* end */
9791};
9792
9793static struct hda_input_mux alc268_capture_source = {
9794 .num_items = 4,
9795 .items = {
9796 { "Mic", 0x0 },
9797 { "Front Mic", 0x1 },
9798 { "Line", 0x2 },
9799 { "CD", 0x3 },
9800 },
9801};
9802
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009803#ifdef CONFIG_SND_DEBUG
9804static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009805 /* Volume widgets */
9806 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9807 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9808 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9809 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9810 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9811 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9812 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9813 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9814 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9815 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9816 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9817 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9818 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009819 /* The below appears problematic on some hardwares */
9820 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009821 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9822 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9823 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9824 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9825
9826 /* Modes for retasking pin widgets */
9827 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9828 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9829 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9830 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9831
9832 /* Controls for GPIO pins, assuming they are configured as outputs */
9833 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9834 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9835 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9836 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9837
9838 /* Switches to allow the digital SPDIF output pin to be enabled.
9839 * The ALC268 does not have an SPDIF input.
9840 */
9841 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9842
9843 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9844 * this output to turn on an external amplifier.
9845 */
9846 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9847 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9848
9849 { } /* end */
9850};
9851#endif
9852
Kailang Yanga361d842007-06-05 12:30:55 +02009853/* create input playback/capture controls for the given pin */
9854static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9855 const char *ctlname, int idx)
9856{
9857 char name[32];
9858 int err;
9859
9860 sprintf(name, "%s Playback Volume", ctlname);
9861 if (nid == 0x14) {
9862 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9863 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9864 HDA_OUTPUT));
9865 if (err < 0)
9866 return err;
9867 } else if (nid == 0x15) {
9868 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9869 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9870 HDA_OUTPUT));
9871 if (err < 0)
9872 return err;
9873 } else
9874 return -1;
9875 sprintf(name, "%s Playback Switch", ctlname);
9876 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9877 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9878 if (err < 0)
9879 return err;
9880 return 0;
9881}
9882
9883/* add playback controls from the parsed DAC table */
9884static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9885 const struct auto_pin_cfg *cfg)
9886{
9887 hda_nid_t nid;
9888 int err;
9889
9890 spec->multiout.num_dacs = 2; /* only use one dac */
9891 spec->multiout.dac_nids = spec->private_dac_nids;
9892 spec->multiout.dac_nids[0] = 2;
9893 spec->multiout.dac_nids[1] = 3;
9894
9895 nid = cfg->line_out_pins[0];
9896 if (nid)
9897 alc268_new_analog_output(spec, nid, "Front", 0);
9898
9899 nid = cfg->speaker_pins[0];
9900 if (nid == 0x1d) {
9901 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9902 "Speaker Playback Volume",
9903 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9904 if (err < 0)
9905 return err;
9906 }
9907 nid = cfg->hp_pins[0];
9908 if (nid)
9909 alc268_new_analog_output(spec, nid, "Headphone", 0);
9910
9911 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9912 if (nid == 0x16) {
9913 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9914 "Mono Playback Switch",
9915 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9916 if (err < 0)
9917 return err;
9918 }
9919 return 0;
9920}
9921
9922/* create playback/capture controls for input pins */
9923static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9924 const struct auto_pin_cfg *cfg)
9925{
9926 struct hda_input_mux *imux = &spec->private_imux;
9927 int i, idx1;
9928
9929 for (i = 0; i < AUTO_PIN_LAST; i++) {
9930 switch(cfg->input_pins[i]) {
9931 case 0x18:
9932 idx1 = 0; /* Mic 1 */
9933 break;
9934 case 0x19:
9935 idx1 = 1; /* Mic 2 */
9936 break;
9937 case 0x1a:
9938 idx1 = 2; /* Line In */
9939 break;
9940 case 0x1c:
9941 idx1 = 3; /* CD */
9942 break;
9943 default:
9944 continue;
9945 }
9946 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9947 imux->items[imux->num_items].index = idx1;
9948 imux->num_items++;
9949 }
9950 return 0;
9951}
9952
9953static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9954{
9955 struct alc_spec *spec = codec->spec;
9956 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9957 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9958 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9959 unsigned int dac_vol1, dac_vol2;
9960
9961 if (speaker_nid) {
9962 snd_hda_codec_write(codec, speaker_nid, 0,
9963 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9964 snd_hda_codec_write(codec, 0x0f, 0,
9965 AC_VERB_SET_AMP_GAIN_MUTE,
9966 AMP_IN_UNMUTE(1));
9967 snd_hda_codec_write(codec, 0x10, 0,
9968 AC_VERB_SET_AMP_GAIN_MUTE,
9969 AMP_IN_UNMUTE(1));
9970 } else {
9971 snd_hda_codec_write(codec, 0x0f, 0,
9972 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9973 snd_hda_codec_write(codec, 0x10, 0,
9974 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9975 }
9976
9977 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9978 if (line_nid == 0x14)
9979 dac_vol2 = AMP_OUT_ZERO;
9980 else if (line_nid == 0x15)
9981 dac_vol1 = AMP_OUT_ZERO;
9982 if (hp_nid == 0x14)
9983 dac_vol2 = AMP_OUT_ZERO;
9984 else if (hp_nid == 0x15)
9985 dac_vol1 = AMP_OUT_ZERO;
9986 if (line_nid != 0x16 || hp_nid != 0x16 ||
9987 spec->autocfg.line_out_pins[1] != 0x16 ||
9988 spec->autocfg.line_out_pins[2] != 0x16)
9989 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9990
9991 snd_hda_codec_write(codec, 0x02, 0,
9992 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9993 snd_hda_codec_write(codec, 0x03, 0,
9994 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9995}
9996
9997/* pcm configuration: identiacal with ALC880 */
9998#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9999#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010000#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010001#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10002
10003/*
10004 * BIOS auto configuration
10005 */
10006static int alc268_parse_auto_config(struct hda_codec *codec)
10007{
10008 struct alc_spec *spec = codec->spec;
10009 int err;
10010 static hda_nid_t alc268_ignore[] = { 0 };
10011
10012 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10013 alc268_ignore);
10014 if (err < 0)
10015 return err;
10016 if (!spec->autocfg.line_outs)
10017 return 0; /* can't find valid BIOS pin config */
10018
10019 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10020 if (err < 0)
10021 return err;
10022 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10023 if (err < 0)
10024 return err;
10025
10026 spec->multiout.max_channels = 2;
10027
10028 /* digital only support output */
10029 if (spec->autocfg.dig_out_pin)
10030 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10031
10032 if (spec->kctl_alloc)
10033 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10034
10035 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10036 spec->num_mux_defs = 1;
10037 spec->input_mux = &spec->private_imux;
10038
Takashi Iwai776e1842007-08-29 15:07:11 +020010039 err = alc_auto_add_mic_boost(codec);
10040 if (err < 0)
10041 return err;
10042
Kailang Yanga361d842007-06-05 12:30:55 +020010043 return 1;
10044}
10045
10046#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10047#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10048#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10049
10050/* init callback for auto-configuration model -- overriding the default init */
10051static void alc268_auto_init(struct hda_codec *codec)
10052{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010053 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010054 alc268_auto_init_multi_out(codec);
10055 alc268_auto_init_hp_out(codec);
10056 alc268_auto_init_mono_speaker_out(codec);
10057 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010058 if (spec->unsol_event)
10059 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010060}
10061
10062/*
10063 * configuration and preset
10064 */
10065static const char *alc268_models[ALC268_MODEL_LAST] = {
10066 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010067 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010068 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010069 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010070 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010071#ifdef CONFIG_SND_DEBUG
10072 [ALC268_TEST] = "test",
10073#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010074 [ALC268_AUTO] = "auto",
10075};
10076
10077static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010078 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010079 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010080 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010081 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010082 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010083 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010084 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010085 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010086 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010087 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010088 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010089 {}
10090};
10091
10092static struct alc_config_preset alc268_presets[] = {
10093 [ALC268_3ST] = {
10094 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10095 .init_verbs = { alc268_base_init_verbs },
10096 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10097 .dac_nids = alc268_dac_nids,
10098 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10099 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010100 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010101 .hp_nid = 0x03,
10102 .dig_out_nid = ALC268_DIGOUT_NID,
10103 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10104 .channel_mode = alc268_modes,
10105 .input_mux = &alc268_capture_source,
10106 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010107 [ALC268_TOSHIBA] = {
10108 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010109 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10110 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010111 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10112 .dac_nids = alc268_dac_nids,
10113 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10114 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010115 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010116 .hp_nid = 0x03,
10117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10118 .channel_mode = alc268_modes,
10119 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010120 .unsol_event = alc268_toshiba_unsol_event,
10121 .init_hook = alc268_toshiba_automute,
10122 },
10123 [ALC268_ACER] = {
10124 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10125 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10126 alc268_acer_verbs },
10127 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10128 .dac_nids = alc268_dac_nids,
10129 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10130 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010131 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010132 .hp_nid = 0x02,
10133 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10134 .channel_mode = alc268_modes,
10135 .input_mux = &alc268_capture_source,
10136 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010137 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010138 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010139 [ALC268_DELL] = {
10140 .mixers = { alc268_dell_mixer },
10141 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10142 alc268_dell_verbs },
10143 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10144 .dac_nids = alc268_dac_nids,
10145 .hp_nid = 0x02,
10146 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10147 .channel_mode = alc268_modes,
10148 .unsol_event = alc268_dell_unsol_event,
10149 .init_hook = alc268_dell_init_hook,
10150 .input_mux = &alc268_capture_source,
10151 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010152 [ALC268_ZEPTO] = {
10153 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10154 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10155 alc268_toshiba_verbs },
10156 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10157 .dac_nids = alc268_dac_nids,
10158 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10159 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010160 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010161 .hp_nid = 0x03,
10162 .dig_out_nid = ALC268_DIGOUT_NID,
10163 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10164 .channel_mode = alc268_modes,
10165 .input_mux = &alc268_capture_source,
10166 .unsol_event = alc268_toshiba_unsol_event,
10167 .init_hook = alc268_toshiba_automute
10168 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010169#ifdef CONFIG_SND_DEBUG
10170 [ALC268_TEST] = {
10171 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10172 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10173 alc268_volume_init_verbs },
10174 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10175 .dac_nids = alc268_dac_nids,
10176 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10177 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010178 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010179 .hp_nid = 0x03,
10180 .dig_out_nid = ALC268_DIGOUT_NID,
10181 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10182 .channel_mode = alc268_modes,
10183 .input_mux = &alc268_capture_source,
10184 },
10185#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010186};
10187
10188static int patch_alc268(struct hda_codec *codec)
10189{
10190 struct alc_spec *spec;
10191 int board_config;
10192 int err;
10193
10194 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10195 if (spec == NULL)
10196 return -ENOMEM;
10197
10198 codec->spec = spec;
10199
10200 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10201 alc268_models,
10202 alc268_cfg_tbl);
10203
10204 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10205 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10206 "trying auto-probe from BIOS...\n");
10207 board_config = ALC268_AUTO;
10208 }
10209
10210 if (board_config == ALC268_AUTO) {
10211 /* automatic parse from the BIOS config */
10212 err = alc268_parse_auto_config(codec);
10213 if (err < 0) {
10214 alc_free(codec);
10215 return err;
10216 } else if (!err) {
10217 printk(KERN_INFO
10218 "hda_codec: Cannot set up configuration "
10219 "from BIOS. Using base mode...\n");
10220 board_config = ALC268_3ST;
10221 }
10222 }
10223
10224 if (board_config != ALC268_AUTO)
10225 setup_preset(spec, &alc268_presets[board_config]);
10226
10227 spec->stream_name_analog = "ALC268 Analog";
10228 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10229 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010230 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010231
10232 spec->stream_name_digital = "ALC268 Digital";
10233 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10234
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010235 if (!spec->adc_nids && spec->input_mux) {
10236 /* check whether NID 0x07 is valid */
10237 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010238
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010239 /* get type */
10240 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10241 if (wcap != AC_WID_AUD_IN) {
10242 spec->adc_nids = alc268_adc_nids_alt;
10243 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10244 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010245 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010246 spec->num_mixers++;
10247 } else {
10248 spec->adc_nids = alc268_adc_nids;
10249 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10250 spec->mixers[spec->num_mixers] =
10251 alc268_capture_mixer;
10252 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010253 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010254 spec->capsrc_nids = alc268_capsrc_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020010255 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010256
10257 spec->vmaster_nid = 0x02;
10258
Kailang Yanga361d842007-06-05 12:30:55 +020010259 codec->patch_ops = alc_patch_ops;
10260 if (board_config == ALC268_AUTO)
10261 spec->init_hook = alc268_auto_init;
10262
10263 return 0;
10264}
10265
10266/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010267 * ALC269 channel source setting (2 channel)
10268 */
10269#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10270
10271#define alc269_dac_nids alc260_dac_nids
10272
10273static hda_nid_t alc269_adc_nids[1] = {
10274 /* ADC1 */
10275 0x07,
10276};
10277
10278#define alc269_modes alc260_modes
10279#define alc269_capture_source alc880_lg_lw_capture_source
10280
10281static struct snd_kcontrol_new alc269_base_mixer[] = {
10282 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10283 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10288 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10289 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10291 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10293 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10294 { } /* end */
10295};
10296
10297/* capture mixer elements */
10298static struct snd_kcontrol_new alc269_capture_mixer[] = {
10299 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10300 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10301 {
10302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10303 /* The multiple "Capture Source" controls confuse alsamixer
10304 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010305 */
10306 /* .name = "Capture Source", */
10307 .name = "Input Source",
10308 .count = 1,
10309 .info = alc_mux_enum_info,
10310 .get = alc_mux_enum_get,
10311 .put = alc_mux_enum_put,
10312 },
10313 { } /* end */
10314};
10315
10316/*
10317 * generic initialization of ADC, input mixers and output mixers
10318 */
10319static struct hda_verb alc269_init_verbs[] = {
10320 /*
10321 * Unmute ADC0 and set the default input to mic-in
10322 */
10323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10324
10325 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10326 * analog-loopback mixer widget
10327 * Note: PASD motherboards uses the Line In 2 as the input for
10328 * front panel mic (mic 2)
10329 */
10330 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10336
10337 /*
10338 * Set up output mixers (0x0c - 0x0e)
10339 */
10340 /* set vol=0 to output mixers */
10341 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10342 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10343
10344 /* set up input amps for analog loopback */
10345 /* Amp Indices: DAC = 0, mixer = 1 */
10346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10352
10353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10357 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10360
10361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10364 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10365 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10367 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10368
10369 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10371
10372 /* FIXME: use matrix-type input source selection */
10373 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10374 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10379
10380 /* set EAPD */
10381 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10382 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10383 { }
10384};
10385
10386/* add playback controls from the parsed DAC table */
10387static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10388 const struct auto_pin_cfg *cfg)
10389{
10390 hda_nid_t nid;
10391 int err;
10392
10393 spec->multiout.num_dacs = 1; /* only use one dac */
10394 spec->multiout.dac_nids = spec->private_dac_nids;
10395 spec->multiout.dac_nids[0] = 2;
10396
10397 nid = cfg->line_out_pins[0];
10398 if (nid) {
10399 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10400 "Front Playback Volume",
10401 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10402 if (err < 0)
10403 return err;
10404 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10405 "Front Playback Switch",
10406 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10407 if (err < 0)
10408 return err;
10409 }
10410
10411 nid = cfg->speaker_pins[0];
10412 if (nid) {
10413 if (!cfg->line_out_pins[0]) {
10414 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10415 "Speaker Playback Volume",
10416 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10417 HDA_OUTPUT));
10418 if (err < 0)
10419 return err;
10420 }
10421 if (nid == 0x16) {
10422 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10423 "Speaker Playback Switch",
10424 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10425 HDA_OUTPUT));
10426 if (err < 0)
10427 return err;
10428 } else {
10429 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10430 "Speaker Playback Switch",
10431 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10432 HDA_OUTPUT));
10433 if (err < 0)
10434 return err;
10435 }
10436 }
10437 nid = cfg->hp_pins[0];
10438 if (nid) {
10439 /* spec->multiout.hp_nid = 2; */
10440 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10441 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10442 "Headphone Playback Volume",
10443 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10444 HDA_OUTPUT));
10445 if (err < 0)
10446 return err;
10447 }
10448 if (nid == 0x16) {
10449 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10450 "Headphone Playback Switch",
10451 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10452 HDA_OUTPUT));
10453 if (err < 0)
10454 return err;
10455 } else {
10456 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10457 "Headphone Playback Switch",
10458 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10459 HDA_OUTPUT));
10460 if (err < 0)
10461 return err;
10462 }
10463 }
10464 return 0;
10465}
10466
10467#define alc269_auto_create_analog_input_ctls \
10468 alc880_auto_create_analog_input_ctls
10469
10470#ifdef CONFIG_SND_HDA_POWER_SAVE
10471#define alc269_loopbacks alc880_loopbacks
10472#endif
10473
10474/* pcm configuration: identiacal with ALC880 */
10475#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10476#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10477#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10478#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10479
10480/*
10481 * BIOS auto configuration
10482 */
10483static int alc269_parse_auto_config(struct hda_codec *codec)
10484{
10485 struct alc_spec *spec = codec->spec;
10486 int err;
10487 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10488
10489 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10490 alc269_ignore);
10491 if (err < 0)
10492 return err;
10493
10494 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10495 if (err < 0)
10496 return err;
10497 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10498 if (err < 0)
10499 return err;
10500
10501 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10502
10503 if (spec->autocfg.dig_out_pin)
10504 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10505
10506 if (spec->kctl_alloc)
10507 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10508
10509 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10510 spec->num_mux_defs = 1;
10511 spec->input_mux = &spec->private_imux;
10512
10513 err = alc_auto_add_mic_boost(codec);
10514 if (err < 0)
10515 return err;
10516
10517 return 1;
10518}
10519
10520#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10521#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10522#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10523
10524
10525/* init callback for auto-configuration model -- overriding the default init */
10526static void alc269_auto_init(struct hda_codec *codec)
10527{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010528 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010010529 alc269_auto_init_multi_out(codec);
10530 alc269_auto_init_hp_out(codec);
10531 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010532 if (spec->unsol_event)
10533 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010010534}
10535
10536/*
10537 * configuration and preset
10538 */
10539static const char *alc269_models[ALC269_MODEL_LAST] = {
10540 [ALC269_BASIC] = "basic",
10541};
10542
10543static struct snd_pci_quirk alc269_cfg_tbl[] = {
10544 {}
10545};
10546
10547static struct alc_config_preset alc269_presets[] = {
10548 [ALC269_BASIC] = {
10549 .mixers = { alc269_base_mixer },
10550 .init_verbs = { alc269_init_verbs },
10551 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10552 .dac_nids = alc269_dac_nids,
10553 .hp_nid = 0x03,
10554 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10555 .channel_mode = alc269_modes,
10556 .input_mux = &alc269_capture_source,
10557 },
10558};
10559
10560static int patch_alc269(struct hda_codec *codec)
10561{
10562 struct alc_spec *spec;
10563 int board_config;
10564 int err;
10565
10566 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10567 if (spec == NULL)
10568 return -ENOMEM;
10569
10570 codec->spec = spec;
10571
10572 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10573 alc269_models,
10574 alc269_cfg_tbl);
10575
10576 if (board_config < 0) {
10577 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10578 "trying auto-probe from BIOS...\n");
10579 board_config = ALC269_AUTO;
10580 }
10581
10582 if (board_config == ALC269_AUTO) {
10583 /* automatic parse from the BIOS config */
10584 err = alc269_parse_auto_config(codec);
10585 if (err < 0) {
10586 alc_free(codec);
10587 return err;
10588 } else if (!err) {
10589 printk(KERN_INFO
10590 "hda_codec: Cannot set up configuration "
10591 "from BIOS. Using base mode...\n");
10592 board_config = ALC269_BASIC;
10593 }
10594 }
10595
10596 if (board_config != ALC269_AUTO)
10597 setup_preset(spec, &alc269_presets[board_config]);
10598
10599 spec->stream_name_analog = "ALC269 Analog";
10600 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10601 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10602
10603 spec->stream_name_digital = "ALC269 Digital";
10604 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10605 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10606
10607 spec->adc_nids = alc269_adc_nids;
10608 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10609 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10610 spec->num_mixers++;
10611
10612 codec->patch_ops = alc_patch_ops;
10613 if (board_config == ALC269_AUTO)
10614 spec->init_hook = alc269_auto_init;
10615#ifdef CONFIG_SND_HDA_POWER_SAVE
10616 if (!spec->loopback.amplist)
10617 spec->loopback.amplist = alc269_loopbacks;
10618#endif
10619
10620 return 0;
10621}
10622
10623/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010624 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10625 */
10626
10627/*
10628 * set the path ways for 2 channel output
10629 * need to set the codec line out and mic 1 pin widgets to inputs
10630 */
10631static struct hda_verb alc861_threestack_ch2_init[] = {
10632 /* set pin widget 1Ah (line in) for input */
10633 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 /* set pin widget 18h (mic1/2) for input, for mic also enable
10635 * the vref
10636 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010637 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10638
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010639 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10640#if 0
10641 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10642 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10643#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010644 { } /* end */
10645};
10646/*
10647 * 6ch mode
10648 * need to set the codec line out and mic 1 pin widgets to outputs
10649 */
10650static struct hda_verb alc861_threestack_ch6_init[] = {
10651 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10652 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10653 /* set pin widget 18h (mic1) for output (CLFE)*/
10654 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10655
10656 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010657 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010658
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010659 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10660#if 0
10661 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10662 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10663#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010664 { } /* end */
10665};
10666
10667static struct hda_channel_mode alc861_threestack_modes[2] = {
10668 { 2, alc861_threestack_ch2_init },
10669 { 6, alc861_threestack_ch6_init },
10670};
Takashi Iwai22309c32006-08-09 16:57:28 +020010671/* Set mic1 as input and unmute the mixer */
10672static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10673 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10675 { } /* end */
10676};
10677/* Set mic1 as output and mute mixer */
10678static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10679 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10680 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10681 { } /* end */
10682};
10683
10684static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10685 { 2, alc861_uniwill_m31_ch2_init },
10686 { 4, alc861_uniwill_m31_ch4_init },
10687};
Kailang Yangdf694da2005-12-05 19:42:22 +010010688
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010689/* Set mic1 and line-in as input and unmute the mixer */
10690static struct hda_verb alc861_asus_ch2_init[] = {
10691 /* set pin widget 1Ah (line in) for input */
10692 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010693 /* set pin widget 18h (mic1/2) for input, for mic also enable
10694 * the vref
10695 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010696 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10697
10698 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10699#if 0
10700 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10701 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10702#endif
10703 { } /* end */
10704};
10705/* Set mic1 nad line-in as output and mute mixer */
10706static struct hda_verb alc861_asus_ch6_init[] = {
10707 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10708 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10709 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10710 /* set pin widget 18h (mic1) for output (CLFE)*/
10711 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10712 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10713 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10714 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10715
10716 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10717#if 0
10718 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10719 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10720#endif
10721 { } /* end */
10722};
10723
10724static struct hda_channel_mode alc861_asus_modes[2] = {
10725 { 2, alc861_asus_ch2_init },
10726 { 6, alc861_asus_ch6_init },
10727};
10728
Kailang Yangdf694da2005-12-05 19:42:22 +010010729/* patch-ALC861 */
10730
10731static struct snd_kcontrol_new alc861_base_mixer[] = {
10732 /* output mixer control */
10733 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10734 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10735 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10736 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10737 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10738
10739 /*Input mixer control */
10740 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10741 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10742 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10743 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10744 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10745 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10747 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10748 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10749 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010750
Kailang Yangdf694da2005-12-05 19:42:22 +010010751 /* Capture mixer control */
10752 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10753 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10754 {
10755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10756 .name = "Capture Source",
10757 .count = 1,
10758 .info = alc_mux_enum_info,
10759 .get = alc_mux_enum_get,
10760 .put = alc_mux_enum_put,
10761 },
10762 { } /* end */
10763};
10764
10765static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10766 /* output mixer control */
10767 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10768 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10769 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10770 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10771 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10772
10773 /* Input mixer control */
10774 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10775 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10776 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10777 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10778 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10779 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10781 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10782 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010784
Kailang Yangdf694da2005-12-05 19:42:22 +010010785 /* Capture mixer control */
10786 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10787 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10788 {
10789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10790 .name = "Capture Source",
10791 .count = 1,
10792 .info = alc_mux_enum_info,
10793 .get = alc_mux_enum_get,
10794 .put = alc_mux_enum_put,
10795 },
10796 {
10797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10798 .name = "Channel Mode",
10799 .info = alc_ch_mode_info,
10800 .get = alc_ch_mode_get,
10801 .put = alc_ch_mode_put,
10802 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10803 },
10804 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010805};
10806
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010807static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010808 /* output mixer control */
10809 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10811 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10812
10813 /*Capture mixer control */
10814 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10815 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10816 {
10817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10818 .name = "Capture Source",
10819 .count = 1,
10820 .info = alc_mux_enum_info,
10821 .get = alc_mux_enum_get,
10822 .put = alc_mux_enum_put,
10823 },
10824
10825 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010826};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010827
Takashi Iwai22309c32006-08-09 16:57:28 +020010828static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10829 /* output mixer control */
10830 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10831 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10832 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10833 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10834 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10835
10836 /* Input mixer control */
10837 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10838 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10839 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10840 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10841 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10842 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10844 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010847
Takashi Iwai22309c32006-08-09 16:57:28 +020010848 /* Capture mixer control */
10849 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10850 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10851 {
10852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10853 .name = "Capture Source",
10854 .count = 1,
10855 .info = alc_mux_enum_info,
10856 .get = alc_mux_enum_get,
10857 .put = alc_mux_enum_put,
10858 },
10859 {
10860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10861 .name = "Channel Mode",
10862 .info = alc_ch_mode_info,
10863 .get = alc_ch_mode_get,
10864 .put = alc_ch_mode_put,
10865 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10866 },
10867 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010869
10870static struct snd_kcontrol_new alc861_asus_mixer[] = {
10871 /* output mixer control */
10872 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10873 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10874 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10875 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10876 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10877
10878 /* Input mixer control */
10879 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10880 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10882 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10883 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10884 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10886 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10889
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010890 /* Capture mixer control */
10891 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10892 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10893 {
10894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10895 .name = "Capture Source",
10896 .count = 1,
10897 .info = alc_mux_enum_info,
10898 .get = alc_mux_enum_get,
10899 .put = alc_mux_enum_put,
10900 },
10901 {
10902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10903 .name = "Channel Mode",
10904 .info = alc_ch_mode_info,
10905 .get = alc_ch_mode_get,
10906 .put = alc_ch_mode_put,
10907 .private_value = ARRAY_SIZE(alc861_asus_modes),
10908 },
10909 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010910};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010911
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010912/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010913static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010914 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10915 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10916 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10917 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10918 { }
10919};
10920
Kailang Yangdf694da2005-12-05 19:42:22 +010010921/*
10922 * generic initialization of ADC, input mixers and output mixers
10923 */
10924static struct hda_verb alc861_base_init_verbs[] = {
10925 /*
10926 * Unmute ADC0 and set the default input to mic-in
10927 */
10928 /* port-A for surround (rear panel) */
10929 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10930 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10931 /* port-B for mic-in (rear panel) with vref */
10932 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10933 /* port-C for line-in (rear panel) */
10934 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10935 /* port-D for Front */
10936 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10937 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10938 /* port-E for HP out (front panel) */
10939 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10940 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010941 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010942 /* port-F for mic-in (front panel) with vref */
10943 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10944 /* port-G for CLFE (rear panel) */
10945 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10946 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10947 /* port-H for side (rear panel) */
10948 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10949 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10950 /* CD-in */
10951 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10952 /* route front mic to ADC1*/
10953 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10955
10956 /* Unmute DAC0~3 & spdif out*/
10957 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10959 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10960 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10962
10963 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10964 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10965 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10966 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10967 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10968
10969 /* Unmute Stereo Mixer 15 */
10970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010974
10975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10982 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010983 /* hp used DAC 3 (Front) */
10984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10986
10987 { }
10988};
10989
10990static struct hda_verb alc861_threestack_init_verbs[] = {
10991 /*
10992 * Unmute ADC0 and set the default input to mic-in
10993 */
10994 /* port-A for surround (rear panel) */
10995 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10996 /* port-B for mic-in (rear panel) with vref */
10997 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10998 /* port-C for line-in (rear panel) */
10999 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11000 /* port-D for Front */
11001 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11002 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11003 /* port-E for HP out (front panel) */
11004 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11005 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011006 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011007 /* port-F for mic-in (front panel) with vref */
11008 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11009 /* port-G for CLFE (rear panel) */
11010 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11011 /* port-H for side (rear panel) */
11012 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11013 /* CD-in */
11014 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11015 /* route front mic to ADC1*/
11016 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 /* Unmute DAC0~3 & spdif out*/
11019 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11022 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11024
11025 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11026 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11028 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11030
11031 /* Unmute Stereo Mixer 15 */
11032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011036
11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011045 /* hp used DAC 3 (Front) */
11046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11048 { }
11049};
Takashi Iwai22309c32006-08-09 16:57:28 +020011050
11051static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11052 /*
11053 * Unmute ADC0 and set the default input to mic-in
11054 */
11055 /* port-A for surround (rear panel) */
11056 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11057 /* port-B for mic-in (rear panel) with vref */
11058 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11059 /* port-C for line-in (rear panel) */
11060 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11061 /* port-D for Front */
11062 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11063 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11064 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011065 /* this has to be set to VREF80 */
11066 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011067 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011068 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011069 /* port-F for mic-in (front panel) with vref */
11070 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11071 /* port-G for CLFE (rear panel) */
11072 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11073 /* port-H for side (rear panel) */
11074 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11075 /* CD-in */
11076 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11077 /* route front mic to ADC1*/
11078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11080 /* Unmute DAC0~3 & spdif out*/
11081 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11082 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11083 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11084 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11086
11087 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11088 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11089 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11090 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092
11093 /* Unmute Stereo Mixer 15 */
11094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11095 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011098
11099 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11100 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11101 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11103 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11104 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11105 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11106 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011107 /* hp used DAC 3 (Front) */
11108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011109 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11110 { }
11111};
11112
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011113static struct hda_verb alc861_asus_init_verbs[] = {
11114 /*
11115 * Unmute ADC0 and set the default input to mic-in
11116 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011117 /* port-A for surround (rear panel)
11118 * according to codec#0 this is the HP jack
11119 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011120 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11121 /* route front PCM to HP */
11122 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11123 /* port-B for mic-in (rear panel) with vref */
11124 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11125 /* port-C for line-in (rear panel) */
11126 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11127 /* port-D for Front */
11128 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11129 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11130 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011131 /* this has to be set to VREF80 */
11132 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011133 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011134 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011135 /* port-F for mic-in (front panel) with vref */
11136 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11137 /* port-G for CLFE (rear panel) */
11138 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11139 /* port-H for side (rear panel) */
11140 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11141 /* CD-in */
11142 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11143 /* route front mic to ADC1*/
11144 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11146 /* Unmute DAC0~3 & spdif out*/
11147 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11148 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11149 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11150 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11152 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11153 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11154 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11155 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11156 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11157
11158 /* Unmute Stereo Mixer 15 */
11159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011163
11164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11167 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11168 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11169 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11170 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011172 /* hp used DAC 3 (Front) */
11173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11175 { }
11176};
11177
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011178/* additional init verbs for ASUS laptops */
11179static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11180 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11181 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11182 { }
11183};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011184
Kailang Yangdf694da2005-12-05 19:42:22 +010011185/*
11186 * generic initialization of ADC, input mixers and output mixers
11187 */
11188static struct hda_verb alc861_auto_init_verbs[] = {
11189 /*
11190 * Unmute ADC0 and set the default input to mic-in
11191 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011192 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11194
11195 /* Unmute DAC0~3 & spdif out*/
11196 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11197 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11198 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11199 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11201
11202 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11203 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11204 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11205 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11206 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11207
11208 /* Unmute Stereo Mixer 15 */
11209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11213
11214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11217 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11218 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11222
11223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11228 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011229 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11230 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011232 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011233
11234 { }
11235};
11236
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011237static struct hda_verb alc861_toshiba_init_verbs[] = {
11238 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011239
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011240 { }
11241};
11242
11243/* toggle speaker-output according to the hp-jack state */
11244static void alc861_toshiba_automute(struct hda_codec *codec)
11245{
11246 unsigned int present;
11247
11248 present = snd_hda_codec_read(codec, 0x0f, 0,
11249 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011250 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11251 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11252 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11253 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011254}
11255
11256static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11257 unsigned int res)
11258{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011259 if ((res >> 26) == ALC880_HP_EVENT)
11260 alc861_toshiba_automute(codec);
11261}
11262
Kailang Yangdf694da2005-12-05 19:42:22 +010011263/* pcm configuration: identiacal with ALC880 */
11264#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11265#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11266#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11267#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11268
11269
11270#define ALC861_DIGOUT_NID 0x07
11271
11272static struct hda_channel_mode alc861_8ch_modes[1] = {
11273 { 8, NULL }
11274};
11275
11276static hda_nid_t alc861_dac_nids[4] = {
11277 /* front, surround, clfe, side */
11278 0x03, 0x06, 0x05, 0x04
11279};
11280
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011281static hda_nid_t alc660_dac_nids[3] = {
11282 /* front, clfe, surround */
11283 0x03, 0x05, 0x06
11284};
11285
Kailang Yangdf694da2005-12-05 19:42:22 +010011286static hda_nid_t alc861_adc_nids[1] = {
11287 /* ADC0-2 */
11288 0x08,
11289};
11290
11291static struct hda_input_mux alc861_capture_source = {
11292 .num_items = 5,
11293 .items = {
11294 { "Mic", 0x0 },
11295 { "Front Mic", 0x3 },
11296 { "Line", 0x1 },
11297 { "CD", 0x4 },
11298 { "Mixer", 0x5 },
11299 },
11300};
11301
11302/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011303static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11304 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011305{
11306 int i;
11307 hda_nid_t nid;
11308
11309 spec->multiout.dac_nids = spec->private_dac_nids;
11310 for (i = 0; i < cfg->line_outs; i++) {
11311 nid = cfg->line_out_pins[i];
11312 if (nid) {
11313 if (i >= ARRAY_SIZE(alc861_dac_nids))
11314 continue;
11315 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11316 }
11317 }
11318 spec->multiout.num_dacs = cfg->line_outs;
11319 return 0;
11320}
11321
11322/* add playback controls from the parsed DAC table */
11323static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11324 const struct auto_pin_cfg *cfg)
11325{
11326 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011327 static const char *chname[4] = {
11328 "Front", "Surround", NULL /*CLFE*/, "Side"
11329 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011330 hda_nid_t nid;
11331 int i, idx, err;
11332
11333 for (i = 0; i < cfg->line_outs; i++) {
11334 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011335 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011336 continue;
11337 if (nid == 0x05) {
11338 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011339 err = add_control(spec, ALC_CTL_BIND_MUTE,
11340 "Center Playback Switch",
11341 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11342 HDA_OUTPUT));
11343 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011344 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011345 err = add_control(spec, ALC_CTL_BIND_MUTE,
11346 "LFE Playback Switch",
11347 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11348 HDA_OUTPUT));
11349 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 return err;
11351 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011352 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11353 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011354 if (nid == alc861_dac_nids[idx])
11355 break;
11356 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11358 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11359 HDA_OUTPUT));
11360 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011361 return err;
11362 }
11363 }
11364 return 0;
11365}
11366
11367static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11368{
11369 int err;
11370 hda_nid_t nid;
11371
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011372 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011373 return 0;
11374
11375 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11376 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011377 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11378 "Headphone Playback Switch",
11379 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11380 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011381 return err;
11382 spec->multiout.hp_nid = nid;
11383 }
11384 return 0;
11385}
11386
11387/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011388static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011390{
Kailang Yangdf694da2005-12-05 19:42:22 +010011391 struct hda_input_mux *imux = &spec->private_imux;
11392 int i, err, idx, idx1;
11393
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011395 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011396 case 0x0c:
11397 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011398 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011399 break;
11400 case 0x0f:
11401 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011402 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011403 break;
11404 case 0x0d:
11405 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011406 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011407 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011408 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011409 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011410 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011411 break;
11412 case 0x11:
11413 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011414 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011415 break;
11416 default:
11417 continue;
11418 }
11419
Takashi Iwai4a471b72005-12-07 13:56:29 +010011420 err = new_analog_input(spec, cfg->input_pins[i],
11421 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011422 if (err < 0)
11423 return err;
11424
Takashi Iwai4a471b72005-12-07 13:56:29 +010011425 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011426 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011427 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011428 }
11429 return 0;
11430}
11431
11432static struct snd_kcontrol_new alc861_capture_mixer[] = {
11433 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11434 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11435
11436 {
11437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11438 /* The multiple "Capture Source" controls confuse alsamixer
11439 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011440 */
11441 /* .name = "Capture Source", */
11442 .name = "Input Source",
11443 .count = 1,
11444 .info = alc_mux_enum_info,
11445 .get = alc_mux_enum_get,
11446 .put = alc_mux_enum_put,
11447 },
11448 { } /* end */
11449};
11450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011451static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11452 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011453 int pin_type, int dac_idx)
11454{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011455 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011456}
11457
11458static void alc861_auto_init_multi_out(struct hda_codec *codec)
11459{
11460 struct alc_spec *spec = codec->spec;
11461 int i;
11462
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011463 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011464 for (i = 0; i < spec->autocfg.line_outs; i++) {
11465 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011466 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011467 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011468 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011469 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011470 }
11471}
11472
11473static void alc861_auto_init_hp_out(struct hda_codec *codec)
11474{
11475 struct alc_spec *spec = codec->spec;
11476 hda_nid_t pin;
11477
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011478 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011479 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011480 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11481 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011482 pin = spec->autocfg.speaker_pins[0];
11483 if (pin)
11484 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010011485}
11486
11487static void alc861_auto_init_analog_input(struct hda_codec *codec)
11488{
11489 struct alc_spec *spec = codec->spec;
11490 int i;
11491
11492 for (i = 0; i < AUTO_PIN_LAST; i++) {
11493 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011494 if (nid >= 0x0c && nid <= 0x11) {
11495 snd_hda_codec_write(codec, nid, 0,
11496 AC_VERB_SET_PIN_WIDGET_CONTROL,
11497 i <= AUTO_PIN_FRONT_MIC ?
11498 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011499 }
11500 }
11501}
11502
11503/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011504/* return 1 if successful, 0 if the proper config is not found,
11505 * or a negative error code
11506 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011507static int alc861_parse_auto_config(struct hda_codec *codec)
11508{
11509 struct alc_spec *spec = codec->spec;
11510 int err;
11511 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11512
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011513 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11514 alc861_ignore);
11515 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011516 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011517 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011518 return 0; /* can't find valid BIOS pin config */
11519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11521 if (err < 0)
11522 return err;
11523 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11524 if (err < 0)
11525 return err;
11526 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11527 if (err < 0)
11528 return err;
11529 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11530 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011531 return err;
11532
11533 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11534
11535 if (spec->autocfg.dig_out_pin)
11536 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11537
11538 if (spec->kctl_alloc)
11539 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11540
11541 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11542
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011543 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011544 spec->input_mux = &spec->private_imux;
11545
11546 spec->adc_nids = alc861_adc_nids;
11547 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11548 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11549 spec->num_mixers++;
11550
11551 return 1;
11552}
11553
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011554/* additional initialization for auto-configuration model */
11555static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011556{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011557 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011558 alc861_auto_init_multi_out(codec);
11559 alc861_auto_init_hp_out(codec);
11560 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011561 if (spec->unsol_event)
11562 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011563}
11564
Takashi Iwaicb53c622007-08-10 17:21:45 +020011565#ifdef CONFIG_SND_HDA_POWER_SAVE
11566static struct hda_amp_list alc861_loopbacks[] = {
11567 { 0x15, HDA_INPUT, 0 },
11568 { 0x15, HDA_INPUT, 1 },
11569 { 0x15, HDA_INPUT, 2 },
11570 { 0x15, HDA_INPUT, 3 },
11571 { } /* end */
11572};
11573#endif
11574
Kailang Yangdf694da2005-12-05 19:42:22 +010011575
11576/*
11577 * configuration and preset
11578 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011579static const char *alc861_models[ALC861_MODEL_LAST] = {
11580 [ALC861_3ST] = "3stack",
11581 [ALC660_3ST] = "3stack-660",
11582 [ALC861_3ST_DIG] = "3stack-dig",
11583 [ALC861_6ST_DIG] = "6stack-dig",
11584 [ALC861_UNIWILL_M31] = "uniwill-m31",
11585 [ALC861_TOSHIBA] = "toshiba",
11586 [ALC861_ASUS] = "asus",
11587 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11588 [ALC861_AUTO] = "auto",
11589};
11590
11591static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011592 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011593 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11594 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11595 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011596 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011597 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011598 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011599 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11600 * Any other models that need this preset?
11601 */
11602 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011603 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11604 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011605 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11606 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11607 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11608 /* FIXME: the below seems conflict */
11609 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11610 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11611 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011612 {}
11613};
11614
11615static struct alc_config_preset alc861_presets[] = {
11616 [ALC861_3ST] = {
11617 .mixers = { alc861_3ST_mixer },
11618 .init_verbs = { alc861_threestack_init_verbs },
11619 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11620 .dac_nids = alc861_dac_nids,
11621 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11622 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011623 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011624 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11625 .adc_nids = alc861_adc_nids,
11626 .input_mux = &alc861_capture_source,
11627 },
11628 [ALC861_3ST_DIG] = {
11629 .mixers = { alc861_base_mixer },
11630 .init_verbs = { alc861_threestack_init_verbs },
11631 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11632 .dac_nids = alc861_dac_nids,
11633 .dig_out_nid = ALC861_DIGOUT_NID,
11634 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11635 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011636 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011637 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11638 .adc_nids = alc861_adc_nids,
11639 .input_mux = &alc861_capture_source,
11640 },
11641 [ALC861_6ST_DIG] = {
11642 .mixers = { alc861_base_mixer },
11643 .init_verbs = { alc861_base_init_verbs },
11644 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11645 .dac_nids = alc861_dac_nids,
11646 .dig_out_nid = ALC861_DIGOUT_NID,
11647 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11648 .channel_mode = alc861_8ch_modes,
11649 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11650 .adc_nids = alc861_adc_nids,
11651 .input_mux = &alc861_capture_source,
11652 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011653 [ALC660_3ST] = {
11654 .mixers = { alc861_3ST_mixer },
11655 .init_verbs = { alc861_threestack_init_verbs },
11656 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11657 .dac_nids = alc660_dac_nids,
11658 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11659 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011660 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011661 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11662 .adc_nids = alc861_adc_nids,
11663 .input_mux = &alc861_capture_source,
11664 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011665 [ALC861_UNIWILL_M31] = {
11666 .mixers = { alc861_uniwill_m31_mixer },
11667 .init_verbs = { alc861_uniwill_m31_init_verbs },
11668 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11669 .dac_nids = alc861_dac_nids,
11670 .dig_out_nid = ALC861_DIGOUT_NID,
11671 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11672 .channel_mode = alc861_uniwill_m31_modes,
11673 .need_dac_fix = 1,
11674 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11675 .adc_nids = alc861_adc_nids,
11676 .input_mux = &alc861_capture_source,
11677 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011678 [ALC861_TOSHIBA] = {
11679 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011680 .init_verbs = { alc861_base_init_verbs,
11681 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011682 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11683 .dac_nids = alc861_dac_nids,
11684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11685 .channel_mode = alc883_3ST_2ch_modes,
11686 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11687 .adc_nids = alc861_adc_nids,
11688 .input_mux = &alc861_capture_source,
11689 .unsol_event = alc861_toshiba_unsol_event,
11690 .init_hook = alc861_toshiba_automute,
11691 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011692 [ALC861_ASUS] = {
11693 .mixers = { alc861_asus_mixer },
11694 .init_verbs = { alc861_asus_init_verbs },
11695 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11696 .dac_nids = alc861_dac_nids,
11697 .dig_out_nid = ALC861_DIGOUT_NID,
11698 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11699 .channel_mode = alc861_asus_modes,
11700 .need_dac_fix = 1,
11701 .hp_nid = 0x06,
11702 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11703 .adc_nids = alc861_adc_nids,
11704 .input_mux = &alc861_capture_source,
11705 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011706 [ALC861_ASUS_LAPTOP] = {
11707 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11708 .init_verbs = { alc861_asus_init_verbs,
11709 alc861_asus_laptop_init_verbs },
11710 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11711 .dac_nids = alc861_dac_nids,
11712 .dig_out_nid = ALC861_DIGOUT_NID,
11713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11714 .channel_mode = alc883_3ST_2ch_modes,
11715 .need_dac_fix = 1,
11716 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11717 .adc_nids = alc861_adc_nids,
11718 .input_mux = &alc861_capture_source,
11719 },
11720};
Kailang Yangdf694da2005-12-05 19:42:22 +010011721
11722
11723static int patch_alc861(struct hda_codec *codec)
11724{
11725 struct alc_spec *spec;
11726 int board_config;
11727 int err;
11728
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011730 if (spec == NULL)
11731 return -ENOMEM;
11732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011733 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011734
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011735 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11736 alc861_models,
11737 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011738
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011739 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011740 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11741 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011742 board_config = ALC861_AUTO;
11743 }
11744
11745 if (board_config == ALC861_AUTO) {
11746 /* automatic parse from the BIOS config */
11747 err = alc861_parse_auto_config(codec);
11748 if (err < 0) {
11749 alc_free(codec);
11750 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011751 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011752 printk(KERN_INFO
11753 "hda_codec: Cannot set up configuration "
11754 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011755 board_config = ALC861_3ST_DIG;
11756 }
11757 }
11758
11759 if (board_config != ALC861_AUTO)
11760 setup_preset(spec, &alc861_presets[board_config]);
11761
11762 spec->stream_name_analog = "ALC861 Analog";
11763 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11764 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11765
11766 spec->stream_name_digital = "ALC861 Digital";
11767 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11768 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11769
Takashi Iwai2134ea42008-01-10 16:53:55 +010011770 spec->vmaster_nid = 0x03;
11771
Kailang Yangdf694da2005-12-05 19:42:22 +010011772 codec->patch_ops = alc_patch_ops;
11773 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011774 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011775#ifdef CONFIG_SND_HDA_POWER_SAVE
11776 if (!spec->loopback.amplist)
11777 spec->loopback.amplist = alc861_loopbacks;
11778#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011779
11780 return 0;
11781}
11782
11783/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011784 * ALC861-VD support
11785 *
11786 * Based on ALC882
11787 *
11788 * In addition, an independent DAC
11789 */
11790#define ALC861VD_DIGOUT_NID 0x06
11791
11792static hda_nid_t alc861vd_dac_nids[4] = {
11793 /* front, surr, clfe, side surr */
11794 0x02, 0x03, 0x04, 0x05
11795};
11796
11797/* dac_nids for ALC660vd are in a different order - according to
11798 * Realtek's driver.
11799 * This should probably tesult in a different mixer for 6stack models
11800 * of ALC660vd codecs, but for now there is only 3stack mixer
11801 * - and it is the same as in 861vd.
11802 * adc_nids in ALC660vd are (is) the same as in 861vd
11803 */
11804static hda_nid_t alc660vd_dac_nids[3] = {
11805 /* front, rear, clfe, rear_surr */
11806 0x02, 0x04, 0x03
11807};
11808
11809static hda_nid_t alc861vd_adc_nids[1] = {
11810 /* ADC0 */
11811 0x09,
11812};
11813
Takashi Iwaie1406342008-02-11 18:32:32 +010011814static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
11815
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011816/* input MUX */
11817/* FIXME: should be a matrix-type input source selection */
11818static struct hda_input_mux alc861vd_capture_source = {
11819 .num_items = 4,
11820 .items = {
11821 { "Mic", 0x0 },
11822 { "Front Mic", 0x1 },
11823 { "Line", 0x2 },
11824 { "CD", 0x4 },
11825 },
11826};
11827
Kailang Yang272a5272007-05-14 11:00:38 +020011828static struct hda_input_mux alc861vd_dallas_capture_source = {
11829 .num_items = 3,
11830 .items = {
11831 { "Front Mic", 0x0 },
11832 { "ATAPI Mic", 0x1 },
11833 { "Line In", 0x5 },
11834 },
11835};
11836
Kailang Yangd1a991a2007-08-15 16:21:59 +020011837static struct hda_input_mux alc861vd_hp_capture_source = {
11838 .num_items = 2,
11839 .items = {
11840 { "Front Mic", 0x0 },
11841 { "ATAPI Mic", 0x1 },
11842 },
11843};
11844
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011845#define alc861vd_mux_enum_info alc_mux_enum_info
11846#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011847/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
11848#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011849
11850/*
11851 * 2ch mode
11852 */
11853static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11854 { 2, NULL }
11855};
11856
11857/*
11858 * 6ch mode
11859 */
11860static struct hda_verb alc861vd_6stack_ch6_init[] = {
11861 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11862 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11863 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11864 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11865 { } /* end */
11866};
11867
11868/*
11869 * 8ch mode
11870 */
11871static struct hda_verb alc861vd_6stack_ch8_init[] = {
11872 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11873 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11874 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11875 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11876 { } /* end */
11877};
11878
11879static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11880 { 6, alc861vd_6stack_ch6_init },
11881 { 8, alc861vd_6stack_ch8_init },
11882};
11883
11884static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11885 {
11886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11887 .name = "Channel Mode",
11888 .info = alc_ch_mode_info,
11889 .get = alc_ch_mode_get,
11890 .put = alc_ch_mode_put,
11891 },
11892 { } /* end */
11893};
11894
11895static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11896 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11897 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11898
11899 {
11900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11901 /* The multiple "Capture Source" controls confuse alsamixer
11902 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011903 */
11904 /* .name = "Capture Source", */
11905 .name = "Input Source",
11906 .count = 1,
11907 .info = alc861vd_mux_enum_info,
11908 .get = alc861vd_mux_enum_get,
11909 .put = alc861vd_mux_enum_put,
11910 },
11911 { } /* end */
11912};
11913
11914/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11915 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11916 */
11917static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11918 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11919 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11920
11921 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11922 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11923
11924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11925 HDA_OUTPUT),
11926 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11927 HDA_OUTPUT),
11928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11930
11931 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11932 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11933
11934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11935
11936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11939
11940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11941 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11942 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11943
11944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11946
11947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11949
11950 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11951 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11952
11953 { } /* end */
11954};
11955
11956static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11957 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11959
11960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11961
11962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11965
11966 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11967 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11968 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11969
11970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11972
11973 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11974 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11975
11976 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11977 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11978
11979 { } /* end */
11980};
11981
Kailang Yangbdd148a2007-05-08 15:19:08 +020011982static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11983 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11984 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11985 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
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("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11998 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11999
12000 { } /* end */
12001};
12002
Kailang Yang272a5272007-05-14 11:00:38 +020012003/* Pin assignment: Front=0x14, HP = 0x15,
12004 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12005 */
12006static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12007 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12008 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12010 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12013 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12014 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12015 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12016 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012017 { } /* end */
12018};
12019
Kailang Yangd1a991a2007-08-15 16:21:59 +020012020/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12021 * Front Mic=0x18, ATAPI Mic = 0x19,
12022 */
12023static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12024 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12025 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12027 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12030 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12031 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12032
12033 { } /* end */
12034};
12035
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012036/*
12037 * generic initialization of ADC, input mixers and output mixers
12038 */
12039static struct hda_verb alc861vd_volume_init_verbs[] = {
12040 /*
12041 * Unmute ADC0 and set the default input to mic-in
12042 */
12043 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12045
12046 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12047 * the analog-loopback mixer widget
12048 */
12049 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012055
12056 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012061
12062 /*
12063 * Set up output mixers (0x02 - 0x05)
12064 */
12065 /* set vol=0 to output mixers */
12066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12070
12071 /* set up input amps for analog loopback */
12072 /* Amp Indices: DAC = 0, mixer = 1 */
12073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12081
12082 { }
12083};
12084
12085/*
12086 * 3-stack pin configuration:
12087 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12088 */
12089static struct hda_verb alc861vd_3stack_init_verbs[] = {
12090 /*
12091 * Set pin mode and muting
12092 */
12093 /* set front pin widgets 0x14 for output */
12094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12095 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12096 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12097
12098 /* Mic (rear) pin: input vref at 80% */
12099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12101 /* Front Mic pin: input vref at 80% */
12102 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12104 /* Line In pin: input */
12105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12107 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12110 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12111 /* CD pin widget for input */
12112 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12113
12114 { }
12115};
12116
12117/*
12118 * 6-stack pin configuration:
12119 */
12120static struct hda_verb alc861vd_6stack_init_verbs[] = {
12121 /*
12122 * Set pin mode and muting
12123 */
12124 /* set front pin widgets 0x14 for output */
12125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12126 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12127 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12128
12129 /* Rear Pin: output 1 (0x0d) */
12130 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12133 /* CLFE Pin: output 2 (0x0e) */
12134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12136 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12137 /* Side Pin: output 3 (0x0f) */
12138 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12139 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12140 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12141
12142 /* Mic (rear) pin: input vref at 80% */
12143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12145 /* Front Mic pin: input vref at 80% */
12146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12148 /* Line In pin: input */
12149 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12150 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12151 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12152 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12153 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12154 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12155 /* CD pin widget for input */
12156 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12157
12158 { }
12159};
12160
Kailang Yangbdd148a2007-05-08 15:19:08 +020012161static struct hda_verb alc861vd_eapd_verbs[] = {
12162 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12163 { }
12164};
12165
12166static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12167 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12170 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12171 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12172 {}
12173};
12174
12175/* toggle speaker-output according to the hp-jack state */
12176static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12177{
12178 unsigned int present;
12179 unsigned char bits;
12180
12181 present = snd_hda_codec_read(codec, 0x1b, 0,
12182 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012183 bits = present ? HDA_AMP_MUTE : 0;
12184 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12185 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012186}
12187
12188static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12189{
12190 unsigned int present;
12191 unsigned char bits;
12192
12193 present = snd_hda_codec_read(codec, 0x18, 0,
12194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012195 bits = present ? HDA_AMP_MUTE : 0;
12196 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12197 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012198}
12199
12200static void alc861vd_lenovo_automute(struct hda_codec *codec)
12201{
12202 alc861vd_lenovo_hp_automute(codec);
12203 alc861vd_lenovo_mic_automute(codec);
12204}
12205
12206static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12207 unsigned int res)
12208{
12209 switch (res >> 26) {
12210 case ALC880_HP_EVENT:
12211 alc861vd_lenovo_hp_automute(codec);
12212 break;
12213 case ALC880_MIC_EVENT:
12214 alc861vd_lenovo_mic_automute(codec);
12215 break;
12216 }
12217}
12218
Kailang Yang272a5272007-05-14 11:00:38 +020012219static struct hda_verb alc861vd_dallas_verbs[] = {
12220 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12221 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12222 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12223 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12224
12225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12233
12234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12238 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12239 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12240 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12241 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12242
12243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12247 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12248 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12249 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12250 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12251
12252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12256
12257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12258 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12260
12261 { } /* end */
12262};
12263
12264/* toggle speaker-output according to the hp-jack state */
12265static void alc861vd_dallas_automute(struct hda_codec *codec)
12266{
12267 unsigned int present;
12268
12269 present = snd_hda_codec_read(codec, 0x15, 0,
12270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012271 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12272 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012273}
12274
12275static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12276{
12277 if ((res >> 26) == ALC880_HP_EVENT)
12278 alc861vd_dallas_automute(codec);
12279}
12280
Takashi Iwaicb53c622007-08-10 17:21:45 +020012281#ifdef CONFIG_SND_HDA_POWER_SAVE
12282#define alc861vd_loopbacks alc880_loopbacks
12283#endif
12284
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012285/* pcm configuration: identiacal with ALC880 */
12286#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12287#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12288#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12289#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12290
12291/*
12292 * configuration and preset
12293 */
12294static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12295 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012296 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012297 [ALC861VD_3ST] = "3stack",
12298 [ALC861VD_3ST_DIG] = "3stack-digout",
12299 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012300 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012301 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012302 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012303 [ALC861VD_AUTO] = "auto",
12304};
12305
12306static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012307 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12308 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012309 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012310 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012311 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012312 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012313 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012314 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012315 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012316 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012317 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012318 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12319 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012320 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012321 {}
12322};
12323
12324static struct alc_config_preset alc861vd_presets[] = {
12325 [ALC660VD_3ST] = {
12326 .mixers = { alc861vd_3st_mixer },
12327 .init_verbs = { alc861vd_volume_init_verbs,
12328 alc861vd_3stack_init_verbs },
12329 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12330 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012331 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12332 .channel_mode = alc861vd_3stack_2ch_modes,
12333 .input_mux = &alc861vd_capture_source,
12334 },
Mike Crash6963f842007-06-25 12:12:51 +020012335 [ALC660VD_3ST_DIG] = {
12336 .mixers = { alc861vd_3st_mixer },
12337 .init_verbs = { alc861vd_volume_init_verbs,
12338 alc861vd_3stack_init_verbs },
12339 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12340 .dac_nids = alc660vd_dac_nids,
12341 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020012342 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12343 .channel_mode = alc861vd_3stack_2ch_modes,
12344 .input_mux = &alc861vd_capture_source,
12345 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012346 [ALC861VD_3ST] = {
12347 .mixers = { alc861vd_3st_mixer },
12348 .init_verbs = { alc861vd_volume_init_verbs,
12349 alc861vd_3stack_init_verbs },
12350 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12351 .dac_nids = alc861vd_dac_nids,
12352 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12353 .channel_mode = alc861vd_3stack_2ch_modes,
12354 .input_mux = &alc861vd_capture_source,
12355 },
12356 [ALC861VD_3ST_DIG] = {
12357 .mixers = { alc861vd_3st_mixer },
12358 .init_verbs = { alc861vd_volume_init_verbs,
12359 alc861vd_3stack_init_verbs },
12360 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12361 .dac_nids = alc861vd_dac_nids,
12362 .dig_out_nid = ALC861VD_DIGOUT_NID,
12363 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12364 .channel_mode = alc861vd_3stack_2ch_modes,
12365 .input_mux = &alc861vd_capture_source,
12366 },
12367 [ALC861VD_6ST_DIG] = {
12368 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12369 .init_verbs = { alc861vd_volume_init_verbs,
12370 alc861vd_6stack_init_verbs },
12371 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12372 .dac_nids = alc861vd_dac_nids,
12373 .dig_out_nid = ALC861VD_DIGOUT_NID,
12374 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12375 .channel_mode = alc861vd_6stack_modes,
12376 .input_mux = &alc861vd_capture_source,
12377 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012378 [ALC861VD_LENOVO] = {
12379 .mixers = { alc861vd_lenovo_mixer },
12380 .init_verbs = { alc861vd_volume_init_verbs,
12381 alc861vd_3stack_init_verbs,
12382 alc861vd_eapd_verbs,
12383 alc861vd_lenovo_unsol_verbs },
12384 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12385 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012386 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12387 .channel_mode = alc861vd_3stack_2ch_modes,
12388 .input_mux = &alc861vd_capture_source,
12389 .unsol_event = alc861vd_lenovo_unsol_event,
12390 .init_hook = alc861vd_lenovo_automute,
12391 },
Kailang Yang272a5272007-05-14 11:00:38 +020012392 [ALC861VD_DALLAS] = {
12393 .mixers = { alc861vd_dallas_mixer },
12394 .init_verbs = { alc861vd_dallas_verbs },
12395 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12396 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020012397 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12398 .channel_mode = alc861vd_3stack_2ch_modes,
12399 .input_mux = &alc861vd_dallas_capture_source,
12400 .unsol_event = alc861vd_dallas_unsol_event,
12401 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012402 },
12403 [ALC861VD_HP] = {
12404 .mixers = { alc861vd_hp_mixer },
12405 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12406 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12407 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012408 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012409 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12410 .channel_mode = alc861vd_3stack_2ch_modes,
12411 .input_mux = &alc861vd_hp_capture_source,
12412 .unsol_event = alc861vd_dallas_unsol_event,
12413 .init_hook = alc861vd_dallas_automute,
12414 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012415};
12416
12417/*
12418 * BIOS auto configuration
12419 */
12420static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12421 hda_nid_t nid, int pin_type, int dac_idx)
12422{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012423 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012424}
12425
12426static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12427{
12428 struct alc_spec *spec = codec->spec;
12429 int i;
12430
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012431 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012432 for (i = 0; i <= HDA_SIDE; i++) {
12433 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012434 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012435 if (nid)
12436 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012437 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012438 }
12439}
12440
12441
12442static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12443{
12444 struct alc_spec *spec = codec->spec;
12445 hda_nid_t pin;
12446
12447 pin = spec->autocfg.hp_pins[0];
12448 if (pin) /* connect to front and use dac 0 */
12449 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012450 pin = spec->autocfg.speaker_pins[0];
12451 if (pin)
12452 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012453}
12454
12455#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12456#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12457
12458static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12459{
12460 struct alc_spec *spec = codec->spec;
12461 int i;
12462
12463 for (i = 0; i < AUTO_PIN_LAST; i++) {
12464 hda_nid_t nid = spec->autocfg.input_pins[i];
12465 if (alc861vd_is_input_pin(nid)) {
12466 snd_hda_codec_write(codec, nid, 0,
12467 AC_VERB_SET_PIN_WIDGET_CONTROL,
12468 i <= AUTO_PIN_FRONT_MIC ?
12469 PIN_VREF80 : PIN_IN);
12470 if (nid != ALC861VD_PIN_CD_NID)
12471 snd_hda_codec_write(codec, nid, 0,
12472 AC_VERB_SET_AMP_GAIN_MUTE,
12473 AMP_OUT_MUTE);
12474 }
12475 }
12476}
12477
12478#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12479#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12480
12481/* add playback controls from the parsed DAC table */
12482/* Based on ALC880 version. But ALC861VD has separate,
12483 * different NIDs for mute/unmute switch and volume control */
12484static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12485 const struct auto_pin_cfg *cfg)
12486{
12487 char name[32];
12488 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12489 hda_nid_t nid_v, nid_s;
12490 int i, err;
12491
12492 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012493 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012494 continue;
12495 nid_v = alc861vd_idx_to_mixer_vol(
12496 alc880_dac_to_idx(
12497 spec->multiout.dac_nids[i]));
12498 nid_s = alc861vd_idx_to_mixer_switch(
12499 alc880_dac_to_idx(
12500 spec->multiout.dac_nids[i]));
12501
12502 if (i == 2) {
12503 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012504 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12505 "Center Playback Volume",
12506 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12507 HDA_OUTPUT));
12508 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012509 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012510 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12511 "LFE Playback Volume",
12512 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12513 HDA_OUTPUT));
12514 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012515 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012516 err = add_control(spec, ALC_CTL_BIND_MUTE,
12517 "Center Playback Switch",
12518 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12519 HDA_INPUT));
12520 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012521 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012522 err = add_control(spec, ALC_CTL_BIND_MUTE,
12523 "LFE Playback Switch",
12524 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12525 HDA_INPUT));
12526 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012527 return err;
12528 } else {
12529 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012530 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12531 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12532 HDA_OUTPUT));
12533 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012534 return err;
12535 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012536 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012537 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012538 HDA_INPUT));
12539 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012540 return err;
12541 }
12542 }
12543 return 0;
12544}
12545
12546/* add playback controls for speaker and HP outputs */
12547/* Based on ALC880 version. But ALC861VD has separate,
12548 * different NIDs for mute/unmute switch and volume control */
12549static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12550 hda_nid_t pin, const char *pfx)
12551{
12552 hda_nid_t nid_v, nid_s;
12553 int err;
12554 char name[32];
12555
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012556 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012557 return 0;
12558
12559 if (alc880_is_fixed_pin(pin)) {
12560 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12561 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012562 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012563 spec->multiout.hp_nid = nid_v;
12564 else
12565 spec->multiout.extra_out_nid[0] = nid_v;
12566 /* control HP volume/switch on the output mixer amp */
12567 nid_v = alc861vd_idx_to_mixer_vol(
12568 alc880_fixed_pin_idx(pin));
12569 nid_s = alc861vd_idx_to_mixer_switch(
12570 alc880_fixed_pin_idx(pin));
12571
12572 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012573 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12574 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12575 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012576 return err;
12577 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012578 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12579 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12580 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012581 return err;
12582 } else if (alc880_is_multi_pin(pin)) {
12583 /* set manual connection */
12584 /* we have only a switch on HP-out PIN */
12585 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012586 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12587 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12588 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012589 return err;
12590 }
12591 return 0;
12592}
12593
12594/* parse the BIOS configuration and set up the alc_spec
12595 * return 1 if successful, 0 if the proper config is not found,
12596 * or a negative error code
12597 * Based on ALC880 version - had to change it to override
12598 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12599static int alc861vd_parse_auto_config(struct hda_codec *codec)
12600{
12601 struct alc_spec *spec = codec->spec;
12602 int err;
12603 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12604
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012605 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12606 alc861vd_ignore);
12607 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012608 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012609 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012610 return 0; /* can't find valid BIOS pin config */
12611
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012612 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12613 if (err < 0)
12614 return err;
12615 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12616 if (err < 0)
12617 return err;
12618 err = alc861vd_auto_create_extra_out(spec,
12619 spec->autocfg.speaker_pins[0],
12620 "Speaker");
12621 if (err < 0)
12622 return err;
12623 err = alc861vd_auto_create_extra_out(spec,
12624 spec->autocfg.hp_pins[0],
12625 "Headphone");
12626 if (err < 0)
12627 return err;
12628 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12629 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012630 return err;
12631
12632 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12633
12634 if (spec->autocfg.dig_out_pin)
12635 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12636
12637 if (spec->kctl_alloc)
12638 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12639
12640 spec->init_verbs[spec->num_init_verbs++]
12641 = alc861vd_volume_init_verbs;
12642
12643 spec->num_mux_defs = 1;
12644 spec->input_mux = &spec->private_imux;
12645
Takashi Iwai776e1842007-08-29 15:07:11 +020012646 err = alc_auto_add_mic_boost(codec);
12647 if (err < 0)
12648 return err;
12649
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012650 return 1;
12651}
12652
12653/* additional initialization for auto-configuration model */
12654static void alc861vd_auto_init(struct hda_codec *codec)
12655{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012656 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012657 alc861vd_auto_init_multi_out(codec);
12658 alc861vd_auto_init_hp_out(codec);
12659 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012660 if (spec->unsol_event)
12661 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012662}
12663
12664static int patch_alc861vd(struct hda_codec *codec)
12665{
12666 struct alc_spec *spec;
12667 int err, board_config;
12668
12669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12670 if (spec == NULL)
12671 return -ENOMEM;
12672
12673 codec->spec = spec;
12674
12675 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12676 alc861vd_models,
12677 alc861vd_cfg_tbl);
12678
12679 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12680 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12681 "ALC861VD, trying auto-probe from BIOS...\n");
12682 board_config = ALC861VD_AUTO;
12683 }
12684
12685 if (board_config == ALC861VD_AUTO) {
12686 /* automatic parse from the BIOS config */
12687 err = alc861vd_parse_auto_config(codec);
12688 if (err < 0) {
12689 alc_free(codec);
12690 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012691 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012692 printk(KERN_INFO
12693 "hda_codec: Cannot set up configuration "
12694 "from BIOS. Using base mode...\n");
12695 board_config = ALC861VD_3ST;
12696 }
12697 }
12698
12699 if (board_config != ALC861VD_AUTO)
12700 setup_preset(spec, &alc861vd_presets[board_config]);
12701
12702 spec->stream_name_analog = "ALC861VD Analog";
12703 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12704 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12705
12706 spec->stream_name_digital = "ALC861VD Digital";
12707 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12708 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12709
12710 spec->adc_nids = alc861vd_adc_nids;
12711 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010012712 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012713
12714 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12715 spec->num_mixers++;
12716
Takashi Iwai2134ea42008-01-10 16:53:55 +010012717 spec->vmaster_nid = 0x02;
12718
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012719 codec->patch_ops = alc_patch_ops;
12720
12721 if (board_config == ALC861VD_AUTO)
12722 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012723#ifdef CONFIG_SND_HDA_POWER_SAVE
12724 if (!spec->loopback.amplist)
12725 spec->loopback.amplist = alc861vd_loopbacks;
12726#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012727
12728 return 0;
12729}
12730
12731/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012732 * ALC662 support
12733 *
12734 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12735 * configuration. Each pin widget can choose any input DACs and a mixer.
12736 * Each ADC is connected from a mixer of all inputs. This makes possible
12737 * 6-channel independent captures.
12738 *
12739 * In addition, an independent DAC for the multi-playback (not used in this
12740 * driver yet).
12741 */
12742#define ALC662_DIGOUT_NID 0x06
12743#define ALC662_DIGIN_NID 0x0a
12744
12745static hda_nid_t alc662_dac_nids[4] = {
12746 /* front, rear, clfe, rear_surr */
12747 0x02, 0x03, 0x04
12748};
12749
12750static hda_nid_t alc662_adc_nids[1] = {
12751 /* ADC1-2 */
12752 0x09,
12753};
Takashi Iwaie1406342008-02-11 18:32:32 +010012754
12755static hda_nid_t alc662_capsrc_nids[1] = { 0x23 };
12756
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012757/* input MUX */
12758/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012759static struct hda_input_mux alc662_capture_source = {
12760 .num_items = 4,
12761 .items = {
12762 { "Mic", 0x0 },
12763 { "Front Mic", 0x1 },
12764 { "Line", 0x2 },
12765 { "CD", 0x4 },
12766 },
12767};
12768
12769static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12770 .num_items = 2,
12771 .items = {
12772 { "Mic", 0x1 },
12773 { "Line", 0x2 },
12774 },
12775};
Kailang Yang291702f2007-10-16 14:28:03 +020012776
12777static struct hda_input_mux alc662_eeepc_capture_source = {
12778 .num_items = 2,
12779 .items = {
12780 { "i-Mic", 0x1 },
12781 { "e-Mic", 0x0 },
12782 },
12783};
12784
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012785#define alc662_mux_enum_info alc_mux_enum_info
12786#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012787#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012788
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012789/*
12790 * 2ch mode
12791 */
12792static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12793 { 2, NULL }
12794};
12795
12796/*
12797 * 2ch mode
12798 */
12799static struct hda_verb alc662_3ST_ch2_init[] = {
12800 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12801 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12804 { } /* end */
12805};
12806
12807/*
12808 * 6ch mode
12809 */
12810static struct hda_verb alc662_3ST_ch6_init[] = {
12811 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12812 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12813 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12814 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12815 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12816 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12817 { } /* end */
12818};
12819
12820static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12821 { 2, alc662_3ST_ch2_init },
12822 { 6, alc662_3ST_ch6_init },
12823};
12824
12825/*
12826 * 2ch mode
12827 */
12828static struct hda_verb alc662_sixstack_ch6_init[] = {
12829 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12830 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12831 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12832 { } /* end */
12833};
12834
12835/*
12836 * 6ch mode
12837 */
12838static struct hda_verb alc662_sixstack_ch8_init[] = {
12839 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12840 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12841 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12842 { } /* end */
12843};
12844
12845static struct hda_channel_mode alc662_5stack_modes[2] = {
12846 { 2, alc662_sixstack_ch6_init },
12847 { 6, alc662_sixstack_ch8_init },
12848};
12849
12850/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12851 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12852 */
12853
12854static struct snd_kcontrol_new alc662_base_mixer[] = {
12855 /* output mixer control */
12856 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12857 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12858 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12859 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12860 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12861 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12862 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12863 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12865
12866 /*Input mixer control */
12867 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12868 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12869 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12870 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12871 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12872 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012875 { } /* end */
12876};
12877
12878static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12879 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12880 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12888 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12889 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12890 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12891 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012892 { } /* end */
12893};
12894
12895static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12896 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12897 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12898 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12899 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12900 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12901 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12902 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12903 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12907 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12908 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12913 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12914 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012915 { } /* end */
12916};
12917
12918static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12919 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12920 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012921 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12922 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012928 { } /* end */
12929};
12930
Kailang Yang291702f2007-10-16 14:28:03 +020012931static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010012932 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012933
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010012934 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12935 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012936
12937 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12938 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12939 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12940
12941 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12942 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12943 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12944 { } /* end */
12945};
12946
Kailang Yang8c427222008-01-10 13:03:59 +010012947static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010012948 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12949 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010012950 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12951 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12952 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012956 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010012957 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12962 { } /* end */
12963};
12964
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012965static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12966 {
12967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12968 .name = "Channel Mode",
12969 .info = alc_ch_mode_info,
12970 .get = alc_ch_mode_get,
12971 .put = alc_ch_mode_put,
12972 },
12973 { } /* end */
12974};
12975
12976static struct hda_verb alc662_init_verbs[] = {
12977 /* ADC: mute amp left and right */
12978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12979 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12980 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12981
Takashi Iwaicb53c622007-08-10 17:21:45 +020012982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012987
Kailang Yangb60dd392007-09-20 12:50:29 +020012988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012994
12995 /* Front Pin: output 0 (0x0c) */
12996 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12997 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12998
12999 /* Rear Pin: output 1 (0x0d) */
13000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13002
13003 /* CLFE Pin: output 2 (0x0e) */
13004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13005 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13006
13007 /* Mic (rear) pin: input vref at 80% */
13008 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13009 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13010 /* Front Mic pin: input vref at 80% */
13011 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13013 /* Line In pin: input */
13014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13016 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13019 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13020 /* CD pin widget for input */
13021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13022
13023 /* FIXME: use matrix-type input source selection */
13024 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13025 /* Input mixer */
13026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013030
13031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013035 { }
13036};
13037
13038static struct hda_verb alc662_sue_init_verbs[] = {
13039 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013041 {}
13042};
13043
13044static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13046 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13047 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013048};
13049
Kailang Yang8c427222008-01-10 13:03:59 +010013050/* Set Unsolicited Event*/
13051static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13053 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13054 {}
13055};
13056
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013057/*
13058 * generic initialization of ADC, input mixers and output mixers
13059 */
13060static struct hda_verb alc662_auto_init_verbs[] = {
13061 /*
13062 * Unmute ADC and set the default input to mic-in
13063 */
13064 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13065 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13066
13067 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13068 * mixer widget
13069 * Note: PASD motherboards uses the Line In 2 as the input for front
13070 * panel mic (mic 2)
13071 */
13072 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013078
13079 /*
13080 * Set up output mixers (0x0c - 0x0f)
13081 */
13082 /* set vol=0 to output mixers */
13083 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13084 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13085 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13086
13087 /* set up input amps for analog loopback */
13088 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013095
13096
13097 /* FIXME: use matrix-type input source selection */
13098 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13099 /* Input mixer */
13100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013102 { }
13103};
13104
13105/* capture mixer elements */
13106static struct snd_kcontrol_new alc662_capture_mixer[] = {
13107 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13108 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13109 {
13110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13111 /* The multiple "Capture Source" controls confuse alsamixer
13112 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013113 */
13114 /* .name = "Capture Source", */
13115 .name = "Input Source",
13116 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013117 .info = alc662_mux_enum_info,
13118 .get = alc662_mux_enum_get,
13119 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013120 },
13121 { } /* end */
13122};
13123
13124static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13125{
13126 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013127 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013128
13129 present = snd_hda_codec_read(codec, 0x14, 0,
13130 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013131 bits = present ? HDA_AMP_MUTE : 0;
13132 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13133 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013134}
13135
13136static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13137{
13138 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013139 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013140
13141 present = snd_hda_codec_read(codec, 0x1b, 0,
13142 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013143 bits = present ? HDA_AMP_MUTE : 0;
13144 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13145 HDA_AMP_MUTE, bits);
13146 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13147 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013148}
13149
13150static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13151 unsigned int res)
13152{
13153 if ((res >> 26) == ALC880_HP_EVENT)
13154 alc662_lenovo_101e_all_automute(codec);
13155 if ((res >> 26) == ALC880_FRONT_EVENT)
13156 alc662_lenovo_101e_ispeaker_automute(codec);
13157}
13158
Kailang Yang291702f2007-10-16 14:28:03 +020013159static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13160{
13161 unsigned int present;
13162
13163 present = snd_hda_codec_read(codec, 0x18, 0,
13164 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13165 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13166 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13167 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13168 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13169 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13170 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13171 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13172 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13173}
13174
13175/* unsolicited event for HP jack sensing */
13176static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13177 unsigned int res)
13178{
13179 if ((res >> 26) == ALC880_HP_EVENT)
13180 alc262_hippo1_automute( codec );
13181
13182 if ((res >> 26) == ALC880_MIC_EVENT)
13183 alc662_eeepc_mic_automute(codec);
13184}
13185
13186static void alc662_eeepc_inithook(struct hda_codec *codec)
13187{
13188 alc262_hippo1_automute( codec );
13189 alc662_eeepc_mic_automute(codec);
13190}
13191
Kailang Yang8c427222008-01-10 13:03:59 +010013192static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13193{
13194 unsigned int mute;
13195 unsigned int present;
13196
13197 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13198 present = snd_hda_codec_read(codec, 0x14, 0,
13199 AC_VERB_GET_PIN_SENSE, 0);
13200 present = (present & 0x80000000) != 0;
13201 if (present) {
13202 /* mute internal speaker */
13203 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13204 HDA_AMP_MUTE, HDA_AMP_MUTE);
13205 } else {
13206 /* unmute internal speaker if necessary */
13207 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13208 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13209 HDA_AMP_MUTE, mute);
13210 }
13211}
13212
13213/* unsolicited event for HP jack sensing */
13214static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13215 unsigned int res)
13216{
13217 if ((res >> 26) == ALC880_HP_EVENT)
13218 alc662_eeepc_ep20_automute(codec);
13219}
13220
13221static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13222{
13223 alc662_eeepc_ep20_automute(codec);
13224}
13225
Takashi Iwaicb53c622007-08-10 17:21:45 +020013226#ifdef CONFIG_SND_HDA_POWER_SAVE
13227#define alc662_loopbacks alc880_loopbacks
13228#endif
13229
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013230
13231/* pcm configuration: identiacal with ALC880 */
13232#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13233#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13234#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13235#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13236
13237/*
13238 * configuration and preset
13239 */
13240static const char *alc662_models[ALC662_MODEL_LAST] = {
13241 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13242 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13243 [ALC662_3ST_6ch] = "3stack-6ch",
13244 [ALC662_5ST_DIG] = "6stack-dig",
13245 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013246 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013247 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013248 [ALC662_AUTO] = "auto",
13249};
13250
13251static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013252 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013253 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013254 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013255 {}
13256};
13257
13258static struct alc_config_preset alc662_presets[] = {
13259 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013260 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013261 .init_verbs = { alc662_init_verbs },
13262 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13263 .dac_nids = alc662_dac_nids,
13264 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013265 .dig_in_nid = ALC662_DIGIN_NID,
13266 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13267 .channel_mode = alc662_3ST_2ch_modes,
13268 .input_mux = &alc662_capture_source,
13269 },
13270 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013271 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13272 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013273 .init_verbs = { alc662_init_verbs },
13274 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13275 .dac_nids = alc662_dac_nids,
13276 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013277 .dig_in_nid = ALC662_DIGIN_NID,
13278 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13279 .channel_mode = alc662_3ST_6ch_modes,
13280 .need_dac_fix = 1,
13281 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013282 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013283 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013284 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13285 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013286 .init_verbs = { alc662_init_verbs },
13287 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13288 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013289 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13290 .channel_mode = alc662_3ST_6ch_modes,
13291 .need_dac_fix = 1,
13292 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013293 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013294 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013295 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13296 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013297 .init_verbs = { alc662_init_verbs },
13298 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13299 .dac_nids = alc662_dac_nids,
13300 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013301 .dig_in_nid = ALC662_DIGIN_NID,
13302 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13303 .channel_mode = alc662_5stack_modes,
13304 .input_mux = &alc662_capture_source,
13305 },
13306 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013307 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013308 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13309 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13310 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013311 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13312 .channel_mode = alc662_3ST_2ch_modes,
13313 .input_mux = &alc662_lenovo_101e_capture_source,
13314 .unsol_event = alc662_lenovo_101e_unsol_event,
13315 .init_hook = alc662_lenovo_101e_all_automute,
13316 },
Kailang Yang291702f2007-10-16 14:28:03 +020013317 [ALC662_ASUS_EEEPC_P701] = {
13318 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13319 .init_verbs = { alc662_init_verbs,
13320 alc662_eeepc_sue_init_verbs },
13321 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13322 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020013323 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13324 .channel_mode = alc662_3ST_2ch_modes,
13325 .input_mux = &alc662_eeepc_capture_source,
13326 .unsol_event = alc662_eeepc_unsol_event,
13327 .init_hook = alc662_eeepc_inithook,
13328 },
Kailang Yang8c427222008-01-10 13:03:59 +010013329 [ALC662_ASUS_EEEPC_EP20] = {
13330 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13331 alc662_chmode_mixer },
13332 .init_verbs = { alc662_init_verbs,
13333 alc662_eeepc_ep20_sue_init_verbs },
13334 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13335 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010013336 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13337 .channel_mode = alc662_3ST_6ch_modes,
13338 .input_mux = &alc662_lenovo_101e_capture_source,
13339 .unsol_event = alc662_eeepc_ep20_unsol_event,
13340 .init_hook = alc662_eeepc_ep20_inithook,
13341 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013342
13343};
13344
13345
13346/*
13347 * BIOS auto configuration
13348 */
13349
13350/* add playback controls from the parsed DAC table */
13351static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13352 const struct auto_pin_cfg *cfg)
13353{
13354 char name[32];
13355 static const char *chname[4] = {
13356 "Front", "Surround", NULL /*CLFE*/, "Side"
13357 };
13358 hda_nid_t nid;
13359 int i, err;
13360
13361 for (i = 0; i < cfg->line_outs; i++) {
13362 if (!spec->multiout.dac_nids[i])
13363 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013364 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013365 if (i == 2) {
13366 /* Center/LFE */
13367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13368 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013369 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13370 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013371 if (err < 0)
13372 return err;
13373 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13374 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013375 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13376 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013377 if (err < 0)
13378 return err;
13379 err = add_control(spec, ALC_CTL_BIND_MUTE,
13380 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013381 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13382 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013383 if (err < 0)
13384 return err;
13385 err = add_control(spec, ALC_CTL_BIND_MUTE,
13386 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013387 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13388 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013389 if (err < 0)
13390 return err;
13391 } else {
13392 sprintf(name, "%s Playback Volume", chname[i]);
13393 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13395 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013396 if (err < 0)
13397 return err;
13398 sprintf(name, "%s Playback Switch", chname[i]);
13399 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013400 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13401 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013402 if (err < 0)
13403 return err;
13404 }
13405 }
13406 return 0;
13407}
13408
13409/* add playback controls for speaker and HP outputs */
13410static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13411 const char *pfx)
13412{
13413 hda_nid_t nid;
13414 int err;
13415 char name[32];
13416
13417 if (!pin)
13418 return 0;
13419
13420 if (alc880_is_fixed_pin(pin)) {
13421 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13422 /* printk("DAC nid=%x\n",nid); */
13423 /* specify the DAC as the extra output */
13424 if (!spec->multiout.hp_nid)
13425 spec->multiout.hp_nid = nid;
13426 else
13427 spec->multiout.extra_out_nid[0] = nid;
13428 /* control HP volume/switch on the output mixer amp */
13429 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13430 sprintf(name, "%s Playback Volume", pfx);
13431 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13432 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13433 if (err < 0)
13434 return err;
13435 sprintf(name, "%s Playback Switch", pfx);
13436 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13437 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13438 if (err < 0)
13439 return err;
13440 } else if (alc880_is_multi_pin(pin)) {
13441 /* set manual connection */
13442 /* we have only a switch on HP-out PIN */
13443 sprintf(name, "%s Playback Switch", pfx);
13444 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13445 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13446 if (err < 0)
13447 return err;
13448 }
13449 return 0;
13450}
13451
13452/* create playback/capture controls for input pins */
13453static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13454 const struct auto_pin_cfg *cfg)
13455{
13456 struct hda_input_mux *imux = &spec->private_imux;
13457 int i, err, idx;
13458
13459 for (i = 0; i < AUTO_PIN_LAST; i++) {
13460 if (alc880_is_input_pin(cfg->input_pins[i])) {
13461 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13462 err = new_analog_input(spec, cfg->input_pins[i],
13463 auto_pin_cfg_labels[i],
13464 idx, 0x0b);
13465 if (err < 0)
13466 return err;
13467 imux->items[imux->num_items].label =
13468 auto_pin_cfg_labels[i];
13469 imux->items[imux->num_items].index =
13470 alc880_input_pin_idx(cfg->input_pins[i]);
13471 imux->num_items++;
13472 }
13473 }
13474 return 0;
13475}
13476
13477static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13478 hda_nid_t nid, int pin_type,
13479 int dac_idx)
13480{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013481 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013482 /* need the manual connection? */
13483 if (alc880_is_multi_pin(nid)) {
13484 struct alc_spec *spec = codec->spec;
13485 int idx = alc880_multi_pin_idx(nid);
13486 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13487 AC_VERB_SET_CONNECT_SEL,
13488 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13489 }
13490}
13491
13492static void alc662_auto_init_multi_out(struct hda_codec *codec)
13493{
13494 struct alc_spec *spec = codec->spec;
13495 int i;
13496
Kailang Yang8c427222008-01-10 13:03:59 +010013497 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013498 for (i = 0; i <= HDA_SIDE; i++) {
13499 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013500 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013501 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013502 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013503 i);
13504 }
13505}
13506
13507static void alc662_auto_init_hp_out(struct hda_codec *codec)
13508{
13509 struct alc_spec *spec = codec->spec;
13510 hda_nid_t pin;
13511
13512 pin = spec->autocfg.hp_pins[0];
13513 if (pin) /* connect to front */
13514 /* use dac 0 */
13515 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013516 pin = spec->autocfg.speaker_pins[0];
13517 if (pin)
13518 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013519}
13520
13521#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13522#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13523
13524static void alc662_auto_init_analog_input(struct hda_codec *codec)
13525{
13526 struct alc_spec *spec = codec->spec;
13527 int i;
13528
13529 for (i = 0; i < AUTO_PIN_LAST; i++) {
13530 hda_nid_t nid = spec->autocfg.input_pins[i];
13531 if (alc662_is_input_pin(nid)) {
13532 snd_hda_codec_write(codec, nid, 0,
13533 AC_VERB_SET_PIN_WIDGET_CONTROL,
13534 (i <= AUTO_PIN_FRONT_MIC ?
13535 PIN_VREF80 : PIN_IN));
13536 if (nid != ALC662_PIN_CD_NID)
13537 snd_hda_codec_write(codec, nid, 0,
13538 AC_VERB_SET_AMP_GAIN_MUTE,
13539 AMP_OUT_MUTE);
13540 }
13541 }
13542}
13543
13544static int alc662_parse_auto_config(struct hda_codec *codec)
13545{
13546 struct alc_spec *spec = codec->spec;
13547 int err;
13548 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13549
13550 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13551 alc662_ignore);
13552 if (err < 0)
13553 return err;
13554 if (!spec->autocfg.line_outs)
13555 return 0; /* can't find valid BIOS pin config */
13556
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013557 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13558 if (err < 0)
13559 return err;
13560 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13561 if (err < 0)
13562 return err;
13563 err = alc662_auto_create_extra_out(spec,
13564 spec->autocfg.speaker_pins[0],
13565 "Speaker");
13566 if (err < 0)
13567 return err;
13568 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13569 "Headphone");
13570 if (err < 0)
13571 return err;
13572 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13573 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013574 return err;
13575
13576 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13577
13578 if (spec->autocfg.dig_out_pin)
13579 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13580
13581 if (spec->kctl_alloc)
13582 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13583
13584 spec->num_mux_defs = 1;
13585 spec->input_mux = &spec->private_imux;
13586
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013587 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013588 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13589 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013590 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013591}
13592
13593/* additional initialization for auto-configuration model */
13594static void alc662_auto_init(struct hda_codec *codec)
13595{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013596 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013597 alc662_auto_init_multi_out(codec);
13598 alc662_auto_init_hp_out(codec);
13599 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013600 if (spec->unsol_event)
13601 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013602}
13603
13604static int patch_alc662(struct hda_codec *codec)
13605{
13606 struct alc_spec *spec;
13607 int err, board_config;
13608
13609 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13610 if (!spec)
13611 return -ENOMEM;
13612
13613 codec->spec = spec;
13614
13615 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13616 alc662_models,
13617 alc662_cfg_tbl);
13618 if (board_config < 0) {
13619 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13620 "trying auto-probe from BIOS...\n");
13621 board_config = ALC662_AUTO;
13622 }
13623
13624 if (board_config == ALC662_AUTO) {
13625 /* automatic parse from the BIOS config */
13626 err = alc662_parse_auto_config(codec);
13627 if (err < 0) {
13628 alc_free(codec);
13629 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013630 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013631 printk(KERN_INFO
13632 "hda_codec: Cannot set up configuration "
13633 "from BIOS. Using base mode...\n");
13634 board_config = ALC662_3ST_2ch_DIG;
13635 }
13636 }
13637
13638 if (board_config != ALC662_AUTO)
13639 setup_preset(spec, &alc662_presets[board_config]);
13640
13641 spec->stream_name_analog = "ALC662 Analog";
13642 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13643 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13644
13645 spec->stream_name_digital = "ALC662 Digital";
13646 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13647 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13648
Takashi Iwaie1406342008-02-11 18:32:32 +010013649 spec->adc_nids = alc662_adc_nids;
13650 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13651 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013652
Takashi Iwai2134ea42008-01-10 16:53:55 +010013653 spec->vmaster_nid = 0x02;
13654
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013655 codec->patch_ops = alc_patch_ops;
13656 if (board_config == ALC662_AUTO)
13657 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013658#ifdef CONFIG_SND_HDA_POWER_SAVE
13659 if (!spec->loopback.amplist)
13660 spec->loopback.amplist = alc662_loopbacks;
13661#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013662
13663 return 0;
13664}
13665
13666/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013667 * patch entries
13668 */
13669struct hda_codec_preset snd_hda_preset_realtek[] = {
13670 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013671 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013672 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013673 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013674 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013675 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013676 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013677 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13678 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13679 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013680 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13681 .patch = patch_alc883 },
13682 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13683 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013684 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013685 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013686 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013687 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013688 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013689 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013690 {} /* terminator */
13691};