blob: b092bd47e56e28ed9c3ae6880413b97f35153f1b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115};
116
Kailang Yangf6a92242007-12-13 16:52:54 +0100117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
Kailang Yangdf694da2005-12-05 19:42:22 +0100124/* ALC861 models */
125enum {
126 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200127 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200130 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200131 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200132 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100133 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136};
137
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100138/* ALC861-VD models */
139enum {
140 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200141 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200145 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200146 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200147 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150};
151
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200152/* ALC662 models */
153enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200159 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100160 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163};
164
Kailang Yangdf694da2005-12-05 19:42:22 +0100165/* ALC882 models */
166enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200169 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200170 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200173 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100174 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200175 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200176 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200177 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 ALC882_MODEL_LAST,
179};
180
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200181/* ALC883 models */
182enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200189 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200190 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200191 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200192 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100193 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100200 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100201 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204};
205
Kailang Yangdf694da2005-12-05 19:42:22 +0100206/* for GPIO Poll */
207#define GPIO_MASK 0x03
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209struct alc_spec {
210 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 unsigned int num_mixers;
213
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215 * don't forget NULL
216 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200217 */
218 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Takashi Iwai16ded522005-06-10 19:58:24 +0200220 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200226 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
229
230 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
234 */
Takashi Iwai63300792008-01-24 15:31:36 +0100235 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
242 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200243 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
246
247 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100248 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200250 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200254
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100258 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200259 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100261
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
265
Takashi Iwai834be882006-03-01 14:16:17 +0100266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100269 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200270
Takashi Iwai2134ea42008-01-10 16:53:55 +0100271 /* for virtual master */
272 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200274#ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_loopback_check loopback;
276#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100277};
278
279/*
280 * configuration template - to be copied to the spec instance
281 */
282struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200283 struct snd_kcontrol_new *mixers[5]; /* should be identical size
284 * with spec
285 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100286 const struct hda_verb *init_verbs[5];
287 unsigned int num_dacs;
288 hda_nid_t *dac_nids;
289 hda_nid_t dig_out_nid; /* optional */
290 hda_nid_t hp_nid; /* optional */
291 unsigned int num_adc_nids;
292 hda_nid_t *adc_nids;
293 hda_nid_t dig_in_nid;
294 unsigned int num_channel_mode;
295 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200296 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200297 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100298 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100299 void (*unsol_event)(struct hda_codec *, unsigned int);
300 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200301#ifdef CONFIG_SND_HDA_POWER_SAVE
302 struct hda_amp_list *loopbacks;
303#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307/*
308 * input MUX handling
309 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200315 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
316 if (mux_idx >= spec->num_mux_defs)
317 mux_idx = 0;
318 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319}
320
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200321static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
326 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
327
328 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
329 return 0;
330}
331
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200332static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200338 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
339 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200340 spec->adc_nids[adc_idx],
341 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342}
343
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345/*
346 * channel mode setting
347 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200348static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
352 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100353 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
354 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355}
356
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359{
360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100362 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363 spec->num_channel_mode,
364 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365}
366
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200367static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200372 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
373 spec->num_channel_mode,
374 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200375 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200376 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
377 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100381 * Control the mode of pin widget settings via the mixer. "pc" is used
382 * instead of "%" to avoid consequences of accidently treating the % as
383 * being part of a format specifier. Maximum allowed length of a value is
384 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100385 *
386 * Note: some retasking pin complexes seem to ignore requests for input
387 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
388 * are requested. Therefore order this list so that this behaviour will not
389 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200390 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
391 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200392 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100394 "Mic 50pc bias", "Mic 80pc bias",
395 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100396};
397static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100398 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100399};
400/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200401 * in the pin being assumed to be exclusively an input or an output pin. In
402 * addition, "input" pins may or may not process the mic bias option
403 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
404 * accept requests for bias as of chip versions up to March 2006) and/or
405 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100406 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407#define ALC_PIN_DIR_IN 0x00
408#define ALC_PIN_DIR_OUT 0x01
409#define ALC_PIN_DIR_INOUT 0x02
410#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
411#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200413/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100414 * For each direction the minimum and maximum values are given.
415 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417 { 0, 2 }, /* ALC_PIN_DIR_IN */
418 { 3, 4 }, /* ALC_PIN_DIR_OUT */
419 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200420 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
421 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422};
423#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
424#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
425#define alc_pin_mode_n_items(_dir) \
426 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
427
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200428static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
429 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200430{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431 unsigned int item_num = uinfo->value.enumerated.item;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
433
434 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200435 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100436 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
437
438 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
439 item_num = alc_pin_mode_min(dir);
440 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200441 return 0;
442}
443
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200446{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100447 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100450 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200451 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200452 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
453 AC_VERB_GET_PIN_WIDGET_CONTROL,
454 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200455
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 /* Find enumerated value for current pinctl setting */
457 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100461 return 0;
462}
463
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100466{
467 signed int change;
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
471 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_PIN_WIDGET_CONTROL,
474 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100475
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200476 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100477 val = alc_pin_mode_min(dir);
478
479 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100480 if (change) {
481 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200482 snd_hda_codec_write_cache(codec, nid, 0,
483 AC_VERB_SET_PIN_WIDGET_CONTROL,
484 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100485
486 /* Also enable the retasking pin's input/output as required
487 * for the requested pin mode. Enum values of 2 or less are
488 * input modes.
489 *
490 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200491 * reduces noise slightly (particularly on input) so we'll
492 * do it. However, having both input and output buffers
493 * enabled simultaneously doesn't seem to be problematic if
494 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100495 */
496 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200497 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
498 HDA_AMP_MUTE, HDA_AMP_MUTE);
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
500 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100501 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200502 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
503 HDA_AMP_MUTE, HDA_AMP_MUTE);
504 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
505 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100506 }
507 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200508 return change;
509}
510
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200512 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513 .info = alc_pin_mode_info, \
514 .get = alc_pin_mode_get, \
515 .put = alc_pin_mode_put, \
516 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100517
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100518/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
519 * together using a mask with more than one bit set. This control is
520 * currently used only by the ALC260 test model. At this stage they are not
521 * needed for any "production" models.
522 */
523#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200524#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200525
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100528{
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 hda_nid_t nid = kcontrol->private_value & 0xffff;
531 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
532 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533 unsigned int val = snd_hda_codec_read(codec, nid, 0,
534 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100535
536 *valp = (val & mask) != 0;
537 return 0;
538}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100541{
542 signed int change;
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
546 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_GPIO_DATA,
549 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100550
551 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
553 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100554 gpio_data &= ~mask;
555 else
556 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200557 snd_hda_codec_write_cache(codec, nid, 0,
558 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100559
560 return change;
561}
562#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
563 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
564 .info = alc_gpio_data_info, \
565 .get = alc_gpio_data_get, \
566 .put = alc_gpio_data_put, \
567 .private_value = nid | (mask<<16) }
568#endif /* CONFIG_SND_DEBUG */
569
Jonathan Woithe92621f12006-02-28 11:47:47 +0100570/* A switch control to allow the enabling of the digital IO pins on the
571 * ALC260. This is incredibly simplistic; the intention of this control is
572 * to provide something in the test model allowing digital outputs to be
573 * identified if present. If models are found which can utilise these
574 * outputs a more complete mixer control can be devised for those models if
575 * necessary.
576 */
577#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200578#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200579
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100582{
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 hda_nid_t nid = kcontrol->private_value & 0xffff;
585 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
586 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100588 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100589
590 *valp = (val & mask) != 0;
591 return 0;
592}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200593static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
594 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100595{
596 signed int change;
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 hda_nid_t nid = kcontrol->private_value & 0xffff;
599 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
600 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100602 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100604
605 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200606 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100607 if (val==0)
608 ctrl_data &= ~mask;
609 else
610 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200611 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
612 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100613
614 return change;
615}
616#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
617 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
618 .info = alc_spdif_ctrl_info, \
619 .get = alc_spdif_ctrl_get, \
620 .put = alc_spdif_ctrl_put, \
621 .private_value = nid | (mask<<16) }
622#endif /* CONFIG_SND_DEBUG */
623
Jonathan Woithef8225f62008-01-08 12:16:54 +0100624/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
625 * Again, this is only used in the ALC26x test models to help identify when
626 * the EAPD line must be asserted for features to work.
627 */
628#ifdef CONFIG_SND_DEBUG
629#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
630
631static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
633{
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 hda_nid_t nid = kcontrol->private_value & 0xffff;
636 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
637 long *valp = ucontrol->value.integer.value;
638 unsigned int val = snd_hda_codec_read(codec, nid, 0,
639 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
640
641 *valp = (val & mask) != 0;
642 return 0;
643}
644
645static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647{
648 int change;
649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
650 hda_nid_t nid = kcontrol->private_value & 0xffff;
651 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
652 long val = *ucontrol->value.integer.value;
653 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
654 AC_VERB_GET_EAPD_BTLENABLE,
655 0x00);
656
657 /* Set/unset the masked control bit(s) as needed */
658 change = (!val ? 0 : mask) != (ctrl_data & mask);
659 if (!val)
660 ctrl_data &= ~mask;
661 else
662 ctrl_data |= mask;
663 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
664 ctrl_data);
665
666 return change;
667}
668
669#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
670 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
671 .info = alc_eapd_ctrl_info, \
672 .get = alc_eapd_ctrl_get, \
673 .put = alc_eapd_ctrl_put, \
674 .private_value = nid | (mask<<16) }
675#endif /* CONFIG_SND_DEBUG */
676
Kailang Yangdf694da2005-12-05 19:42:22 +0100677/*
678 * set up from the preset table
679 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680static void setup_preset(struct alc_spec *spec,
681 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100682{
683 int i;
684
685 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
686 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
688 i++)
689 spec->init_verbs[spec->num_init_verbs++] =
690 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100691
692 spec->channel_mode = preset->channel_mode;
693 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200694 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100695
696 spec->multiout.max_channels = spec->channel_mode[0].channels;
697
698 spec->multiout.num_dacs = preset->num_dacs;
699 spec->multiout.dac_nids = preset->dac_nids;
700 spec->multiout.dig_out_nid = preset->dig_out_nid;
701 spec->multiout.hp_nid = preset->hp_nid;
702
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200703 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200704 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200705 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100706 spec->input_mux = preset->input_mux;
707
708 spec->num_adc_nids = preset->num_adc_nids;
709 spec->adc_nids = preset->adc_nids;
710 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100711
712 spec->unsol_event = preset->unsol_event;
713 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200714#ifdef CONFIG_SND_HDA_POWER_SAVE
715 spec->loopback.amplist = preset->loopbacks;
716#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100717}
718
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200719/* Enable GPIO mask and set output */
720static struct hda_verb alc_gpio1_init_verbs[] = {
721 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
723 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
724 { }
725};
726
727static struct hda_verb alc_gpio2_init_verbs[] = {
728 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
730 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
731 { }
732};
733
Kailang Yangbdd148a2007-05-08 15:19:08 +0200734static struct hda_verb alc_gpio3_init_verbs[] = {
735 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
737 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
738 { }
739};
740
Kailang Yangc9b58002007-10-16 14:30:01 +0200741static void alc_sku_automute(struct hda_codec *codec)
742{
743 struct alc_spec *spec = codec->spec;
744 unsigned int mute;
745 unsigned int present;
746 unsigned int hp_nid = spec->autocfg.hp_pins[0];
747 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
748
749 /* need to execute and sync at first */
750 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
751 present = snd_hda_codec_read(codec, hp_nid, 0,
752 AC_VERB_GET_PIN_SENSE, 0);
753 spec->jack_present = (present & 0x80000000) != 0;
754 if (spec->jack_present) {
755 /* mute internal speaker */
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, HDA_AMP_MUTE);
758 } else {
759 /* unmute internal speaker if necessary */
760 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, mute);
763 }
764}
765
766/* unsolicited event for HP jack sensing */
767static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
768{
769 if (codec->vendor_id == 0x10ec0880)
770 res >>= 28;
771 else
772 res >>= 26;
773 if (res != ALC880_HP_EVENT)
774 return;
775
776 alc_sku_automute(codec);
777}
778
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200779/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
780 * 31 ~ 16 : Manufacture ID
781 * 15 ~ 8 : SKU ID
782 * 7 ~ 0 : Assembly ID
783 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
784 */
785static void alc_subsystem_id(struct hda_codec *codec,
786 unsigned int porta, unsigned int porte,
787 unsigned int portd)
788{
Kailang Yangc9b58002007-10-16 14:30:01 +0200789 unsigned int ass, tmp, i;
790 unsigned nid;
791 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200792
Kailang Yangc9b58002007-10-16 14:30:01 +0200793 ass = codec->subsystem_id & 0xffff;
794 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
795 goto do_sku;
796
797 /*
798 * 31~30 : port conetcivity
799 * 29~21 : reserve
800 * 20 : PCBEEP input
801 * 19~16 : Check sum (15:1)
802 * 15~1 : Custom
803 * 0 : override
804 */
805 nid = 0x1d;
806 if (codec->vendor_id == 0x10ec0260)
807 nid = 0x17;
808 ass = snd_hda_codec_read(codec, nid, 0,
809 AC_VERB_GET_CONFIG_DEFAULT, 0);
810 if (!(ass & 1) && !(ass & 0x100000))
811 return;
812 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200813 return;
814
Kailang Yangc9b58002007-10-16 14:30:01 +0200815 /* check sum */
816 tmp = 0;
817 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100818 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200819 tmp++;
820 }
821 if (((ass >> 16) & 0xf) != tmp)
822 return;
823do_sku:
824 /*
825 * 0 : override
826 * 1 : Swap Jack
827 * 2 : 0 --> Desktop, 1 --> Laptop
828 * 3~5 : External Amplifier control
829 * 7~6 : Reserved
830 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200831 tmp = (ass & 0x38) >> 3; /* external Amp control */
832 switch (tmp) {
833 case 1:
834 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
835 break;
836 case 3:
837 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
838 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200839 case 7:
840 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
841 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200842 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200843 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200844 case 0x10ec0260:
845 snd_hda_codec_write(codec, 0x0f, 0,
846 AC_VERB_SET_EAPD_BTLENABLE, 2);
847 snd_hda_codec_write(codec, 0x10, 0,
848 AC_VERB_SET_EAPD_BTLENABLE, 2);
849 break;
850 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200851 case 0x10ec0267:
852 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200853 case 0x10ec0269:
854 case 0x10ec0862:
855 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200856 snd_hda_codec_write(codec, 0x14, 0,
857 AC_VERB_SET_EAPD_BTLENABLE, 2);
858 snd_hda_codec_write(codec, 0x15, 0,
859 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200860 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200861 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200862 switch (codec->vendor_id) {
863 case 0x10ec0260:
864 snd_hda_codec_write(codec, 0x1a, 0,
865 AC_VERB_SET_COEF_INDEX, 7);
866 tmp = snd_hda_codec_read(codec, 0x1a, 0,
867 AC_VERB_GET_PROC_COEF, 0);
868 snd_hda_codec_write(codec, 0x1a, 0,
869 AC_VERB_SET_COEF_INDEX, 7);
870 snd_hda_codec_write(codec, 0x1a, 0,
871 AC_VERB_SET_PROC_COEF,
872 tmp | 0x2010);
873 break;
874 case 0x10ec0262:
875 case 0x10ec0880:
876 case 0x10ec0882:
877 case 0x10ec0883:
878 case 0x10ec0885:
879 case 0x10ec0888:
880 snd_hda_codec_write(codec, 0x20, 0,
881 AC_VERB_SET_COEF_INDEX, 7);
882 tmp = snd_hda_codec_read(codec, 0x20, 0,
883 AC_VERB_GET_PROC_COEF, 0);
884 snd_hda_codec_write(codec, 0x20, 0,
885 AC_VERB_SET_COEF_INDEX, 7);
886 snd_hda_codec_write(codec, 0x20, 0,
887 AC_VERB_SET_PROC_COEF,
888 tmp | 0x2010);
889 break;
890 case 0x10ec0267:
891 case 0x10ec0268:
892 snd_hda_codec_write(codec, 0x20, 0,
893 AC_VERB_SET_COEF_INDEX, 7);
894 tmp = snd_hda_codec_read(codec, 0x20, 0,
895 AC_VERB_GET_PROC_COEF, 0);
896 snd_hda_codec_write(codec, 0x20, 0,
897 AC_VERB_SET_COEF_INDEX, 7);
898 snd_hda_codec_write(codec, 0x20, 0,
899 AC_VERB_SET_PROC_COEF,
900 tmp | 0x3000);
901 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200902 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200903 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200904 break;
905 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200906
Kailang Yang8c427222008-01-10 13:03:59 +0100907 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200908 * when the external headphone out jack is plugged"
909 */
Kailang Yang8c427222008-01-10 13:03:59 +0100910 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200911 return;
912 /*
913 * 10~8 : Jack location
914 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
915 * 14~13: Resvered
916 * 15 : 1 --> enable the function "Mute internal speaker
917 * when the external headphone out jack is plugged"
918 */
919 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100920 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200921 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100922 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200923 else
924 return;
925 }
926
927 if (!spec->autocfg.hp_pins[0]) {
928 tmp = (ass >> 11) & 0x3; /* HP to chassis */
929 if (tmp == 0)
930 spec->autocfg.hp_pins[0] = porta;
931 else if (tmp == 1)
932 spec->autocfg.hp_pins[0] = porte;
933 else if (tmp == 2)
934 spec->autocfg.hp_pins[0] = portd;
935 else
936 return;
937 }
938
939 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
940 AC_VERB_SET_UNSOLICITED_ENABLE,
941 AC_USRSP_EN | ALC880_HP_EVENT);
942 spec->unsol_event = alc_sku_unsol_event;
943 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200944}
945
Takashi Iwai41e41f12005-06-08 14:48:49 +0200946/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200947 * Fix-up pin default configurations
948 */
949
950struct alc_pincfg {
951 hda_nid_t nid;
952 u32 val;
953};
954
955static void alc_fix_pincfg(struct hda_codec *codec,
956 const struct snd_pci_quirk *quirk,
957 const struct alc_pincfg **pinfix)
958{
959 const struct alc_pincfg *cfg;
960
961 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
962 if (!quirk)
963 return;
964
965 cfg = pinfix[quirk->value];
966 for (; cfg->nid; cfg++) {
967 int i;
968 u32 val = cfg->val;
969 for (i = 0; i < 4; i++) {
970 snd_hda_codec_write(codec, cfg->nid, 0,
971 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
972 val & 0xff);
973 val >>= 8;
974 }
975 }
976}
977
978/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200979 * ALC880 3-stack model
980 *
981 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200982 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
983 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 */
985
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200986static hda_nid_t alc880_dac_nids[4] = {
987 /* front, rear, clfe, rear_surr */
988 0x02, 0x05, 0x04, 0x03
989};
990
991static hda_nid_t alc880_adc_nids[3] = {
992 /* ADC0-2 */
993 0x07, 0x08, 0x09,
994};
995
996/* The datasheet says the node 0x07 is connected from inputs,
997 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100998 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001000static hda_nid_t alc880_adc_nids_alt[2] = {
1001 /* ADC1-2 */
1002 0x08, 0x09,
1003};
1004
1005#define ALC880_DIGOUT_NID 0x06
1006#define ALC880_DIGIN_NID 0x0a
1007
1008static struct hda_input_mux alc880_capture_source = {
1009 .num_items = 4,
1010 .items = {
1011 { "Mic", 0x0 },
1012 { "Front Mic", 0x3 },
1013 { "Line", 0x2 },
1014 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001016};
1017
1018/* channel source setting (2/6 channel selection for 3-stack) */
1019/* 2ch mode */
1020static struct hda_verb alc880_threestack_ch2_init[] = {
1021 /* set line-in to input, mute it */
1022 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1023 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1024 /* set mic-in to input vref 80%, mute it */
1025 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1026 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 { } /* end */
1028};
1029
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001030/* 6ch mode */
1031static struct hda_verb alc880_threestack_ch6_init[] = {
1032 /* set line-in to output, unmute it */
1033 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1034 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1035 /* set mic-in to output, unmute it */
1036 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1037 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1038 { } /* end */
1039};
1040
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001041static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 { 2, alc880_threestack_ch2_init },
1043 { 6, alc880_threestack_ch6_init },
1044};
1045
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001046static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001047 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001048 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001049 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001050 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001051 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001053 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1054 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1063 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1064 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001066 {
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001069 .info = alc_ch_mode_info,
1070 .get = alc_ch_mode_get,
1071 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 },
1073 { } /* end */
1074};
1075
1076/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001077static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001078 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1084 {
1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1086 /* The multiple "Capture Source" controls confuse alsamixer
1087 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001088 */
1089 /* .name = "Capture Source", */
1090 .name = "Input Source",
1091 .count = 3,
1092 .info = alc_mux_enum_info,
1093 .get = alc_mux_enum_get,
1094 .put = alc_mux_enum_put,
1095 },
1096 { } /* end */
1097};
1098
1099/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001100static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1103 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 {
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1107 /* The multiple "Capture Source" controls confuse alsamixer
1108 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 */
1110 /* .name = "Capture Source", */
1111 .name = "Input Source",
1112 .count = 2,
1113 .info = alc_mux_enum_info,
1114 .get = alc_mux_enum_get,
1115 .put = alc_mux_enum_put,
1116 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 { } /* end */
1118};
1119
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001120
1121
1122/*
1123 * ALC880 5-stack model
1124 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001125 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1126 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001127 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1128 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1129 */
1130
1131/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001132static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001134 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 { } /* end */
1136};
1137
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001138/* channel source setting (6/8 channel selection for 5-stack) */
1139/* 6ch mode */
1140static struct hda_verb alc880_fivestack_ch6_init[] = {
1141 /* set line-in to input, mute it */
1142 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1143 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001144 { } /* end */
1145};
1146
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001147/* 8ch mode */
1148static struct hda_verb alc880_fivestack_ch8_init[] = {
1149 /* set line-in to output, unmute it */
1150 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1151 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1152 { } /* end */
1153};
1154
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001155static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156 { 6, alc880_fivestack_ch6_init },
1157 { 8, alc880_fivestack_ch8_init },
1158};
1159
1160
1161/*
1162 * ALC880 6-stack model
1163 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001164 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1165 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001166 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1167 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1168 */
1169
1170static hda_nid_t alc880_6st_dac_nids[4] = {
1171 /* front, rear, clfe, rear_surr */
1172 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001173};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001174
1175static struct hda_input_mux alc880_6stack_capture_source = {
1176 .num_items = 4,
1177 .items = {
1178 { "Mic", 0x0 },
1179 { "Front Mic", 0x1 },
1180 { "Line", 0x2 },
1181 { "CD", 0x4 },
1182 },
1183};
1184
1185/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001186static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001187 { 8, NULL },
1188};
1189
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001190static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001194 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1209 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1210 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001211 {
1212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1213 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001214 .info = alc_ch_mode_info,
1215 .get = alc_ch_mode_get,
1216 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001217 },
1218 { } /* end */
1219};
1220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001221
1222/*
1223 * ALC880 W810 model
1224 *
1225 * W810 has rear IO for:
1226 * Front (DAC 02)
1227 * Surround (DAC 03)
1228 * Center/LFE (DAC 04)
1229 * Digital out (06)
1230 *
1231 * The system also has a pair of internal speakers, and a headphone jack.
1232 * These are both connected to Line2 on the codec, hence to DAC 02.
1233 *
1234 * There is a variable resistor to control the speaker or headphone
1235 * volume. This is a hardware-only device without a software API.
1236 *
1237 * Plugging headphones in will disable the internal speakers. This is
1238 * implemented in hardware, not via the driver using jack sense. In
1239 * a similar fashion, plugging into the rear socket marked "front" will
1240 * disable both the speakers and headphones.
1241 *
1242 * For input, there's a microphone jack, and an "audio in" jack.
1243 * These may not do anything useful with this driver yet, because I
1244 * haven't setup any initialization verbs for these yet...
1245 */
1246
1247static hda_nid_t alc880_w810_dac_nids[3] = {
1248 /* front, rear/surround, clfe */
1249 0x02, 0x03, 0x04
1250};
1251
1252/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001253static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 { 6, NULL }
1255};
1256
1257/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001258static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001261 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001262 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001265 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1266 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1268 { } /* end */
1269};
1270
1271
1272/*
1273 * Z710V model
1274 *
1275 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001276 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1277 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278 */
1279
1280static hda_nid_t alc880_z71v_dac_nids[1] = {
1281 0x02
1282};
1283#define ALC880_Z71V_HP_DAC 0x03
1284
1285/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001286static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287 { 2, NULL }
1288};
1289
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001290static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001294 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1299 { } /* end */
1300};
1301
1302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001303/*
1304 * ALC880 F1734 model
1305 *
1306 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1307 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1308 */
1309
1310static hda_nid_t alc880_f1734_dac_nids[1] = {
1311 0x03
1312};
1313#define ALC880_F1734_HP_DAC 0x02
1314
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001315static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001317 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001324 { } /* end */
1325};
1326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001327
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001328/*
1329 * ALC880 ASUS model
1330 *
1331 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1332 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1333 * Mic = 0x18, Line = 0x1a
1334 */
1335
1336#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1337#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1338
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001339static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001341 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001343 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001354 {
1355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1356 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001357 .info = alc_ch_mode_info,
1358 .get = alc_ch_mode_get,
1359 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001360 },
1361 { } /* end */
1362};
1363
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001364/*
1365 * ALC880 ASUS W1V model
1366 *
1367 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1368 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1369 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1370 */
1371
1372/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001373static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001374 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1375 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001376 { } /* end */
1377};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001378
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001379/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001380static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001381 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1382 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1383 { } /* end */
1384};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001385
Kailang Yangdf694da2005-12-05 19:42:22 +01001386/* TCL S700 */
1387static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1395 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1396 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1397 {
1398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1399 /* The multiple "Capture Source" controls confuse alsamixer
1400 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001401 */
1402 /* .name = "Capture Source", */
1403 .name = "Input Source",
1404 .count = 1,
1405 .info = alc_mux_enum_info,
1406 .get = alc_mux_enum_get,
1407 .put = alc_mux_enum_put,
1408 },
1409 { } /* end */
1410};
1411
Kailang Yangccc656c2006-10-17 12:32:26 +02001412/* Uniwill */
1413static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1415 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1417 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001418 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1420 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1421 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1422 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1428 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1432 {
1433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1434 .name = "Channel Mode",
1435 .info = alc_ch_mode_info,
1436 .get = alc_ch_mode_get,
1437 .put = alc_ch_mode_put,
1438 },
1439 { } /* end */
1440};
1441
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001442static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1452 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1453 { } /* end */
1454};
1455
Kailang Yangccc656c2006-10-17 12:32:26 +02001456static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1458 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1460 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1463 { } /* end */
1464};
1465
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001467 * virtual master controls
1468 */
1469
1470/*
1471 * slave controls for virtual master
1472 */
1473static const char *alc_slave_vols[] = {
1474 "Front Playback Volume",
1475 "Surround Playback Volume",
1476 "Center Playback Volume",
1477 "LFE Playback Volume",
1478 "Side Playback Volume",
1479 "Headphone Playback Volume",
1480 "Speaker Playback Volume",
1481 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001482 "Line-Out Playback Volume",
1483 NULL,
1484};
1485
1486static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001495 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001496 NULL,
1497};
1498
1499/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001500 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 */
1502static int alc_build_controls(struct hda_codec *codec)
1503{
1504 struct alc_spec *spec = codec->spec;
1505 int err;
1506 int i;
1507
1508 for (i = 0; i < spec->num_mixers; i++) {
1509 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1510 if (err < 0)
1511 return err;
1512 }
1513
1514 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001515 err = snd_hda_create_spdif_out_ctls(codec,
1516 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 if (err < 0)
1518 return err;
1519 }
1520 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1522 if (err < 0)
1523 return err;
1524 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001525
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1534 }
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1540 }
1541
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 return 0;
1543}
1544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001545
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546/*
1547 * initialize the codec volumes, etc
1548 */
1549
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001550/*
1551 * generic initialization of ADC, input mixers and output mixers
1552 */
1553static struct hda_verb alc880_volume_init_verbs[] = {
1554 /*
1555 * Unmute ADC0-2 and set the default input to mic-in
1556 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1565 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001566 * Note: PASD motherboards uses the Line In 2 as the input for front
1567 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 /*
1579 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001581 /* set vol=0 to output mixers */
1582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 /* set up input amps for analog loopback */
1587 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596
1597 { }
1598};
1599
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001600/*
1601 * 3-stack pin configuration:
1602 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1603 */
1604static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1605 /*
1606 * preset connection lists of input pins
1607 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1608 */
1609 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1610 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1612
1613 /*
1614 * Set pin mode and muting
1615 */
1616 /* set front pin widgets 0x14 for output */
1617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* Mic2 (as headphone out) for HP output */
1623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Line In pin widget for input */
1626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* Line2 (as front mic) pin widget for input and vref at 80% */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* CD pin widget for input */
1632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1633
1634 { }
1635};
1636
1637/*
1638 * 5-stack pin configuration:
1639 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1640 * line-in/side = 0x1a, f-mic = 0x1b
1641 */
1642static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1643 /*
1644 * preset connection lists of input pins
1645 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1646 */
1647 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1648 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1649
1650 /*
1651 * Set pin mode and muting
1652 */
1653 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 /* unmute pins for output (no gain on this amp) */
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 /* Mic2 (as headphone out) for HP output */
1668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001670 /* Line In pin widget for input */
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* Line2 (as front mic) pin widget for input and vref at 80% */
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* CD pin widget for input */
1677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678
1679 { }
1680};
1681
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001682/*
1683 * W810 pin configuration:
1684 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1685 */
1686static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 /* hphone/speaker input selector: front DAC */
1688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1689
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 { }
1701};
1702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001703/*
1704 * Z71V pin configuration:
1705 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1706 */
1707static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001712
Takashi Iwai16ded522005-06-10 19:58:24 +02001713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001717
1718 { }
1719};
1720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721/*
1722 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001723 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1724 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725 */
1726static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737
Takashi Iwai16ded522005-06-10 19:58:24 +02001738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1747
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 { }
1749};
Takashi Iwai16ded522005-06-10 19:58:24 +02001750
Kailang Yangccc656c2006-10-17 12:32:26 +02001751/*
1752 * Uniwill pin configuration:
1753 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1754 * line = 0x1a
1755 */
1756static struct hda_verb alc880_uniwill_init_verbs[] = {
1757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1758
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1773
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1780 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1781 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1783
1784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1786
1787 { }
1788};
1789
1790/*
1791* Uniwill P53
1792* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1793 */
1794static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1796
1797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1809
1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1816
1817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1819
1820 { }
1821};
1822
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001823static struct hda_verb alc880_beep_init_verbs[] = {
1824 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1825 { }
1826};
1827
Kailang Yangccc656c2006-10-17 12:32:26 +02001828/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001829static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001830{
1831 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001832 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001833
1834 present = snd_hda_codec_read(codec, 0x14, 0,
1835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001836 bits = present ? HDA_AMP_MUTE : 0;
1837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
1839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1840 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001841}
1842
1843/* auto-toggle front mic */
1844static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1845{
1846 unsigned int present;
1847 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001848
1849 present = snd_hda_codec_read(codec, 0x18, 0,
1850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001851 bits = present ? HDA_AMP_MUTE : 0;
1852 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001853}
1854
1855static void alc880_uniwill_automute(struct hda_codec *codec)
1856{
1857 alc880_uniwill_hp_automute(codec);
1858 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001859}
1860
1861static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1862 unsigned int res)
1863{
1864 /* Looks like the unsol event is incompatible with the standard
1865 * definition. 4bit tag is placed at 28 bit!
1866 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001867 switch (res >> 28) {
1868 case ALC880_HP_EVENT:
1869 alc880_uniwill_hp_automute(codec);
1870 break;
1871 case ALC880_MIC_EVENT:
1872 alc880_uniwill_mic_automute(codec);
1873 break;
1874 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001875}
1876
1877static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1878{
1879 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001880 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001881
1882 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001884 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001886}
1887
1888static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1889{
1890 unsigned int present;
1891
1892 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001893 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1894 present &= HDA_AMP_VOLMASK;
1895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
1897 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1898 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001899}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001900
Kailang Yangccc656c2006-10-17 12:32:26 +02001901static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1902 unsigned int res)
1903{
1904 /* Looks like the unsol event is incompatible with the standard
1905 * definition. 4bit tag is placed at 28 bit!
1906 */
1907 if ((res >> 28) == ALC880_HP_EVENT)
1908 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001909 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001910 alc880_uniwill_p53_dcvol_automute(codec);
1911}
1912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001913/*
1914 * F1734 pin configuration:
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */
1917static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1921 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1922
1923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001937
1938 { }
1939};
1940
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001941/*
1942 * ASUS pin configuration:
1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1944 */
1945static struct hda_verb alc880_pin_asus_init_verbs[] = {
1946 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1947 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1948 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1950
1951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959
1960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1969
1970 { }
1971};
1972
1973/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001974#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1975#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001976
Kailang Yangdf694da2005-12-05 19:42:22 +01001977/* Clevo m520g init */
1978static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1979 /* headphone output */
1980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1981 /* line-out */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* Line-in */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* CD */
1988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1989 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic1 (rear panel) */
1991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* Mic2 (front panel) */
1994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* headphone */
1997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* change to EAPD mode */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2002
2003 { }
2004};
2005
2006static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002007 /* change to EAPD mode */
2008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2009 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2010
Kailang Yangdf694da2005-12-05 19:42:22 +01002011 /* Headphone output */
2012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 /* Front output*/
2014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2016
2017 /* Line In pin widget for input */
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* CD pin widget for input */
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2023
2024 /* change to EAPD mode */
2025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2027
2028 { }
2029};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030
2031/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002032 * LG m1 express dual
2033 *
2034 * Pin assignment:
2035 * Rear Line-In/Out (blue): 0x14
2036 * Build-in Mic-In: 0x15
2037 * Speaker-out: 0x17
2038 * HP-Out (green): 0x1b
2039 * Mic-In/Out (red): 0x19
2040 * SPDIF-Out: 0x1e
2041 */
2042
2043/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2044static hda_nid_t alc880_lg_dac_nids[3] = {
2045 0x05, 0x02, 0x03
2046};
2047
2048/* seems analog CD is not working */
2049static struct hda_input_mux alc880_lg_capture_source = {
2050 .num_items = 3,
2051 .items = {
2052 { "Mic", 0x1 },
2053 { "Line", 0x5 },
2054 { "Internal Mic", 0x6 },
2055 },
2056};
2057
2058/* 2,4,6 channel modes */
2059static struct hda_verb alc880_lg_ch2_init[] = {
2060 /* set line-in and mic-in to input */
2061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2062 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2063 { }
2064};
2065
2066static struct hda_verb alc880_lg_ch4_init[] = {
2067 /* set line-in to out and mic-in to input */
2068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2069 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2070 { }
2071};
2072
2073static struct hda_verb alc880_lg_ch6_init[] = {
2074 /* set line-in and mic-in to output */
2075 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2076 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2077 { }
2078};
2079
2080static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2081 { 2, alc880_lg_ch2_init },
2082 { 4, alc880_lg_ch4_init },
2083 { 6, alc880_lg_ch6_init },
2084};
2085
2086static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2100 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2101 {
2102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2103 .name = "Channel Mode",
2104 .info = alc_ch_mode_info,
2105 .get = alc_ch_mode_get,
2106 .put = alc_ch_mode_put,
2107 },
2108 { } /* end */
2109};
2110
2111static struct hda_verb alc880_lg_init_verbs[] = {
2112 /* set capture source to mic-in */
2113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 /* mute all amp mixer inputs */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002120 /* line-in to input */
2121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* built-in mic */
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* speaker-out */
2127 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* mic-in to input */
2130 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* HP-out */
2134 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 /* jack sense */
2138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2139 { }
2140};
2141
2142/* toggle speaker-output according to the hp-jack state */
2143static void alc880_lg_automute(struct hda_codec *codec)
2144{
2145 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002146 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002147
2148 present = snd_hda_codec_read(codec, 0x1b, 0,
2149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002150 bits = present ? HDA_AMP_MUTE : 0;
2151 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2152 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002153}
2154
2155static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2156{
2157 /* Looks like the unsol event is incompatible with the standard
2158 * definition. 4bit tag is placed at 28 bit!
2159 */
2160 if ((res >> 28) == 0x01)
2161 alc880_lg_automute(codec);
2162}
2163
2164/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002165 * LG LW20
2166 *
2167 * Pin assignment:
2168 * Speaker-out: 0x14
2169 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002170 * Built-in Mic-In: 0x19
2171 * Line-In: 0x1b
2172 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002173 * SPDIF-Out: 0x1e
2174 */
2175
Takashi Iwaid6815182006-03-23 16:06:23 +01002176static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002177 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002178 .items = {
2179 { "Mic", 0x0 },
2180 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002181 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002182 },
2183};
2184
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002185#define alc880_lg_lw_modes alc880_threestack_modes
2186
Takashi Iwaid6815182006-03-23 16:06:23 +01002187static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002202 {
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2208 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002209 { } /* end */
2210};
2211
2212static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2214 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2216
Takashi Iwaid6815182006-03-23 16:06:23 +01002217 /* set capture source to mic-in */
2218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002222 /* speaker-out */
2223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* mic-in to input */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* built-in mic */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* jack sense */
2235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2236 { }
2237};
2238
2239/* toggle speaker-output according to the hp-jack state */
2240static void alc880_lg_lw_automute(struct hda_codec *codec)
2241{
2242 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002243 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002244
2245 present = snd_hda_codec_read(codec, 0x1b, 0,
2246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002247 bits = present ? HDA_AMP_MUTE : 0;
2248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2249 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002250}
2251
2252static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2253{
2254 /* Looks like the unsol event is incompatible with the standard
2255 * definition. 4bit tag is placed at 28 bit!
2256 */
2257 if ((res >> 28) == 0x01)
2258 alc880_lg_lw_automute(codec);
2259}
2260
Takashi Iwaicb53c622007-08-10 17:21:45 +02002261#ifdef CONFIG_SND_HDA_POWER_SAVE
2262static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 },
2264 { 0x0b, HDA_INPUT, 1 },
2265 { 0x0b, HDA_INPUT, 2 },
2266 { 0x0b, HDA_INPUT, 3 },
2267 { 0x0b, HDA_INPUT, 4 },
2268 { } /* end */
2269};
2270
2271static struct hda_amp_list alc880_lg_loopbacks[] = {
2272 { 0x0b, HDA_INPUT, 1 },
2273 { 0x0b, HDA_INPUT, 6 },
2274 { 0x0b, HDA_INPUT, 7 },
2275 { } /* end */
2276};
2277#endif
2278
Takashi Iwaid6815182006-03-23 16:06:23 +01002279/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002280 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002281 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002282
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283static int alc_init(struct hda_codec *codec)
2284{
2285 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002286 unsigned int i;
2287
2288 for (i = 0; i < spec->num_init_verbs; i++)
2289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002290
2291 if (spec->init_hook)
2292 spec->init_hook(codec);
2293
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 return 0;
2295}
2296
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002297static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2298{
2299 struct alc_spec *spec = codec->spec;
2300
2301 if (spec->unsol_event)
2302 spec->unsol_event(codec, res);
2303}
2304
Takashi Iwaicb53c622007-08-10 17:21:45 +02002305#ifdef CONFIG_SND_HDA_POWER_SAVE
2306static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2307{
2308 struct alc_spec *spec = codec->spec;
2309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2310}
2311#endif
2312
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313/*
2314 * Analog playback callbacks
2315 */
2316static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002318 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319{
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2322}
2323
2324static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002328 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329{
2330 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2332 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333}
2334
2335static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002337 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338{
2339 struct alc_spec *spec = codec->spec;
2340 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2341}
2342
2343/*
2344 * Digital out
2345 */
2346static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002348 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349{
2350 struct alc_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2352}
2353
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002354static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2359{
2360 struct alc_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2363}
2364
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368{
2369 struct alc_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371}
2372
2373/*
2374 * Analog capture
2375 */
Takashi Iwai63300792008-01-24 15:31:36 +01002376static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
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
Takashi Iwai63300792008-01-24 15:31:36 +01002384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 stream_tag, 0, format);
2386 return 0;
2387}
2388
Takashi Iwai63300792008-01-24 15:31:36 +01002389static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002391 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392{
2393 struct alc_spec *spec = codec->spec;
2394
Takashi Iwai63300792008-01-24 15:31:36 +01002395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002396 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 return 0;
2398}
2399
2400
2401/*
2402 */
2403static struct hda_pcm_stream alc880_pcm_analog_playback = {
2404 .substreams = 1,
2405 .channels_min = 2,
2406 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 .ops = {
2409 .open = alc880_playback_pcm_open,
2410 .prepare = alc880_playback_pcm_prepare,
2411 .cleanup = alc880_playback_pcm_cleanup
2412 },
2413};
2414
2415static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2420};
2421
2422static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427};
2428
2429static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 .channels_min = 2,
2432 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002433 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002435 .prepare = alc880_alt_capture_pcm_prepare,
2436 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 },
2438};
2439
2440static struct hda_pcm_stream alc880_pcm_digital_playback = {
2441 .substreams = 1,
2442 .channels_min = 2,
2443 .channels_max = 2,
2444 /* NID is set in alc_build_pcms */
2445 .ops = {
2446 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002447 .close = alc880_dig_playback_pcm_close,
2448 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 },
2450};
2451
2452static struct hda_pcm_stream alc880_pcm_digital_capture = {
2453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 /* NID is set in alc_build_pcms */
2457};
2458
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002459/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002460static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002461 .substreams = 0,
2462 .channels_min = 0,
2463 .channels_max = 0,
2464};
2465
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466static int alc_build_pcms(struct hda_codec *codec)
2467{
2468 struct alc_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470 int i;
2471
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2474
2475 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002476 if (spec->stream_analog_playback) {
2477 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2480 }
2481 if (spec->stream_analog_capture) {
2482 snd_assert(spec->adc_nids, return -EINVAL);
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2485 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486
Takashi Iwai4a471b72005-12-07 13:56:29 +01002487 if (spec->channel_mode) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2489 for (i = 0; i < spec->num_channel_mode; i++) {
2490 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2492 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 }
2494 }
2495
Takashi Iwaie08a0072006-09-07 17:52:14 +02002496 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002498 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002499 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002501 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2505 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002506 if (spec->dig_in_nid &&
2507 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2510 }
2511 }
2512
Takashi Iwaie08a0072006-09-07 17:52:14 +02002513 /* If the use of more than one ADC is requested for the current
2514 * model, configure a second analog capture-only PCM.
2515 */
2516 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002519 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002520 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002521 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002522 if (spec->alt_dac_nid) {
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2524 *spec->stream_analog_alt_playback;
2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2526 spec->alt_dac_nid;
2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2531 }
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002543 }
2544 }
2545
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 return 0;
2547}
2548
2549static void alc_free(struct hda_codec *codec)
2550{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551 struct alc_spec *spec = codec->spec;
2552 unsigned int i;
2553
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002554 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 return;
2556
2557 if (spec->kctl_alloc) {
2558 for (i = 0; i < spec->num_kctl_used; i++)
2559 kfree(spec->kctl_alloc[i].name);
2560 kfree(spec->kctl_alloc);
2561 }
2562 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563}
2564
2565/*
2566 */
2567static struct hda_codec_ops alc_patch_ops = {
2568 .build_controls = alc_build_controls,
2569 .build_pcms = alc_build_pcms,
2570 .init = alc_init,
2571 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002572 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002573#ifdef CONFIG_SND_HDA_POWER_SAVE
2574 .check_power_status = alc_check_power_status,
2575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576};
2577
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002578
2579/*
2580 * Test configuration for debugging
2581 *
2582 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2583 * enum controls.
2584 */
2585#ifdef CONFIG_SND_DEBUG
2586static hda_nid_t alc880_test_dac_nids[4] = {
2587 0x02, 0x03, 0x04, 0x05
2588};
2589
2590static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002591 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002592 .items = {
2593 { "In-1", 0x0 },
2594 { "In-2", 0x1 },
2595 { "In-3", 0x2 },
2596 { "In-4", 0x3 },
2597 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002598 { "Front", 0x5 },
2599 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002600 },
2601};
2602
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002603static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002604 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002605 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002606 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002607 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002608};
2609
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002610static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002612{
2613 static char *texts[] = {
2614 "N/A", "Line Out", "HP Out",
2615 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2616 };
2617 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2618 uinfo->count = 1;
2619 uinfo->value.enumerated.items = 8;
2620 if (uinfo->value.enumerated.item >= 8)
2621 uinfo->value.enumerated.item = 7;
2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2623 return 0;
2624}
2625
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002626static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002628{
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2631 unsigned int pin_ctl, item = 0;
2632
2633 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2634 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2635 if (pin_ctl & AC_PINCTL_OUT_EN) {
2636 if (pin_ctl & AC_PINCTL_HP_EN)
2637 item = 2;
2638 else
2639 item = 1;
2640 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2641 switch (pin_ctl & AC_PINCTL_VREFEN) {
2642 case AC_PINCTL_VREF_HIZ: item = 3; break;
2643 case AC_PINCTL_VREF_50: item = 4; break;
2644 case AC_PINCTL_VREF_GRD: item = 5; break;
2645 case AC_PINCTL_VREF_80: item = 6; break;
2646 case AC_PINCTL_VREF_100: item = 7; break;
2647 }
2648 }
2649 ucontrol->value.enumerated.item[0] = item;
2650 return 0;
2651}
2652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002653static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002655{
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2658 static unsigned int ctls[] = {
2659 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2665 };
2666 unsigned int old_ctl, new_ctl;
2667
2668 old_ctl = snd_hda_codec_read(codec, nid, 0,
2669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2670 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2671 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002672 int val;
2673 snd_hda_codec_write_cache(codec, nid, 0,
2674 AC_VERB_SET_PIN_WIDGET_CONTROL,
2675 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002676 val = ucontrol->value.enumerated.item[0] >= 3 ?
2677 HDA_AMP_MUTE : 0;
2678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2679 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002680 return 1;
2681 }
2682 return 0;
2683}
2684
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002687{
2688 static char *texts[] = {
2689 "Front", "Surround", "CLFE", "Side"
2690 };
2691 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2692 uinfo->count = 1;
2693 uinfo->value.enumerated.items = 4;
2694 if (uinfo->value.enumerated.item >= 4)
2695 uinfo->value.enumerated.item = 3;
2696 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2697 return 0;
2698}
2699
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002700static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2701 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002702{
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2705 unsigned int sel;
2706
2707 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2708 ucontrol->value.enumerated.item[0] = sel & 3;
2709 return 0;
2710}
2711
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002712static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2713 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002714{
2715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2716 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2717 unsigned int sel;
2718
2719 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2720 if (ucontrol->value.enumerated.item[0] != sel) {
2721 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002722 snd_hda_codec_write_cache(codec, nid, 0,
2723 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002724 return 1;
2725 }
2726 return 0;
2727}
2728
2729#define PIN_CTL_TEST(xname,nid) { \
2730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2731 .name = xname, \
2732 .info = alc_test_pin_ctl_info, \
2733 .get = alc_test_pin_ctl_get, \
2734 .put = alc_test_pin_ctl_put, \
2735 .private_value = nid \
2736 }
2737
2738#define PIN_SRC_TEST(xname,nid) { \
2739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2740 .name = xname, \
2741 .info = alc_test_pin_src_info, \
2742 .get = alc_test_pin_src_get, \
2743 .put = alc_test_pin_src_put, \
2744 .private_value = nid \
2745 }
2746
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002747static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002748 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002756 PIN_CTL_TEST("Front Pin Mode", 0x14),
2757 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2758 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2759 PIN_CTL_TEST("Side Pin Mode", 0x17),
2760 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2761 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2762 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2763 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2764 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2765 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2766 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2767 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2768 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2775 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002778 {
2779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2780 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002781 .info = alc_ch_mode_info,
2782 .get = alc_ch_mode_get,
2783 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002784 },
2785 { } /* end */
2786};
2787
2788static struct hda_verb alc880_test_init_verbs[] = {
2789 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002798 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002803 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002808 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002813 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002819 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002824 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002831 /* Analog input/passthru */
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002837 { }
2838};
2839#endif
2840
Linus Torvalds1da177e2005-04-16 15:20:36 -07002841/*
2842 */
2843
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002844static const char *alc880_models[ALC880_MODEL_LAST] = {
2845 [ALC880_3ST] = "3stack",
2846 [ALC880_TCL_S700] = "tcl",
2847 [ALC880_3ST_DIG] = "3stack-digout",
2848 [ALC880_CLEVO] = "clevo",
2849 [ALC880_5ST] = "5stack",
2850 [ALC880_5ST_DIG] = "5stack-digout",
2851 [ALC880_W810] = "w810",
2852 [ALC880_Z71V] = "z71v",
2853 [ALC880_6ST] = "6stack",
2854 [ALC880_6ST_DIG] = "6stack-digout",
2855 [ALC880_ASUS] = "asus",
2856 [ALC880_ASUS_W1V] = "asus-w1v",
2857 [ALC880_ASUS_DIG] = "asus-dig",
2858 [ALC880_ASUS_DIG2] = "asus-dig2",
2859 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002860 [ALC880_UNIWILL_P53] = "uniwill-p53",
2861 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002862 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002865#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002866 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002867#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002868 [ALC880_AUTO] = "auto",
2869};
2870
2871static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2890 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2891 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002893 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 {}
2942};
2943
Takashi Iwai16ded522005-06-10 19:58:24 +02002944/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002945 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002946 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002947static struct alc_config_preset alc880_presets[] = {
2948 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002953 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2955 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002956 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002957 .input_mux = &alc880_capture_source,
2958 },
2959 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002960 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002963 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 .dac_nids = alc880_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2967 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002968 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .input_mux = &alc880_capture_source,
2970 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002971 [ALC880_TCL_S700] = {
2972 .mixers = { alc880_tcl_s700_mixer },
2973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_tcl_S700_init_verbs,
2975 alc880_gpio2_init_verbs },
2976 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2977 .dac_nids = alc880_dac_nids,
2978 .hp_nid = 0x03,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
2981 .input_mux = &alc880_capture_source,
2982 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002984 .mixers = { alc880_three_stack_mixer,
2985 alc880_five_stack_mixer},
2986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2989 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002990 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2991 .channel_mode = alc880_fivestack_modes,
2992 .input_mux = &alc880_capture_source,
2993 },
2994 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002995 .mixers = { alc880_three_stack_mixer,
2996 alc880_five_stack_mixer },
2997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3000 .dac_nids = alc880_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3003 .channel_mode = alc880_fivestack_modes,
3004 .input_mux = &alc880_capture_source,
3005 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003006 [ALC880_6ST] = {
3007 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003010 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3011 .dac_nids = alc880_6st_dac_nids,
3012 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3013 .channel_mode = alc880_sixstack_modes,
3014 .input_mux = &alc880_6stack_capture_source,
3015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003018 .init_verbs = { alc880_volume_init_verbs,
3019 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003020 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3021 .dac_nids = alc880_6st_dac_nids,
3022 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003023 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3024 .channel_mode = alc880_sixstack_modes,
3025 .input_mux = &alc880_6stack_capture_source,
3026 },
3027 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003029 .init_verbs = { alc880_volume_init_verbs,
3030 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003031 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003032 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3033 .dac_nids = alc880_w810_dac_nids,
3034 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003035 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3036 .channel_mode = alc880_w810_modes,
3037 .input_mux = &alc880_capture_source,
3038 },
3039 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003041 .init_verbs = { alc880_volume_init_verbs,
3042 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003043 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3044 .dac_nids = alc880_z71v_dac_nids,
3045 .dig_out_nid = ALC880_DIGOUT_NID,
3046 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3048 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .input_mux = &alc880_capture_source,
3050 },
3051 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003053 .init_verbs = { alc880_volume_init_verbs,
3054 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3056 .dac_nids = alc880_f1734_dac_nids,
3057 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 .input_mux = &alc880_capture_source,
3061 },
3062 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003063 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003064 .init_verbs = { alc880_volume_init_verbs,
3065 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 alc880_gpio1_init_verbs },
3067 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3068 .dac_nids = alc880_asus_dac_nids,
3069 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3070 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003071 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003072 .input_mux = &alc880_capture_source,
3073 },
3074 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 .init_verbs = { alc880_volume_init_verbs,
3077 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003078 alc880_gpio1_init_verbs },
3079 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3080 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003081 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3083 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003084 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003085 .input_mux = &alc880_capture_source,
3086 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003087 [ALC880_ASUS_DIG2] = {
3088 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003091 alc880_gpio2_init_verbs }, /* use GPIO2 */
3092 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3093 .dac_nids = alc880_asus_dac_nids,
3094 .dig_out_nid = ALC880_DIGOUT_NID,
3095 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3096 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003097 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003098 .input_mux = &alc880_capture_source,
3099 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003100 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003102 .init_verbs = { alc880_volume_init_verbs,
3103 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 alc880_gpio1_init_verbs },
3105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3106 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003107 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3109 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003110 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003111 .input_mux = &alc880_capture_source,
3112 },
3113 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003114 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3118 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3121 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003122 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .input_mux = &alc880_capture_source,
3124 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003125 [ALC880_UNIWILL] = {
3126 .mixers = { alc880_uniwill_mixer },
3127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_uniwill_init_verbs },
3129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3130 .dac_nids = alc880_asus_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
3132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
3134 .need_dac_fix = 1,
3135 .input_mux = &alc880_capture_source,
3136 .unsol_event = alc880_uniwill_unsol_event,
3137 .init_hook = alc880_uniwill_automute,
3138 },
3139 [ALC880_UNIWILL_P53] = {
3140 .mixers = { alc880_uniwill_p53_mixer },
3141 .init_verbs = { alc880_volume_init_verbs,
3142 alc880_uniwill_p53_init_verbs },
3143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3144 .dac_nids = alc880_asus_dac_nids,
3145 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003146 .channel_mode = alc880_threestack_modes,
3147 .input_mux = &alc880_capture_source,
3148 .unsol_event = alc880_uniwill_p53_unsol_event,
3149 .init_hook = alc880_uniwill_p53_hp_automute,
3150 },
3151 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003152 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003153 alc880_pcbeep_mixer, },
3154 .init_verbs = { alc880_volume_init_verbs,
3155 alc880_uniwill_p53_init_verbs,
3156 alc880_beep_init_verbs },
3157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003159 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003160 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3161 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003162 .input_mux = &alc880_capture_source,
3163 .unsol_event = alc880_uniwill_p53_unsol_event,
3164 .init_hook = alc880_uniwill_p53_hp_automute,
3165 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003166 [ALC880_CLEVO] = {
3167 .mixers = { alc880_three_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_clevo_init_verbs },
3170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .hp_nid = 0x03,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003175 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003176 .input_mux = &alc880_capture_source,
3177 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003178 [ALC880_LG] = {
3179 .mixers = { alc880_lg_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_lg_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3183 .dac_nids = alc880_lg_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3186 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003187 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003188 .input_mux = &alc880_lg_capture_source,
3189 .unsol_event = alc880_lg_unsol_event,
3190 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003191#ifdef CONFIG_SND_HDA_POWER_SAVE
3192 .loopbacks = alc880_lg_loopbacks,
3193#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003194 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003195 [ALC880_LG_LW] = {
3196 .mixers = { alc880_lg_lw_mixer },
3197 .init_verbs = { alc880_volume_init_verbs,
3198 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003199 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003200 .dac_nids = alc880_dac_nids,
3201 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003202 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3203 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003204 .input_mux = &alc880_lg_lw_capture_source,
3205 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute,
3207 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003208#ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 .mixers = { alc880_test_mixer },
3211 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003212 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3213 .dac_nids = alc880_test_dac_nids,
3214 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3216 .channel_mode = alc880_test_modes,
3217 .input_mux = &alc880_test_capture_source,
3218 },
3219#endif
3220};
3221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222/*
3223 * Automatic parse of I/O pins from the BIOS configuration
3224 */
3225
3226#define NUM_CONTROL_ALLOC 32
3227#define NUM_VERB_ALLOC 32
3228
3229enum {
3230 ALC_CTL_WIDGET_VOL,
3231 ALC_CTL_WIDGET_MUTE,
3232 ALC_CTL_BIND_MUTE,
3233};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003234static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3236 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003237 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238};
3239
3240/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003241static int add_control(struct alc_spec *spec, int type, const char *name,
3242 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003244 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003245
3246 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3247 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3248
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 /* array + terminator */
3250 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3251 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 return -ENOMEM;
3253 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254 memcpy(knew, spec->kctl_alloc,
3255 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 kfree(spec->kctl_alloc);
3257 }
3258 spec->kctl_alloc = knew;
3259 spec->num_kctl_alloc = num;
3260 }
3261
3262 knew = &spec->kctl_alloc[spec->num_kctl_used];
3263 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003264 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003265 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 return -ENOMEM;
3267 knew->private_value = val;
3268 spec->num_kctl_used++;
3269 return 0;
3270}
3271
3272#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3273#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3274#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3275#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3276#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3277#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3278#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3279#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3280#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3281#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3282#define ALC880_PIN_CD_NID 0x1c
3283
3284/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003285static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3286 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287{
3288 hda_nid_t nid;
3289 int assigned[4];
3290 int i, j;
3291
3292 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003293 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294
3295 /* check the pins hardwired to audio widget */
3296 for (i = 0; i < cfg->line_outs; i++) {
3297 nid = cfg->line_out_pins[i];
3298 if (alc880_is_fixed_pin(nid)) {
3299 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003300 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003301 assigned[idx] = 1;
3302 }
3303 }
3304 /* left pins can be connect to any audio widget */
3305 for (i = 0; i < cfg->line_outs; i++) {
3306 nid = cfg->line_out_pins[i];
3307 if (alc880_is_fixed_pin(nid))
3308 continue;
3309 /* search for an empty channel */
3310 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003311 if (!assigned[j]) {
3312 spec->multiout.dac_nids[i] =
3313 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003314 assigned[j] = 1;
3315 break;
3316 }
3317 }
3318 }
3319 spec->multiout.num_dacs = cfg->line_outs;
3320 return 0;
3321}
3322
3323/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003324static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3325 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003326{
3327 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003328 static const char *chname[4] = {
3329 "Front", "Surround", NULL /*CLFE*/, "Side"
3330 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 hda_nid_t nid;
3332 int i, err;
3333
3334 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003335 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003336 continue;
3337 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3338 if (i == 2) {
3339 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3341 "Center Playback Volume",
3342 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3343 HDA_OUTPUT));
3344 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3347 "LFE Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3349 HDA_OUTPUT));
3350 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003352 err = add_control(spec, ALC_CTL_BIND_MUTE,
3353 "Center Playback Switch",
3354 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3355 HDA_INPUT));
3356 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003358 err = add_control(spec, ALC_CTL_BIND_MUTE,
3359 "LFE Playback Switch",
3360 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3361 HDA_INPUT));
3362 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003363 return err;
3364 } else {
3365 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 return err;
3371 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003372 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3374 HDA_INPUT));
3375 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 return err;
3377 }
3378 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 return 0;
3380}
3381
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003382/* add playback controls for speaker and HP outputs */
3383static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3384 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385{
3386 hda_nid_t nid;
3387 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003388 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003390 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391 return 0;
3392
3393 if (alc880_is_fixed_pin(pin)) {
3394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003395 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003396 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003397 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003398 else
3399 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400 /* control HP volume/switch on the output mixer amp */
3401 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003402 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3404 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3405 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003407 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3409 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3410 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411 return err;
3412 } else if (alc880_is_multi_pin(pin)) {
3413 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003414 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003415 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003416 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3417 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 return err;
3420 }
3421 return 0;
3422}
3423
3424/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003425static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3426 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003427 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003428{
3429 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003430 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431
3432 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3434 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3435 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 return err;
3437 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003438 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3440 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003441 return err;
3442 return 0;
3443}
3444
3445/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003446static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3447 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003450 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451
3452 for (i = 0; i < AUTO_PIN_LAST; i++) {
3453 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003454 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003455 err = new_analog_input(spec, cfg->input_pins[i],
3456 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003457 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 if (err < 0)
3459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003460 imux->items[imux->num_items].label =
3461 auto_pin_cfg_labels[i];
3462 imux->items[imux->num_items].index =
3463 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464 imux->num_items++;
3465 }
3466 }
3467 return 0;
3468}
3469
Kailang Yangdf694da2005-12-05 19:42:22 +01003470static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3471 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003472 int dac_idx)
3473{
3474 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type);
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003479 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec;
3482 int idx = alc880_multi_pin_idx(nid);
3483 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3484 AC_VERB_SET_CONNECT_SEL,
3485 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3486 }
3487}
3488
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003489static int get_pin_type(int line_out_type)
3490{
3491 if (line_out_type == AUTO_PIN_HP_OUT)
3492 return PIN_HP;
3493 else
3494 return PIN_OUT;
3495}
3496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497static void alc880_auto_init_multi_out(struct hda_codec *codec)
3498{
3499 struct alc_spec *spec = codec->spec;
3500 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003501
3502 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 for (i = 0; i < spec->autocfg.line_outs; i++) {
3504 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003505 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3506 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003507 }
3508}
3509
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003510static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003511{
3512 struct alc_spec *spec = codec->spec;
3513 hda_nid_t pin;
3514
Takashi Iwai82bc9552006-03-21 11:24:42 +01003515 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003516 if (pin) /* connect to front */
3517 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003518 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 if (pin) /* connect to front */
3520 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3521}
3522
3523static void alc880_auto_init_analog_input(struct hda_codec *codec)
3524{
3525 struct alc_spec *spec = codec->spec;
3526 int i;
3527
3528 for (i = 0; i < AUTO_PIN_LAST; i++) {
3529 hda_nid_t nid = spec->autocfg.input_pins[i];
3530 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003531 snd_hda_codec_write(codec, nid, 0,
3532 AC_VERB_SET_PIN_WIDGET_CONTROL,
3533 i <= AUTO_PIN_FRONT_MIC ?
3534 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003535 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003536 snd_hda_codec_write(codec, nid, 0,
3537 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 AMP_OUT_MUTE);
3539 }
3540 }
3541}
3542
3543/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003544/* return 1 if successful, 0 if the proper config is not found,
3545 * or a negative error code
3546 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003547static int alc880_parse_auto_config(struct hda_codec *codec)
3548{
3549 struct alc_spec *spec = codec->spec;
3550 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003551 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3554 alc880_ignore);
3555 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003558 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3561 if (err < 0)
3562 return err;
3563 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3564 if (err < 0)
3565 return err;
3566 err = alc880_auto_create_extra_out(spec,
3567 spec->autocfg.speaker_pins[0],
3568 "Speaker");
3569 if (err < 0)
3570 return err;
3571 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3572 "Headphone");
3573 if (err < 0)
3574 return err;
3575 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3576 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 return err;
3578
3579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3580
3581 if (spec->autocfg.dig_out_pin)
3582 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3583 if (spec->autocfg.dig_in_pin)
3584 spec->dig_in_nid = ALC880_DIGIN_NID;
3585
3586 if (spec->kctl_alloc)
3587 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3588
3589 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3590
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003591 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592 spec->input_mux = &spec->private_imux;
3593
3594 return 1;
3595}
3596
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003597/* additional initialization for auto-configuration model */
3598static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003601 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603}
3604
3605/*
3606 * OK, here we have finally the patch for ALC880
3607 */
3608
Linus Torvalds1da177e2005-04-16 15:20:36 -07003609static int patch_alc880(struct hda_codec *codec)
3610{
3611 struct alc_spec *spec;
3612 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003613 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003616 if (spec == NULL)
3617 return -ENOMEM;
3618
3619 codec->spec = spec;
3620
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003621 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3622 alc880_models,
3623 alc880_cfg_tbl);
3624 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003625 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3626 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628 }
3629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630 if (board_config == ALC880_AUTO) {
3631 /* automatic parse from the BIOS config */
3632 err = alc880_parse_auto_config(codec);
3633 if (err < 0) {
3634 alc_free(codec);
3635 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003636 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637 printk(KERN_INFO
3638 "hda_codec: Cannot set up configuration "
3639 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640 board_config = ALC880_3ST;
3641 }
3642 }
3643
Kailang Yangdf694da2005-12-05 19:42:22 +01003644 if (board_config != ALC880_AUTO)
3645 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646
3647 spec->stream_name_analog = "ALC880 Analog";
3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003651
3652 spec->stream_name_digital = "ALC880 Digital";
3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3654 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003656 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003658 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003659 /* get type */
3660 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003661 if (wcap != AC_WID_AUD_IN) {
3662 spec->adc_nids = alc880_adc_nids_alt;
3663 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 spec->mixers[spec->num_mixers] =
3665 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666 spec->num_mixers++;
3667 } else {
3668 spec->adc_nids = alc880_adc_nids;
3669 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3670 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3671 spec->num_mixers++;
3672 }
3673 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674
Takashi Iwai2134ea42008-01-10 16:53:55 +01003675 spec->vmaster_nid = 0x0c;
3676
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003678 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003679 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003680#ifdef CONFIG_SND_HDA_POWER_SAVE
3681 if (!spec->loopback.amplist)
3682 spec->loopback.amplist = alc880_loopbacks;
3683#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684
3685 return 0;
3686}
3687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689/*
3690 * ALC260 support
3691 */
3692
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003693static hda_nid_t alc260_dac_nids[1] = {
3694 /* front */
3695 0x02,
3696};
3697
3698static hda_nid_t alc260_adc_nids[1] = {
3699 /* ADC0 */
3700 0x04,
3701};
3702
Kailang Yangdf694da2005-12-05 19:42:22 +01003703static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003704 /* ADC1 */
3705 0x05,
3706};
3707
Kailang Yangdf694da2005-12-05 19:42:22 +01003708static hda_nid_t alc260_hp_adc_nids[2] = {
3709 /* ADC1, 0 */
3710 0x05, 0x04
3711};
3712
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003713/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3714 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3715 */
3716static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003717 /* ADC0, ADC1 */
3718 0x04, 0x05
3719};
3720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721#define ALC260_DIGOUT_NID 0x03
3722#define ALC260_DIGIN_NID 0x06
3723
3724static struct hda_input_mux alc260_capture_source = {
3725 .num_items = 4,
3726 .items = {
3727 { "Mic", 0x0 },
3728 { "Front Mic", 0x1 },
3729 { "Line", 0x2 },
3730 { "CD", 0x4 },
3731 },
3732};
3733
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003734/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003735 * headphone jack and the internal CD lines since these are the only pins at
3736 * which audio can appear. For flexibility, also allow the option of
3737 * recording the mixer output on the second ADC (ADC0 doesn't have a
3738 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003739 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003740static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3741 {
3742 .num_items = 3,
3743 .items = {
3744 { "Mic/Line", 0x0 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x2 },
3747 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003748 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003749 {
3750 .num_items = 4,
3751 .items = {
3752 { "Mic/Line", 0x0 },
3753 { "CD", 0x4 },
3754 { "Headphone", 0x2 },
3755 { "Mixer", 0x5 },
3756 },
3757 },
3758
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003759};
3760
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003761/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3762 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003763 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003764static struct hda_input_mux alc260_acer_capture_sources[2] = {
3765 {
3766 .num_items = 4,
3767 .items = {
3768 { "Mic", 0x0 },
3769 { "Line", 0x2 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x5 },
3772 },
3773 },
3774 {
3775 .num_items = 5,
3776 .items = {
3777 { "Mic", 0x0 },
3778 { "Line", 0x2 },
3779 { "CD", 0x4 },
3780 { "Headphone", 0x6 },
3781 { "Mixer", 0x5 },
3782 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003783 },
3784};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003785/*
3786 * This is just place-holder, so there's something for alc_build_pcms to look
3787 * at when it calculates the maximum number of channels. ALC260 has no mixer
3788 * element which allows changing the channel mode, so the verb list is
3789 * never used.
3790 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003791static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792 { 2, NULL },
3793};
3794
Kailang Yangdf694da2005-12-05 19:42:22 +01003795
3796/* Mixer combinations
3797 *
3798 * basic: base_output + input + pc_beep + capture
3799 * HP: base_output + input + capture_alt
3800 * HP_3013: hp_3013 + input + capture
3801 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003802 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003803 */
3804
3805static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003806 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003807 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3812 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003813};
Kailang Yangdf694da2005-12-05 19:42:22 +01003814
3815static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003824 { } /* end */
3825};
3826
Kailang Yangdf694da2005-12-05 19:42:22 +01003827static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3830 { } /* end */
3831};
3832
Takashi Iwaibec15c32008-01-28 18:16:30 +01003833/* update HP, line and mono out pins according to the master switch */
3834static void alc260_hp_master_update(struct hda_codec *codec,
3835 hda_nid_t hp, hda_nid_t line,
3836 hda_nid_t mono)
3837{
3838 struct alc_spec *spec = codec->spec;
3839 unsigned int val = spec->master_sw ? PIN_HP : 0;
3840 /* change HP and line-out pins */
3841 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3842 val);
3843 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3844 val);
3845 /* mono (speaker) depending on the HP jack sense */
3846 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3847 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3848 val);
3849}
3850
3851static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3852 struct snd_ctl_elem_value *ucontrol)
3853{
3854 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3855 struct alc_spec *spec = codec->spec;
3856 *ucontrol->value.integer.value = spec->master_sw;
3857 return 0;
3858}
3859
3860static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3861 struct snd_ctl_elem_value *ucontrol)
3862{
3863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3864 struct alc_spec *spec = codec->spec;
3865 int val = !!*ucontrol->value.integer.value;
3866 hda_nid_t hp, line, mono;
3867
3868 if (val == spec->master_sw)
3869 return 0;
3870 spec->master_sw = val;
3871 hp = (kcontrol->private_value >> 16) & 0xff;
3872 line = (kcontrol->private_value >> 8) & 0xff;
3873 mono = kcontrol->private_value & 0xff;
3874 alc260_hp_master_update(codec, hp, line, mono);
3875 return 1;
3876}
3877
3878static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3879 {
3880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3881 .name = "Master Playback Switch",
3882 .info = snd_ctl_boolean_mono_info,
3883 .get = alc260_hp_master_sw_get,
3884 .put = alc260_hp_master_sw_put,
3885 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3886 },
3887 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3888 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3890 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3891 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3894 { } /* end */
3895};
3896
3897static struct hda_verb alc260_hp_unsol_verbs[] = {
3898 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3899 {},
3900};
3901
3902static void alc260_hp_automute(struct hda_codec *codec)
3903{
3904 struct alc_spec *spec = codec->spec;
3905 unsigned int present;
3906
3907 present = snd_hda_codec_read(codec, 0x10, 0,
3908 AC_VERB_GET_PIN_SENSE, 0);
3909 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3910 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3911}
3912
3913static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3914{
3915 if ((res >> 26) == ALC880_HP_EVENT)
3916 alc260_hp_automute(codec);
3917}
3918
Kailang Yangdf694da2005-12-05 19:42:22 +01003919static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003920 {
3921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3922 .name = "Master Playback Switch",
3923 .info = snd_ctl_boolean_mono_info,
3924 .get = alc260_hp_master_sw_get,
3925 .put = alc260_hp_master_sw_put,
3926 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3927 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003928 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3929 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3931 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003934 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3935 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003936 { } /* end */
3937};
3938
Takashi Iwaibec15c32008-01-28 18:16:30 +01003939static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3941 {},
3942};
3943
3944static void alc260_hp_3013_automute(struct hda_codec *codec)
3945{
3946 struct alc_spec *spec = codec->spec;
3947 unsigned int present;
3948
3949 present = snd_hda_codec_read(codec, 0x15, 0,
3950 AC_VERB_GET_PIN_SENSE, 0);
3951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3952 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3953}
3954
3955static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3956 unsigned int res)
3957{
3958 if ((res >> 26) == ALC880_HP_EVENT)
3959 alc260_hp_3013_automute(codec);
3960}
3961
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003962/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3963 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3964 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003965static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003967 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003968 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003969 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3970 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3971 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3972 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003973 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003974 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3975 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3976 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003977 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003978 { } /* end */
3979};
3980
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003981/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3982 * versions of the ALC260 don't act on requests to enable mic bias from NID
3983 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3984 * datasheet doesn't mention this restriction. At this stage it's not clear
3985 * whether this behaviour is intentional or is a hardware bug in chip
3986 * revisions available in early 2006. Therefore for now allow the
3987 * "Headphone Jack Mode" control to span all choices, but if it turns out
3988 * that the lack of mic bias for this NID is intentional we could change the
3989 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3990 *
3991 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3992 * don't appear to make the mic bias available from the "line" jack, even
3993 * though the NID used for this jack (0x14) can supply it. The theory is
3994 * that perhaps Acer have included blocking capacitors between the ALC260
3995 * and the output jack. If this turns out to be the case for all such
3996 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3997 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003998 *
3999 * The C20x Tablet series have a mono internal speaker which is controlled
4000 * via the chip's Mono sum widget and pin complex, so include the necessary
4001 * controls for such models. On models without a "mono speaker" the control
4002 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004003 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004004static struct snd_kcontrol_new alc260_acer_mixer[] = {
4005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004007 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01004008 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
4009 HDA_OUTPUT),
4010 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
4011 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4015 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4016 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4017 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4018 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4019 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4020 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4021 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4022 { } /* end */
4023};
4024
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004025/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4026 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4027 */
4028static struct snd_kcontrol_new alc260_will_mixer[] = {
4029 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4030 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4032 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4033 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4034 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4035 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4036 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4037 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("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4040 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4041 { } /* end */
4042};
4043
4044/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4045 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4046 */
4047static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4048 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4049 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4051 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4052 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4053 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4054 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4055 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4056 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4057 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4058 { } /* end */
4059};
4060
Kailang Yangdf694da2005-12-05 19:42:22 +01004061/* capture mixer elements */
4062static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004063 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4064 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004065 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4066 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004067 {
4068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004069 /* The multiple "Capture Source" controls confuse alsamixer
4070 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004071 */
4072 /* .name = "Capture Source", */
4073 .name = "Input Source",
4074 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004075 .info = alc_mux_enum_info,
4076 .get = alc_mux_enum_get,
4077 .put = alc_mux_enum_put,
4078 },
4079 { } /* end */
4080};
4081
Kailang Yangdf694da2005-12-05 19:42:22 +01004082static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4083 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4084 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4085 {
4086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4087 /* The multiple "Capture Source" controls confuse alsamixer
4088 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004089 */
4090 /* .name = "Capture Source", */
4091 .name = "Input Source",
4092 .count = 1,
4093 .info = alc_mux_enum_info,
4094 .get = alc_mux_enum_get,
4095 .put = alc_mux_enum_put,
4096 },
4097 { } /* end */
4098};
4099
4100/*
4101 * initialization verbs
4102 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004103static struct hda_verb alc260_init_verbs[] = {
4104 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004105 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004106 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004107 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004108 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004109 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004110 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004111 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004115 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004116 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004117 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004118 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004119 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004120 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004121 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4122 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004123 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004124 /* set connection select to line in (default select for this ADC) */
4125 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004126 /* mute capture amp left and right */
4127 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4128 /* set connection select to line in (default select for this ADC) */
4129 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004130 /* set vol=0 Line-Out mixer amp left and right */
4131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4132 /* unmute pin widget amp left and right (no gain on this amp) */
4133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4134 /* set vol=0 HP mixer amp left and right */
4135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4136 /* unmute pin widget amp left and right (no gain on this amp) */
4137 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4138 /* set vol=0 Mono mixer amp left and right */
4139 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4140 /* unmute pin widget amp left and right (no gain on this amp) */
4141 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4142 /* unmute LINE-2 out pin */
4143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4145 * Line In 2 = 0x03
4146 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004147 /* mute analog inputs */
4148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004153 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004154 /* mute Front out path */
4155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4157 /* mute Headphone out path */
4158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4160 /* mute Mono out path */
4161 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004163 { }
4164};
4165
Takashi Iwai474167d2006-05-17 17:17:43 +02004166#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004167static struct hda_verb alc260_hp_init_verbs[] = {
4168 /* Headphone and output */
4169 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4170 /* mono output */
4171 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4172 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4173 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4174 /* Mic2 (front panel) pin widget for input and vref at 80% */
4175 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4176 /* Line In pin widget for input */
4177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4178 /* Line-2 pin widget for output */
4179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4180 /* CD pin widget for input */
4181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4182 /* unmute amp left and right */
4183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4184 /* set connection select to line in (default select for this ADC) */
4185 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4186 /* unmute Line-Out mixer amp left and right (volume = 0) */
4187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4188 /* mute pin widget amp left and right (no gain on this amp) */
4189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4190 /* unmute HP mixer amp left and right (volume = 0) */
4191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4192 /* mute pin widget amp left and right (no gain on this amp) */
4193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004194 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4195 * Line In 2 = 0x03
4196 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004197 /* mute analog inputs */
4198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004203 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4204 /* Unmute Front out path */
4205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4207 /* Unmute Headphone out path */
4208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4210 /* Unmute Mono out path */
4211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4213 { }
4214};
Takashi Iwai474167d2006-05-17 17:17:43 +02004215#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004216
4217static struct hda_verb alc260_hp_3013_init_verbs[] = {
4218 /* Line out and output */
4219 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4220 /* mono output */
4221 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4222 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4223 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4224 /* Mic2 (front panel) pin widget for input and vref at 80% */
4225 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4226 /* Line In pin widget for input */
4227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4228 /* Headphone pin widget for output */
4229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4230 /* CD pin widget for input */
4231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4232 /* unmute amp left and right */
4233 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4234 /* set connection select to line in (default select for this ADC) */
4235 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4236 /* unmute Line-Out mixer amp left and right (volume = 0) */
4237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4238 /* mute pin widget amp left and right (no gain on this amp) */
4239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4240 /* unmute HP mixer amp left and right (volume = 0) */
4241 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4242 /* mute pin widget amp left and right (no gain on this amp) */
4243 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4245 * Line In 2 = 0x03
4246 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004247 /* mute analog inputs */
4248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004253 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4254 /* Unmute Front out path */
4255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4257 /* Unmute Headphone out path */
4258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4260 /* Unmute Mono out path */
4261 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4262 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4263 { }
4264};
4265
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004266/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004267 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4268 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004269 */
4270static struct hda_verb alc260_fujitsu_init_verbs[] = {
4271 /* Disable all GPIOs */
4272 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4273 /* Internal speaker is connected to headphone pin */
4274 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4275 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004277 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4278 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4279 /* Ensure all other unused pins are disabled and muted. */
4280 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004282 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004283 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004284 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004285 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004288
Jonathan Woithef7ace402006-02-28 11:46:14 +01004289 /* Disable digital (SPDIF) pins */
4290 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4291 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004292
Jonathan Woithef7ace402006-02-28 11:46:14 +01004293 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4294 * when acting as an output.
4295 */
4296 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4297
4298 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4305 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4306 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4307 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004308
Jonathan Woithef7ace402006-02-28 11:46:14 +01004309 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4310 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4311 /* Unmute Line1 pin widget output buffer since it starts as an output.
4312 * If the pin mode is changed by the user the pin mode control will
4313 * take care of enabling the pin's input/output buffers as needed.
4314 * Therefore there's no need to enable the input buffer at this
4315 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004316 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004318 /* Unmute input buffer of pin widget used for Line-in (no equiv
4319 * mixer ctrl)
4320 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004321 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004322
Jonathan Woithef7ace402006-02-28 11:46:14 +01004323 /* Mute capture amp left and right */
4324 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4325 /* Set ADC connection select to match default mixer setting - line
4326 * in (on mic1 pin)
4327 */
4328 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004329
Jonathan Woithef7ace402006-02-28 11:46:14 +01004330 /* Do the same for the second ADC: mute capture input amp and
4331 * set ADC connection to line in (on mic1 pin)
4332 */
4333 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4334 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004335
Jonathan Woithef7ace402006-02-28 11:46:14 +01004336 /* Mute all inputs to mixer widget (even unconnected ones) */
4337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004345
4346 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004347};
4348
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004349/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4350 * similar laptops (adapted from Fujitsu init verbs).
4351 */
4352static struct hda_verb alc260_acer_init_verbs[] = {
4353 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4354 * the headphone jack. Turn this on and rely on the standard mute
4355 * methods whenever the user wants to turn these outputs off.
4356 */
4357 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4358 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4359 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4360 /* Internal speaker/Headphone jack is connected to Line-out pin */
4361 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4362 /* Internal microphone/Mic jack is connected to Mic1 pin */
4363 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4364 /* Line In jack is connected to Line1 pin */
4365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004366 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4367 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004368 /* Ensure all other unused pins are disabled and muted. */
4369 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4370 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004371 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4372 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4375 /* Disable digital (SPDIF) pins */
4376 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4377 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4378
4379 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4380 * bus when acting as outputs.
4381 */
4382 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4383 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4384
4385 /* Start with output sum widgets muted and their output gains at min */
4386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4392 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4393 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4395
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004396 /* Unmute Line-out pin widget amp left and right
4397 * (no equiv mixer ctrl)
4398 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004400 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4401 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004402 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4403 * inputs. If the pin mode is changed by the user the pin mode control
4404 * will take care of enabling the pin's input/output buffers as needed.
4405 * Therefore there's no need to enable the input buffer at this
4406 * stage.
4407 */
4408 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4409 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4410
4411 /* Mute capture amp left and right */
4412 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4413 /* Set ADC connection select to match default mixer setting - mic
4414 * (on mic1 pin)
4415 */
4416 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4417
4418 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004419 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004420 */
4421 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004422 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004423
4424 /* Mute all inputs to mixer widget (even unconnected ones) */
4425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4433
4434 { }
4435};
4436
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004437static struct hda_verb alc260_will_verbs[] = {
4438 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4439 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4440 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4441 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4442 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4443 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4444 {}
4445};
4446
4447static struct hda_verb alc260_replacer_672v_verbs[] = {
4448 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4449 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4450 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4451
4452 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4453 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4454 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4455
4456 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4457 {}
4458};
4459
4460/* toggle speaker-output according to the hp-jack state */
4461static void alc260_replacer_672v_automute(struct hda_codec *codec)
4462{
4463 unsigned int present;
4464
4465 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4466 present = snd_hda_codec_read(codec, 0x0f, 0,
4467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4468 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004469 snd_hda_codec_write_cache(codec, 0x01, 0,
4470 AC_VERB_SET_GPIO_DATA, 1);
4471 snd_hda_codec_write_cache(codec, 0x0f, 0,
4472 AC_VERB_SET_PIN_WIDGET_CONTROL,
4473 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004474 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004475 snd_hda_codec_write_cache(codec, 0x01, 0,
4476 AC_VERB_SET_GPIO_DATA, 0);
4477 snd_hda_codec_write_cache(codec, 0x0f, 0,
4478 AC_VERB_SET_PIN_WIDGET_CONTROL,
4479 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004480 }
4481}
4482
4483static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4484 unsigned int res)
4485{
4486 if ((res >> 26) == ALC880_HP_EVENT)
4487 alc260_replacer_672v_automute(codec);
4488}
4489
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004490/* Test configuration for debugging, modelled after the ALC880 test
4491 * configuration.
4492 */
4493#ifdef CONFIG_SND_DEBUG
4494static hda_nid_t alc260_test_dac_nids[1] = {
4495 0x02,
4496};
4497static hda_nid_t alc260_test_adc_nids[2] = {
4498 0x04, 0x05,
4499};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004500/* For testing the ALC260, each input MUX needs its own definition since
4501 * the signal assignments are different. This assumes that the first ADC
4502 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004503 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004504static struct hda_input_mux alc260_test_capture_sources[2] = {
4505 {
4506 .num_items = 7,
4507 .items = {
4508 { "MIC1 pin", 0x0 },
4509 { "MIC2 pin", 0x1 },
4510 { "LINE1 pin", 0x2 },
4511 { "LINE2 pin", 0x3 },
4512 { "CD pin", 0x4 },
4513 { "LINE-OUT pin", 0x5 },
4514 { "HP-OUT pin", 0x6 },
4515 },
4516 },
4517 {
4518 .num_items = 8,
4519 .items = {
4520 { "MIC1 pin", 0x0 },
4521 { "MIC2 pin", 0x1 },
4522 { "LINE1 pin", 0x2 },
4523 { "LINE2 pin", 0x3 },
4524 { "CD pin", 0x4 },
4525 { "Mixer", 0x5 },
4526 { "LINE-OUT pin", 0x6 },
4527 { "HP-OUT pin", 0x7 },
4528 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004529 },
4530};
4531static struct snd_kcontrol_new alc260_test_mixer[] = {
4532 /* Output driver widgets */
4533 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4534 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4535 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4536 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4537 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4538 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4539
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004540 /* Modes for retasking pin widgets
4541 * Note: the ALC260 doesn't seem to act on requests to enable mic
4542 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4543 * mention this restriction. At this stage it's not clear whether
4544 * this behaviour is intentional or is a hardware bug in chip
4545 * revisions available at least up until early 2006. Therefore for
4546 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4547 * choices, but if it turns out that the lack of mic bias for these
4548 * NIDs is intentional we could change their modes from
4549 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4550 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004551 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4552 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4553 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4554 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4555 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4556 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4557
4558 /* Loopback mixer controls */
4559 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4560 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4561 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4562 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4563 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4564 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4565 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4566 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4567 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4568 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4569 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4570 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4571 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4572 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4573 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4574 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004575
4576 /* Controls for GPIO pins, assuming they are configured as outputs */
4577 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4578 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4579 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4580 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4581
Jonathan Woithe92621f12006-02-28 11:47:47 +01004582 /* Switches to allow the digital IO pins to be enabled. The datasheet
4583 * is ambigious as to which NID is which; testing on laptops which
4584 * make this output available should provide clarification.
4585 */
4586 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4587 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4588
Jonathan Woithef8225f62008-01-08 12:16:54 +01004589 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4590 * this output to turn on an external amplifier.
4591 */
4592 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4593 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4594
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004595 { } /* end */
4596};
4597static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004598 /* Enable all GPIOs as outputs with an initial value of 0 */
4599 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4600 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4601 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4602
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004603 /* Enable retasking pins as output, initially without power amp */
4604 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4605 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4608 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4609 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4610
Jonathan Woithe92621f12006-02-28 11:47:47 +01004611 /* Disable digital (SPDIF) pins initially, but users can enable
4612 * them via a mixer switch. In the case of SPDIF-out, this initverb
4613 * payload also sets the generation to 0, output to be in "consumer"
4614 * PCM format, copyright asserted, no pre-emphasis and no validity
4615 * control.
4616 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004617 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4618 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4619
Jonathan Woithef7ace402006-02-28 11:46:14 +01004620 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004621 * OUT1 sum bus when acting as an output.
4622 */
4623 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4624 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4625 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4626 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4627
4628 /* Start with output sum widgets muted and their output gains at min */
4629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4635 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4636 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4638
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004639 /* Unmute retasking pin widget output buffers since the default
4640 * state appears to be output. As the pin mode is changed by the
4641 * user the pin mode control will take care of enabling the pin's
4642 * input/output buffers as needed.
4643 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004644 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4648 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4649 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4650 /* Also unmute the mono-out pin widget */
4651 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4652
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004653 /* Mute capture amp left and right */
4654 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004655 /* Set ADC connection select to match default mixer setting (mic1
4656 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004657 */
4658 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4659
4660 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004661 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004662 */
4663 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4664 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4665
4666 /* Mute all inputs to mixer widget (even unconnected ones) */
4667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4675
4676 { }
4677};
4678#endif
4679
Takashi Iwai63300792008-01-24 15:31:36 +01004680#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4681#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004682
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004683#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4684#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4685
Kailang Yangdf694da2005-12-05 19:42:22 +01004686/*
4687 * for BIOS auto-configuration
4688 */
4689
4690static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4691 const char *pfx)
4692{
4693 hda_nid_t nid_vol;
4694 unsigned long vol_val, sw_val;
4695 char name[32];
4696 int err;
4697
4698 if (nid >= 0x0f && nid < 0x11) {
4699 nid_vol = nid - 0x7;
4700 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4701 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4702 } else if (nid == 0x11) {
4703 nid_vol = nid - 0x7;
4704 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4705 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4706 } else if (nid >= 0x12 && nid <= 0x15) {
4707 nid_vol = 0x08;
4708 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4709 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4710 } else
4711 return 0; /* N/A */
4712
4713 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004714 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4715 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004716 return err;
4717 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004718 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4719 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004720 return err;
4721 return 1;
4722}
4723
4724/* add playback controls from the parsed DAC table */
4725static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4726 const struct auto_pin_cfg *cfg)
4727{
4728 hda_nid_t nid;
4729 int err;
4730
4731 spec->multiout.num_dacs = 1;
4732 spec->multiout.dac_nids = spec->private_dac_nids;
4733 spec->multiout.dac_nids[0] = 0x02;
4734
4735 nid = cfg->line_out_pins[0];
4736 if (nid) {
4737 err = alc260_add_playback_controls(spec, nid, "Front");
4738 if (err < 0)
4739 return err;
4740 }
4741
Takashi Iwai82bc9552006-03-21 11:24:42 +01004742 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004743 if (nid) {
4744 err = alc260_add_playback_controls(spec, nid, "Speaker");
4745 if (err < 0)
4746 return err;
4747 }
4748
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004749 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004750 if (nid) {
4751 err = alc260_add_playback_controls(spec, nid, "Headphone");
4752 if (err < 0)
4753 return err;
4754 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004755 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004756}
4757
4758/* create playback/capture controls for input pins */
4759static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4760 const struct auto_pin_cfg *cfg)
4761{
Kailang Yangdf694da2005-12-05 19:42:22 +01004762 struct hda_input_mux *imux = &spec->private_imux;
4763 int i, err, idx;
4764
4765 for (i = 0; i < AUTO_PIN_LAST; i++) {
4766 if (cfg->input_pins[i] >= 0x12) {
4767 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004768 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004769 auto_pin_cfg_labels[i], idx,
4770 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004771 if (err < 0)
4772 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004773 imux->items[imux->num_items].label =
4774 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004775 imux->items[imux->num_items].index = idx;
4776 imux->num_items++;
4777 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004778 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004779 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004780 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 auto_pin_cfg_labels[i], idx,
4782 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004783 if (err < 0)
4784 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 imux->items[imux->num_items].label =
4786 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 imux->items[imux->num_items].index = idx;
4788 imux->num_items++;
4789 }
4790 }
4791 return 0;
4792}
4793
4794static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4795 hda_nid_t nid, int pin_type,
4796 int sel_idx)
4797{
4798 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 pin_type);
4801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4802 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004803 /* need the manual connection? */
4804 if (nid >= 0x12) {
4805 int idx = nid - 0x12;
4806 snd_hda_codec_write(codec, idx + 0x0b, 0,
4807 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 }
4809}
4810
4811static void alc260_auto_init_multi_out(struct hda_codec *codec)
4812{
4813 struct alc_spec *spec = codec->spec;
4814 hda_nid_t nid;
4815
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004816 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004818 if (nid) {
4819 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4820 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4821 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004822
Takashi Iwai82bc9552006-03-21 11:24:42 +01004823 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 if (nid)
4825 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4826
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004827 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004828 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004829 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004830}
Kailang Yangdf694da2005-12-05 19:42:22 +01004831
4832#define ALC260_PIN_CD_NID 0x16
4833static void alc260_auto_init_analog_input(struct hda_codec *codec)
4834{
4835 struct alc_spec *spec = codec->spec;
4836 int i;
4837
4838 for (i = 0; i < AUTO_PIN_LAST; i++) {
4839 hda_nid_t nid = spec->autocfg.input_pins[i];
4840 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004841 snd_hda_codec_write(codec, nid, 0,
4842 AC_VERB_SET_PIN_WIDGET_CONTROL,
4843 i <= AUTO_PIN_FRONT_MIC ?
4844 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004845 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004846 snd_hda_codec_write(codec, nid, 0,
4847 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004848 AMP_OUT_MUTE);
4849 }
4850 }
4851}
4852
4853/*
4854 * generic initialization of ADC, input mixers and output mixers
4855 */
4856static struct hda_verb alc260_volume_init_verbs[] = {
4857 /*
4858 * Unmute ADC0-1 and set the default input to mic-in
4859 */
4860 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4862 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4863 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4864
4865 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4866 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004867 * Note: PASD motherboards uses the Line In 2 as the input for
4868 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004869 */
4870 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004871 /* mute analog inputs */
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004877
4878 /*
4879 * Set up output mixers (0x08 - 0x0a)
4880 */
4881 /* set vol=0 to output mixers */
4882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4884 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4885 /* set up input amps for analog loopback */
4886 /* Amp Indices: DAC = 0, mixer = 1 */
4887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4891 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4892 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4893
4894 { }
4895};
4896
4897static int alc260_parse_auto_config(struct hda_codec *codec)
4898{
4899 struct alc_spec *spec = codec->spec;
4900 unsigned int wcap;
4901 int err;
4902 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4903
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004904 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4905 alc260_ignore);
4906 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004907 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004908 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4909 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004911 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004912 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004913 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4914 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004915 return err;
4916
4917 spec->multiout.max_channels = 2;
4918
4919 if (spec->autocfg.dig_out_pin)
4920 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4921 if (spec->kctl_alloc)
4922 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4923
4924 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4925
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004926 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004927 spec->input_mux = &spec->private_imux;
4928
4929 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004930 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004931 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4932 if (wcap != AC_WID_AUD_IN) {
4933 spec->adc_nids = alc260_adc_nids_alt;
4934 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4935 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004936 } else {
4937 spec->adc_nids = alc260_adc_nids;
4938 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4939 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004940 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004941 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004942
4943 return 1;
4944}
4945
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004946/* additional initialization for auto-configuration model */
4947static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004948{
Kailang Yangdf694da2005-12-05 19:42:22 +01004949 alc260_auto_init_multi_out(codec);
4950 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004951}
4952
Takashi Iwaicb53c622007-08-10 17:21:45 +02004953#ifdef CONFIG_SND_HDA_POWER_SAVE
4954static struct hda_amp_list alc260_loopbacks[] = {
4955 { 0x07, HDA_INPUT, 0 },
4956 { 0x07, HDA_INPUT, 1 },
4957 { 0x07, HDA_INPUT, 2 },
4958 { 0x07, HDA_INPUT, 3 },
4959 { 0x07, HDA_INPUT, 4 },
4960 { } /* end */
4961};
4962#endif
4963
Kailang Yangdf694da2005-12-05 19:42:22 +01004964/*
4965 * ALC260 configurations
4966 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004967static const char *alc260_models[ALC260_MODEL_LAST] = {
4968 [ALC260_BASIC] = "basic",
4969 [ALC260_HP] = "hp",
4970 [ALC260_HP_3013] = "hp-3013",
4971 [ALC260_FUJITSU_S702X] = "fujitsu",
4972 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004973 [ALC260_WILL] = "will",
4974 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004975#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004976 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004977#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004978 [ALC260_AUTO] = "auto",
4979};
4980
4981static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004982 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004983 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004984 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004985 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004986 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4987 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4988 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4989 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4990 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4991 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4992 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4993 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4994 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4995 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4996 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4997 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004998 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004999 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005000 {}
5001};
5002
Kailang Yangdf694da2005-12-05 19:42:22 +01005003static struct alc_config_preset alc260_presets[] = {
5004 [ALC260_BASIC] = {
5005 .mixers = { alc260_base_output_mixer,
5006 alc260_input_mixer,
5007 alc260_pc_beep_mixer,
5008 alc260_capture_mixer },
5009 .init_verbs = { alc260_init_verbs },
5010 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5011 .dac_nids = alc260_dac_nids,
5012 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5013 .adc_nids = alc260_adc_nids,
5014 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5015 .channel_mode = alc260_modes,
5016 .input_mux = &alc260_capture_source,
5017 },
5018 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005019 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005020 alc260_input_mixer,
5021 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005022 .init_verbs = { alc260_init_verbs,
5023 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005024 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5025 .dac_nids = alc260_dac_nids,
5026 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5027 .adc_nids = alc260_hp_adc_nids,
5028 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5029 .channel_mode = alc260_modes,
5030 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005031 .unsol_event = alc260_hp_unsol_event,
5032 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005033 },
5034 [ALC260_HP_3013] = {
5035 .mixers = { alc260_hp_3013_mixer,
5036 alc260_input_mixer,
5037 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005038 .init_verbs = { alc260_hp_3013_init_verbs,
5039 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005040 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5041 .dac_nids = alc260_dac_nids,
5042 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5043 .adc_nids = alc260_hp_adc_nids,
5044 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5045 .channel_mode = alc260_modes,
5046 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005047 .unsol_event = alc260_hp_3013_unsol_event,
5048 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 },
5050 [ALC260_FUJITSU_S702X] = {
5051 .mixers = { alc260_fujitsu_mixer,
5052 alc260_capture_mixer },
5053 .init_verbs = { alc260_fujitsu_init_verbs },
5054 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5055 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005056 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5057 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005058 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5059 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005060 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5061 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005062 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005063 [ALC260_ACER] = {
5064 .mixers = { alc260_acer_mixer,
5065 alc260_capture_mixer },
5066 .init_verbs = { alc260_acer_init_verbs },
5067 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5068 .dac_nids = alc260_dac_nids,
5069 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5070 .adc_nids = alc260_dual_adc_nids,
5071 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5072 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005073 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5074 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005075 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005076 [ALC260_WILL] = {
5077 .mixers = { alc260_will_mixer,
5078 alc260_capture_mixer },
5079 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5080 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5081 .dac_nids = alc260_dac_nids,
5082 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5083 .adc_nids = alc260_adc_nids,
5084 .dig_out_nid = ALC260_DIGOUT_NID,
5085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5086 .channel_mode = alc260_modes,
5087 .input_mux = &alc260_capture_source,
5088 },
5089 [ALC260_REPLACER_672V] = {
5090 .mixers = { alc260_replacer_672v_mixer,
5091 alc260_capture_mixer },
5092 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5093 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5094 .dac_nids = alc260_dac_nids,
5095 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5096 .adc_nids = alc260_adc_nids,
5097 .dig_out_nid = ALC260_DIGOUT_NID,
5098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5099 .channel_mode = alc260_modes,
5100 .input_mux = &alc260_capture_source,
5101 .unsol_event = alc260_replacer_672v_unsol_event,
5102 .init_hook = alc260_replacer_672v_automute,
5103 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005104#ifdef CONFIG_SND_DEBUG
5105 [ALC260_TEST] = {
5106 .mixers = { alc260_test_mixer,
5107 alc260_capture_mixer },
5108 .init_verbs = { alc260_test_init_verbs },
5109 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5110 .dac_nids = alc260_test_dac_nids,
5111 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5112 .adc_nids = alc260_test_adc_nids,
5113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5114 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005115 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5116 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005117 },
5118#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005119};
5120
Linus Torvalds1da177e2005-04-16 15:20:36 -07005121static int patch_alc260(struct hda_codec *codec)
5122{
5123 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005124 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005125
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005126 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005127 if (spec == NULL)
5128 return -ENOMEM;
5129
5130 codec->spec = spec;
5131
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005132 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5133 alc260_models,
5134 alc260_cfg_tbl);
5135 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005136 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5137 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005138 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005139 }
5140
Kailang Yangdf694da2005-12-05 19:42:22 +01005141 if (board_config == ALC260_AUTO) {
5142 /* automatic parse from the BIOS config */
5143 err = alc260_parse_auto_config(codec);
5144 if (err < 0) {
5145 alc_free(codec);
5146 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005147 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005148 printk(KERN_INFO
5149 "hda_codec: Cannot set up configuration "
5150 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005151 board_config = ALC260_BASIC;
5152 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005153 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005154
Kailang Yangdf694da2005-12-05 19:42:22 +01005155 if (board_config != ALC260_AUTO)
5156 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005157
5158 spec->stream_name_analog = "ALC260 Analog";
5159 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5160 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5161
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005162 spec->stream_name_digital = "ALC260 Digital";
5163 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5164 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5165
Takashi Iwai2134ea42008-01-10 16:53:55 +01005166 spec->vmaster_nid = 0x08;
5167
Linus Torvalds1da177e2005-04-16 15:20:36 -07005168 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005170 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005171#ifdef CONFIG_SND_HDA_POWER_SAVE
5172 if (!spec->loopback.amplist)
5173 spec->loopback.amplist = alc260_loopbacks;
5174#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005175
5176 return 0;
5177}
5178
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005179
Linus Torvalds1da177e2005-04-16 15:20:36 -07005180/*
5181 * ALC882 support
5182 *
5183 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5184 * configuration. Each pin widget can choose any input DACs and a mixer.
5185 * Each ADC is connected from a mixer of all inputs. This makes possible
5186 * 6-channel independent captures.
5187 *
5188 * In addition, an independent DAC for the multi-playback (not used in this
5189 * driver yet).
5190 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005191#define ALC882_DIGOUT_NID 0x06
5192#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005193
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005194static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005195 { 8, NULL }
5196};
5197
5198static hda_nid_t alc882_dac_nids[4] = {
5199 /* front, rear, clfe, rear_surr */
5200 0x02, 0x03, 0x04, 0x05
5201};
5202
Kailang Yangdf694da2005-12-05 19:42:22 +01005203/* identical with ALC880 */
5204#define alc882_adc_nids alc880_adc_nids
5205#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005206
5207/* input MUX */
5208/* FIXME: should be a matrix-type input source selection */
5209
5210static struct hda_input_mux alc882_capture_source = {
5211 .num_items = 4,
5212 .items = {
5213 { "Mic", 0x0 },
5214 { "Front Mic", 0x1 },
5215 { "Line", 0x2 },
5216 { "CD", 0x4 },
5217 },
5218};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005219#define alc882_mux_enum_info alc_mux_enum_info
5220#define alc882_mux_enum_get alc_mux_enum_get
5221
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005222static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5223 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005224{
5225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5226 struct alc_spec *spec = codec->spec;
5227 const struct hda_input_mux *imux = spec->input_mux;
5228 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5229 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
Takashi Iwaicced83b2008-02-22 18:45:30 +01005230 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005231 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5232 unsigned int i, idx;
5233
Takashi Iwaicced83b2008-02-22 18:45:30 +01005234 if (spec->num_adc_nids < 3)
5235 nid = capture_mixers[adc_idx + 1];
5236 else
5237 nid = capture_mixers[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005238 idx = ucontrol->value.enumerated.item[0];
5239 if (idx >= imux->num_items)
5240 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005241 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005242 return 0;
5243 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005244 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5245 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005246 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005247 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005248 }
5249 *cur_val = idx;
5250 return 1;
5251}
5252
Kailang Yangdf694da2005-12-05 19:42:22 +01005253/*
Kailang Yang272a5272007-05-14 11:00:38 +02005254 * 2ch mode
5255 */
5256static struct hda_verb alc882_3ST_ch2_init[] = {
5257 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5258 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5259 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5260 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5261 { } /* end */
5262};
5263
5264/*
5265 * 6ch mode
5266 */
5267static struct hda_verb alc882_3ST_ch6_init[] = {
5268 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5269 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5270 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5271 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5272 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5273 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5274 { } /* end */
5275};
5276
5277static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5278 { 2, alc882_3ST_ch2_init },
5279 { 6, alc882_3ST_ch6_init },
5280};
5281
5282/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005283 * 6ch mode
5284 */
5285static struct hda_verb alc882_sixstack_ch6_init[] = {
5286 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5287 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5288 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5289 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5290 { } /* end */
5291};
5292
5293/*
5294 * 8ch mode
5295 */
5296static struct hda_verb alc882_sixstack_ch8_init[] = {
5297 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5298 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5299 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5300 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5301 { } /* end */
5302};
5303
5304static struct hda_channel_mode alc882_sixstack_modes[2] = {
5305 { 6, alc882_sixstack_ch6_init },
5306 { 8, alc882_sixstack_ch8_init },
5307};
5308
Takashi Iwai87350ad2007-08-16 18:19:38 +02005309/*
5310 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5311 */
5312
5313/*
5314 * 2ch mode
5315 */
5316static struct hda_verb alc885_mbp_ch2_init[] = {
5317 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5318 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5319 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5320 { } /* end */
5321};
5322
5323/*
5324 * 6ch mode
5325 */
5326static struct hda_verb alc885_mbp_ch6_init[] = {
5327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5329 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5330 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5331 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5332 { } /* end */
5333};
5334
5335static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5336 { 2, alc885_mbp_ch2_init },
5337 { 6, alc885_mbp_ch6_init },
5338};
5339
5340
Linus Torvalds1da177e2005-04-16 15:20:36 -07005341/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5342 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5343 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005344static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005348 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005349 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5350 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005351 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5352 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005353 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005354 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5363 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5366 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5367 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005368 { } /* end */
5369};
5370
Takashi Iwai87350ad2007-08-16 18:19:38 +02005371static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5373 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5374 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5375 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5377 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5379 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005380 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005381 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5382 { } /* end */
5383};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005384static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5386 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5394 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5395 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5396 { } /* end */
5397};
5398
Kailang Yang272a5272007-05-14 11:00:38 +02005399static struct snd_kcontrol_new alc882_targa_mixer[] = {
5400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5406 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005410 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5411 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005412 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005413 { } /* end */
5414};
5415
5416/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5417 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5418 */
5419static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5421 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5423 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5424 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5425 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5426 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5427 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5428 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5429 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, 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 { } /* end */
5434};
5435
Takashi Iwai914759b2007-09-06 14:52:04 +02005436static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5447 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5448 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5449 { } /* end */
5450};
5451
Kailang Yangdf694da2005-12-05 19:42:22 +01005452static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5453 {
5454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5455 .name = "Channel Mode",
5456 .info = alc_ch_mode_info,
5457 .get = alc_ch_mode_get,
5458 .put = alc_ch_mode_put,
5459 },
5460 { } /* end */
5461};
5462
Linus Torvalds1da177e2005-04-16 15:20:36 -07005463static struct hda_verb alc882_init_verbs[] = {
5464 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005468 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005472 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005476 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005481 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005485 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005489 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005492 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005493 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005494 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005496 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005497 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5500 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5503 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5506 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005512
5513 /* FIXME: use matrix-type input source selection */
5514 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5515 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005525 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5530 /* ADC1: mute amp left and right */
5531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005532 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005533 /* ADC2: mute amp left and right */
5534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005536 /* ADC3: mute amp left and right */
5537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005538 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005539
5540 { }
5541};
5542
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005543static struct hda_verb alc882_eapd_verbs[] = {
5544 /* change to EAPD mode */
5545 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005546 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005547 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005548};
5549
Tobin Davis9102cd12006-12-15 10:02:12 +01005550/* Mac Pro test */
5551static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5555 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5557 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5558 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5559 { } /* end */
5560};
5561
5562static struct hda_verb alc882_macpro_init_verbs[] = {
5563 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5567 /* Front Pin: output 0 (0x0c) */
5568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5570 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5571 /* Front Mic pin: input vref at 80% */
5572 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5574 /* Speaker: output */
5575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5577 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5578 /* Headphone output (output 0 - 0x0c) */
5579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5581 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5582
5583 /* FIXME: use matrix-type input source selection */
5584 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5585 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5590 /* Input mixer2 */
5591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5595 /* Input mixer3 */
5596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5600 /* ADC1: mute amp left and right */
5601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5602 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5603 /* ADC2: mute amp left and right */
5604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5605 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5606 /* ADC3: mute amp left and right */
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5608 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5609
5610 { }
5611};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005612
Takashi Iwai87350ad2007-08-16 18:19:38 +02005613/* Macbook Pro rev3 */
5614static struct hda_verb alc885_mbp3_init_verbs[] = {
5615 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5619 /* Rear mixer */
5620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5623 /* Front Pin: output 0 (0x0c) */
5624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5626 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5627 /* HP Pin: output 0 (0x0d) */
5628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5630 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5632 /* Mic (rear) pin: input vref at 80% */
5633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5635 /* Front Mic pin: input vref at 80% */
5636 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5638 /* Line In pin: use output 1 when in LineOut mode */
5639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5641 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5642
5643 /* FIXME: use matrix-type input source selection */
5644 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5645 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5650 /* Input mixer2 */
5651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5655 /* Input mixer3 */
5656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5660 /* ADC1: mute amp left and right */
5661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5663 /* ADC2: mute amp left and right */
5664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5666 /* ADC3: mute amp left and right */
5667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5669
5670 { }
5671};
5672
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005673/* iMac 24 mixer. */
5674static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5675 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5676 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5677 { } /* end */
5678};
5679
5680/* iMac 24 init verbs. */
5681static struct hda_verb alc885_imac24_init_verbs[] = {
5682 /* Internal speakers: output 0 (0x0c) */
5683 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5684 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5685 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5686 /* Internal speakers: output 0 (0x0c) */
5687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5690 /* Headphone: output 0 (0x0c) */
5691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5693 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5695 /* Front Mic: input vref at 80% */
5696 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5698 { }
5699};
5700
5701/* Toggle speaker-output according to the hp-jack state */
5702static void alc885_imac24_automute(struct hda_codec *codec)
5703{
5704 unsigned int present;
5705
5706 present = snd_hda_codec_read(codec, 0x14, 0,
5707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005708 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5709 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5710 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5711 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005712}
5713
5714/* Processes unsolicited events. */
5715static void alc885_imac24_unsol_event(struct hda_codec *codec,
5716 unsigned int res)
5717{
5718 /* Headphone insertion or removal. */
5719 if ((res >> 26) == ALC880_HP_EVENT)
5720 alc885_imac24_automute(codec);
5721}
5722
Takashi Iwai87350ad2007-08-16 18:19:38 +02005723static void alc885_mbp3_automute(struct hda_codec *codec)
5724{
5725 unsigned int present;
5726
5727 present = snd_hda_codec_read(codec, 0x15, 0,
5728 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5729 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5730 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5731 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5732 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5733
5734}
5735static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5736 unsigned int res)
5737{
5738 /* Headphone insertion or removal. */
5739 if ((res >> 26) == ALC880_HP_EVENT)
5740 alc885_mbp3_automute(codec);
5741}
5742
5743
Kailang Yang272a5272007-05-14 11:00:38 +02005744static struct hda_verb alc882_targa_verbs[] = {
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5747
5748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5750
5751 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5752 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5753 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5754
5755 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5756 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5757 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5758 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5759 { } /* end */
5760};
5761
5762/* toggle speaker-output according to the hp-jack state */
5763static void alc882_targa_automute(struct hda_codec *codec)
5764{
5765 unsigned int present;
5766
5767 present = snd_hda_codec_read(codec, 0x14, 0,
5768 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005769 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5770 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005771 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5772 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005773}
5774
5775static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5776{
5777 /* Looks like the unsol event is incompatible with the standard
5778 * definition. 4bit tag is placed at 26 bit!
5779 */
5780 if (((res >> 26) == ALC880_HP_EVENT)) {
5781 alc882_targa_automute(codec);
5782 }
5783}
5784
5785static struct hda_verb alc882_asus_a7j_verbs[] = {
5786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5788
5789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5792
5793 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5795 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5796
5797 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5798 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5799 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5800 { } /* end */
5801};
5802
Takashi Iwai914759b2007-09-06 14:52:04 +02005803static struct hda_verb alc882_asus_a7m_verbs[] = {
5804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5806
5807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5810
5811 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5813 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5814
5815 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5816 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5817 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5818 { } /* end */
5819};
5820
Tobin Davis9102cd12006-12-15 10:02:12 +01005821static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5822{
5823 unsigned int gpiostate, gpiomask, gpiodir;
5824
5825 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5826 AC_VERB_GET_GPIO_DATA, 0);
5827
5828 if (!muted)
5829 gpiostate |= (1 << pin);
5830 else
5831 gpiostate &= ~(1 << pin);
5832
5833 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5834 AC_VERB_GET_GPIO_MASK, 0);
5835 gpiomask |= (1 << pin);
5836
5837 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5838 AC_VERB_GET_GPIO_DIRECTION, 0);
5839 gpiodir |= (1 << pin);
5840
5841
5842 snd_hda_codec_write(codec, codec->afg, 0,
5843 AC_VERB_SET_GPIO_MASK, gpiomask);
5844 snd_hda_codec_write(codec, codec->afg, 0,
5845 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5846
5847 msleep(1);
5848
5849 snd_hda_codec_write(codec, codec->afg, 0,
5850 AC_VERB_SET_GPIO_DATA, gpiostate);
5851}
5852
Takashi Iwai7debbe52007-08-16 15:01:03 +02005853/* set up GPIO at initialization */
5854static void alc885_macpro_init_hook(struct hda_codec *codec)
5855{
5856 alc882_gpio_mute(codec, 0, 0);
5857 alc882_gpio_mute(codec, 1, 0);
5858}
5859
5860/* set up GPIO and update auto-muting at initialization */
5861static void alc885_imac24_init_hook(struct hda_codec *codec)
5862{
5863 alc885_macpro_init_hook(codec);
5864 alc885_imac24_automute(codec);
5865}
5866
Kailang Yangdf694da2005-12-05 19:42:22 +01005867/*
5868 * generic initialization of ADC, input mixers and output mixers
5869 */
5870static struct hda_verb alc882_auto_init_verbs[] = {
5871 /*
5872 * Unmute ADC0-2 and set the default input to mic-in
5873 */
5874 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5876 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5878 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5880
Takashi Iwaicb53c622007-08-10 17:21:45 +02005881 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005882 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005883 * Note: PASD motherboards uses the Line In 2 as the input for
5884 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005885 */
5886 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005892
5893 /*
5894 * Set up output mixers (0x0c - 0x0f)
5895 */
5896 /* set vol=0 to output mixers */
5897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 /* set up input amps for analog loopback */
5902 /* Amp Indices: DAC = 0, mixer = 1 */
5903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5909 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5910 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5911 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5912 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5913
5914 /* FIXME: use matrix-type input source selection */
5915 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5916 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5921 /* Input mixer2 */
5922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5926 /* Input mixer3 */
5927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5931
5932 { }
5933};
5934
5935/* capture mixer elements */
5936static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5937 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5938 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5940 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5941 {
5942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5943 /* The multiple "Capture Source" controls confuse alsamixer
5944 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005945 */
5946 /* .name = "Capture Source", */
5947 .name = "Input Source",
5948 .count = 2,
5949 .info = alc882_mux_enum_info,
5950 .get = alc882_mux_enum_get,
5951 .put = alc882_mux_enum_put,
5952 },
5953 { } /* end */
5954};
5955
5956static struct snd_kcontrol_new alc882_capture_mixer[] = {
5957 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5958 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5959 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5962 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5963 {
5964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5965 /* The multiple "Capture Source" controls confuse alsamixer
5966 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 */
5968 /* .name = "Capture Source", */
5969 .name = "Input Source",
5970 .count = 3,
5971 .info = alc882_mux_enum_info,
5972 .get = alc882_mux_enum_get,
5973 .put = alc882_mux_enum_put,
5974 },
5975 { } /* end */
5976};
5977
Takashi Iwaicb53c622007-08-10 17:21:45 +02005978#ifdef CONFIG_SND_HDA_POWER_SAVE
5979#define alc882_loopbacks alc880_loopbacks
5980#endif
5981
Kailang Yangdf694da2005-12-05 19:42:22 +01005982/* pcm configuration: identiacal with ALC880 */
5983#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5984#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5985#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5986#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5987
5988/*
5989 * configuration and preset
5990 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005991static const char *alc882_models[ALC882_MODEL_LAST] = {
5992 [ALC882_3ST_DIG] = "3stack-dig",
5993 [ALC882_6ST_DIG] = "6stack-dig",
5994 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005995 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005996 [ALC882_TARGA] = "targa",
5997 [ALC882_ASUS_A7J] = "asus-a7j",
5998 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005999 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006000 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006001 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006002 [ALC882_AUTO] = "auto",
6003};
6004
6005static struct snd_pci_quirk alc882_cfg_tbl[] = {
6006 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006007 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006008 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006009 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006010 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006011 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006012 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006013 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006014 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006015 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6016 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6017 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006018 {}
6019};
6020
6021static struct alc_config_preset alc882_presets[] = {
6022 [ALC882_3ST_DIG] = {
6023 .mixers = { alc882_base_mixer },
6024 .init_verbs = { alc882_init_verbs },
6025 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6026 .dac_nids = alc882_dac_nids,
6027 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006028 .dig_in_nid = ALC882_DIGIN_NID,
6029 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6030 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006031 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006032 .input_mux = &alc882_capture_source,
6033 },
6034 [ALC882_6ST_DIG] = {
6035 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6036 .init_verbs = { alc882_init_verbs },
6037 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6038 .dac_nids = alc882_dac_nids,
6039 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006040 .dig_in_nid = ALC882_DIGIN_NID,
6041 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6042 .channel_mode = alc882_sixstack_modes,
6043 .input_mux = &alc882_capture_source,
6044 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006045 [ALC882_ARIMA] = {
6046 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6047 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6048 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6049 .dac_nids = alc882_dac_nids,
6050 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6051 .channel_mode = alc882_sixstack_modes,
6052 .input_mux = &alc882_capture_source,
6053 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006054 [ALC882_W2JC] = {
6055 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6056 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6057 alc880_gpio1_init_verbs },
6058 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6059 .dac_nids = alc882_dac_nids,
6060 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6061 .channel_mode = alc880_threestack_modes,
6062 .need_dac_fix = 1,
6063 .input_mux = &alc882_capture_source,
6064 .dig_out_nid = ALC882_DIGOUT_NID,
6065 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006066 [ALC885_MBP3] = {
6067 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6068 .init_verbs = { alc885_mbp3_init_verbs,
6069 alc880_gpio1_init_verbs },
6070 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6071 .dac_nids = alc882_dac_nids,
6072 .channel_mode = alc885_mbp_6ch_modes,
6073 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6074 .input_mux = &alc882_capture_source,
6075 .dig_out_nid = ALC882_DIGOUT_NID,
6076 .dig_in_nid = ALC882_DIGIN_NID,
6077 .unsol_event = alc885_mbp3_unsol_event,
6078 .init_hook = alc885_mbp3_automute,
6079 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006080 [ALC885_MACPRO] = {
6081 .mixers = { alc882_macpro_mixer },
6082 .init_verbs = { alc882_macpro_init_verbs },
6083 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6084 .dac_nids = alc882_dac_nids,
6085 .dig_out_nid = ALC882_DIGOUT_NID,
6086 .dig_in_nid = ALC882_DIGIN_NID,
6087 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6088 .channel_mode = alc882_ch_modes,
6089 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006090 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006091 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006092 [ALC885_IMAC24] = {
6093 .mixers = { alc885_imac24_mixer },
6094 .init_verbs = { alc885_imac24_init_verbs },
6095 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6096 .dac_nids = alc882_dac_nids,
6097 .dig_out_nid = ALC882_DIGOUT_NID,
6098 .dig_in_nid = ALC882_DIGIN_NID,
6099 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6100 .channel_mode = alc882_ch_modes,
6101 .input_mux = &alc882_capture_source,
6102 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006103 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006104 },
Kailang Yang272a5272007-05-14 11:00:38 +02006105 [ALC882_TARGA] = {
6106 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6107 alc882_capture_mixer },
6108 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6109 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6110 .dac_nids = alc882_dac_nids,
6111 .dig_out_nid = ALC882_DIGOUT_NID,
6112 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6113 .adc_nids = alc882_adc_nids,
6114 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6115 .channel_mode = alc882_3ST_6ch_modes,
6116 .need_dac_fix = 1,
6117 .input_mux = &alc882_capture_source,
6118 .unsol_event = alc882_targa_unsol_event,
6119 .init_hook = alc882_targa_automute,
6120 },
6121 [ALC882_ASUS_A7J] = {
6122 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6123 alc882_capture_mixer },
6124 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6125 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6126 .dac_nids = alc882_dac_nids,
6127 .dig_out_nid = ALC882_DIGOUT_NID,
6128 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6129 .adc_nids = alc882_adc_nids,
6130 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6131 .channel_mode = alc882_3ST_6ch_modes,
6132 .need_dac_fix = 1,
6133 .input_mux = &alc882_capture_source,
6134 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006135 [ALC882_ASUS_A7M] = {
6136 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6137 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6138 alc880_gpio1_init_verbs,
6139 alc882_asus_a7m_verbs },
6140 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6141 .dac_nids = alc882_dac_nids,
6142 .dig_out_nid = ALC882_DIGOUT_NID,
6143 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6144 .channel_mode = alc880_threestack_modes,
6145 .need_dac_fix = 1,
6146 .input_mux = &alc882_capture_source,
6147 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006148};
6149
6150
6151/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006152 * Pin config fixes
6153 */
6154enum {
6155 PINFIX_ABIT_AW9D_MAX
6156};
6157
6158static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6159 { 0x15, 0x01080104 }, /* side */
6160 { 0x16, 0x01011012 }, /* rear */
6161 { 0x17, 0x01016011 }, /* clfe */
6162 { }
6163};
6164
6165static const struct alc_pincfg *alc882_pin_fixes[] = {
6166 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6167};
6168
6169static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6170 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6171 {}
6172};
6173
6174/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006175 * BIOS auto configuration
6176 */
6177static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6178 hda_nid_t nid, int pin_type,
6179 int dac_idx)
6180{
6181 /* set as output */
6182 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006183 int idx;
6184
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6186 idx = 4;
6187 else
6188 idx = spec->multiout.dac_nids[dac_idx] - 2;
6189
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6191 pin_type);
6192 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6193 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6195
6196}
6197
6198static void alc882_auto_init_multi_out(struct hda_codec *codec)
6199{
6200 struct alc_spec *spec = codec->spec;
6201 int i;
6202
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006203 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006205 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006206 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006207 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006208 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006209 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006210 }
6211}
6212
6213static void alc882_auto_init_hp_out(struct hda_codec *codec)
6214{
6215 struct alc_spec *spec = codec->spec;
6216 hda_nid_t pin;
6217
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006218 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006220 /* use dac 0 */
6221 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006222}
6223
6224#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6225#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6226
6227static void alc882_auto_init_analog_input(struct hda_codec *codec)
6228{
6229 struct alc_spec *spec = codec->spec;
6230 int i;
6231
6232 for (i = 0; i < AUTO_PIN_LAST; i++) {
6233 hda_nid_t nid = spec->autocfg.input_pins[i];
6234 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006235 snd_hda_codec_write(codec, nid, 0,
6236 AC_VERB_SET_PIN_WIDGET_CONTROL,
6237 i <= AUTO_PIN_FRONT_MIC ?
6238 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006239 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006240 snd_hda_codec_write(codec, nid, 0,
6241 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006242 AMP_OUT_MUTE);
6243 }
6244 }
6245}
6246
Takashi Iwai776e1842007-08-29 15:07:11 +02006247/* add mic boosts if needed */
6248static int alc_auto_add_mic_boost(struct hda_codec *codec)
6249{
6250 struct alc_spec *spec = codec->spec;
6251 int err;
6252 hda_nid_t nid;
6253
6254 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006255 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6257 "Mic Boost",
6258 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6259 if (err < 0)
6260 return err;
6261 }
6262 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006263 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006264 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6265 "Front Mic Boost",
6266 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6267 if (err < 0)
6268 return err;
6269 }
6270 return 0;
6271}
6272
Kailang Yangdf694da2005-12-05 19:42:22 +01006273/* almost identical with ALC880 parser... */
6274static int alc882_parse_auto_config(struct hda_codec *codec)
6275{
6276 struct alc_spec *spec = codec->spec;
6277 int err = alc880_parse_auto_config(codec);
6278
6279 if (err < 0)
6280 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006281 else if (!err)
6282 return 0; /* no config found */
6283
6284 err = alc_auto_add_mic_boost(codec);
6285 if (err < 0)
6286 return err;
6287
6288 /* hack - override the init verbs */
6289 spec->init_verbs[0] = alc882_auto_init_verbs;
6290
6291 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006292}
6293
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006294/* additional initialization for auto-configuration model */
6295static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006296{
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 alc882_auto_init_multi_out(codec);
6298 alc882_auto_init_hp_out(codec);
6299 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006300}
6301
Linus Torvalds1da177e2005-04-16 15:20:36 -07006302static int patch_alc882(struct hda_codec *codec)
6303{
6304 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006306
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006307 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006308 if (spec == NULL)
6309 return -ENOMEM;
6310
Linus Torvalds1da177e2005-04-16 15:20:36 -07006311 codec->spec = spec;
6312
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006313 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6314 alc882_models,
6315 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006316
Kailang Yangdf694da2005-12-05 19:42:22 +01006317 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006318 /* Pick up systems that don't supply PCI SSID */
6319 switch (codec->subsystem_id) {
6320 case 0x106b0c00: /* Mac Pro */
6321 board_config = ALC885_MACPRO;
6322 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006323 case 0x106b1000: /* iMac 24 */
6324 board_config = ALC885_IMAC24;
6325 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006326 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006327 case 0x106b2c00: /* Macbook Pro rev3 */
6328 board_config = ALC885_MBP3;
6329 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006330 default:
6331 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6332 "trying auto-probe from BIOS...\n");
6333 board_config = ALC882_AUTO;
6334 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006336
Takashi Iwaif95474e2007-07-10 00:47:43 +02006337 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6338
Kailang Yangdf694da2005-12-05 19:42:22 +01006339 if (board_config == ALC882_AUTO) {
6340 /* automatic parse from the BIOS config */
6341 err = alc882_parse_auto_config(codec);
6342 if (err < 0) {
6343 alc_free(codec);
6344 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006345 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006346 printk(KERN_INFO
6347 "hda_codec: Cannot set up configuration "
6348 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006349 board_config = ALC882_3ST_DIG;
6350 }
6351 }
6352
6353 if (board_config != ALC882_AUTO)
6354 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006355
6356 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006357 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6358 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006359 /* FIXME: setup DAC5 */
6360 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6361 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006362
6363 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006364 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6365 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006366
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006367 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006368 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006369 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006370 /* get type */
6371 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006372 if (wcap != AC_WID_AUD_IN) {
6373 spec->adc_nids = alc882_adc_nids_alt;
6374 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006375 spec->mixers[spec->num_mixers] =
6376 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006377 spec->num_mixers++;
6378 } else {
6379 spec->adc_nids = alc882_adc_nids;
6380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6381 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6382 spec->num_mixers++;
6383 }
6384 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006385
Takashi Iwai2134ea42008-01-10 16:53:55 +01006386 spec->vmaster_nid = 0x0c;
6387
Linus Torvalds1da177e2005-04-16 15:20:36 -07006388 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006390 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006391#ifdef CONFIG_SND_HDA_POWER_SAVE
6392 if (!spec->loopback.amplist)
6393 spec->loopback.amplist = alc882_loopbacks;
6394#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006395
6396 return 0;
6397}
6398
6399/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006400 * ALC883 support
6401 *
6402 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6403 * configuration. Each pin widget can choose any input DACs and a mixer.
6404 * Each ADC is connected from a mixer of all inputs. This makes possible
6405 * 6-channel independent captures.
6406 *
6407 * In addition, an independent DAC for the multi-playback (not used in this
6408 * driver yet).
6409 */
6410#define ALC883_DIGOUT_NID 0x06
6411#define ALC883_DIGIN_NID 0x0a
6412
6413static hda_nid_t alc883_dac_nids[4] = {
6414 /* front, rear, clfe, rear_surr */
6415 0x02, 0x04, 0x03, 0x05
6416};
6417
6418static hda_nid_t alc883_adc_nids[2] = {
6419 /* ADC1-2 */
6420 0x08, 0x09,
6421};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006422
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006423/* input MUX */
6424/* FIXME: should be a matrix-type input source selection */
6425
6426static struct hda_input_mux alc883_capture_source = {
6427 .num_items = 4,
6428 .items = {
6429 { "Mic", 0x0 },
6430 { "Front Mic", 0x1 },
6431 { "Line", 0x2 },
6432 { "CD", 0x4 },
6433 },
6434};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006435
6436static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6437 .num_items = 2,
6438 .items = {
6439 { "Mic", 0x1 },
6440 { "Line", 0x2 },
6441 },
6442};
6443
Kailang Yang272a5272007-05-14 11:00:38 +02006444static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6445 .num_items = 4,
6446 .items = {
6447 { "Mic", 0x0 },
6448 { "iMic", 0x1 },
6449 { "Line", 0x2 },
6450 { "CD", 0x4 },
6451 },
6452};
6453
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006454#define alc883_mux_enum_info alc_mux_enum_info
6455#define alc883_mux_enum_get alc_mux_enum_get
6456
6457static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6458 struct snd_ctl_elem_value *ucontrol)
6459{
6460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6461 struct alc_spec *spec = codec->spec;
6462 const struct hda_input_mux *imux = spec->input_mux;
6463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai614ca922008-02-22 18:44:21 +01006464 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006465 hda_nid_t nid = capture_mixers[adc_idx];
6466 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6467 unsigned int i, idx;
6468
6469 idx = ucontrol->value.enumerated.item[0];
6470 if (idx >= imux->num_items)
6471 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006472 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006473 return 0;
6474 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006475 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6476 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006477 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006478 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006479 }
6480 *cur_val = idx;
6481 return 1;
6482}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006483
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006484/*
6485 * 2ch mode
6486 */
6487static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6488 { 2, NULL }
6489};
6490
6491/*
6492 * 2ch mode
6493 */
6494static struct hda_verb alc883_3ST_ch2_init[] = {
6495 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6496 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6497 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6498 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6499 { } /* end */
6500};
6501
6502/*
Tobin Davisb2011312007-09-17 12:45:11 +02006503 * 4ch mode
6504 */
6505static struct hda_verb alc883_3ST_ch4_init[] = {
6506 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6507 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6508 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6509 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6510 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6511 { } /* end */
6512};
6513
6514/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006515 * 6ch mode
6516 */
6517static struct hda_verb alc883_3ST_ch6_init[] = {
6518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6520 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6523 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6524 { } /* end */
6525};
6526
Tobin Davisb2011312007-09-17 12:45:11 +02006527static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006528 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006529 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006530 { 6, alc883_3ST_ch6_init },
6531};
6532
6533/*
6534 * 6ch mode
6535 */
6536static struct hda_verb alc883_sixstack_ch6_init[] = {
6537 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6538 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6539 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6540 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6541 { } /* end */
6542};
6543
6544/*
6545 * 8ch mode
6546 */
6547static struct hda_verb alc883_sixstack_ch8_init[] = {
6548 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6549 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6550 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6551 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6552 { } /* end */
6553};
6554
6555static struct hda_channel_mode alc883_sixstack_modes[2] = {
6556 { 6, alc883_sixstack_ch6_init },
6557 { 8, alc883_sixstack_ch8_init },
6558};
6559
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006560static struct hda_verb alc883_medion_eapd_verbs[] = {
6561 /* eanable EAPD on medion laptop */
6562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6563 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6564 { }
6565};
6566
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006567/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6568 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6569 */
6570
6571static struct snd_kcontrol_new alc883_base_mixer[] = {
6572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6573 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6574 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6575 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6576 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6577 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6578 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6579 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6580 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6581 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6585 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6586 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6590 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006591 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6593 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6594 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6595 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6596 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6597 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6598 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6599 {
6600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6601 /* .name = "Capture Source", */
6602 .name = "Input Source",
6603 .count = 2,
6604 .info = alc883_mux_enum_info,
6605 .get = alc883_mux_enum_get,
6606 .put = alc883_mux_enum_put,
6607 },
6608 { } /* end */
6609};
6610
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006611static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6620 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6623 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6625 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6626 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6627 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6628 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6629 {
6630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6631 /* .name = "Capture Source", */
6632 .name = "Input Source",
6633 .count = 2,
6634 .info = alc883_mux_enum_info,
6635 .get = alc883_mux_enum_get,
6636 .put = alc883_mux_enum_put,
6637 },
6638 { } /* end */
6639};
6640
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006641static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6652 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006653 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006654 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6655 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6656 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6657 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6658 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6659 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6660 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6661 {
6662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6663 /* .name = "Capture Source", */
6664 .name = "Input Source",
6665 .count = 2,
6666 .info = alc883_mux_enum_info,
6667 .get = alc883_mux_enum_get,
6668 .put = alc883_mux_enum_put,
6669 },
6670 { } /* end */
6671};
6672
6673static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6677 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6690 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006692 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6693 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6694 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6695 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6696 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6697 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6698 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6699 {
6700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6701 /* .name = "Capture Source", */
6702 .name = "Input Source",
6703 .count = 2,
6704 .info = alc883_mux_enum_info,
6705 .get = alc883_mux_enum_get,
6706 .put = alc883_mux_enum_put,
6707 },
6708 { } /* end */
6709};
6710
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006711static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006712 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6713 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6715 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6716 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6717 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6718 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6719 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6722 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006726 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6728 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006729 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6731 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6732 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6735
6736 {
6737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6738 /* .name = "Capture Source", */
6739 .name = "Input Source",
6740 .count = 1,
6741 .info = alc883_mux_enum_info,
6742 .get = alc883_mux_enum_get,
6743 .put = alc883_mux_enum_put,
6744 },
6745 { } /* end */
6746};
6747
Kailang Yangccc656c2006-10-17 12:32:26 +02006748static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6750 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6751 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6752 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6754 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6755 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6757 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6765 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6766 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6768 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6769 {
6770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6771 /* .name = "Capture Source", */
6772 .name = "Input Source",
6773 .count = 2,
6774 .info = alc883_mux_enum_info,
6775 .get = alc883_mux_enum_get,
6776 .put = alc883_mux_enum_put,
6777 },
6778 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006779};
Kailang Yangccc656c2006-10-17 12:32:26 +02006780
6781static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6782 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6784 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6790 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6792 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6793 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6794 {
6795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6796 /* .name = "Capture Source", */
6797 .name = "Input Source",
6798 .count = 2,
6799 .info = alc883_mux_enum_info,
6800 .get = alc883_mux_enum_get,
6801 .put = alc883_mux_enum_put,
6802 },
6803 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006804};
Kailang Yangccc656c2006-10-17 12:32:26 +02006805
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006806static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6817 {
6818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6819 /* .name = "Capture Source", */
6820 .name = "Input Source",
6821 .count = 1,
6822 .info = alc883_mux_enum_info,
6823 .get = alc883_mux_enum_get,
6824 .put = alc883_mux_enum_put,
6825 },
6826 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006828
Kailang Yang272a5272007-05-14 11:00:38 +02006829static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6831 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6837 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6838 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6841 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6843 {
6844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6845 /* .name = "Capture Source", */
6846 .name = "Input Source",
6847 .count = 2,
6848 .info = alc883_mux_enum_info,
6849 .get = alc883_mux_enum_get,
6850 .put = alc883_mux_enum_put,
6851 },
6852 { } /* end */
6853};
6854
6855static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6860 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6865 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6866 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6867 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6868 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6869 {
6870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6871 /* .name = "Capture Source", */
6872 .name = "Input Source",
6873 .count = 2,
6874 .info = alc883_mux_enum_info,
6875 .get = alc883_mux_enum_get,
6876 .put = alc883_mux_enum_put,
6877 },
6878 { } /* end */
6879};
6880
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006881static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6885 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6903 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6904 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6908 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6909 {
6910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6911 /* .name = "Capture Source", */
6912 .name = "Input Source",
6913 .count = 2,
6914 .info = alc883_mux_enum_info,
6915 .get = alc883_mux_enum_get,
6916 .put = alc883_mux_enum_put,
6917 },
6918 { } /* end */
6919};
6920
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006921static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6925 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6941 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6942 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6943 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6946 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6947 {
6948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6949 /* .name = "Capture Source", */
6950 .name = "Input Source",
6951 .count = 2,
6952 .info = alc883_mux_enum_info,
6953 .get = alc883_mux_enum_get,
6954 .put = alc883_mux_enum_put,
6955 },
6956 { } /* end */
6957};
6958
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006959static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6963 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6969 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6981 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6982 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6985 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6986 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6987 {
6988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6989 /* .name = "Capture Source", */
6990 .name = "Input Source",
6991 .count = 2,
6992 .info = alc883_mux_enum_info,
6993 .get = alc883_mux_enum_get,
6994 .put = alc883_mux_enum_put,
6995 },
6996 { } /* end */
6997};
6998
Tobin Davis2880a8672007-08-07 11:50:26 +02006999static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7001 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7006 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007008 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7009 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7010 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7011 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7012 {
7013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7014 /* .name = "Capture Source", */
7015 .name = "Input Source",
7016 .count = 2,
7017 .info = alc883_mux_enum_info,
7018 .get = alc883_mux_enum_get,
7019 .put = alc883_mux_enum_put,
7020 },
7021 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007022};
Tobin Davis2880a8672007-08-07 11:50:26 +02007023
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007024static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7025 {
7026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7027 .name = "Channel Mode",
7028 .info = alc_ch_mode_info,
7029 .get = alc_ch_mode_get,
7030 .put = alc_ch_mode_put,
7031 },
7032 { } /* end */
7033};
7034
7035static struct hda_verb alc883_init_verbs[] = {
7036 /* ADC1: mute amp left and right */
7037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7038 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7039 /* ADC2: mute amp left and right */
7040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7041 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7042 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7046 /* Rear mixer */
7047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7050 /* CLFE mixer */
7051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7054 /* Side mixer */
7055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7058
Takashi Iwaicb53c622007-08-10 17:21:45 +02007059 /* mute analog input loopbacks */
7060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007065
7066 /* Front Pin: output 0 (0x0c) */
7067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7070 /* Rear Pin: output 1 (0x0d) */
7071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7074 /* CLFE Pin: output 2 (0x0e) */
7075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7078 /* Side Pin: output 3 (0x0f) */
7079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7081 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7082 /* Mic (rear) pin: input vref at 80% */
7083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7085 /* Front Mic pin: input vref at 80% */
7086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7088 /* Line In pin: input */
7089 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7091 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7095 /* CD pin widget for input */
7096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7097
7098 /* FIXME: use matrix-type input source selection */
7099 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7100 /* Input mixer2 */
7101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7105 /* Input mixer3 */
7106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7110 { }
7111};
7112
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007113/* toggle speaker-output according to the hp-jack state */
7114static void alc883_mitac_hp_automute(struct hda_codec *codec)
7115{
7116 unsigned int present;
7117
7118 present = snd_hda_codec_read(codec, 0x15, 0,
7119 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7120 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7122 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7123 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7124}
7125
7126/* auto-toggle front mic */
7127/*
7128static void alc883_mitac_mic_automute(struct hda_codec *codec)
7129{
7130 unsigned int present;
7131 unsigned char bits;
7132
7133 present = snd_hda_codec_read(codec, 0x18, 0,
7134 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7135 bits = present ? HDA_AMP_MUTE : 0;
7136 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7137}
7138*/
7139
7140static void alc883_mitac_automute(struct hda_codec *codec)
7141{
7142 alc883_mitac_hp_automute(codec);
7143 /* alc883_mitac_mic_automute(codec); */
7144}
7145
7146static void alc883_mitac_unsol_event(struct hda_codec *codec,
7147 unsigned int res)
7148{
7149 switch (res >> 26) {
7150 case ALC880_HP_EVENT:
7151 alc883_mitac_hp_automute(codec);
7152 break;
7153 case ALC880_MIC_EVENT:
7154 /* alc883_mitac_mic_automute(codec); */
7155 break;
7156 }
7157}
7158
7159static struct hda_verb alc883_mitac_verbs[] = {
7160 /* HP */
7161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7163 /* Subwoofer */
7164 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7165 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7166
7167 /* enable unsolicited event */
7168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7169 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7170
7171 { } /* end */
7172};
7173
Kailang Yangccc656c2006-10-17 12:32:26 +02007174static struct hda_verb alc883_tagra_verbs[] = {
7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7177
7178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7180
7181 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7182 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7183 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7184
7185 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007186 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7187 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7188 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007189
7190 { } /* end */
7191};
7192
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007193static struct hda_verb alc883_lenovo_101e_verbs[] = {
7194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7195 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7196 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7197 { } /* end */
7198};
7199
Kailang Yang272a5272007-05-14 11:00:38 +02007200static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7204 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7205 { } /* end */
7206};
7207
7208static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7213 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7214 { } /* end */
7215};
7216
Kailang Yang189609a2007-08-20 11:31:23 +02007217static struct hda_verb alc883_haier_w66_verbs[] = {
7218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7220
7221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7222
7223 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7225 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7227 { } /* end */
7228};
7229
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007230static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7233 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7234 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7235 { }
7236};
7237
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007238static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7240 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7241 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7242 { }
7243};
7244
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007245static struct hda_verb alc888_6st_dell_verbs[] = {
7246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7248 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7251 { }
7252};
7253
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007254static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007255 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7256 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7257 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7258 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7259 { }
7260};
7261
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007262static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007263 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7264 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7265 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7266 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7267 { }
7268};
7269
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007270static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7271 { 2, alc888_3st_hp_2ch_init },
7272 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007273};
7274
Kailang Yang272a5272007-05-14 11:00:38 +02007275/* toggle front-jack and RCA according to the hp-jack state */
7276static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7277{
7278 unsigned int present;
7279
7280 present = snd_hda_codec_read(codec, 0x1b, 0,
7281 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007282 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7283 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7284 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7285 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007286}
7287
7288/* toggle RCA according to the front-jack state */
7289static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7290{
7291 unsigned int present;
7292
7293 present = snd_hda_codec_read(codec, 0x14, 0,
7294 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007295 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7296 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007297}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007298
Kailang Yang272a5272007-05-14 11:00:38 +02007299static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7300 unsigned int res)
7301{
7302 if ((res >> 26) == ALC880_HP_EVENT)
7303 alc888_lenovo_ms7195_front_automute(codec);
7304 if ((res >> 26) == ALC880_FRONT_EVENT)
7305 alc888_lenovo_ms7195_rca_automute(codec);
7306}
7307
7308static struct hda_verb alc883_medion_md2_verbs[] = {
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311
7312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7313
7314 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7315 { } /* end */
7316};
7317
7318/* toggle speaker-output according to the hp-jack state */
7319static void alc883_medion_md2_automute(struct hda_codec *codec)
7320{
7321 unsigned int present;
7322
7323 present = snd_hda_codec_read(codec, 0x14, 0,
7324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7326 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007327}
7328
7329static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7330 unsigned int res)
7331{
7332 if ((res >> 26) == ALC880_HP_EVENT)
7333 alc883_medion_md2_automute(codec);
7334}
7335
Kailang Yangccc656c2006-10-17 12:32:26 +02007336/* toggle speaker-output according to the hp-jack state */
7337static void alc883_tagra_automute(struct hda_codec *codec)
7338{
7339 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007340 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007341
7342 present = snd_hda_codec_read(codec, 0x14, 0,
7343 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007344 bits = present ? HDA_AMP_MUTE : 0;
7345 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7346 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007347 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7348 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007349}
7350
7351static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7352{
7353 if ((res >> 26) == ALC880_HP_EVENT)
7354 alc883_tagra_automute(codec);
7355}
7356
Kailang Yang189609a2007-08-20 11:31:23 +02007357static void alc883_haier_w66_automute(struct hda_codec *codec)
7358{
7359 unsigned int present;
7360 unsigned char bits;
7361
7362 present = snd_hda_codec_read(codec, 0x1b, 0,
7363 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7364 bits = present ? 0x80 : 0;
7365 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7366 0x80, bits);
7367}
7368
7369static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7370 unsigned int res)
7371{
7372 if ((res >> 26) == ALC880_HP_EVENT)
7373 alc883_haier_w66_automute(codec);
7374}
7375
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007376static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7377{
7378 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007379 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007380
7381 present = snd_hda_codec_read(codec, 0x14, 0,
7382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007383 bits = present ? HDA_AMP_MUTE : 0;
7384 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7385 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007386}
7387
7388static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7389{
7390 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007391 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007392
7393 present = snd_hda_codec_read(codec, 0x1b, 0,
7394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007395 bits = present ? HDA_AMP_MUTE : 0;
7396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7397 HDA_AMP_MUTE, bits);
7398 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7399 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007400}
7401
7402static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7403 unsigned int res)
7404{
7405 if ((res >> 26) == ALC880_HP_EVENT)
7406 alc883_lenovo_101e_all_automute(codec);
7407 if ((res >> 26) == ALC880_FRONT_EVENT)
7408 alc883_lenovo_101e_ispeaker_automute(codec);
7409}
7410
Takashi Iwai676a9b52007-08-16 15:23:35 +02007411/* toggle speaker-output according to the hp-jack state */
7412static void alc883_acer_aspire_automute(struct hda_codec *codec)
7413{
7414 unsigned int present;
7415
7416 present = snd_hda_codec_read(codec, 0x14, 0,
7417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7418 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7420 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7422}
7423
7424static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7425 unsigned int res)
7426{
7427 if ((res >> 26) == ALC880_HP_EVENT)
7428 alc883_acer_aspire_automute(codec);
7429}
7430
Kailang Yangd1a991a2007-08-15 16:21:59 +02007431static struct hda_verb alc883_acer_eapd_verbs[] = {
7432 /* HP Pin: output 0 (0x0c) */
7433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7435 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7436 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7438 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007440 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7441 /* eanable EAPD on medion laptop */
7442 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7443 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007444 /* enable unsolicited event */
7445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007446 { }
7447};
7448
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007449static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7450{
7451 unsigned int present;
7452
7453 present = snd_hda_codec_read(codec, 0x1b, 0,
7454 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7455 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7459 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7460 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7461 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7463}
7464
7465static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7466 unsigned int res)
7467{
7468 switch (res >> 26) {
7469 case ALC880_HP_EVENT:
7470 printk("hp_event\n");
7471 alc888_6st_dell_front_automute(codec);
7472 break;
7473 }
7474}
7475
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007476/*
7477 * generic initialization of ADC, input mixers and output mixers
7478 */
7479static struct hda_verb alc883_auto_init_verbs[] = {
7480 /*
7481 * Unmute ADC0-2 and set the default input to mic-in
7482 */
7483 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7485 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487
Takashi Iwaicb53c622007-08-10 17:21:45 +02007488 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007489 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007490 * Note: PASD motherboards uses the Line In 2 as the input for
7491 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007492 */
7493 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007499
7500 /*
7501 * Set up output mixers (0x0c - 0x0f)
7502 */
7503 /* set vol=0 to output mixers */
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7508 /* set up input amps for analog loopback */
7509 /* Amp Indices: DAC = 0, mixer = 1 */
7510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7518 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7519 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7520
7521 /* FIXME: use matrix-type input source selection */
7522 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7523 /* Input mixer1 */
7524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007527 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7529 /* Input mixer2 */
7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007533 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007535
7536 { }
7537};
7538
7539/* capture mixer elements */
7540static struct snd_kcontrol_new alc883_capture_mixer[] = {
7541 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7542 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7543 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7544 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7545 {
7546 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7547 /* The multiple "Capture Source" controls confuse alsamixer
7548 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007549 */
7550 /* .name = "Capture Source", */
7551 .name = "Input Source",
7552 .count = 2,
7553 .info = alc882_mux_enum_info,
7554 .get = alc882_mux_enum_get,
7555 .put = alc882_mux_enum_put,
7556 },
7557 { } /* end */
7558};
7559
Takashi Iwaicb53c622007-08-10 17:21:45 +02007560#ifdef CONFIG_SND_HDA_POWER_SAVE
7561#define alc883_loopbacks alc880_loopbacks
7562#endif
7563
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007564/* pcm configuration: identiacal with ALC880 */
7565#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7566#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007567#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007568#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7569#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7570
7571/*
7572 * configuration and preset
7573 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007574static const char *alc883_models[ALC883_MODEL_LAST] = {
7575 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7576 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7577 [ALC883_3ST_6ch] = "3stack-6ch",
7578 [ALC883_6ST_DIG] = "6stack-dig",
7579 [ALC883_TARGA_DIG] = "targa-dig",
7580 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007581 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02007582 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007583 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007584 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007585 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007586 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007587 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7588 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007589 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007590 [ALC888_6ST_HP] = "6stack-hp",
7591 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007592 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007593 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007594 [ALC883_AUTO] = "auto",
7595};
7596
7597static struct snd_pci_quirk alc883_cfg_tbl[] = {
7598 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007599 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7600 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7601 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7602 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007603 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007604 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007605 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7606 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7607 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7608 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007609 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007610 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7611 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7612 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007613 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007614 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7615 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7621 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7622 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7625 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007627 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7628 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007629 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007630 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007631 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007632 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007633 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7634 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007635 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007636 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007637 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007638 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7640 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007641 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007642 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007643 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007644 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007645 {}
7646};
7647
7648static struct alc_config_preset alc883_presets[] = {
7649 [ALC883_3ST_2ch_DIG] = {
7650 .mixers = { alc883_3ST_2ch_mixer },
7651 .init_verbs = { alc883_init_verbs },
7652 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7653 .dac_nids = alc883_dac_nids,
7654 .dig_out_nid = ALC883_DIGOUT_NID,
7655 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7656 .adc_nids = alc883_adc_nids,
7657 .dig_in_nid = ALC883_DIGIN_NID,
7658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7659 .channel_mode = alc883_3ST_2ch_modes,
7660 .input_mux = &alc883_capture_source,
7661 },
7662 [ALC883_3ST_6ch_DIG] = {
7663 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7664 .init_verbs = { alc883_init_verbs },
7665 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7666 .dac_nids = alc883_dac_nids,
7667 .dig_out_nid = ALC883_DIGOUT_NID,
7668 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7669 .adc_nids = alc883_adc_nids,
7670 .dig_in_nid = ALC883_DIGIN_NID,
7671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7672 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007673 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007674 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007675 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007676 [ALC883_3ST_6ch] = {
7677 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7678 .init_verbs = { alc883_init_verbs },
7679 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7680 .dac_nids = alc883_dac_nids,
7681 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7682 .adc_nids = alc883_adc_nids,
7683 .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,
7694 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7695 .adc_nids = alc883_adc_nids,
7696 .dig_in_nid = ALC883_DIGIN_NID,
7697 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7698 .channel_mode = alc883_sixstack_modes,
7699 .input_mux = &alc883_capture_source,
7700 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007701 [ALC883_TARGA_DIG] = {
7702 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7703 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7704 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7705 .dac_nids = alc883_dac_nids,
7706 .dig_out_nid = ALC883_DIGOUT_NID,
7707 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7708 .adc_nids = alc883_adc_nids,
7709 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7710 .channel_mode = alc883_3ST_6ch_modes,
7711 .need_dac_fix = 1,
7712 .input_mux = &alc883_capture_source,
7713 .unsol_event = alc883_tagra_unsol_event,
7714 .init_hook = alc883_tagra_automute,
7715 },
7716 [ALC883_TARGA_2ch_DIG] = {
7717 .mixers = { alc883_tagra_2ch_mixer},
7718 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7719 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7720 .dac_nids = alc883_dac_nids,
7721 .dig_out_nid = ALC883_DIGOUT_NID,
7722 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7723 .adc_nids = alc883_adc_nids,
7724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7725 .channel_mode = alc883_3ST_2ch_modes,
7726 .input_mux = &alc883_capture_source,
7727 .unsol_event = alc883_tagra_unsol_event,
7728 .init_hook = alc883_tagra_automute,
7729 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007730 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007731 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007732 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7733 * and the headphone jack. Turn this on and rely on the
7734 * standard mute methods whenever the user wants to turn
7735 * these outputs off.
7736 */
7737 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7738 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7739 .dac_nids = alc883_dac_nids,
7740 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7741 .adc_nids = alc883_adc_nids,
7742 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7743 .channel_mode = alc883_3ST_2ch_modes,
7744 .input_mux = &alc883_capture_source,
7745 },
Tobin Davis2880a8672007-08-07 11:50:26 +02007746 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007747 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007748 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02007749 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7750 .dac_nids = alc883_dac_nids,
7751 .dig_out_nid = ALC883_DIGOUT_NID,
7752 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7753 .adc_nids = alc883_adc_nids,
7754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7755 .channel_mode = alc883_3ST_2ch_modes,
7756 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007757 .unsol_event = alc883_acer_aspire_unsol_event,
7758 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007759 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007760 [ALC883_MEDION] = {
7761 .mixers = { alc883_fivestack_mixer,
7762 alc883_chmode_mixer },
7763 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007764 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007765 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7766 .dac_nids = alc883_dac_nids,
7767 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7768 .adc_nids = alc883_adc_nids,
7769 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7770 .channel_mode = alc883_sixstack_modes,
7771 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007772 },
Kailang Yang272a5272007-05-14 11:00:38 +02007773 [ALC883_MEDION_MD2] = {
7774 .mixers = { alc883_medion_md2_mixer},
7775 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7776 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7777 .dac_nids = alc883_dac_nids,
7778 .dig_out_nid = ALC883_DIGOUT_NID,
7779 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7780 .adc_nids = alc883_adc_nids,
7781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7782 .channel_mode = alc883_3ST_2ch_modes,
7783 .input_mux = &alc883_capture_source,
7784 .unsol_event = alc883_medion_md2_unsol_event,
7785 .init_hook = alc883_medion_md2_automute,
7786 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007787 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007788 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007789 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7790 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7791 .dac_nids = alc883_dac_nids,
7792 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7793 .adc_nids = alc883_adc_nids,
7794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7795 .channel_mode = alc883_3ST_2ch_modes,
7796 .input_mux = &alc883_capture_source,
7797 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007798 [ALC883_LENOVO_101E_2ch] = {
7799 .mixers = { alc883_lenovo_101e_2ch_mixer},
7800 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7801 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7802 .dac_nids = alc883_dac_nids,
7803 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7804 .adc_nids = alc883_adc_nids,
7805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7806 .channel_mode = alc883_3ST_2ch_modes,
7807 .input_mux = &alc883_lenovo_101e_capture_source,
7808 .unsol_event = alc883_lenovo_101e_unsol_event,
7809 .init_hook = alc883_lenovo_101e_all_automute,
7810 },
Kailang Yang272a5272007-05-14 11:00:38 +02007811 [ALC883_LENOVO_NB0763] = {
7812 .mixers = { alc883_lenovo_nb0763_mixer },
7813 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7814 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7815 .dac_nids = alc883_dac_nids,
7816 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7817 .adc_nids = alc883_adc_nids,
7818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7819 .channel_mode = alc883_3ST_2ch_modes,
7820 .need_dac_fix = 1,
7821 .input_mux = &alc883_lenovo_nb0763_capture_source,
7822 .unsol_event = alc883_medion_md2_unsol_event,
7823 .init_hook = alc883_medion_md2_automute,
7824 },
7825 [ALC888_LENOVO_MS7195_DIG] = {
7826 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7827 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7828 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7829 .dac_nids = alc883_dac_nids,
7830 .dig_out_nid = ALC883_DIGOUT_NID,
7831 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7832 .adc_nids = alc883_adc_nids,
7833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7834 .channel_mode = alc883_3ST_6ch_modes,
7835 .need_dac_fix = 1,
7836 .input_mux = &alc883_capture_source,
7837 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7838 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007839 },
7840 [ALC883_HAIER_W66] = {
7841 .mixers = { alc883_tagra_2ch_mixer},
7842 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7843 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7844 .dac_nids = alc883_dac_nids,
7845 .dig_out_nid = ALC883_DIGOUT_NID,
7846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7847 .adc_nids = alc883_adc_nids,
7848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7849 .channel_mode = alc883_3ST_2ch_modes,
7850 .input_mux = &alc883_capture_source,
7851 .unsol_event = alc883_haier_w66_unsol_event,
7852 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007853 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007854 [ALC888_6ST_HP] = {
7855 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7856 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7858 .dac_nids = alc883_dac_nids,
7859 .dig_out_nid = ALC883_DIGOUT_NID,
7860 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7861 .adc_nids = alc883_adc_nids,
7862 .dig_in_nid = ALC883_DIGIN_NID,
7863 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7864 .channel_mode = alc883_sixstack_modes,
7865 .input_mux = &alc883_capture_source,
7866 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007867 [ALC888_3ST_HP] = {
7868 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7869 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007870 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7871 .dac_nids = alc883_dac_nids,
7872 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7873 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007874 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7875 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007876 .need_dac_fix = 1,
7877 .input_mux = &alc883_capture_source,
7878 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007879 [ALC888_6ST_DELL] = {
7880 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7881 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7883 .dac_nids = alc883_dac_nids,
7884 .dig_out_nid = ALC883_DIGOUT_NID,
7885 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7886 .adc_nids = alc883_adc_nids,
7887 .dig_in_nid = ALC883_DIGIN_NID,
7888 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7889 .channel_mode = alc883_sixstack_modes,
7890 .input_mux = &alc883_capture_source,
7891 .unsol_event = alc888_6st_dell_unsol_event,
7892 .init_hook = alc888_6st_dell_front_automute,
7893 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007894 [ALC883_MITAC] = {
7895 .mixers = { alc883_mitac_mixer },
7896 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7897 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7898 .dac_nids = alc883_dac_nids,
7899 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7900 .adc_nids = alc883_adc_nids,
7901 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7902 .channel_mode = alc883_3ST_2ch_modes,
7903 .input_mux = &alc883_capture_source,
7904 .unsol_event = alc883_mitac_unsol_event,
7905 .init_hook = alc883_mitac_automute,
7906 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007907};
7908
7909
7910/*
7911 * BIOS auto configuration
7912 */
7913static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7914 hda_nid_t nid, int pin_type,
7915 int dac_idx)
7916{
7917 /* set as output */
7918 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007919 int idx;
7920
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007921 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7922 idx = 4;
7923 else
7924 idx = spec->multiout.dac_nids[dac_idx] - 2;
7925
7926 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7927 pin_type);
7928 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7929 AMP_OUT_UNMUTE);
7930 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7931
7932}
7933
7934static void alc883_auto_init_multi_out(struct hda_codec *codec)
7935{
7936 struct alc_spec *spec = codec->spec;
7937 int i;
7938
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007939 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007940 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007941 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007942 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007943 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007944 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007945 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007946 }
7947}
7948
7949static void alc883_auto_init_hp_out(struct hda_codec *codec)
7950{
7951 struct alc_spec *spec = codec->spec;
7952 hda_nid_t pin;
7953
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007954 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007955 if (pin) /* connect to front */
7956 /* use dac 0 */
7957 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7958}
7959
7960#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7961#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7962
7963static void alc883_auto_init_analog_input(struct hda_codec *codec)
7964{
7965 struct alc_spec *spec = codec->spec;
7966 int i;
7967
7968 for (i = 0; i < AUTO_PIN_LAST; i++) {
7969 hda_nid_t nid = spec->autocfg.input_pins[i];
7970 if (alc883_is_input_pin(nid)) {
7971 snd_hda_codec_write(codec, nid, 0,
7972 AC_VERB_SET_PIN_WIDGET_CONTROL,
7973 (i <= AUTO_PIN_FRONT_MIC ?
7974 PIN_VREF80 : PIN_IN));
7975 if (nid != ALC883_PIN_CD_NID)
7976 snd_hda_codec_write(codec, nid, 0,
7977 AC_VERB_SET_AMP_GAIN_MUTE,
7978 AMP_OUT_MUTE);
7979 }
7980 }
7981}
7982
7983/* almost identical with ALC880 parser... */
7984static int alc883_parse_auto_config(struct hda_codec *codec)
7985{
7986 struct alc_spec *spec = codec->spec;
7987 int err = alc880_parse_auto_config(codec);
7988
7989 if (err < 0)
7990 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007991 else if (!err)
7992 return 0; /* no config found */
7993
7994 err = alc_auto_add_mic_boost(codec);
7995 if (err < 0)
7996 return err;
7997
7998 /* hack - override the init verbs */
7999 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008000 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8001 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008002
8003 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008004}
8005
8006/* additional initialization for auto-configuration model */
8007static void alc883_auto_init(struct hda_codec *codec)
8008{
8009 alc883_auto_init_multi_out(codec);
8010 alc883_auto_init_hp_out(codec);
8011 alc883_auto_init_analog_input(codec);
8012}
8013
8014static int patch_alc883(struct hda_codec *codec)
8015{
8016 struct alc_spec *spec;
8017 int err, board_config;
8018
8019 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8020 if (spec == NULL)
8021 return -ENOMEM;
8022
8023 codec->spec = spec;
8024
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008025 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8026 alc883_models,
8027 alc883_cfg_tbl);
8028 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008029 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8030 "trying auto-probe from BIOS...\n");
8031 board_config = ALC883_AUTO;
8032 }
8033
8034 if (board_config == ALC883_AUTO) {
8035 /* automatic parse from the BIOS config */
8036 err = alc883_parse_auto_config(codec);
8037 if (err < 0) {
8038 alc_free(codec);
8039 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008040 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008041 printk(KERN_INFO
8042 "hda_codec: Cannot set up configuration "
8043 "from BIOS. Using base mode...\n");
8044 board_config = ALC883_3ST_2ch_DIG;
8045 }
8046 }
8047
8048 if (board_config != ALC883_AUTO)
8049 setup_preset(spec, &alc883_presets[board_config]);
8050
8051 spec->stream_name_analog = "ALC883 Analog";
8052 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8053 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008054 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008055
8056 spec->stream_name_digital = "ALC883 Digital";
8057 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8058 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8059
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008060 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008061 spec->adc_nids = alc883_adc_nids;
8062 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8063 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008064
Takashi Iwai2134ea42008-01-10 16:53:55 +01008065 spec->vmaster_nid = 0x0c;
8066
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008067 codec->patch_ops = alc_patch_ops;
8068 if (board_config == ALC883_AUTO)
8069 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008070#ifdef CONFIG_SND_HDA_POWER_SAVE
8071 if (!spec->loopback.amplist)
8072 spec->loopback.amplist = alc883_loopbacks;
8073#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008074
8075 return 0;
8076}
8077
8078/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008079 * ALC262 support
8080 */
8081
8082#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8083#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8084
8085#define alc262_dac_nids alc260_dac_nids
8086#define alc262_adc_nids alc882_adc_nids
8087#define alc262_adc_nids_alt alc882_adc_nids_alt
8088
8089#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008090#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008091
8092static struct snd_kcontrol_new alc262_base_mixer[] = {
8093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008101 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008104 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008105 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8106 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8107 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8110 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008111 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008112};
8113
Kailang Yangccc656c2006-10-17 12:32:26 +02008114static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8115 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008123 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008126 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008127 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8128 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8129 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8131 { } /* end */
8132};
8133
Takashi Iwaice875f02008-01-28 18:17:43 +01008134/* update HP, line and mono-out pins according to the master switch */
8135static void alc262_hp_master_update(struct hda_codec *codec)
8136{
8137 struct alc_spec *spec = codec->spec;
8138 int val = spec->master_sw;
8139
8140 /* HP & line-out */
8141 snd_hda_codec_write_cache(codec, 0x1b, 0,
8142 AC_VERB_SET_PIN_WIDGET_CONTROL,
8143 val ? PIN_HP : 0);
8144 snd_hda_codec_write_cache(codec, 0x15, 0,
8145 AC_VERB_SET_PIN_WIDGET_CONTROL,
8146 val ? PIN_HP : 0);
8147 /* mono (speaker) depending on the HP jack sense */
8148 val = val && !spec->jack_present;
8149 snd_hda_codec_write_cache(codec, 0x16, 0,
8150 AC_VERB_SET_PIN_WIDGET_CONTROL,
8151 val ? PIN_OUT : 0);
8152}
8153
8154static void alc262_hp_bpc_automute(struct hda_codec *codec)
8155{
8156 struct alc_spec *spec = codec->spec;
8157 unsigned int presence;
8158 presence = snd_hda_codec_read(codec, 0x1b, 0,
8159 AC_VERB_GET_PIN_SENSE, 0);
8160 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8161 alc262_hp_master_update(codec);
8162}
8163
8164static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8165{
8166 if ((res >> 26) != ALC880_HP_EVENT)
8167 return;
8168 alc262_hp_bpc_automute(codec);
8169}
8170
8171static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8172{
8173 struct alc_spec *spec = codec->spec;
8174 unsigned int presence;
8175 presence = snd_hda_codec_read(codec, 0x15, 0,
8176 AC_VERB_GET_PIN_SENSE, 0);
8177 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8178 alc262_hp_master_update(codec);
8179}
8180
8181static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8182 unsigned int res)
8183{
8184 if ((res >> 26) != ALC880_HP_EVENT)
8185 return;
8186 alc262_hp_wildwest_automute(codec);
8187}
8188
8189static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8190 struct snd_ctl_elem_value *ucontrol)
8191{
8192 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8193 struct alc_spec *spec = codec->spec;
8194 *ucontrol->value.integer.value = spec->master_sw;
8195 return 0;
8196}
8197
8198static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8199 struct snd_ctl_elem_value *ucontrol)
8200{
8201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8202 struct alc_spec *spec = codec->spec;
8203 int val = !!*ucontrol->value.integer.value;
8204
8205 if (val == spec->master_sw)
8206 return 0;
8207 spec->master_sw = val;
8208 alc262_hp_master_update(codec);
8209 return 1;
8210}
8211
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008212static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008213 {
8214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8215 .name = "Master Playback Switch",
8216 .info = snd_ctl_boolean_mono_info,
8217 .get = alc262_hp_master_sw_get,
8218 .put = alc262_hp_master_sw_put,
8219 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8221 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008223 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8224 HDA_OUTPUT),
8225 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8226 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008230 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8231 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008232 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8237 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8238 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8239 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8240 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8241 { } /* end */
8242};
8243
Kailang Yangcd7509a2007-01-26 18:33:17 +01008244static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008245 {
8246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8247 .name = "Master Playback Switch",
8248 .info = snd_ctl_boolean_mono_info,
8249 .get = alc262_hp_master_sw_get,
8250 .put = alc262_hp_master_sw_put,
8251 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8253 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008256 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8257 HDA_OUTPUT),
8258 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8259 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008262 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8267 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8268 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8269 { } /* end */
8270};
8271
8272static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8273 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008275 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008276 { } /* end */
8277};
8278
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008279/* mute/unmute internal speaker according to the hp jack and mute state */
8280static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8281{
8282 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008283
8284 if (force || !spec->sense_updated) {
8285 unsigned int present;
8286 present = snd_hda_codec_read(codec, 0x15, 0,
8287 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008288 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008289 spec->sense_updated = 1;
8290 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008291 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8292 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008293}
8294
8295static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8296 unsigned int res)
8297{
8298 if ((res >> 26) != ALC880_HP_EVENT)
8299 return;
8300 alc262_hp_t5735_automute(codec, 1);
8301}
8302
8303static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8304{
8305 alc262_hp_t5735_automute(codec, 1);
8306}
8307
8308static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8310 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008311 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8315 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8316 { } /* end */
8317};
8318
8319static struct hda_verb alc262_hp_t5735_verbs[] = {
8320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8322
8323 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8324 { }
8325};
8326
Kailang Yang8c427222008-01-10 13:03:59 +01008327static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008328 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008330 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8331 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8334 { } /* end */
8335};
8336
8337static struct hda_verb alc262_hp_rp5700_verbs[] = {
8338 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8339 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8343 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8348 {}
8349};
8350
8351static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8352 .num_items = 1,
8353 .items = {
8354 { "Line", 0x1 },
8355 },
8356};
8357
Takashi Iwai0724ea22007-08-23 00:31:43 +02008358/* bind hp and internal speaker mute (with plug check) */
8359static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8360 struct snd_ctl_elem_value *ucontrol)
8361{
8362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8363 long *valp = ucontrol->value.integer.value;
8364 int change;
8365
8366 /* change hp mute */
8367 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8368 HDA_AMP_MUTE,
8369 valp[0] ? 0 : HDA_AMP_MUTE);
8370 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8371 HDA_AMP_MUTE,
8372 valp[1] ? 0 : HDA_AMP_MUTE);
8373 if (change) {
8374 /* change speaker according to HP jack state */
8375 struct alc_spec *spec = codec->spec;
8376 unsigned int mute;
8377 if (spec->jack_present)
8378 mute = HDA_AMP_MUTE;
8379 else
8380 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8381 HDA_OUTPUT, 0);
8382 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8383 HDA_AMP_MUTE, mute);
8384 }
8385 return change;
8386}
Takashi Iwai5b319542007-07-26 11:49:22 +02008387
Kailang Yang272a5272007-05-14 11:00:38 +02008388static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008389 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8390 {
8391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8392 .name = "Master Playback Switch",
8393 .info = snd_hda_mixer_amp_switch_info,
8394 .get = snd_hda_mixer_amp_switch_get,
8395 .put = alc262_sony_master_sw_put,
8396 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8397 },
Kailang Yang272a5272007-05-14 11:00:38 +02008398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8399 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8400 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8401 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8402 { } /* end */
8403};
8404
Kailang Yang83c34212007-07-05 11:43:05 +02008405static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8407 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8411 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8412 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8413 { } /* end */
8414};
Kailang Yang272a5272007-05-14 11:00:38 +02008415
Kailang Yangdf694da2005-12-05 19:42:22 +01008416#define alc262_capture_mixer alc882_capture_mixer
8417#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8418
8419/*
8420 * generic initialization of ADC, input mixers and output mixers
8421 */
8422static struct hda_verb alc262_init_verbs[] = {
8423 /*
8424 * Unmute ADC0-2 and set the default input to mic-in
8425 */
8426 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8428 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8430 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8432
Takashi Iwaicb53c622007-08-10 17:21:45 +02008433 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008434 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008435 * Note: PASD motherboards uses the Line In 2 as the input for
8436 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008437 */
8438 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008444
8445 /*
8446 * Set up output mixers (0x0c - 0x0e)
8447 */
8448 /* set vol=0 to output mixers */
8449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8451 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8452 /* set up input amps for analog loopback */
8453 /* Amp Indices: DAC = 0, mixer = 1 */
8454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8460
8461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8465 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8466 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8467
8468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8471 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8473
8474 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8475 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8476
8477 /* FIXME: use matrix-type input source selection */
8478 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8479 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8484 /* Input mixer2 */
8485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8489 /* Input mixer3 */
8490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008494
8495 { }
8496};
8497
Kailang Yangccc656c2006-10-17 12:32:26 +02008498static struct hda_verb alc262_hippo_unsol_verbs[] = {
8499 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8501 {}
8502};
8503
8504static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8507 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8508
8509 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8511 {}
8512};
8513
Kailang Yang272a5272007-05-14 11:00:38 +02008514static struct hda_verb alc262_sony_unsol_verbs[] = {
8515 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8517 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8518
8519 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8521};
8522
Kailang Yangccc656c2006-10-17 12:32:26 +02008523/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008524static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008525{
8526 struct alc_spec *spec = codec->spec;
8527 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008528 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008529
Takashi Iwai5b319542007-07-26 11:49:22 +02008530 /* need to execute and sync at first */
8531 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8532 present = snd_hda_codec_read(codec, 0x15, 0,
8533 AC_VERB_GET_PIN_SENSE, 0);
8534 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008535 if (spec->jack_present) {
8536 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008537 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8538 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008539 } else {
8540 /* unmute internal speaker if necessary */
8541 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008542 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8543 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008544 }
8545}
8546
8547/* unsolicited event for HP jack sensing */
8548static void alc262_hippo_unsol_event(struct hda_codec *codec,
8549 unsigned int res)
8550{
8551 if ((res >> 26) != ALC880_HP_EVENT)
8552 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008553 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008554}
8555
Takashi Iwai5b319542007-07-26 11:49:22 +02008556static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008557{
Kailang Yangccc656c2006-10-17 12:32:26 +02008558 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008559 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008560
Takashi Iwai5b319542007-07-26 11:49:22 +02008561 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8562 present = snd_hda_codec_read(codec, 0x1b, 0,
8563 AC_VERB_GET_PIN_SENSE, 0);
8564 present = (present & 0x80000000) != 0;
8565 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008566 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008567 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8568 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008569 } else {
8570 /* unmute internal speaker if necessary */
8571 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008572 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8573 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008574 }
8575}
8576
8577/* unsolicited event for HP jack sensing */
8578static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8579 unsigned int res)
8580{
8581 if ((res >> 26) != ALC880_HP_EVENT)
8582 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008583 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008584}
8585
Takashi Iwai834be882006-03-01 14:16:17 +01008586/*
8587 * fujitsu model
8588 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8589 */
8590
8591#define ALC_HP_EVENT 0x37
8592
8593static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8596 {}
8597};
8598
8599static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008600 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008601 .items = {
8602 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008603 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008604 { "CD", 0x4 },
8605 },
8606};
8607
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008608static struct hda_input_mux alc262_HP_capture_source = {
8609 .num_items = 5,
8610 .items = {
8611 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008612 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008613 { "Line", 0x2 },
8614 { "CD", 0x4 },
8615 { "AUX IN", 0x6 },
8616 },
8617};
8618
zhejiangaccbe492007-08-31 12:36:05 +02008619static struct hda_input_mux alc262_HP_D7000_capture_source = {
8620 .num_items = 4,
8621 .items = {
8622 { "Mic", 0x0 },
8623 { "Front Mic", 0x2 },
8624 { "Line", 0x1 },
8625 { "CD", 0x4 },
8626 },
8627};
8628
Takashi Iwai834be882006-03-01 14:16:17 +01008629/* mute/unmute internal speaker according to the hp jack and mute state */
8630static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8631{
8632 struct alc_spec *spec = codec->spec;
8633 unsigned int mute;
8634
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008635 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008636 unsigned int present;
8637 /* need to execute and sync at first */
8638 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8639 present = snd_hda_codec_read(codec, 0x14, 0,
8640 AC_VERB_GET_PIN_SENSE, 0);
8641 spec->jack_present = (present & 0x80000000) != 0;
8642 spec->sense_updated = 1;
8643 }
8644 if (spec->jack_present) {
8645 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008646 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8647 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008648 } else {
8649 /* unmute internal speaker if necessary */
8650 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008651 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8652 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008653 }
8654}
8655
8656/* unsolicited event for HP jack sensing */
8657static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8658 unsigned int res)
8659{
8660 if ((res >> 26) != ALC_HP_EVENT)
8661 return;
8662 alc262_fujitsu_automute(codec, 1);
8663}
8664
8665/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008666static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8667 .ops = &snd_hda_bind_vol,
8668 .values = {
8669 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8670 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8671 0
8672 },
8673};
Takashi Iwai834be882006-03-01 14:16:17 +01008674
8675/* bind hp and internal speaker mute (with plug check) */
8676static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8677 struct snd_ctl_elem_value *ucontrol)
8678{
8679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8680 long *valp = ucontrol->value.integer.value;
8681 int change;
8682
8683 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008684 HDA_AMP_MUTE,
8685 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008686 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008687 HDA_AMP_MUTE,
8688 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008689 if (change)
8690 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008691 return change;
8692}
8693
8694static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008695 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008696 {
8697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8698 .name = "Master Playback Switch",
8699 .info = snd_hda_mixer_amp_switch_info,
8700 .get = snd_hda_mixer_amp_switch_get,
8701 .put = alc262_fujitsu_master_sw_put,
8702 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8703 },
8704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008709 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8710 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8711 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008712 { } /* end */
8713};
8714
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008715/* additional init verbs for Benq laptops */
8716static struct hda_verb alc262_EAPD_verbs[] = {
8717 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8718 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8719 {}
8720};
8721
Kailang Yang83c34212007-07-05 11:43:05 +02008722static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8725
8726 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8727 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8728 {}
8729};
8730
Tobin Davisf651b502007-10-26 12:40:47 +02008731/* Samsung Q1 Ultra Vista model setup */
8732static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8734 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8738 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8739 { } /* end */
8740};
8741
8742static struct hda_verb alc262_ultra_verbs[] = {
8743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8746 /* Mic is on Node 0x19 */
8747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8748 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8750 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8752 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8754 {}
8755};
8756
8757static struct hda_input_mux alc262_ultra_capture_source = {
8758 .num_items = 1,
8759 .items = {
8760 { "Mic", 0x1 },
8761 },
8762};
8763
8764/* mute/unmute internal speaker according to the hp jack and mute state */
8765static void alc262_ultra_automute(struct hda_codec *codec)
8766{
8767 struct alc_spec *spec = codec->spec;
8768 unsigned int mute;
8769 unsigned int present;
8770
8771 /* need to execute and sync at first */
8772 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8773 present = snd_hda_codec_read(codec, 0x15, 0,
8774 AC_VERB_GET_PIN_SENSE, 0);
8775 spec->jack_present = (present & 0x80000000) != 0;
8776 if (spec->jack_present) {
8777 /* mute internal speaker */
8778 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8779 HDA_AMP_MUTE, HDA_AMP_MUTE);
8780 } else {
8781 /* unmute internal speaker if necessary */
8782 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8783 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8784 HDA_AMP_MUTE, mute);
8785 }
8786}
8787
8788/* unsolicited event for HP jack sensing */
8789static void alc262_ultra_unsol_event(struct hda_codec *codec,
8790 unsigned int res)
8791{
8792 if ((res >> 26) != ALC880_HP_EVENT)
8793 return;
8794 alc262_ultra_automute(codec);
8795}
8796
Kailang Yangdf694da2005-12-05 19:42:22 +01008797/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008798static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8799 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008800{
8801 hda_nid_t nid;
8802 int err;
8803
8804 spec->multiout.num_dacs = 1; /* only use one dac */
8805 spec->multiout.dac_nids = spec->private_dac_nids;
8806 spec->multiout.dac_nids[0] = 2;
8807
8808 nid = cfg->line_out_pins[0];
8809 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008810 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8811 "Front Playback Volume",
8812 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008815 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8816 "Front Playback Switch",
8817 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8818 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008819 return err;
8820 }
8821
Takashi Iwai82bc9552006-03-21 11:24:42 +01008822 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008823 if (nid) {
8824 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008825 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8826 "Speaker Playback Volume",
8827 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8828 HDA_OUTPUT));
8829 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008830 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008831 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8832 "Speaker Playback Switch",
8833 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8834 HDA_OUTPUT));
8835 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008836 return err;
8837 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008838 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8839 "Speaker Playback Switch",
8840 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8841 HDA_OUTPUT));
8842 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008843 return err;
8844 }
8845 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008846 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008847 if (nid) {
8848 /* spec->multiout.hp_nid = 2; */
8849 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008850 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8851 "Headphone Playback Volume",
8852 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8853 HDA_OUTPUT));
8854 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008855 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008856 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8857 "Headphone Playback Switch",
8858 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8859 HDA_OUTPUT));
8860 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008861 return err;
8862 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008863 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8864 "Headphone Playback Switch",
8865 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8866 HDA_OUTPUT));
8867 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008868 return err;
8869 }
8870 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008871 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008872}
8873
8874/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008875#define alc262_auto_create_analog_input_ctls \
8876 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008877
8878/*
8879 * generic initialization of ADC, input mixers and output mixers
8880 */
8881static struct hda_verb alc262_volume_init_verbs[] = {
8882 /*
8883 * Unmute ADC0-2 and set the default input to mic-in
8884 */
8885 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8887 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8889 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8891
Takashi Iwaicb53c622007-08-10 17:21:45 +02008892 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008893 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008894 * Note: PASD motherboards uses the Line In 2 as the input for
8895 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008896 */
8897 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008903
8904 /*
8905 * Set up output mixers (0x0c - 0x0f)
8906 */
8907 /* set vol=0 to output mixers */
8908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8911
8912 /* set up input amps for analog loopback */
8913 /* Amp Indices: DAC = 0, mixer = 1 */
8914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920
8921 /* FIXME: use matrix-type input source selection */
8922 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8923 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8928 /* Input mixer2 */
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8933 /* Input mixer3 */
8934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8938
8939 { }
8940};
8941
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008942static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8943 /*
8944 * Unmute ADC0-2 and set the default input to mic-in
8945 */
8946 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8948 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8950 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8952
Takashi Iwaicb53c622007-08-10 17:21:45 +02008953 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008954 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008955 * Note: PASD motherboards uses the Line In 2 as the input for
8956 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008957 */
8958 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8962 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8963 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008966
8967 /*
8968 * Set up output mixers (0x0c - 0x0e)
8969 */
8970 /* set vol=0 to output mixers */
8971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8972 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8973 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8974
8975 /* set up input amps for analog loopback */
8976 /* Amp Indices: DAC = 0, mixer = 1 */
8977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8979 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8981 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8983
Takashi Iwaice875f02008-01-28 18:17:43 +01008984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8986 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8987
8988 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8990
8991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8992 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8993
8994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8995 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8996 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8997 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8998 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8999
9000 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9004 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9005 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9006
9007
9008 /* FIXME: use matrix-type input source selection */
9009 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9010 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9015 /* Input mixer2 */
9016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9018 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9019 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9020 /* Input mixer3 */
9021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9025
Takashi Iwaice875f02008-01-28 18:17:43 +01009026 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9027
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009028 { }
9029};
9030
Kailang Yangcd7509a2007-01-26 18:33:17 +01009031static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9032 /*
9033 * Unmute ADC0-2 and set the default input to mic-in
9034 */
9035 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9037 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9039 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9041
Takashi Iwaicb53c622007-08-10 17:21:45 +02009042 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009043 * mixer widget
9044 * Note: PASD motherboards uses the Line In 2 as the input for front
9045 * panel mic (mic 2)
9046 */
9047 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009056 /*
9057 * Set up output mixers (0x0c - 0x0e)
9058 */
9059 /* set vol=0 to output mixers */
9060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9063
9064 /* set up input amps for analog loopback */
9065 /* Amp Indices: DAC = 0, mixer = 1 */
9066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9072
9073
9074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9076 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9080 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9081
9082 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9084
9085 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9087
9088 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9092 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9093 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9094
9095 /* FIXME: use matrix-type input source selection */
9096 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9097 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9103 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9105 /* Input mixer2 */
9106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9111 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9113 /* Input mixer3 */
9114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9119 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9121
Takashi Iwaice875f02008-01-28 18:17:43 +01009122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9123
Kailang Yangcd7509a2007-01-26 18:33:17 +01009124 { }
9125};
9126
Takashi Iwaicb53c622007-08-10 17:21:45 +02009127#ifdef CONFIG_SND_HDA_POWER_SAVE
9128#define alc262_loopbacks alc880_loopbacks
9129#endif
9130
Kailang Yangdf694da2005-12-05 19:42:22 +01009131/* pcm configuration: identiacal with ALC880 */
9132#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9133#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9134#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9135#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9136
9137/*
9138 * BIOS auto configuration
9139 */
9140static int alc262_parse_auto_config(struct hda_codec *codec)
9141{
9142 struct alc_spec *spec = codec->spec;
9143 int err;
9144 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009146 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9147 alc262_ignore);
9148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009149 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009150 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009151 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009152 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9153 if (err < 0)
9154 return err;
9155 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9156 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009157 return err;
9158
9159 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9160
9161 if (spec->autocfg.dig_out_pin)
9162 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9163 if (spec->autocfg.dig_in_pin)
9164 spec->dig_in_nid = ALC262_DIGIN_NID;
9165
9166 if (spec->kctl_alloc)
9167 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9168
9169 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009170 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009171 spec->input_mux = &spec->private_imux;
9172
Takashi Iwai776e1842007-08-29 15:07:11 +02009173 err = alc_auto_add_mic_boost(codec);
9174 if (err < 0)
9175 return err;
9176
Kailang Yangdf694da2005-12-05 19:42:22 +01009177 return 1;
9178}
9179
9180#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9181#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9182#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9183
9184
9185/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009186static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009187{
Kailang Yangdf694da2005-12-05 19:42:22 +01009188 alc262_auto_init_multi_out(codec);
9189 alc262_auto_init_hp_out(codec);
9190 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009191}
9192
9193/*
9194 * configuration and preset
9195 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009196static const char *alc262_models[ALC262_MODEL_LAST] = {
9197 [ALC262_BASIC] = "basic",
9198 [ALC262_HIPPO] = "hippo",
9199 [ALC262_HIPPO_1] = "hippo_1",
9200 [ALC262_FUJITSU] = "fujitsu",
9201 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009202 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009203 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009204 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009205 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009206 [ALC262_BENQ_T31] = "benq-t31",
9207 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009208 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009209 [ALC262_AUTO] = "auto",
9210};
9211
9212static struct snd_pci_quirk alc262_cfg_tbl[] = {
9213 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9214 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009215 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009216 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9217 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009218 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009219 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009220 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009221 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009222 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009223 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009224 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009225 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009226 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009227 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009228 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009229 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009230 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9231 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9232 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009233 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9234 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009235 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009236 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009237 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009238 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9239 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9240 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009241 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009242 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009243 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009244 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009245 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009246 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009247 {}
9248};
9249
9250static struct alc_config_preset alc262_presets[] = {
9251 [ALC262_BASIC] = {
9252 .mixers = { alc262_base_mixer },
9253 .init_verbs = { alc262_init_verbs },
9254 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9255 .dac_nids = alc262_dac_nids,
9256 .hp_nid = 0x03,
9257 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9258 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009259 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009260 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009261 [ALC262_HIPPO] = {
9262 .mixers = { alc262_base_mixer },
9263 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9264 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9265 .dac_nids = alc262_dac_nids,
9266 .hp_nid = 0x03,
9267 .dig_out_nid = ALC262_DIGOUT_NID,
9268 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9269 .channel_mode = alc262_modes,
9270 .input_mux = &alc262_capture_source,
9271 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009272 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009273 },
9274 [ALC262_HIPPO_1] = {
9275 .mixers = { alc262_hippo1_mixer },
9276 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9277 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9278 .dac_nids = alc262_dac_nids,
9279 .hp_nid = 0x02,
9280 .dig_out_nid = ALC262_DIGOUT_NID,
9281 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9282 .channel_mode = alc262_modes,
9283 .input_mux = &alc262_capture_source,
9284 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009285 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009286 },
Takashi Iwai834be882006-03-01 14:16:17 +01009287 [ALC262_FUJITSU] = {
9288 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009289 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9290 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009291 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9292 .dac_nids = alc262_dac_nids,
9293 .hp_nid = 0x03,
9294 .dig_out_nid = ALC262_DIGOUT_NID,
9295 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9296 .channel_mode = alc262_modes,
9297 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009298 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009299 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009300 [ALC262_HP_BPC] = {
9301 .mixers = { alc262_HP_BPC_mixer },
9302 .init_verbs = { alc262_HP_BPC_init_verbs },
9303 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9304 .dac_nids = alc262_dac_nids,
9305 .hp_nid = 0x03,
9306 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9307 .channel_mode = alc262_modes,
9308 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009309 .unsol_event = alc262_hp_bpc_unsol_event,
9310 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009311 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009312 [ALC262_HP_BPC_D7000_WF] = {
9313 .mixers = { alc262_HP_BPC_WildWest_mixer },
9314 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9315 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9316 .dac_nids = alc262_dac_nids,
9317 .hp_nid = 0x03,
9318 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9319 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009320 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009321 .unsol_event = alc262_hp_wildwest_unsol_event,
9322 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009323 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009324 [ALC262_HP_BPC_D7000_WL] = {
9325 .mixers = { alc262_HP_BPC_WildWest_mixer,
9326 alc262_HP_BPC_WildWest_option_mixer },
9327 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9328 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9329 .dac_nids = alc262_dac_nids,
9330 .hp_nid = 0x03,
9331 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9332 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009333 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009334 .unsol_event = alc262_hp_wildwest_unsol_event,
9335 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009336 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009337 [ALC262_HP_TC_T5735] = {
9338 .mixers = { alc262_hp_t5735_mixer },
9339 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9340 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9341 .dac_nids = alc262_dac_nids,
9342 .hp_nid = 0x03,
9343 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9344 .channel_mode = alc262_modes,
9345 .input_mux = &alc262_capture_source,
9346 .unsol_event = alc262_hp_t5735_unsol_event,
9347 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009348 },
9349 [ALC262_HP_RP5700] = {
9350 .mixers = { alc262_hp_rp5700_mixer },
9351 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9352 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9353 .dac_nids = alc262_dac_nids,
9354 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9355 .channel_mode = alc262_modes,
9356 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009357 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009358 [ALC262_BENQ_ED8] = {
9359 .mixers = { alc262_base_mixer },
9360 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9361 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9362 .dac_nids = alc262_dac_nids,
9363 .hp_nid = 0x03,
9364 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9365 .channel_mode = alc262_modes,
9366 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009367 },
Kailang Yang272a5272007-05-14 11:00:38 +02009368 [ALC262_SONY_ASSAMD] = {
9369 .mixers = { alc262_sony_mixer },
9370 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9371 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9372 .dac_nids = alc262_dac_nids,
9373 .hp_nid = 0x02,
9374 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9375 .channel_mode = alc262_modes,
9376 .input_mux = &alc262_capture_source,
9377 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009378 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009379 },
9380 [ALC262_BENQ_T31] = {
9381 .mixers = { alc262_benq_t31_mixer },
9382 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9384 .dac_nids = alc262_dac_nids,
9385 .hp_nid = 0x03,
9386 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9387 .channel_mode = alc262_modes,
9388 .input_mux = &alc262_capture_source,
9389 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009390 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009391 },
Tobin Davisf651b502007-10-26 12:40:47 +02009392 [ALC262_ULTRA] = {
9393 .mixers = { alc262_ultra_mixer },
9394 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9395 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9396 .dac_nids = alc262_dac_nids,
9397 .hp_nid = 0x03,
9398 .dig_out_nid = ALC262_DIGOUT_NID,
9399 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9400 .channel_mode = alc262_modes,
9401 .input_mux = &alc262_ultra_capture_source,
9402 .unsol_event = alc262_ultra_unsol_event,
9403 .init_hook = alc262_ultra_automute,
9404 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009405};
9406
9407static int patch_alc262(struct hda_codec *codec)
9408{
9409 struct alc_spec *spec;
9410 int board_config;
9411 int err;
9412
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009413 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009414 if (spec == NULL)
9415 return -ENOMEM;
9416
9417 codec->spec = spec;
9418#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009419 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9420 * under-run
9421 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009422 {
9423 int tmp;
9424 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9425 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9426 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9427 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9428 }
9429#endif
9430
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009431 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9432 alc262_models,
9433 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009434
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009435 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009436 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9437 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009438 board_config = ALC262_AUTO;
9439 }
9440
9441 if (board_config == ALC262_AUTO) {
9442 /* automatic parse from the BIOS config */
9443 err = alc262_parse_auto_config(codec);
9444 if (err < 0) {
9445 alc_free(codec);
9446 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009447 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009448 printk(KERN_INFO
9449 "hda_codec: Cannot set up configuration "
9450 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 board_config = ALC262_BASIC;
9452 }
9453 }
9454
9455 if (board_config != ALC262_AUTO)
9456 setup_preset(spec, &alc262_presets[board_config]);
9457
9458 spec->stream_name_analog = "ALC262 Analog";
9459 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9460 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9461
9462 spec->stream_name_digital = "ALC262 Digital";
9463 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9464 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009466 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009467 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009468 unsigned int wcap = get_wcaps(codec, 0x07);
9469
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009470 /* get type */
9471 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009472 if (wcap != AC_WID_AUD_IN) {
9473 spec->adc_nids = alc262_adc_nids_alt;
9474 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009475 spec->mixers[spec->num_mixers] =
9476 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009477 spec->num_mixers++;
9478 } else {
9479 spec->adc_nids = alc262_adc_nids;
9480 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9481 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9482 spec->num_mixers++;
9483 }
9484 }
9485
Takashi Iwai2134ea42008-01-10 16:53:55 +01009486 spec->vmaster_nid = 0x0c;
9487
Kailang Yangdf694da2005-12-05 19:42:22 +01009488 codec->patch_ops = alc_patch_ops;
9489 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009490 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009491#ifdef CONFIG_SND_HDA_POWER_SAVE
9492 if (!spec->loopback.amplist)
9493 spec->loopback.amplist = alc262_loopbacks;
9494#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009495
Kailang Yangdf694da2005-12-05 19:42:22 +01009496 return 0;
9497}
9498
Kailang Yangdf694da2005-12-05 19:42:22 +01009499/*
Kailang Yanga361d842007-06-05 12:30:55 +02009500 * ALC268 channel source setting (2 channel)
9501 */
9502#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9503#define alc268_modes alc260_modes
9504
9505static hda_nid_t alc268_dac_nids[2] = {
9506 /* front, hp */
9507 0x02, 0x03
9508};
9509
9510static hda_nid_t alc268_adc_nids[2] = {
9511 /* ADC0-1 */
9512 0x08, 0x07
9513};
9514
9515static hda_nid_t alc268_adc_nids_alt[1] = {
9516 /* ADC0 */
9517 0x08
9518};
9519
9520static struct snd_kcontrol_new alc268_base_mixer[] = {
9521 /* output mixer control */
9522 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9523 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9524 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009526 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9527 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9528 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009529 { }
9530};
9531
Kailang Yangd1a991a2007-08-15 16:21:59 +02009532static struct hda_verb alc268_eapd_verbs[] = {
9533 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9534 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9535 { }
9536};
9537
Takashi Iwaid2738092007-08-16 14:59:45 +02009538/* Toshiba specific */
9539#define alc268_toshiba_automute alc262_hippo_automute
9540
9541static struct hda_verb alc268_toshiba_verbs[] = {
9542 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9543 { } /* end */
9544};
9545
9546/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009547/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009548static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9549 .ops = &snd_hda_bind_vol,
9550 .values = {
9551 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9552 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9553 0
9554 },
9555};
9556
Takashi Iwai889c4392007-08-23 18:56:52 +02009557/* mute/unmute internal speaker according to the hp jack and mute state */
9558static void alc268_acer_automute(struct hda_codec *codec, int force)
9559{
9560 struct alc_spec *spec = codec->spec;
9561 unsigned int mute;
9562
9563 if (force || !spec->sense_updated) {
9564 unsigned int present;
9565 present = snd_hda_codec_read(codec, 0x14, 0,
9566 AC_VERB_GET_PIN_SENSE, 0);
9567 spec->jack_present = (present & 0x80000000) != 0;
9568 spec->sense_updated = 1;
9569 }
9570 if (spec->jack_present)
9571 mute = HDA_AMP_MUTE; /* mute internal speaker */
9572 else /* unmute internal speaker if necessary */
9573 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9574 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9575 HDA_AMP_MUTE, mute);
9576}
9577
9578
9579/* bind hp and internal speaker mute (with plug check) */
9580static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9581 struct snd_ctl_elem_value *ucontrol)
9582{
9583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9584 long *valp = ucontrol->value.integer.value;
9585 int change;
9586
9587 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9588 HDA_AMP_MUTE,
9589 valp[0] ? 0 : HDA_AMP_MUTE);
9590 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9591 HDA_AMP_MUTE,
9592 valp[1] ? 0 : HDA_AMP_MUTE);
9593 if (change)
9594 alc268_acer_automute(codec, 0);
9595 return change;
9596}
Takashi Iwaid2738092007-08-16 14:59:45 +02009597
9598static struct snd_kcontrol_new alc268_acer_mixer[] = {
9599 /* output mixer control */
9600 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9601 {
9602 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9603 .name = "Master Playback Switch",
9604 .info = snd_hda_mixer_amp_switch_info,
9605 .get = snd_hda_mixer_amp_switch_get,
9606 .put = alc268_acer_master_sw_put,
9607 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9608 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009609 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9610 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9611 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009612 { }
9613};
9614
9615static struct hda_verb alc268_acer_verbs[] = {
9616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9618
9619 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9620 { }
9621};
9622
9623/* unsolicited event for HP jack sensing */
9624static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9625 unsigned int res)
9626{
Takashi Iwai889c4392007-08-23 18:56:52 +02009627 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009628 return;
9629 alc268_toshiba_automute(codec);
9630}
9631
9632static void alc268_acer_unsol_event(struct hda_codec *codec,
9633 unsigned int res)
9634{
Takashi Iwai889c4392007-08-23 18:56:52 +02009635 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009636 return;
9637 alc268_acer_automute(codec, 1);
9638}
9639
Takashi Iwai889c4392007-08-23 18:56:52 +02009640static void alc268_acer_init_hook(struct hda_codec *codec)
9641{
9642 alc268_acer_automute(codec, 1);
9643}
9644
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009645static struct snd_kcontrol_new alc268_dell_mixer[] = {
9646 /* output mixer control */
9647 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9648 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9649 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9651 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9652 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9653 { }
9654};
9655
9656static struct hda_verb alc268_dell_verbs[] = {
9657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9659 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9660 { }
9661};
9662
9663/* mute/unmute internal speaker according to the hp jack and mute state */
9664static void alc268_dell_automute(struct hda_codec *codec)
9665{
9666 unsigned int present;
9667 unsigned int mute;
9668
9669 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9670 if (present & 0x80000000)
9671 mute = HDA_AMP_MUTE;
9672 else
9673 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9674 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9675 HDA_AMP_MUTE, mute);
9676}
9677
9678static void alc268_dell_unsol_event(struct hda_codec *codec,
9679 unsigned int res)
9680{
9681 if ((res >> 26) != ALC880_HP_EVENT)
9682 return;
9683 alc268_dell_automute(codec);
9684}
9685
9686#define alc268_dell_init_hook alc268_dell_automute
9687
Kailang Yanga361d842007-06-05 12:30:55 +02009688/*
9689 * generic initialization of ADC, input mixers and output mixers
9690 */
9691static struct hda_verb alc268_base_init_verbs[] = {
9692 /* Unmute DAC0-1 and set vol = 0 */
9693 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9695 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9696 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9699
9700 /*
9701 * Set up output mixers (0x0c - 0x0e)
9702 */
9703 /* set vol=0 to output mixers */
9704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9707 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9708
9709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9710 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9711
9712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9714 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9715 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9717 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9718 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9719 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9720
9721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9724 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9728 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9729
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009730 /* Unmute Selector 23h,24h and set the default input to mic-in */
9731
9732 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9733 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9734 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009736
Kailang Yanga361d842007-06-05 12:30:55 +02009737 { }
9738};
9739
9740/*
9741 * generic initialization of ADC, input mixers and output mixers
9742 */
9743static struct hda_verb alc268_volume_init_verbs[] = {
9744 /* set output DAC */
9745 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9748 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9749
9750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9751 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9753 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9754 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9755
9756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9760 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9761
9762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9765 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9766
9767 /* set PCBEEP vol = 0 */
9768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9769
9770 { }
9771};
9772
9773#define alc268_mux_enum_info alc_mux_enum_info
9774#define alc268_mux_enum_get alc_mux_enum_get
9775
9776static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9777 struct snd_ctl_elem_value *ucontrol)
9778{
9779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9780 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009781
Kailang Yanga361d842007-06-05 12:30:55 +02009782 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9783 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9784 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009785
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009786 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9787 nid,
9788 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009789}
9790
9791static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9792 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9793 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9794 {
9795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9796 /* The multiple "Capture Source" controls confuse alsamixer
9797 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009798 */
9799 /* .name = "Capture Source", */
9800 .name = "Input Source",
9801 .count = 1,
9802 .info = alc268_mux_enum_info,
9803 .get = alc268_mux_enum_get,
9804 .put = alc268_mux_enum_put,
9805 },
9806 { } /* end */
9807};
9808
9809static struct snd_kcontrol_new alc268_capture_mixer[] = {
9810 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9812 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9813 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9814 {
9815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9816 /* The multiple "Capture Source" controls confuse alsamixer
9817 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009818 */
9819 /* .name = "Capture Source", */
9820 .name = "Input Source",
9821 .count = 2,
9822 .info = alc268_mux_enum_info,
9823 .get = alc268_mux_enum_get,
9824 .put = alc268_mux_enum_put,
9825 },
9826 { } /* end */
9827};
9828
9829static struct hda_input_mux alc268_capture_source = {
9830 .num_items = 4,
9831 .items = {
9832 { "Mic", 0x0 },
9833 { "Front Mic", 0x1 },
9834 { "Line", 0x2 },
9835 { "CD", 0x3 },
9836 },
9837};
9838
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009839#ifdef CONFIG_SND_DEBUG
9840static struct snd_kcontrol_new alc268_test_mixer[] = {
9841 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9843 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9845
9846 /* Volume widgets */
9847 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9848 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9849 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9850 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9851 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9852 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9853 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9854 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9855 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9856 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9857 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9858 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9859 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009860 /* The below appears problematic on some hardwares */
9861 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009862 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9863 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9864 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9865 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9866
9867 /* Modes for retasking pin widgets */
9868 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9869 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9870 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9871 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9872
9873 /* Controls for GPIO pins, assuming they are configured as outputs */
9874 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9875 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9876 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9877 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9878
9879 /* Switches to allow the digital SPDIF output pin to be enabled.
9880 * The ALC268 does not have an SPDIF input.
9881 */
9882 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9883
9884 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9885 * this output to turn on an external amplifier.
9886 */
9887 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9888 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9889
9890 { } /* end */
9891};
9892#endif
9893
Kailang Yanga361d842007-06-05 12:30:55 +02009894/* create input playback/capture controls for the given pin */
9895static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9896 const char *ctlname, int idx)
9897{
9898 char name[32];
9899 int err;
9900
9901 sprintf(name, "%s Playback Volume", ctlname);
9902 if (nid == 0x14) {
9903 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9904 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9905 HDA_OUTPUT));
9906 if (err < 0)
9907 return err;
9908 } else if (nid == 0x15) {
9909 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9910 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9911 HDA_OUTPUT));
9912 if (err < 0)
9913 return err;
9914 } else
9915 return -1;
9916 sprintf(name, "%s Playback Switch", ctlname);
9917 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9918 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9919 if (err < 0)
9920 return err;
9921 return 0;
9922}
9923
9924/* add playback controls from the parsed DAC table */
9925static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9926 const struct auto_pin_cfg *cfg)
9927{
9928 hda_nid_t nid;
9929 int err;
9930
9931 spec->multiout.num_dacs = 2; /* only use one dac */
9932 spec->multiout.dac_nids = spec->private_dac_nids;
9933 spec->multiout.dac_nids[0] = 2;
9934 spec->multiout.dac_nids[1] = 3;
9935
9936 nid = cfg->line_out_pins[0];
9937 if (nid)
9938 alc268_new_analog_output(spec, nid, "Front", 0);
9939
9940 nid = cfg->speaker_pins[0];
9941 if (nid == 0x1d) {
9942 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9943 "Speaker Playback Volume",
9944 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9945 if (err < 0)
9946 return err;
9947 }
9948 nid = cfg->hp_pins[0];
9949 if (nid)
9950 alc268_new_analog_output(spec, nid, "Headphone", 0);
9951
9952 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9953 if (nid == 0x16) {
9954 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9955 "Mono Playback Switch",
9956 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9957 if (err < 0)
9958 return err;
9959 }
9960 return 0;
9961}
9962
9963/* create playback/capture controls for input pins */
9964static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9965 const struct auto_pin_cfg *cfg)
9966{
9967 struct hda_input_mux *imux = &spec->private_imux;
9968 int i, idx1;
9969
9970 for (i = 0; i < AUTO_PIN_LAST; i++) {
9971 switch(cfg->input_pins[i]) {
9972 case 0x18:
9973 idx1 = 0; /* Mic 1 */
9974 break;
9975 case 0x19:
9976 idx1 = 1; /* Mic 2 */
9977 break;
9978 case 0x1a:
9979 idx1 = 2; /* Line In */
9980 break;
9981 case 0x1c:
9982 idx1 = 3; /* CD */
9983 break;
9984 default:
9985 continue;
9986 }
9987 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9988 imux->items[imux->num_items].index = idx1;
9989 imux->num_items++;
9990 }
9991 return 0;
9992}
9993
9994static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9995{
9996 struct alc_spec *spec = codec->spec;
9997 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9998 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9999 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10000 unsigned int dac_vol1, dac_vol2;
10001
10002 if (speaker_nid) {
10003 snd_hda_codec_write(codec, speaker_nid, 0,
10004 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10005 snd_hda_codec_write(codec, 0x0f, 0,
10006 AC_VERB_SET_AMP_GAIN_MUTE,
10007 AMP_IN_UNMUTE(1));
10008 snd_hda_codec_write(codec, 0x10, 0,
10009 AC_VERB_SET_AMP_GAIN_MUTE,
10010 AMP_IN_UNMUTE(1));
10011 } else {
10012 snd_hda_codec_write(codec, 0x0f, 0,
10013 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10014 snd_hda_codec_write(codec, 0x10, 0,
10015 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10016 }
10017
10018 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10019 if (line_nid == 0x14)
10020 dac_vol2 = AMP_OUT_ZERO;
10021 else if (line_nid == 0x15)
10022 dac_vol1 = AMP_OUT_ZERO;
10023 if (hp_nid == 0x14)
10024 dac_vol2 = AMP_OUT_ZERO;
10025 else if (hp_nid == 0x15)
10026 dac_vol1 = AMP_OUT_ZERO;
10027 if (line_nid != 0x16 || hp_nid != 0x16 ||
10028 spec->autocfg.line_out_pins[1] != 0x16 ||
10029 spec->autocfg.line_out_pins[2] != 0x16)
10030 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10031
10032 snd_hda_codec_write(codec, 0x02, 0,
10033 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10034 snd_hda_codec_write(codec, 0x03, 0,
10035 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10036}
10037
10038/* pcm configuration: identiacal with ALC880 */
10039#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10040#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010041#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010042#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10043
10044/*
10045 * BIOS auto configuration
10046 */
10047static int alc268_parse_auto_config(struct hda_codec *codec)
10048{
10049 struct alc_spec *spec = codec->spec;
10050 int err;
10051 static hda_nid_t alc268_ignore[] = { 0 };
10052
10053 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10054 alc268_ignore);
10055 if (err < 0)
10056 return err;
10057 if (!spec->autocfg.line_outs)
10058 return 0; /* can't find valid BIOS pin config */
10059
10060 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10061 if (err < 0)
10062 return err;
10063 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10064 if (err < 0)
10065 return err;
10066
10067 spec->multiout.max_channels = 2;
10068
10069 /* digital only support output */
10070 if (spec->autocfg.dig_out_pin)
10071 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10072
10073 if (spec->kctl_alloc)
10074 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10075
10076 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10077 spec->num_mux_defs = 1;
10078 spec->input_mux = &spec->private_imux;
10079
Takashi Iwai776e1842007-08-29 15:07:11 +020010080 err = alc_auto_add_mic_boost(codec);
10081 if (err < 0)
10082 return err;
10083
Kailang Yanga361d842007-06-05 12:30:55 +020010084 return 1;
10085}
10086
10087#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10088#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10089#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10090
10091/* init callback for auto-configuration model -- overriding the default init */
10092static void alc268_auto_init(struct hda_codec *codec)
10093{
10094 alc268_auto_init_multi_out(codec);
10095 alc268_auto_init_hp_out(codec);
10096 alc268_auto_init_mono_speaker_out(codec);
10097 alc268_auto_init_analog_input(codec);
10098}
10099
10100/*
10101 * configuration and preset
10102 */
10103static const char *alc268_models[ALC268_MODEL_LAST] = {
10104 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010105 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010106 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010107 [ALC268_DELL] = "dell",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010108#ifdef CONFIG_SND_DEBUG
10109 [ALC268_TEST] = "test",
10110#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010111 [ALC268_AUTO] = "auto",
10112};
10113
10114static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010115 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010116 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010117 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010118 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010119 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010120 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010121 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010122 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010123 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010124 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +020010125 {}
10126};
10127
10128static struct alc_config_preset alc268_presets[] = {
10129 [ALC268_3ST] = {
10130 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10131 .init_verbs = { alc268_base_init_verbs },
10132 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10133 .dac_nids = alc268_dac_nids,
10134 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10135 .adc_nids = alc268_adc_nids_alt,
10136 .hp_nid = 0x03,
10137 .dig_out_nid = ALC268_DIGOUT_NID,
10138 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10139 .channel_mode = alc268_modes,
10140 .input_mux = &alc268_capture_source,
10141 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010142 [ALC268_TOSHIBA] = {
10143 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10145 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010146 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10147 .dac_nids = alc268_dac_nids,
10148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10149 .adc_nids = alc268_adc_nids_alt,
10150 .hp_nid = 0x03,
10151 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10152 .channel_mode = alc268_modes,
10153 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010154 .unsol_event = alc268_toshiba_unsol_event,
10155 .init_hook = alc268_toshiba_automute,
10156 },
10157 [ALC268_ACER] = {
10158 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10159 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10160 alc268_acer_verbs },
10161 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10162 .dac_nids = alc268_dac_nids,
10163 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10164 .adc_nids = alc268_adc_nids_alt,
10165 .hp_nid = 0x02,
10166 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10167 .channel_mode = alc268_modes,
10168 .input_mux = &alc268_capture_source,
10169 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010170 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010171 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010172 [ALC268_DELL] = {
10173 .mixers = { alc268_dell_mixer },
10174 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10175 alc268_dell_verbs },
10176 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10177 .dac_nids = alc268_dac_nids,
10178 .hp_nid = 0x02,
10179 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10180 .channel_mode = alc268_modes,
10181 .unsol_event = alc268_dell_unsol_event,
10182 .init_hook = alc268_dell_init_hook,
10183 .input_mux = &alc268_capture_source,
10184 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010185#ifdef CONFIG_SND_DEBUG
10186 [ALC268_TEST] = {
10187 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10188 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10189 alc268_volume_init_verbs },
10190 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10191 .dac_nids = alc268_dac_nids,
10192 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10193 .adc_nids = alc268_adc_nids_alt,
10194 .hp_nid = 0x03,
10195 .dig_out_nid = ALC268_DIGOUT_NID,
10196 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10197 .channel_mode = alc268_modes,
10198 .input_mux = &alc268_capture_source,
10199 },
10200#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010201};
10202
10203static int patch_alc268(struct hda_codec *codec)
10204{
10205 struct alc_spec *spec;
10206 int board_config;
10207 int err;
10208
10209 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10210 if (spec == NULL)
10211 return -ENOMEM;
10212
10213 codec->spec = spec;
10214
10215 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10216 alc268_models,
10217 alc268_cfg_tbl);
10218
10219 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10220 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10221 "trying auto-probe from BIOS...\n");
10222 board_config = ALC268_AUTO;
10223 }
10224
10225 if (board_config == ALC268_AUTO) {
10226 /* automatic parse from the BIOS config */
10227 err = alc268_parse_auto_config(codec);
10228 if (err < 0) {
10229 alc_free(codec);
10230 return err;
10231 } else if (!err) {
10232 printk(KERN_INFO
10233 "hda_codec: Cannot set up configuration "
10234 "from BIOS. Using base mode...\n");
10235 board_config = ALC268_3ST;
10236 }
10237 }
10238
10239 if (board_config != ALC268_AUTO)
10240 setup_preset(spec, &alc268_presets[board_config]);
10241
10242 spec->stream_name_analog = "ALC268 Analog";
10243 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10244 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010245 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010246
10247 spec->stream_name_digital = "ALC268 Digital";
10248 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10249
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010250 if (!spec->adc_nids && spec->input_mux) {
10251 /* check whether NID 0x07 is valid */
10252 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010253
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010254 /* get type */
10255 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10256 if (wcap != AC_WID_AUD_IN) {
10257 spec->adc_nids = alc268_adc_nids_alt;
10258 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10259 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010260 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010261 spec->num_mixers++;
10262 } else {
10263 spec->adc_nids = alc268_adc_nids;
10264 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10265 spec->mixers[spec->num_mixers] =
10266 alc268_capture_mixer;
10267 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010268 }
10269 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010270
10271 spec->vmaster_nid = 0x02;
10272
Kailang Yanga361d842007-06-05 12:30:55 +020010273 codec->patch_ops = alc_patch_ops;
10274 if (board_config == ALC268_AUTO)
10275 spec->init_hook = alc268_auto_init;
10276
10277 return 0;
10278}
10279
10280/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010281 * ALC269 channel source setting (2 channel)
10282 */
10283#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10284
10285#define alc269_dac_nids alc260_dac_nids
10286
10287static hda_nid_t alc269_adc_nids[1] = {
10288 /* ADC1 */
10289 0x07,
10290};
10291
10292#define alc269_modes alc260_modes
10293#define alc269_capture_source alc880_lg_lw_capture_source
10294
10295static struct snd_kcontrol_new alc269_base_mixer[] = {
10296 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10297 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10302 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10303 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10304 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10305 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10307 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10308 { } /* end */
10309};
10310
10311/* capture mixer elements */
10312static struct snd_kcontrol_new alc269_capture_mixer[] = {
10313 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10314 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10315 {
10316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10317 /* The multiple "Capture Source" controls confuse alsamixer
10318 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010319 */
10320 /* .name = "Capture Source", */
10321 .name = "Input Source",
10322 .count = 1,
10323 .info = alc_mux_enum_info,
10324 .get = alc_mux_enum_get,
10325 .put = alc_mux_enum_put,
10326 },
10327 { } /* end */
10328};
10329
10330/*
10331 * generic initialization of ADC, input mixers and output mixers
10332 */
10333static struct hda_verb alc269_init_verbs[] = {
10334 /*
10335 * Unmute ADC0 and set the default input to mic-in
10336 */
10337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10338
10339 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10340 * analog-loopback mixer widget
10341 * Note: PASD motherboards uses the Line In 2 as the input for
10342 * front panel mic (mic 2)
10343 */
10344 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10350
10351 /*
10352 * Set up output mixers (0x0c - 0x0e)
10353 */
10354 /* set vol=0 to output mixers */
10355 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10356 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10357
10358 /* set up input amps for analog loopback */
10359 /* Amp Indices: DAC = 0, mixer = 1 */
10360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10366
10367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10370 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10372 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10374
10375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10377 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10378 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10379 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10382
10383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10385
10386 /* FIXME: use matrix-type input source selection */
10387 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10393
10394 /* set EAPD */
10395 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10396 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10397 { }
10398};
10399
10400/* add playback controls from the parsed DAC table */
10401static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10402 const struct auto_pin_cfg *cfg)
10403{
10404 hda_nid_t nid;
10405 int err;
10406
10407 spec->multiout.num_dacs = 1; /* only use one dac */
10408 spec->multiout.dac_nids = spec->private_dac_nids;
10409 spec->multiout.dac_nids[0] = 2;
10410
10411 nid = cfg->line_out_pins[0];
10412 if (nid) {
10413 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10414 "Front Playback Volume",
10415 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10416 if (err < 0)
10417 return err;
10418 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10419 "Front Playback Switch",
10420 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10421 if (err < 0)
10422 return err;
10423 }
10424
10425 nid = cfg->speaker_pins[0];
10426 if (nid) {
10427 if (!cfg->line_out_pins[0]) {
10428 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10429 "Speaker Playback Volume",
10430 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10431 HDA_OUTPUT));
10432 if (err < 0)
10433 return err;
10434 }
10435 if (nid == 0x16) {
10436 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10437 "Speaker Playback Switch",
10438 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10439 HDA_OUTPUT));
10440 if (err < 0)
10441 return err;
10442 } else {
10443 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10444 "Speaker Playback Switch",
10445 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10446 HDA_OUTPUT));
10447 if (err < 0)
10448 return err;
10449 }
10450 }
10451 nid = cfg->hp_pins[0];
10452 if (nid) {
10453 /* spec->multiout.hp_nid = 2; */
10454 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10455 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10456 "Headphone Playback Volume",
10457 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10458 HDA_OUTPUT));
10459 if (err < 0)
10460 return err;
10461 }
10462 if (nid == 0x16) {
10463 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10464 "Headphone Playback Switch",
10465 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10466 HDA_OUTPUT));
10467 if (err < 0)
10468 return err;
10469 } else {
10470 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10471 "Headphone Playback Switch",
10472 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10473 HDA_OUTPUT));
10474 if (err < 0)
10475 return err;
10476 }
10477 }
10478 return 0;
10479}
10480
10481#define alc269_auto_create_analog_input_ctls \
10482 alc880_auto_create_analog_input_ctls
10483
10484#ifdef CONFIG_SND_HDA_POWER_SAVE
10485#define alc269_loopbacks alc880_loopbacks
10486#endif
10487
10488/* pcm configuration: identiacal with ALC880 */
10489#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10490#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10491#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10492#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10493
10494/*
10495 * BIOS auto configuration
10496 */
10497static int alc269_parse_auto_config(struct hda_codec *codec)
10498{
10499 struct alc_spec *spec = codec->spec;
10500 int err;
10501 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10502
10503 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10504 alc269_ignore);
10505 if (err < 0)
10506 return err;
10507
10508 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10509 if (err < 0)
10510 return err;
10511 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10512 if (err < 0)
10513 return err;
10514
10515 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10516
10517 if (spec->autocfg.dig_out_pin)
10518 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10519
10520 if (spec->kctl_alloc)
10521 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10522
10523 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10524 spec->num_mux_defs = 1;
10525 spec->input_mux = &spec->private_imux;
10526
10527 err = alc_auto_add_mic_boost(codec);
10528 if (err < 0)
10529 return err;
10530
10531 return 1;
10532}
10533
10534#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10535#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10536#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10537
10538
10539/* init callback for auto-configuration model -- overriding the default init */
10540static void alc269_auto_init(struct hda_codec *codec)
10541{
10542 alc269_auto_init_multi_out(codec);
10543 alc269_auto_init_hp_out(codec);
10544 alc269_auto_init_analog_input(codec);
10545}
10546
10547/*
10548 * configuration and preset
10549 */
10550static const char *alc269_models[ALC269_MODEL_LAST] = {
10551 [ALC269_BASIC] = "basic",
10552};
10553
10554static struct snd_pci_quirk alc269_cfg_tbl[] = {
10555 {}
10556};
10557
10558static struct alc_config_preset alc269_presets[] = {
10559 [ALC269_BASIC] = {
10560 .mixers = { alc269_base_mixer },
10561 .init_verbs = { alc269_init_verbs },
10562 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10563 .dac_nids = alc269_dac_nids,
10564 .hp_nid = 0x03,
10565 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10566 .channel_mode = alc269_modes,
10567 .input_mux = &alc269_capture_source,
10568 },
10569};
10570
10571static int patch_alc269(struct hda_codec *codec)
10572{
10573 struct alc_spec *spec;
10574 int board_config;
10575 int err;
10576
10577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10578 if (spec == NULL)
10579 return -ENOMEM;
10580
10581 codec->spec = spec;
10582
10583 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10584 alc269_models,
10585 alc269_cfg_tbl);
10586
10587 if (board_config < 0) {
10588 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10589 "trying auto-probe from BIOS...\n");
10590 board_config = ALC269_AUTO;
10591 }
10592
10593 if (board_config == ALC269_AUTO) {
10594 /* automatic parse from the BIOS config */
10595 err = alc269_parse_auto_config(codec);
10596 if (err < 0) {
10597 alc_free(codec);
10598 return err;
10599 } else if (!err) {
10600 printk(KERN_INFO
10601 "hda_codec: Cannot set up configuration "
10602 "from BIOS. Using base mode...\n");
10603 board_config = ALC269_BASIC;
10604 }
10605 }
10606
10607 if (board_config != ALC269_AUTO)
10608 setup_preset(spec, &alc269_presets[board_config]);
10609
10610 spec->stream_name_analog = "ALC269 Analog";
10611 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10612 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10613
10614 spec->stream_name_digital = "ALC269 Digital";
10615 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10616 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10617
10618 spec->adc_nids = alc269_adc_nids;
10619 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10620 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10621 spec->num_mixers++;
10622
10623 codec->patch_ops = alc_patch_ops;
10624 if (board_config == ALC269_AUTO)
10625 spec->init_hook = alc269_auto_init;
10626#ifdef CONFIG_SND_HDA_POWER_SAVE
10627 if (!spec->loopback.amplist)
10628 spec->loopback.amplist = alc269_loopbacks;
10629#endif
10630
10631 return 0;
10632}
10633
10634/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010635 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10636 */
10637
10638/*
10639 * set the path ways for 2 channel output
10640 * need to set the codec line out and mic 1 pin widgets to inputs
10641 */
10642static struct hda_verb alc861_threestack_ch2_init[] = {
10643 /* set pin widget 1Ah (line in) for input */
10644 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010645 /* set pin widget 18h (mic1/2) for input, for mic also enable
10646 * the vref
10647 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010648 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10649
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10651#if 0
10652 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10653 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10654#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010655 { } /* end */
10656};
10657/*
10658 * 6ch mode
10659 * need to set the codec line out and mic 1 pin widgets to outputs
10660 */
10661static struct hda_verb alc861_threestack_ch6_init[] = {
10662 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10663 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10664 /* set pin widget 18h (mic1) for output (CLFE)*/
10665 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10666
10667 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010668 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010669
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010670 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10671#if 0
10672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10673 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10674#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010675 { } /* end */
10676};
10677
10678static struct hda_channel_mode alc861_threestack_modes[2] = {
10679 { 2, alc861_threestack_ch2_init },
10680 { 6, alc861_threestack_ch6_init },
10681};
Takashi Iwai22309c32006-08-09 16:57:28 +020010682/* Set mic1 as input and unmute the mixer */
10683static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10684 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10685 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10686 { } /* end */
10687};
10688/* Set mic1 as output and mute mixer */
10689static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10690 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10692 { } /* end */
10693};
10694
10695static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10696 { 2, alc861_uniwill_m31_ch2_init },
10697 { 4, alc861_uniwill_m31_ch4_init },
10698};
Kailang Yangdf694da2005-12-05 19:42:22 +010010699
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010700/* Set mic1 and line-in as input and unmute the mixer */
10701static struct hda_verb alc861_asus_ch2_init[] = {
10702 /* set pin widget 1Ah (line in) for input */
10703 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010704 /* set pin widget 18h (mic1/2) for input, for mic also enable
10705 * the vref
10706 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010707 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10708
10709 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10710#if 0
10711 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10713#endif
10714 { } /* end */
10715};
10716/* Set mic1 nad line-in as output and mute mixer */
10717static struct hda_verb alc861_asus_ch6_init[] = {
10718 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10719 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10720 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10721 /* set pin widget 18h (mic1) for output (CLFE)*/
10722 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10723 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10724 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10725 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10726
10727 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10728#if 0
10729 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10731#endif
10732 { } /* end */
10733};
10734
10735static struct hda_channel_mode alc861_asus_modes[2] = {
10736 { 2, alc861_asus_ch2_init },
10737 { 6, alc861_asus_ch6_init },
10738};
10739
Kailang Yangdf694da2005-12-05 19:42:22 +010010740/* patch-ALC861 */
10741
10742static struct snd_kcontrol_new alc861_base_mixer[] = {
10743 /* output mixer control */
10744 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10745 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10746 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10747 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10748 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10749
10750 /*Input mixer control */
10751 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10752 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10753 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10754 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10756 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10758 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10759 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010761
Kailang Yangdf694da2005-12-05 19:42:22 +010010762 /* Capture mixer control */
10763 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10764 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10765 {
10766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10767 .name = "Capture Source",
10768 .count = 1,
10769 .info = alc_mux_enum_info,
10770 .get = alc_mux_enum_get,
10771 .put = alc_mux_enum_put,
10772 },
10773 { } /* end */
10774};
10775
10776static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10777 /* output mixer control */
10778 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10779 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10780 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10781 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10782 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10783
10784 /* Input mixer control */
10785 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10786 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10787 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10788 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10790 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10792 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10793 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010795
Kailang Yangdf694da2005-12-05 19:42:22 +010010796 /* Capture mixer control */
10797 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10798 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10799 {
10800 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10801 .name = "Capture Source",
10802 .count = 1,
10803 .info = alc_mux_enum_info,
10804 .get = alc_mux_enum_get,
10805 .put = alc_mux_enum_put,
10806 },
10807 {
10808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10809 .name = "Channel Mode",
10810 .info = alc_ch_mode_info,
10811 .get = alc_ch_mode_get,
10812 .put = alc_ch_mode_put,
10813 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10814 },
10815 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010816};
10817
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010818static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010819 /* output mixer control */
10820 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10822 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10823
10824 /*Capture mixer control */
10825 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10826 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10827 {
10828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10829 .name = "Capture Source",
10830 .count = 1,
10831 .info = alc_mux_enum_info,
10832 .get = alc_mux_enum_get,
10833 .put = alc_mux_enum_put,
10834 },
10835
10836 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010837};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010838
Takashi Iwai22309c32006-08-09 16:57:28 +020010839static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10840 /* output mixer control */
10841 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10842 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10843 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10844 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10845 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10846
10847 /* Input mixer control */
10848 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10849 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10850 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10851 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10852 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10853 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10855 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10856 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010858
Takashi Iwai22309c32006-08-09 16:57:28 +020010859 /* Capture mixer control */
10860 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10861 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10862 {
10863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10864 .name = "Capture Source",
10865 .count = 1,
10866 .info = alc_mux_enum_info,
10867 .get = alc_mux_enum_get,
10868 .put = alc_mux_enum_put,
10869 },
10870 {
10871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10872 .name = "Channel Mode",
10873 .info = alc_ch_mode_info,
10874 .get = alc_ch_mode_get,
10875 .put = alc_ch_mode_put,
10876 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10877 },
10878 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010879};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010880
10881static struct snd_kcontrol_new alc861_asus_mixer[] = {
10882 /* output mixer control */
10883 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10886 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10887 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10888
10889 /* Input mixer control */
10890 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10891 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10892 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10893 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10894 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10895 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10897 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10900
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010901 /* Capture mixer control */
10902 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10903 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10904 {
10905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10906 .name = "Capture Source",
10907 .count = 1,
10908 .info = alc_mux_enum_info,
10909 .get = alc_mux_enum_get,
10910 .put = alc_mux_enum_put,
10911 },
10912 {
10913 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10914 .name = "Channel Mode",
10915 .info = alc_ch_mode_info,
10916 .get = alc_ch_mode_get,
10917 .put = alc_ch_mode_put,
10918 .private_value = ARRAY_SIZE(alc861_asus_modes),
10919 },
10920 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010921};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010922
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010923/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010924static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010925 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10926 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10927 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10928 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10929 { }
10930};
10931
Kailang Yangdf694da2005-12-05 19:42:22 +010010932/*
10933 * generic initialization of ADC, input mixers and output mixers
10934 */
10935static struct hda_verb alc861_base_init_verbs[] = {
10936 /*
10937 * Unmute ADC0 and set the default input to mic-in
10938 */
10939 /* port-A for surround (rear panel) */
10940 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10941 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10942 /* port-B for mic-in (rear panel) with vref */
10943 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10944 /* port-C for line-in (rear panel) */
10945 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10946 /* port-D for Front */
10947 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10948 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10949 /* port-E for HP out (front panel) */
10950 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10951 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010952 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010953 /* port-F for mic-in (front panel) with vref */
10954 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10955 /* port-G for CLFE (rear panel) */
10956 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10957 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10958 /* port-H for side (rear panel) */
10959 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10960 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10961 /* CD-in */
10962 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10963 /* route front mic to ADC1*/
10964 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10966
10967 /* Unmute DAC0~3 & spdif out*/
10968 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10969 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10970 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10971 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10973
10974 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10975 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10979
10980 /* Unmute Stereo Mixer 15 */
10981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010985
10986 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10988 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010994 /* hp used DAC 3 (Front) */
10995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10997
10998 { }
10999};
11000
11001static struct hda_verb alc861_threestack_init_verbs[] = {
11002 /*
11003 * Unmute ADC0 and set the default input to mic-in
11004 */
11005 /* port-A for surround (rear panel) */
11006 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11007 /* port-B for mic-in (rear panel) with vref */
11008 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11009 /* port-C for line-in (rear panel) */
11010 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11011 /* port-D for Front */
11012 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11013 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11014 /* port-E for HP out (front panel) */
11015 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11016 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011017 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011018 /* port-F for mic-in (front panel) with vref */
11019 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11020 /* port-G for CLFE (rear panel) */
11021 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11022 /* port-H for side (rear panel) */
11023 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11024 /* CD-in */
11025 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11026 /* route front mic to ADC1*/
11027 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029 /* Unmute DAC0~3 & spdif out*/
11030 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11032 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11035
11036 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11037 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11040 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11041
11042 /* Unmute Stereo Mixer 15 */
11043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011047
11048 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11051 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11055 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011056 /* hp used DAC 3 (Front) */
11057 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011058 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11059 { }
11060};
Takashi Iwai22309c32006-08-09 16:57:28 +020011061
11062static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11063 /*
11064 * Unmute ADC0 and set the default input to mic-in
11065 */
11066 /* port-A for surround (rear panel) */
11067 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11068 /* port-B for mic-in (rear panel) with vref */
11069 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11070 /* port-C for line-in (rear panel) */
11071 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11072 /* port-D for Front */
11073 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11074 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11075 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011076 /* this has to be set to VREF80 */
11077 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011078 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011079 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011080 /* port-F for mic-in (front panel) with vref */
11081 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11082 /* port-G for CLFE (rear panel) */
11083 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11084 /* port-H for side (rear panel) */
11085 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11086 /* CD-in */
11087 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11088 /* route front mic to ADC1*/
11089 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 /* Unmute DAC0~3 & spdif out*/
11092 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11093 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11094 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11095 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11097
11098 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11099 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11100 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11101 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11102 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11103
11104 /* Unmute Stereo Mixer 15 */
11105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11107 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011109
11110 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11113 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11114 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11116 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011118 /* hp used DAC 3 (Front) */
11119 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011120 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11121 { }
11122};
11123
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011124static struct hda_verb alc861_asus_init_verbs[] = {
11125 /*
11126 * Unmute ADC0 and set the default input to mic-in
11127 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011128 /* port-A for surround (rear panel)
11129 * according to codec#0 this is the HP jack
11130 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011131 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11132 /* route front PCM to HP */
11133 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11134 /* port-B for mic-in (rear panel) with vref */
11135 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11136 /* port-C for line-in (rear panel) */
11137 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11138 /* port-D for Front */
11139 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11140 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11141 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011142 /* this has to be set to VREF80 */
11143 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011144 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011145 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011146 /* port-F for mic-in (front panel) with vref */
11147 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11148 /* port-G for CLFE (rear panel) */
11149 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11150 /* port-H for side (rear panel) */
11151 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11152 /* CD-in */
11153 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11154 /* route front mic to ADC1*/
11155 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11157 /* Unmute DAC0~3 & spdif out*/
11158 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11159 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11161 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11163 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11164 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11167 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11168
11169 /* Unmute Stereo Mixer 15 */
11170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011174
11175 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11176 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11177 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11178 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011183 /* hp used DAC 3 (Front) */
11184 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11186 { }
11187};
11188
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011189/* additional init verbs for ASUS laptops */
11190static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11191 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11192 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11193 { }
11194};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011195
Kailang Yangdf694da2005-12-05 19:42:22 +010011196/*
11197 * generic initialization of ADC, input mixers and output mixers
11198 */
11199static struct hda_verb alc861_auto_init_verbs[] = {
11200 /*
11201 * Unmute ADC0 and set the default input to mic-in
11202 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011203 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11205
11206 /* Unmute DAC0~3 & spdif out*/
11207 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11210 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11212
11213 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11214 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11215 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11216 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11217 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11218
11219 /* Unmute Stereo Mixer 15 */
11220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11224
11225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11233
11234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11235 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11237 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011238 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011240 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011243 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011244
11245 { }
11246};
11247
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011248static struct hda_verb alc861_toshiba_init_verbs[] = {
11249 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011250
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011251 { }
11252};
11253
11254/* toggle speaker-output according to the hp-jack state */
11255static void alc861_toshiba_automute(struct hda_codec *codec)
11256{
11257 unsigned int present;
11258
11259 present = snd_hda_codec_read(codec, 0x0f, 0,
11260 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011261 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11262 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11263 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11264 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011265}
11266
11267static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11268 unsigned int res)
11269{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011270 if ((res >> 26) == ALC880_HP_EVENT)
11271 alc861_toshiba_automute(codec);
11272}
11273
Kailang Yangdf694da2005-12-05 19:42:22 +010011274/* pcm configuration: identiacal with ALC880 */
11275#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11276#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11277#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11278#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11279
11280
11281#define ALC861_DIGOUT_NID 0x07
11282
11283static struct hda_channel_mode alc861_8ch_modes[1] = {
11284 { 8, NULL }
11285};
11286
11287static hda_nid_t alc861_dac_nids[4] = {
11288 /* front, surround, clfe, side */
11289 0x03, 0x06, 0x05, 0x04
11290};
11291
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011292static hda_nid_t alc660_dac_nids[3] = {
11293 /* front, clfe, surround */
11294 0x03, 0x05, 0x06
11295};
11296
Kailang Yangdf694da2005-12-05 19:42:22 +010011297static hda_nid_t alc861_adc_nids[1] = {
11298 /* ADC0-2 */
11299 0x08,
11300};
11301
11302static struct hda_input_mux alc861_capture_source = {
11303 .num_items = 5,
11304 .items = {
11305 { "Mic", 0x0 },
11306 { "Front Mic", 0x3 },
11307 { "Line", 0x1 },
11308 { "CD", 0x4 },
11309 { "Mixer", 0x5 },
11310 },
11311};
11312
11313/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011314static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11315 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011316{
11317 int i;
11318 hda_nid_t nid;
11319
11320 spec->multiout.dac_nids = spec->private_dac_nids;
11321 for (i = 0; i < cfg->line_outs; i++) {
11322 nid = cfg->line_out_pins[i];
11323 if (nid) {
11324 if (i >= ARRAY_SIZE(alc861_dac_nids))
11325 continue;
11326 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11327 }
11328 }
11329 spec->multiout.num_dacs = cfg->line_outs;
11330 return 0;
11331}
11332
11333/* add playback controls from the parsed DAC table */
11334static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11335 const struct auto_pin_cfg *cfg)
11336{
11337 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011338 static const char *chname[4] = {
11339 "Front", "Surround", NULL /*CLFE*/, "Side"
11340 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011341 hda_nid_t nid;
11342 int i, idx, err;
11343
11344 for (i = 0; i < cfg->line_outs; i++) {
11345 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011346 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011347 continue;
11348 if (nid == 0x05) {
11349 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011350 err = add_control(spec, ALC_CTL_BIND_MUTE,
11351 "Center Playback Switch",
11352 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11353 HDA_OUTPUT));
11354 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011356 err = add_control(spec, ALC_CTL_BIND_MUTE,
11357 "LFE Playback Switch",
11358 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11359 HDA_OUTPUT));
11360 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011361 return err;
11362 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011363 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11364 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011365 if (nid == alc861_dac_nids[idx])
11366 break;
11367 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011368 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11369 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11370 HDA_OUTPUT));
11371 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011372 return err;
11373 }
11374 }
11375 return 0;
11376}
11377
11378static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11379{
11380 int err;
11381 hda_nid_t nid;
11382
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011383 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 return 0;
11385
11386 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11387 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011388 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11389 "Headphone Playback Switch",
11390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11391 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011392 return err;
11393 spec->multiout.hp_nid = nid;
11394 }
11395 return 0;
11396}
11397
11398/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011399static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11400 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011401{
Kailang Yangdf694da2005-12-05 19:42:22 +010011402 struct hda_input_mux *imux = &spec->private_imux;
11403 int i, err, idx, idx1;
11404
11405 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011406 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011407 case 0x0c:
11408 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011409 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011410 break;
11411 case 0x0f:
11412 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011413 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011414 break;
11415 case 0x0d:
11416 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011417 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011418 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011419 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011420 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011421 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011422 break;
11423 case 0x11:
11424 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011425 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011426 break;
11427 default:
11428 continue;
11429 }
11430
Takashi Iwai4a471b72005-12-07 13:56:29 +010011431 err = new_analog_input(spec, cfg->input_pins[i],
11432 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011433 if (err < 0)
11434 return err;
11435
Takashi Iwai4a471b72005-12-07 13:56:29 +010011436 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011437 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011438 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011439 }
11440 return 0;
11441}
11442
11443static struct snd_kcontrol_new alc861_capture_mixer[] = {
11444 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11445 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11446
11447 {
11448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11449 /* The multiple "Capture Source" controls confuse alsamixer
11450 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011451 */
11452 /* .name = "Capture Source", */
11453 .name = "Input Source",
11454 .count = 1,
11455 .info = alc_mux_enum_info,
11456 .get = alc_mux_enum_get,
11457 .put = alc_mux_enum_put,
11458 },
11459 { } /* end */
11460};
11461
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011462static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11463 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011464 int pin_type, int dac_idx)
11465{
11466 /* set as output */
11467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011468 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 pin_type);
11470 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11471 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011472
11473}
11474
11475static void alc861_auto_init_multi_out(struct hda_codec *codec)
11476{
11477 struct alc_spec *spec = codec->spec;
11478 int i;
11479
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011480 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011481 for (i = 0; i < spec->autocfg.line_outs; i++) {
11482 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011483 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011484 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011485 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011486 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011487 }
11488}
11489
11490static void alc861_auto_init_hp_out(struct hda_codec *codec)
11491{
11492 struct alc_spec *spec = codec->spec;
11493 hda_nid_t pin;
11494
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011495 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011496 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011497 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11498 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011499}
11500
11501static void alc861_auto_init_analog_input(struct hda_codec *codec)
11502{
11503 struct alc_spec *spec = codec->spec;
11504 int i;
11505
11506 for (i = 0; i < AUTO_PIN_LAST; i++) {
11507 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011508 if (nid >= 0x0c && nid <= 0x11) {
11509 snd_hda_codec_write(codec, nid, 0,
11510 AC_VERB_SET_PIN_WIDGET_CONTROL,
11511 i <= AUTO_PIN_FRONT_MIC ?
11512 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011513 }
11514 }
11515}
11516
11517/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011518/* return 1 if successful, 0 if the proper config is not found,
11519 * or a negative error code
11520 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011521static int alc861_parse_auto_config(struct hda_codec *codec)
11522{
11523 struct alc_spec *spec = codec->spec;
11524 int err;
11525 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11526
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011527 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11528 alc861_ignore);
11529 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011530 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011531 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011532 return 0; /* can't find valid BIOS pin config */
11533
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011534 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11535 if (err < 0)
11536 return err;
11537 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11538 if (err < 0)
11539 return err;
11540 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11541 if (err < 0)
11542 return err;
11543 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11544 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011545 return err;
11546
11547 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11548
11549 if (spec->autocfg.dig_out_pin)
11550 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11551
11552 if (spec->kctl_alloc)
11553 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11554
11555 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11556
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011557 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011558 spec->input_mux = &spec->private_imux;
11559
11560 spec->adc_nids = alc861_adc_nids;
11561 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11562 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11563 spec->num_mixers++;
11564
11565 return 1;
11566}
11567
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011568/* additional initialization for auto-configuration model */
11569static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011570{
Kailang Yangdf694da2005-12-05 19:42:22 +010011571 alc861_auto_init_multi_out(codec);
11572 alc861_auto_init_hp_out(codec);
11573 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011574}
11575
Takashi Iwaicb53c622007-08-10 17:21:45 +020011576#ifdef CONFIG_SND_HDA_POWER_SAVE
11577static struct hda_amp_list alc861_loopbacks[] = {
11578 { 0x15, HDA_INPUT, 0 },
11579 { 0x15, HDA_INPUT, 1 },
11580 { 0x15, HDA_INPUT, 2 },
11581 { 0x15, HDA_INPUT, 3 },
11582 { } /* end */
11583};
11584#endif
11585
Kailang Yangdf694da2005-12-05 19:42:22 +010011586
11587/*
11588 * configuration and preset
11589 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011590static const char *alc861_models[ALC861_MODEL_LAST] = {
11591 [ALC861_3ST] = "3stack",
11592 [ALC660_3ST] = "3stack-660",
11593 [ALC861_3ST_DIG] = "3stack-dig",
11594 [ALC861_6ST_DIG] = "6stack-dig",
11595 [ALC861_UNIWILL_M31] = "uniwill-m31",
11596 [ALC861_TOSHIBA] = "toshiba",
11597 [ALC861_ASUS] = "asus",
11598 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11599 [ALC861_AUTO] = "auto",
11600};
11601
11602static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011603 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011604 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11605 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11606 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011607 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011608 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011609 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011610 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11611 * Any other models that need this preset?
11612 */
11613 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011614 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11615 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011616 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11617 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11618 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11619 /* FIXME: the below seems conflict */
11620 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11621 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11622 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011623 {}
11624};
11625
11626static struct alc_config_preset alc861_presets[] = {
11627 [ALC861_3ST] = {
11628 .mixers = { alc861_3ST_mixer },
11629 .init_verbs = { alc861_threestack_init_verbs },
11630 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11631 .dac_nids = alc861_dac_nids,
11632 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11633 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011634 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011635 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11636 .adc_nids = alc861_adc_nids,
11637 .input_mux = &alc861_capture_source,
11638 },
11639 [ALC861_3ST_DIG] = {
11640 .mixers = { alc861_base_mixer },
11641 .init_verbs = { alc861_threestack_init_verbs },
11642 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11643 .dac_nids = alc861_dac_nids,
11644 .dig_out_nid = ALC861_DIGOUT_NID,
11645 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11646 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011647 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011648 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11649 .adc_nids = alc861_adc_nids,
11650 .input_mux = &alc861_capture_source,
11651 },
11652 [ALC861_6ST_DIG] = {
11653 .mixers = { alc861_base_mixer },
11654 .init_verbs = { alc861_base_init_verbs },
11655 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11656 .dac_nids = alc861_dac_nids,
11657 .dig_out_nid = ALC861_DIGOUT_NID,
11658 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11659 .channel_mode = alc861_8ch_modes,
11660 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11661 .adc_nids = alc861_adc_nids,
11662 .input_mux = &alc861_capture_source,
11663 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011664 [ALC660_3ST] = {
11665 .mixers = { alc861_3ST_mixer },
11666 .init_verbs = { alc861_threestack_init_verbs },
11667 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11668 .dac_nids = alc660_dac_nids,
11669 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11670 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011671 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011672 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11673 .adc_nids = alc861_adc_nids,
11674 .input_mux = &alc861_capture_source,
11675 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011676 [ALC861_UNIWILL_M31] = {
11677 .mixers = { alc861_uniwill_m31_mixer },
11678 .init_verbs = { alc861_uniwill_m31_init_verbs },
11679 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11680 .dac_nids = alc861_dac_nids,
11681 .dig_out_nid = ALC861_DIGOUT_NID,
11682 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11683 .channel_mode = alc861_uniwill_m31_modes,
11684 .need_dac_fix = 1,
11685 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11686 .adc_nids = alc861_adc_nids,
11687 .input_mux = &alc861_capture_source,
11688 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011689 [ALC861_TOSHIBA] = {
11690 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011691 .init_verbs = { alc861_base_init_verbs,
11692 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011693 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11694 .dac_nids = alc861_dac_nids,
11695 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11696 .channel_mode = alc883_3ST_2ch_modes,
11697 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11698 .adc_nids = alc861_adc_nids,
11699 .input_mux = &alc861_capture_source,
11700 .unsol_event = alc861_toshiba_unsol_event,
11701 .init_hook = alc861_toshiba_automute,
11702 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011703 [ALC861_ASUS] = {
11704 .mixers = { alc861_asus_mixer },
11705 .init_verbs = { alc861_asus_init_verbs },
11706 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11707 .dac_nids = alc861_dac_nids,
11708 .dig_out_nid = ALC861_DIGOUT_NID,
11709 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11710 .channel_mode = alc861_asus_modes,
11711 .need_dac_fix = 1,
11712 .hp_nid = 0x06,
11713 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11714 .adc_nids = alc861_adc_nids,
11715 .input_mux = &alc861_capture_source,
11716 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011717 [ALC861_ASUS_LAPTOP] = {
11718 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11719 .init_verbs = { alc861_asus_init_verbs,
11720 alc861_asus_laptop_init_verbs },
11721 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11722 .dac_nids = alc861_dac_nids,
11723 .dig_out_nid = ALC861_DIGOUT_NID,
11724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11725 .channel_mode = alc883_3ST_2ch_modes,
11726 .need_dac_fix = 1,
11727 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11728 .adc_nids = alc861_adc_nids,
11729 .input_mux = &alc861_capture_source,
11730 },
11731};
Kailang Yangdf694da2005-12-05 19:42:22 +010011732
11733
11734static int patch_alc861(struct hda_codec *codec)
11735{
11736 struct alc_spec *spec;
11737 int board_config;
11738 int err;
11739
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011740 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011741 if (spec == NULL)
11742 return -ENOMEM;
11743
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011744 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011745
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011746 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11747 alc861_models,
11748 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011749
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011750 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011751 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11752 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011753 board_config = ALC861_AUTO;
11754 }
11755
11756 if (board_config == ALC861_AUTO) {
11757 /* automatic parse from the BIOS config */
11758 err = alc861_parse_auto_config(codec);
11759 if (err < 0) {
11760 alc_free(codec);
11761 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011762 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011763 printk(KERN_INFO
11764 "hda_codec: Cannot set up configuration "
11765 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011766 board_config = ALC861_3ST_DIG;
11767 }
11768 }
11769
11770 if (board_config != ALC861_AUTO)
11771 setup_preset(spec, &alc861_presets[board_config]);
11772
11773 spec->stream_name_analog = "ALC861 Analog";
11774 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11775 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11776
11777 spec->stream_name_digital = "ALC861 Digital";
11778 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11779 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11780
Takashi Iwai2134ea42008-01-10 16:53:55 +010011781 spec->vmaster_nid = 0x03;
11782
Kailang Yangdf694da2005-12-05 19:42:22 +010011783 codec->patch_ops = alc_patch_ops;
11784 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011785 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011786#ifdef CONFIG_SND_HDA_POWER_SAVE
11787 if (!spec->loopback.amplist)
11788 spec->loopback.amplist = alc861_loopbacks;
11789#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011790
11791 return 0;
11792}
11793
11794/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011795 * ALC861-VD support
11796 *
11797 * Based on ALC882
11798 *
11799 * In addition, an independent DAC
11800 */
11801#define ALC861VD_DIGOUT_NID 0x06
11802
11803static hda_nid_t alc861vd_dac_nids[4] = {
11804 /* front, surr, clfe, side surr */
11805 0x02, 0x03, 0x04, 0x05
11806};
11807
11808/* dac_nids for ALC660vd are in a different order - according to
11809 * Realtek's driver.
11810 * This should probably tesult in a different mixer for 6stack models
11811 * of ALC660vd codecs, but for now there is only 3stack mixer
11812 * - and it is the same as in 861vd.
11813 * adc_nids in ALC660vd are (is) the same as in 861vd
11814 */
11815static hda_nid_t alc660vd_dac_nids[3] = {
11816 /* front, rear, clfe, rear_surr */
11817 0x02, 0x04, 0x03
11818};
11819
11820static hda_nid_t alc861vd_adc_nids[1] = {
11821 /* ADC0 */
11822 0x09,
11823};
11824
11825/* input MUX */
11826/* FIXME: should be a matrix-type input source selection */
11827static struct hda_input_mux alc861vd_capture_source = {
11828 .num_items = 4,
11829 .items = {
11830 { "Mic", 0x0 },
11831 { "Front Mic", 0x1 },
11832 { "Line", 0x2 },
11833 { "CD", 0x4 },
11834 },
11835};
11836
Kailang Yang272a5272007-05-14 11:00:38 +020011837static struct hda_input_mux alc861vd_dallas_capture_source = {
11838 .num_items = 3,
11839 .items = {
11840 { "Front Mic", 0x0 },
11841 { "ATAPI Mic", 0x1 },
11842 { "Line In", 0x5 },
11843 },
11844};
11845
Kailang Yangd1a991a2007-08-15 16:21:59 +020011846static struct hda_input_mux alc861vd_hp_capture_source = {
11847 .num_items = 2,
11848 .items = {
11849 { "Front Mic", 0x0 },
11850 { "ATAPI Mic", 0x1 },
11851 },
11852};
11853
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011854#define alc861vd_mux_enum_info alc_mux_enum_info
11855#define alc861vd_mux_enum_get alc_mux_enum_get
11856
11857static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11858 struct snd_ctl_elem_value *ucontrol)
11859{
11860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11861 struct alc_spec *spec = codec->spec;
11862 const struct hda_input_mux *imux = spec->input_mux;
11863 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11864 static hda_nid_t capture_mixers[1] = { 0x22 };
11865 hda_nid_t nid = capture_mixers[adc_idx];
11866 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11867 unsigned int i, idx;
11868
11869 idx = ucontrol->value.enumerated.item[0];
11870 if (idx >= imux->num_items)
11871 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011872 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011873 return 0;
11874 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011875 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11876 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11877 imux->items[i].index,
11878 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011879 }
11880 *cur_val = idx;
11881 return 1;
11882}
11883
11884/*
11885 * 2ch mode
11886 */
11887static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11888 { 2, NULL }
11889};
11890
11891/*
11892 * 6ch mode
11893 */
11894static struct hda_verb alc861vd_6stack_ch6_init[] = {
11895 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11896 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11897 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11898 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11899 { } /* end */
11900};
11901
11902/*
11903 * 8ch mode
11904 */
11905static struct hda_verb alc861vd_6stack_ch8_init[] = {
11906 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11907 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11909 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11910 { } /* end */
11911};
11912
11913static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11914 { 6, alc861vd_6stack_ch6_init },
11915 { 8, alc861vd_6stack_ch8_init },
11916};
11917
11918static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11919 {
11920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11921 .name = "Channel Mode",
11922 .info = alc_ch_mode_info,
11923 .get = alc_ch_mode_get,
11924 .put = alc_ch_mode_put,
11925 },
11926 { } /* end */
11927};
11928
11929static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11930 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11931 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11932
11933 {
11934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11935 /* The multiple "Capture Source" controls confuse alsamixer
11936 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011937 */
11938 /* .name = "Capture Source", */
11939 .name = "Input Source",
11940 .count = 1,
11941 .info = alc861vd_mux_enum_info,
11942 .get = alc861vd_mux_enum_get,
11943 .put = alc861vd_mux_enum_put,
11944 },
11945 { } /* end */
11946};
11947
11948/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11949 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11950 */
11951static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11952 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11953 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11954
11955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11956 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11957
11958 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11959 HDA_OUTPUT),
11960 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11961 HDA_OUTPUT),
11962 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11963 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11964
11965 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11966 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11967
11968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11969
11970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11973
11974 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11977
11978 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11979 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11980
11981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11983
11984 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11985 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11986
11987 { } /* end */
11988};
11989
11990static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11991 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11993
11994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11995
11996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11999
12000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12003
12004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12006
12007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12009
12010 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12011 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12012
12013 { } /* end */
12014};
12015
Kailang Yangbdd148a2007-05-08 15:19:08 +020012016static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12017 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12018 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12019 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12020
12021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12022
12023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12026
12027 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12030
12031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12033
12034 { } /* end */
12035};
12036
Kailang Yang272a5272007-05-14 11:00:38 +020012037/* Pin assignment: Front=0x14, HP = 0x15,
12038 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12039 */
12040static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12041 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12046 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12048 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012051 { } /* end */
12052};
12053
Kailang Yangd1a991a2007-08-15 16:21:59 +020012054/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12055 * Front Mic=0x18, ATAPI Mic = 0x19,
12056 */
12057static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12058 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12059 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12060 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12061 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12064 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12065 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12066
12067 { } /* end */
12068};
12069
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012070/*
12071 * generic initialization of ADC, input mixers and output mixers
12072 */
12073static struct hda_verb alc861vd_volume_init_verbs[] = {
12074 /*
12075 * Unmute ADC0 and set the default input to mic-in
12076 */
12077 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12078 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12079
12080 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12081 * the analog-loopback mixer widget
12082 */
12083 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012089
12090 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012095
12096 /*
12097 * Set up output mixers (0x02 - 0x05)
12098 */
12099 /* set vol=0 to output mixers */
12100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12103 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12104
12105 /* set up input amps for analog loopback */
12106 /* Amp Indices: DAC = 0, mixer = 1 */
12107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12114 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12115
12116 { }
12117};
12118
12119/*
12120 * 3-stack pin configuration:
12121 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12122 */
12123static struct hda_verb alc861vd_3stack_init_verbs[] = {
12124 /*
12125 * Set pin mode and muting
12126 */
12127 /* set front pin widgets 0x14 for output */
12128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12130 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12131
12132 /* Mic (rear) pin: input vref at 80% */
12133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12135 /* Front Mic pin: input vref at 80% */
12136 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12138 /* Line In pin: input */
12139 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12141 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12142 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12143 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12144 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12145 /* CD pin widget for input */
12146 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12147
12148 { }
12149};
12150
12151/*
12152 * 6-stack pin configuration:
12153 */
12154static struct hda_verb alc861vd_6stack_init_verbs[] = {
12155 /*
12156 * Set pin mode and muting
12157 */
12158 /* set front pin widgets 0x14 for output */
12159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12160 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12161 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12162
12163 /* Rear Pin: output 1 (0x0d) */
12164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12166 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12167 /* CLFE Pin: output 2 (0x0e) */
12168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12169 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12170 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12171 /* Side Pin: output 3 (0x0f) */
12172 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12173 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12174 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12175
12176 /* Mic (rear) pin: input vref at 80% */
12177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12179 /* Front Mic pin: input vref at 80% */
12180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12182 /* Line In pin: input */
12183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12184 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12185 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12188 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12189 /* CD pin widget for input */
12190 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12191
12192 { }
12193};
12194
Kailang Yangbdd148a2007-05-08 15:19:08 +020012195static struct hda_verb alc861vd_eapd_verbs[] = {
12196 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12197 { }
12198};
12199
12200static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12204 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12205 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12206 {}
12207};
12208
12209/* toggle speaker-output according to the hp-jack state */
12210static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12211{
12212 unsigned int present;
12213 unsigned char bits;
12214
12215 present = snd_hda_codec_read(codec, 0x1b, 0,
12216 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012217 bits = present ? HDA_AMP_MUTE : 0;
12218 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12219 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012220}
12221
12222static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12223{
12224 unsigned int present;
12225 unsigned char bits;
12226
12227 present = snd_hda_codec_read(codec, 0x18, 0,
12228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012229 bits = present ? HDA_AMP_MUTE : 0;
12230 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12231 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012232}
12233
12234static void alc861vd_lenovo_automute(struct hda_codec *codec)
12235{
12236 alc861vd_lenovo_hp_automute(codec);
12237 alc861vd_lenovo_mic_automute(codec);
12238}
12239
12240static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12241 unsigned int res)
12242{
12243 switch (res >> 26) {
12244 case ALC880_HP_EVENT:
12245 alc861vd_lenovo_hp_automute(codec);
12246 break;
12247 case ALC880_MIC_EVENT:
12248 alc861vd_lenovo_mic_automute(codec);
12249 break;
12250 }
12251}
12252
Kailang Yang272a5272007-05-14 11:00:38 +020012253static struct hda_verb alc861vd_dallas_verbs[] = {
12254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12258
12259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12267
12268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12276
12277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12285
12286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12290
12291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12294
12295 { } /* end */
12296};
12297
12298/* toggle speaker-output according to the hp-jack state */
12299static void alc861vd_dallas_automute(struct hda_codec *codec)
12300{
12301 unsigned int present;
12302
12303 present = snd_hda_codec_read(codec, 0x15, 0,
12304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012305 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12306 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012307}
12308
12309static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12310{
12311 if ((res >> 26) == ALC880_HP_EVENT)
12312 alc861vd_dallas_automute(codec);
12313}
12314
Takashi Iwaicb53c622007-08-10 17:21:45 +020012315#ifdef CONFIG_SND_HDA_POWER_SAVE
12316#define alc861vd_loopbacks alc880_loopbacks
12317#endif
12318
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012319/* pcm configuration: identiacal with ALC880 */
12320#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12321#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12322#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12323#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12324
12325/*
12326 * configuration and preset
12327 */
12328static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12329 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012330 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012331 [ALC861VD_3ST] = "3stack",
12332 [ALC861VD_3ST_DIG] = "3stack-digout",
12333 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012334 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012335 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012336 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012337 [ALC861VD_AUTO] = "auto",
12338};
12339
12340static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012341 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12342 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012343 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012344 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012345 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012346 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012347 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012348 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012349 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012350 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012351 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012352 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12353 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012354 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012355 {}
12356};
12357
12358static struct alc_config_preset alc861vd_presets[] = {
12359 [ALC660VD_3ST] = {
12360 .mixers = { alc861vd_3st_mixer },
12361 .init_verbs = { alc861vd_volume_init_verbs,
12362 alc861vd_3stack_init_verbs },
12363 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12364 .dac_nids = alc660vd_dac_nids,
12365 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12366 .adc_nids = alc861vd_adc_nids,
12367 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12368 .channel_mode = alc861vd_3stack_2ch_modes,
12369 .input_mux = &alc861vd_capture_source,
12370 },
Mike Crash6963f842007-06-25 12:12:51 +020012371 [ALC660VD_3ST_DIG] = {
12372 .mixers = { alc861vd_3st_mixer },
12373 .init_verbs = { alc861vd_volume_init_verbs,
12374 alc861vd_3stack_init_verbs },
12375 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12376 .dac_nids = alc660vd_dac_nids,
12377 .dig_out_nid = ALC861VD_DIGOUT_NID,
12378 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12379 .adc_nids = alc861vd_adc_nids,
12380 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12381 .channel_mode = alc861vd_3stack_2ch_modes,
12382 .input_mux = &alc861vd_capture_source,
12383 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012384 [ALC861VD_3ST] = {
12385 .mixers = { alc861vd_3st_mixer },
12386 .init_verbs = { alc861vd_volume_init_verbs,
12387 alc861vd_3stack_init_verbs },
12388 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12389 .dac_nids = alc861vd_dac_nids,
12390 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12391 .channel_mode = alc861vd_3stack_2ch_modes,
12392 .input_mux = &alc861vd_capture_source,
12393 },
12394 [ALC861VD_3ST_DIG] = {
12395 .mixers = { alc861vd_3st_mixer },
12396 .init_verbs = { alc861vd_volume_init_verbs,
12397 alc861vd_3stack_init_verbs },
12398 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12399 .dac_nids = alc861vd_dac_nids,
12400 .dig_out_nid = ALC861VD_DIGOUT_NID,
12401 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12402 .channel_mode = alc861vd_3stack_2ch_modes,
12403 .input_mux = &alc861vd_capture_source,
12404 },
12405 [ALC861VD_6ST_DIG] = {
12406 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12407 .init_verbs = { alc861vd_volume_init_verbs,
12408 alc861vd_6stack_init_verbs },
12409 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12410 .dac_nids = alc861vd_dac_nids,
12411 .dig_out_nid = ALC861VD_DIGOUT_NID,
12412 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12413 .channel_mode = alc861vd_6stack_modes,
12414 .input_mux = &alc861vd_capture_source,
12415 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012416 [ALC861VD_LENOVO] = {
12417 .mixers = { alc861vd_lenovo_mixer },
12418 .init_verbs = { alc861vd_volume_init_verbs,
12419 alc861vd_3stack_init_verbs,
12420 alc861vd_eapd_verbs,
12421 alc861vd_lenovo_unsol_verbs },
12422 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12423 .dac_nids = alc660vd_dac_nids,
12424 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12425 .adc_nids = alc861vd_adc_nids,
12426 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12427 .channel_mode = alc861vd_3stack_2ch_modes,
12428 .input_mux = &alc861vd_capture_source,
12429 .unsol_event = alc861vd_lenovo_unsol_event,
12430 .init_hook = alc861vd_lenovo_automute,
12431 },
Kailang Yang272a5272007-05-14 11:00:38 +020012432 [ALC861VD_DALLAS] = {
12433 .mixers = { alc861vd_dallas_mixer },
12434 .init_verbs = { alc861vd_dallas_verbs },
12435 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12436 .dac_nids = alc861vd_dac_nids,
12437 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12438 .adc_nids = alc861vd_adc_nids,
12439 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12440 .channel_mode = alc861vd_3stack_2ch_modes,
12441 .input_mux = &alc861vd_dallas_capture_source,
12442 .unsol_event = alc861vd_dallas_unsol_event,
12443 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012444 },
12445 [ALC861VD_HP] = {
12446 .mixers = { alc861vd_hp_mixer },
12447 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12448 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12449 .dac_nids = alc861vd_dac_nids,
12450 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12451 .dig_out_nid = ALC861VD_DIGOUT_NID,
12452 .adc_nids = alc861vd_adc_nids,
12453 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12454 .channel_mode = alc861vd_3stack_2ch_modes,
12455 .input_mux = &alc861vd_hp_capture_source,
12456 .unsol_event = alc861vd_dallas_unsol_event,
12457 .init_hook = alc861vd_dallas_automute,
12458 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012459};
12460
12461/*
12462 * BIOS auto configuration
12463 */
12464static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12465 hda_nid_t nid, int pin_type, int dac_idx)
12466{
12467 /* set as output */
12468 snd_hda_codec_write(codec, nid, 0,
12469 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12470 snd_hda_codec_write(codec, nid, 0,
12471 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12472}
12473
12474static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12475{
12476 struct alc_spec *spec = codec->spec;
12477 int i;
12478
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012479 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012480 for (i = 0; i <= HDA_SIDE; i++) {
12481 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012482 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012483 if (nid)
12484 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012485 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012486 }
12487}
12488
12489
12490static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12491{
12492 struct alc_spec *spec = codec->spec;
12493 hda_nid_t pin;
12494
12495 pin = spec->autocfg.hp_pins[0];
12496 if (pin) /* connect to front and use dac 0 */
12497 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12498}
12499
12500#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12501#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12502
12503static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12504{
12505 struct alc_spec *spec = codec->spec;
12506 int i;
12507
12508 for (i = 0; i < AUTO_PIN_LAST; i++) {
12509 hda_nid_t nid = spec->autocfg.input_pins[i];
12510 if (alc861vd_is_input_pin(nid)) {
12511 snd_hda_codec_write(codec, nid, 0,
12512 AC_VERB_SET_PIN_WIDGET_CONTROL,
12513 i <= AUTO_PIN_FRONT_MIC ?
12514 PIN_VREF80 : PIN_IN);
12515 if (nid != ALC861VD_PIN_CD_NID)
12516 snd_hda_codec_write(codec, nid, 0,
12517 AC_VERB_SET_AMP_GAIN_MUTE,
12518 AMP_OUT_MUTE);
12519 }
12520 }
12521}
12522
12523#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12524#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12525
12526/* add playback controls from the parsed DAC table */
12527/* Based on ALC880 version. But ALC861VD has separate,
12528 * different NIDs for mute/unmute switch and volume control */
12529static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12530 const struct auto_pin_cfg *cfg)
12531{
12532 char name[32];
12533 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12534 hda_nid_t nid_v, nid_s;
12535 int i, err;
12536
12537 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012538 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012539 continue;
12540 nid_v = alc861vd_idx_to_mixer_vol(
12541 alc880_dac_to_idx(
12542 spec->multiout.dac_nids[i]));
12543 nid_s = alc861vd_idx_to_mixer_switch(
12544 alc880_dac_to_idx(
12545 spec->multiout.dac_nids[i]));
12546
12547 if (i == 2) {
12548 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012549 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12550 "Center Playback Volume",
12551 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12552 HDA_OUTPUT));
12553 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012555 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12556 "LFE Playback Volume",
12557 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12558 HDA_OUTPUT));
12559 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012560 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012561 err = add_control(spec, ALC_CTL_BIND_MUTE,
12562 "Center Playback Switch",
12563 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12564 HDA_INPUT));
12565 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012566 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012567 err = add_control(spec, ALC_CTL_BIND_MUTE,
12568 "LFE Playback Switch",
12569 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12570 HDA_INPUT));
12571 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012572 return err;
12573 } else {
12574 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012575 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12576 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12577 HDA_OUTPUT));
12578 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012579 return err;
12580 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012581 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012582 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012583 HDA_INPUT));
12584 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012585 return err;
12586 }
12587 }
12588 return 0;
12589}
12590
12591/* add playback controls for speaker and HP outputs */
12592/* Based on ALC880 version. But ALC861VD has separate,
12593 * different NIDs for mute/unmute switch and volume control */
12594static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12595 hda_nid_t pin, const char *pfx)
12596{
12597 hda_nid_t nid_v, nid_s;
12598 int err;
12599 char name[32];
12600
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012601 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012602 return 0;
12603
12604 if (alc880_is_fixed_pin(pin)) {
12605 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12606 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012607 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012608 spec->multiout.hp_nid = nid_v;
12609 else
12610 spec->multiout.extra_out_nid[0] = nid_v;
12611 /* control HP volume/switch on the output mixer amp */
12612 nid_v = alc861vd_idx_to_mixer_vol(
12613 alc880_fixed_pin_idx(pin));
12614 nid_s = alc861vd_idx_to_mixer_switch(
12615 alc880_fixed_pin_idx(pin));
12616
12617 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012618 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12619 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12620 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012621 return err;
12622 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012623 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12624 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12625 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012626 return err;
12627 } else if (alc880_is_multi_pin(pin)) {
12628 /* set manual connection */
12629 /* we have only a switch on HP-out PIN */
12630 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012631 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12632 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12633 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012634 return err;
12635 }
12636 return 0;
12637}
12638
12639/* parse the BIOS configuration and set up the alc_spec
12640 * return 1 if successful, 0 if the proper config is not found,
12641 * or a negative error code
12642 * Based on ALC880 version - had to change it to override
12643 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12644static int alc861vd_parse_auto_config(struct hda_codec *codec)
12645{
12646 struct alc_spec *spec = codec->spec;
12647 int err;
12648 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12649
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012650 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12651 alc861vd_ignore);
12652 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012653 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012654 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012655 return 0; /* can't find valid BIOS pin config */
12656
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012657 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12658 if (err < 0)
12659 return err;
12660 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12661 if (err < 0)
12662 return err;
12663 err = alc861vd_auto_create_extra_out(spec,
12664 spec->autocfg.speaker_pins[0],
12665 "Speaker");
12666 if (err < 0)
12667 return err;
12668 err = alc861vd_auto_create_extra_out(spec,
12669 spec->autocfg.hp_pins[0],
12670 "Headphone");
12671 if (err < 0)
12672 return err;
12673 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12674 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012675 return err;
12676
12677 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12678
12679 if (spec->autocfg.dig_out_pin)
12680 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12681
12682 if (spec->kctl_alloc)
12683 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12684
12685 spec->init_verbs[spec->num_init_verbs++]
12686 = alc861vd_volume_init_verbs;
12687
12688 spec->num_mux_defs = 1;
12689 spec->input_mux = &spec->private_imux;
12690
Takashi Iwai776e1842007-08-29 15:07:11 +020012691 err = alc_auto_add_mic_boost(codec);
12692 if (err < 0)
12693 return err;
12694
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012695 return 1;
12696}
12697
12698/* additional initialization for auto-configuration model */
12699static void alc861vd_auto_init(struct hda_codec *codec)
12700{
12701 alc861vd_auto_init_multi_out(codec);
12702 alc861vd_auto_init_hp_out(codec);
12703 alc861vd_auto_init_analog_input(codec);
12704}
12705
12706static int patch_alc861vd(struct hda_codec *codec)
12707{
12708 struct alc_spec *spec;
12709 int err, board_config;
12710
12711 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12712 if (spec == NULL)
12713 return -ENOMEM;
12714
12715 codec->spec = spec;
12716
12717 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12718 alc861vd_models,
12719 alc861vd_cfg_tbl);
12720
12721 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12722 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12723 "ALC861VD, trying auto-probe from BIOS...\n");
12724 board_config = ALC861VD_AUTO;
12725 }
12726
12727 if (board_config == ALC861VD_AUTO) {
12728 /* automatic parse from the BIOS config */
12729 err = alc861vd_parse_auto_config(codec);
12730 if (err < 0) {
12731 alc_free(codec);
12732 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012733 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012734 printk(KERN_INFO
12735 "hda_codec: Cannot set up configuration "
12736 "from BIOS. Using base mode...\n");
12737 board_config = ALC861VD_3ST;
12738 }
12739 }
12740
12741 if (board_config != ALC861VD_AUTO)
12742 setup_preset(spec, &alc861vd_presets[board_config]);
12743
12744 spec->stream_name_analog = "ALC861VD Analog";
12745 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12746 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12747
12748 spec->stream_name_digital = "ALC861VD Digital";
12749 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12750 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12751
12752 spec->adc_nids = alc861vd_adc_nids;
12753 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12754
12755 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12756 spec->num_mixers++;
12757
Takashi Iwai2134ea42008-01-10 16:53:55 +010012758 spec->vmaster_nid = 0x02;
12759
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012760 codec->patch_ops = alc_patch_ops;
12761
12762 if (board_config == ALC861VD_AUTO)
12763 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012764#ifdef CONFIG_SND_HDA_POWER_SAVE
12765 if (!spec->loopback.amplist)
12766 spec->loopback.amplist = alc861vd_loopbacks;
12767#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012768
12769 return 0;
12770}
12771
12772/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012773 * ALC662 support
12774 *
12775 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12776 * configuration. Each pin widget can choose any input DACs and a mixer.
12777 * Each ADC is connected from a mixer of all inputs. This makes possible
12778 * 6-channel independent captures.
12779 *
12780 * In addition, an independent DAC for the multi-playback (not used in this
12781 * driver yet).
12782 */
12783#define ALC662_DIGOUT_NID 0x06
12784#define ALC662_DIGIN_NID 0x0a
12785
12786static hda_nid_t alc662_dac_nids[4] = {
12787 /* front, rear, clfe, rear_surr */
12788 0x02, 0x03, 0x04
12789};
12790
12791static hda_nid_t alc662_adc_nids[1] = {
12792 /* ADC1-2 */
12793 0x09,
12794};
12795/* input MUX */
12796/* FIXME: should be a matrix-type input source selection */
12797
12798static struct hda_input_mux alc662_capture_source = {
12799 .num_items = 4,
12800 .items = {
12801 { "Mic", 0x0 },
12802 { "Front Mic", 0x1 },
12803 { "Line", 0x2 },
12804 { "CD", 0x4 },
12805 },
12806};
12807
12808static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12809 .num_items = 2,
12810 .items = {
12811 { "Mic", 0x1 },
12812 { "Line", 0x2 },
12813 },
12814};
Kailang Yang291702f2007-10-16 14:28:03 +020012815
12816static struct hda_input_mux alc662_eeepc_capture_source = {
12817 .num_items = 2,
12818 .items = {
12819 { "i-Mic", 0x1 },
12820 { "e-Mic", 0x0 },
12821 },
12822};
12823
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012824#define alc662_mux_enum_info alc_mux_enum_info
12825#define alc662_mux_enum_get alc_mux_enum_get
12826
12827static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12828 struct snd_ctl_elem_value *ucontrol)
12829{
12830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12831 struct alc_spec *spec = codec->spec;
12832 const struct hda_input_mux *imux = spec->input_mux;
12833 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012834 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012835 hda_nid_t nid = capture_mixers[adc_idx];
12836 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12837 unsigned int i, idx;
12838
12839 idx = ucontrol->value.enumerated.item[0];
12840 if (idx >= imux->num_items)
12841 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012842 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012843 return 0;
12844 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012845 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12846 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12847 imux->items[i].index,
12848 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012849 }
12850 *cur_val = idx;
12851 return 1;
12852}
12853/*
12854 * 2ch mode
12855 */
12856static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12857 { 2, NULL }
12858};
12859
12860/*
12861 * 2ch mode
12862 */
12863static struct hda_verb alc662_3ST_ch2_init[] = {
12864 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12865 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12868 { } /* end */
12869};
12870
12871/*
12872 * 6ch mode
12873 */
12874static struct hda_verb alc662_3ST_ch6_init[] = {
12875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12877 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12880 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12881 { } /* end */
12882};
12883
12884static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12885 { 2, alc662_3ST_ch2_init },
12886 { 6, alc662_3ST_ch6_init },
12887};
12888
12889/*
12890 * 2ch mode
12891 */
12892static struct hda_verb alc662_sixstack_ch6_init[] = {
12893 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12894 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12895 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12896 { } /* end */
12897};
12898
12899/*
12900 * 6ch mode
12901 */
12902static struct hda_verb alc662_sixstack_ch8_init[] = {
12903 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12904 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12905 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12906 { } /* end */
12907};
12908
12909static struct hda_channel_mode alc662_5stack_modes[2] = {
12910 { 2, alc662_sixstack_ch6_init },
12911 { 6, alc662_sixstack_ch8_init },
12912};
12913
12914/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12915 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12916 */
12917
12918static struct snd_kcontrol_new alc662_base_mixer[] = {
12919 /* output mixer control */
12920 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12921 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12929
12930 /*Input mixer control */
12931 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12932 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12934 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12935 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12936 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012939 { } /* end */
12940};
12941
12942static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12948 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12949 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12954 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12955 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012956 { } /* end */
12957};
12958
12959static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12960 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12977 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12978 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012979 { } /* end */
12980};
12981
12982static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12983 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12984 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010012985 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12986 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012992 { } /* end */
12993};
12994
Kailang Yang291702f2007-10-16 14:28:03 +020012995static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010012996 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020012997
12998 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12999 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13000
13001 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13002 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13003 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13004
13005 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13006 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13007 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13008 { } /* end */
13009};
13010
Kailang Yang8c427222008-01-10 13:03:59 +010013011static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13012 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13013 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13015 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13017 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013020 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013021 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13026 { } /* end */
13027};
13028
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013029static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13030 {
13031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13032 .name = "Channel Mode",
13033 .info = alc_ch_mode_info,
13034 .get = alc_ch_mode_get,
13035 .put = alc_ch_mode_put,
13036 },
13037 { } /* end */
13038};
13039
13040static struct hda_verb alc662_init_verbs[] = {
13041 /* ADC: mute amp left and right */
13042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13043 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13044 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13045
Takashi Iwaicb53c622007-08-10 17:21:45 +020013046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013051
Kailang Yangb60dd392007-09-20 12:50:29 +020013052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013058
13059 /* Front Pin: output 0 (0x0c) */
13060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13062
13063 /* Rear Pin: output 1 (0x0d) */
13064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13066
13067 /* CLFE Pin: output 2 (0x0e) */
13068 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13070
13071 /* Mic (rear) pin: input vref at 80% */
13072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13074 /* Front Mic pin: input vref at 80% */
13075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13077 /* Line In pin: input */
13078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13080 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13082 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13083 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13084 /* CD pin widget for input */
13085 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13086
13087 /* FIXME: use matrix-type input source selection */
13088 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13089 /* Input mixer */
13090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013094
13095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013099 { }
13100};
13101
13102static struct hda_verb alc662_sue_init_verbs[] = {
13103 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13104 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013105 {}
13106};
13107
13108static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13111 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013112};
13113
Kailang Yang8c427222008-01-10 13:03:59 +010013114/* Set Unsolicited Event*/
13115static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13117 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13118 {}
13119};
13120
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013121/*
13122 * generic initialization of ADC, input mixers and output mixers
13123 */
13124static struct hda_verb alc662_auto_init_verbs[] = {
13125 /*
13126 * Unmute ADC and set the default input to mic-in
13127 */
13128 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13130
13131 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13132 * mixer widget
13133 * Note: PASD motherboards uses the Line In 2 as the input for front
13134 * panel mic (mic 2)
13135 */
13136 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013142
13143 /*
13144 * Set up output mixers (0x0c - 0x0f)
13145 */
13146 /* set vol=0 to output mixers */
13147 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13148 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13150
13151 /* set up input amps for analog loopback */
13152 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13156 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013159
13160
13161 /* FIXME: use matrix-type input source selection */
13162 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13163 /* Input mixer */
13164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013166 { }
13167};
13168
13169/* capture mixer elements */
13170static struct snd_kcontrol_new alc662_capture_mixer[] = {
13171 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13172 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13173 {
13174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13175 /* The multiple "Capture Source" controls confuse alsamixer
13176 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013177 */
13178 /* .name = "Capture Source", */
13179 .name = "Input Source",
13180 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013181 .info = alc662_mux_enum_info,
13182 .get = alc662_mux_enum_get,
13183 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013184 },
13185 { } /* end */
13186};
13187
13188static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13189{
13190 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013191 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013192
13193 present = snd_hda_codec_read(codec, 0x14, 0,
13194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013195 bits = present ? HDA_AMP_MUTE : 0;
13196 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13197 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013198}
13199
13200static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13201{
13202 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013203 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013204
13205 present = snd_hda_codec_read(codec, 0x1b, 0,
13206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013207 bits = present ? HDA_AMP_MUTE : 0;
13208 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13209 HDA_AMP_MUTE, bits);
13210 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13211 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013212}
13213
13214static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13215 unsigned int res)
13216{
13217 if ((res >> 26) == ALC880_HP_EVENT)
13218 alc662_lenovo_101e_all_automute(codec);
13219 if ((res >> 26) == ALC880_FRONT_EVENT)
13220 alc662_lenovo_101e_ispeaker_automute(codec);
13221}
13222
Kailang Yang291702f2007-10-16 14:28:03 +020013223static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13224{
13225 unsigned int present;
13226
13227 present = snd_hda_codec_read(codec, 0x18, 0,
13228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13229 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13230 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13231 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13232 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13233 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13234 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13235 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13236 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13237}
13238
13239/* unsolicited event for HP jack sensing */
13240static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13241 unsigned int res)
13242{
13243 if ((res >> 26) == ALC880_HP_EVENT)
13244 alc262_hippo1_automute( codec );
13245
13246 if ((res >> 26) == ALC880_MIC_EVENT)
13247 alc662_eeepc_mic_automute(codec);
13248}
13249
13250static void alc662_eeepc_inithook(struct hda_codec *codec)
13251{
13252 alc262_hippo1_automute( codec );
13253 alc662_eeepc_mic_automute(codec);
13254}
13255
Kailang Yang8c427222008-01-10 13:03:59 +010013256static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13257{
13258 unsigned int mute;
13259 unsigned int present;
13260
13261 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13262 present = snd_hda_codec_read(codec, 0x14, 0,
13263 AC_VERB_GET_PIN_SENSE, 0);
13264 present = (present & 0x80000000) != 0;
13265 if (present) {
13266 /* mute internal speaker */
13267 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13268 HDA_AMP_MUTE, HDA_AMP_MUTE);
13269 } else {
13270 /* unmute internal speaker if necessary */
13271 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13272 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13273 HDA_AMP_MUTE, mute);
13274 }
13275}
13276
13277/* unsolicited event for HP jack sensing */
13278static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13279 unsigned int res)
13280{
13281 if ((res >> 26) == ALC880_HP_EVENT)
13282 alc662_eeepc_ep20_automute(codec);
13283}
13284
13285static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13286{
13287 alc662_eeepc_ep20_automute(codec);
13288}
13289
Takashi Iwaicb53c622007-08-10 17:21:45 +020013290#ifdef CONFIG_SND_HDA_POWER_SAVE
13291#define alc662_loopbacks alc880_loopbacks
13292#endif
13293
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013294
13295/* pcm configuration: identiacal with ALC880 */
13296#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13297#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13298#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13299#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13300
13301/*
13302 * configuration and preset
13303 */
13304static const char *alc662_models[ALC662_MODEL_LAST] = {
13305 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13306 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13307 [ALC662_3ST_6ch] = "3stack-6ch",
13308 [ALC662_5ST_DIG] = "6stack-dig",
13309 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013310 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013311 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013312 [ALC662_AUTO] = "auto",
13313};
13314
13315static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013316 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013317 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013318 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013319 {}
13320};
13321
13322static struct alc_config_preset alc662_presets[] = {
13323 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013324 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013325 .init_verbs = { alc662_init_verbs },
13326 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13327 .dac_nids = alc662_dac_nids,
13328 .dig_out_nid = ALC662_DIGOUT_NID,
13329 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13330 .adc_nids = alc662_adc_nids,
13331 .dig_in_nid = ALC662_DIGIN_NID,
13332 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13333 .channel_mode = alc662_3ST_2ch_modes,
13334 .input_mux = &alc662_capture_source,
13335 },
13336 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013337 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13338 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013339 .init_verbs = { alc662_init_verbs },
13340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13341 .dac_nids = alc662_dac_nids,
13342 .dig_out_nid = ALC662_DIGOUT_NID,
13343 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13344 .adc_nids = alc662_adc_nids,
13345 .dig_in_nid = ALC662_DIGIN_NID,
13346 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13347 .channel_mode = alc662_3ST_6ch_modes,
13348 .need_dac_fix = 1,
13349 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013350 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013351 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013352 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13353 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013354 .init_verbs = { alc662_init_verbs },
13355 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13356 .dac_nids = alc662_dac_nids,
13357 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13358 .adc_nids = alc662_adc_nids,
13359 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13360 .channel_mode = alc662_3ST_6ch_modes,
13361 .need_dac_fix = 1,
13362 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013363 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013364 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013365 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13366 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013367 .init_verbs = { alc662_init_verbs },
13368 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13369 .dac_nids = alc662_dac_nids,
13370 .dig_out_nid = ALC662_DIGOUT_NID,
13371 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13372 .adc_nids = alc662_adc_nids,
13373 .dig_in_nid = ALC662_DIGIN_NID,
13374 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13375 .channel_mode = alc662_5stack_modes,
13376 .input_mux = &alc662_capture_source,
13377 },
13378 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013379 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013380 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13381 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13382 .dac_nids = alc662_dac_nids,
13383 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13384 .adc_nids = alc662_adc_nids,
13385 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13386 .channel_mode = alc662_3ST_2ch_modes,
13387 .input_mux = &alc662_lenovo_101e_capture_source,
13388 .unsol_event = alc662_lenovo_101e_unsol_event,
13389 .init_hook = alc662_lenovo_101e_all_automute,
13390 },
Kailang Yang291702f2007-10-16 14:28:03 +020013391 [ALC662_ASUS_EEEPC_P701] = {
13392 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13393 .init_verbs = { alc662_init_verbs,
13394 alc662_eeepc_sue_init_verbs },
13395 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13396 .dac_nids = alc662_dac_nids,
13397 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13398 .adc_nids = alc662_adc_nids,
13399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13400 .channel_mode = alc662_3ST_2ch_modes,
13401 .input_mux = &alc662_eeepc_capture_source,
13402 .unsol_event = alc662_eeepc_unsol_event,
13403 .init_hook = alc662_eeepc_inithook,
13404 },
Kailang Yang8c427222008-01-10 13:03:59 +010013405 [ALC662_ASUS_EEEPC_EP20] = {
13406 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13407 alc662_chmode_mixer },
13408 .init_verbs = { alc662_init_verbs,
13409 alc662_eeepc_ep20_sue_init_verbs },
13410 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13411 .dac_nids = alc662_dac_nids,
13412 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13413 .adc_nids = alc662_adc_nids,
13414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13415 .channel_mode = alc662_3ST_6ch_modes,
13416 .input_mux = &alc662_lenovo_101e_capture_source,
13417 .unsol_event = alc662_eeepc_ep20_unsol_event,
13418 .init_hook = alc662_eeepc_ep20_inithook,
13419 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013420
13421};
13422
13423
13424/*
13425 * BIOS auto configuration
13426 */
13427
13428/* add playback controls from the parsed DAC table */
13429static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13430 const struct auto_pin_cfg *cfg)
13431{
13432 char name[32];
13433 static const char *chname[4] = {
13434 "Front", "Surround", NULL /*CLFE*/, "Side"
13435 };
13436 hda_nid_t nid;
13437 int i, err;
13438
13439 for (i = 0; i < cfg->line_outs; i++) {
13440 if (!spec->multiout.dac_nids[i])
13441 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013442 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013443 if (i == 2) {
13444 /* Center/LFE */
13445 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13446 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013447 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13448 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013449 if (err < 0)
13450 return err;
13451 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13452 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013453 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13454 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013455 if (err < 0)
13456 return err;
13457 err = add_control(spec, ALC_CTL_BIND_MUTE,
13458 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013459 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13460 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013461 if (err < 0)
13462 return err;
13463 err = add_control(spec, ALC_CTL_BIND_MUTE,
13464 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013465 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13466 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013467 if (err < 0)
13468 return err;
13469 } else {
13470 sprintf(name, "%s Playback Volume", chname[i]);
13471 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013472 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13473 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013474 if (err < 0)
13475 return err;
13476 sprintf(name, "%s Playback Switch", chname[i]);
13477 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013478 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13479 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013480 if (err < 0)
13481 return err;
13482 }
13483 }
13484 return 0;
13485}
13486
13487/* add playback controls for speaker and HP outputs */
13488static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13489 const char *pfx)
13490{
13491 hda_nid_t nid;
13492 int err;
13493 char name[32];
13494
13495 if (!pin)
13496 return 0;
13497
13498 if (alc880_is_fixed_pin(pin)) {
13499 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13500 /* printk("DAC nid=%x\n",nid); */
13501 /* specify the DAC as the extra output */
13502 if (!spec->multiout.hp_nid)
13503 spec->multiout.hp_nid = nid;
13504 else
13505 spec->multiout.extra_out_nid[0] = nid;
13506 /* control HP volume/switch on the output mixer amp */
13507 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13508 sprintf(name, "%s Playback Volume", pfx);
13509 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13510 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13511 if (err < 0)
13512 return err;
13513 sprintf(name, "%s Playback Switch", pfx);
13514 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13515 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13516 if (err < 0)
13517 return err;
13518 } else if (alc880_is_multi_pin(pin)) {
13519 /* set manual connection */
13520 /* we have only a switch on HP-out PIN */
13521 sprintf(name, "%s Playback Switch", pfx);
13522 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13523 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13524 if (err < 0)
13525 return err;
13526 }
13527 return 0;
13528}
13529
13530/* create playback/capture controls for input pins */
13531static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13532 const struct auto_pin_cfg *cfg)
13533{
13534 struct hda_input_mux *imux = &spec->private_imux;
13535 int i, err, idx;
13536
13537 for (i = 0; i < AUTO_PIN_LAST; i++) {
13538 if (alc880_is_input_pin(cfg->input_pins[i])) {
13539 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13540 err = new_analog_input(spec, cfg->input_pins[i],
13541 auto_pin_cfg_labels[i],
13542 idx, 0x0b);
13543 if (err < 0)
13544 return err;
13545 imux->items[imux->num_items].label =
13546 auto_pin_cfg_labels[i];
13547 imux->items[imux->num_items].index =
13548 alc880_input_pin_idx(cfg->input_pins[i]);
13549 imux->num_items++;
13550 }
13551 }
13552 return 0;
13553}
13554
13555static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13556 hda_nid_t nid, int pin_type,
13557 int dac_idx)
13558{
13559 /* set as output */
13560 snd_hda_codec_write(codec, nid, 0,
13561 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13562 snd_hda_codec_write(codec, nid, 0,
13563 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13564 /* need the manual connection? */
13565 if (alc880_is_multi_pin(nid)) {
13566 struct alc_spec *spec = codec->spec;
13567 int idx = alc880_multi_pin_idx(nid);
13568 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13569 AC_VERB_SET_CONNECT_SEL,
13570 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13571 }
13572}
13573
13574static void alc662_auto_init_multi_out(struct hda_codec *codec)
13575{
13576 struct alc_spec *spec = codec->spec;
13577 int i;
13578
Kailang Yang8c427222008-01-10 13:03:59 +010013579 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013580 for (i = 0; i <= HDA_SIDE; i++) {
13581 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013582 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013583 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013584 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013585 i);
13586 }
13587}
13588
13589static void alc662_auto_init_hp_out(struct hda_codec *codec)
13590{
13591 struct alc_spec *spec = codec->spec;
13592 hda_nid_t pin;
13593
13594 pin = spec->autocfg.hp_pins[0];
13595 if (pin) /* connect to front */
13596 /* use dac 0 */
13597 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13598}
13599
13600#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13601#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13602
13603static void alc662_auto_init_analog_input(struct hda_codec *codec)
13604{
13605 struct alc_spec *spec = codec->spec;
13606 int i;
13607
13608 for (i = 0; i < AUTO_PIN_LAST; i++) {
13609 hda_nid_t nid = spec->autocfg.input_pins[i];
13610 if (alc662_is_input_pin(nid)) {
13611 snd_hda_codec_write(codec, nid, 0,
13612 AC_VERB_SET_PIN_WIDGET_CONTROL,
13613 (i <= AUTO_PIN_FRONT_MIC ?
13614 PIN_VREF80 : PIN_IN));
13615 if (nid != ALC662_PIN_CD_NID)
13616 snd_hda_codec_write(codec, nid, 0,
13617 AC_VERB_SET_AMP_GAIN_MUTE,
13618 AMP_OUT_MUTE);
13619 }
13620 }
13621}
13622
13623static int alc662_parse_auto_config(struct hda_codec *codec)
13624{
13625 struct alc_spec *spec = codec->spec;
13626 int err;
13627 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13628
13629 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13630 alc662_ignore);
13631 if (err < 0)
13632 return err;
13633 if (!spec->autocfg.line_outs)
13634 return 0; /* can't find valid BIOS pin config */
13635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13637 if (err < 0)
13638 return err;
13639 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13640 if (err < 0)
13641 return err;
13642 err = alc662_auto_create_extra_out(spec,
13643 spec->autocfg.speaker_pins[0],
13644 "Speaker");
13645 if (err < 0)
13646 return err;
13647 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13648 "Headphone");
13649 if (err < 0)
13650 return err;
13651 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13652 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013653 return err;
13654
13655 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13656
13657 if (spec->autocfg.dig_out_pin)
13658 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13659
13660 if (spec->kctl_alloc)
13661 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13662
13663 spec->num_mux_defs = 1;
13664 spec->input_mux = &spec->private_imux;
13665
Takashi Iwai8c872862007-06-19 12:11:16 +020013666 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013667 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13668 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020013669 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013670}
13671
13672/* additional initialization for auto-configuration model */
13673static void alc662_auto_init(struct hda_codec *codec)
13674{
13675 alc662_auto_init_multi_out(codec);
13676 alc662_auto_init_hp_out(codec);
13677 alc662_auto_init_analog_input(codec);
13678}
13679
13680static int patch_alc662(struct hda_codec *codec)
13681{
13682 struct alc_spec *spec;
13683 int err, board_config;
13684
13685 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13686 if (!spec)
13687 return -ENOMEM;
13688
13689 codec->spec = spec;
13690
13691 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13692 alc662_models,
13693 alc662_cfg_tbl);
13694 if (board_config < 0) {
13695 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13696 "trying auto-probe from BIOS...\n");
13697 board_config = ALC662_AUTO;
13698 }
13699
13700 if (board_config == ALC662_AUTO) {
13701 /* automatic parse from the BIOS config */
13702 err = alc662_parse_auto_config(codec);
13703 if (err < 0) {
13704 alc_free(codec);
13705 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020013706 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013707 printk(KERN_INFO
13708 "hda_codec: Cannot set up configuration "
13709 "from BIOS. Using base mode...\n");
13710 board_config = ALC662_3ST_2ch_DIG;
13711 }
13712 }
13713
13714 if (board_config != ALC662_AUTO)
13715 setup_preset(spec, &alc662_presets[board_config]);
13716
13717 spec->stream_name_analog = "ALC662 Analog";
13718 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13719 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13720
13721 spec->stream_name_digital = "ALC662 Digital";
13722 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13723 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13724
13725 if (!spec->adc_nids && spec->input_mux) {
13726 spec->adc_nids = alc662_adc_nids;
13727 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13728 }
13729
Takashi Iwai2134ea42008-01-10 16:53:55 +010013730 spec->vmaster_nid = 0x02;
13731
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013732 codec->patch_ops = alc_patch_ops;
13733 if (board_config == ALC662_AUTO)
13734 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013735#ifdef CONFIG_SND_HDA_POWER_SAVE
13736 if (!spec->loopback.amplist)
13737 spec->loopback.amplist = alc662_loopbacks;
13738#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013739
13740 return 0;
13741}
13742
13743/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013744 * patch entries
13745 */
13746struct hda_codec_preset snd_hda_preset_realtek[] = {
13747 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013749 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013750 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013751 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013752 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013753 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013754 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13755 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13756 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013757 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13758 .patch = patch_alc883 },
13759 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13760 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013761 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013762 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013763 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013764 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013765 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013766 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013767 {} /* terminator */
13768};