blob: 6f652afd3cbeb8e88db806097bb042395751358c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115};
116
Kailang Yangf6a92242007-12-13 16:52:54 +0100117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
Kailang Yangdf694da2005-12-05 19:42:22 +0100124/* ALC861 models */
125enum {
126 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200127 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200130 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200131 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200132 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100133 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136};
137
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100138/* ALC861-VD models */
139enum {
140 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200141 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200145 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200146 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200147 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150};
151
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200152/* ALC662 models */
153enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200159 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100160 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163};
164
Kailang Yangdf694da2005-12-05 19:42:22 +0100165/* ALC882 models */
166enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200169 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200170 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200173 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100174 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200175 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200176 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200177 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 ALC882_MODEL_LAST,
179};
180
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200181/* ALC883 models */
182enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200189 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200190 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200191 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200192 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100193 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100200 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100201 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204};
205
Kailang Yangdf694da2005-12-05 19:42:22 +0100206/* for GPIO Poll */
207#define GPIO_MASK 0x03
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209struct alc_spec {
210 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 unsigned int num_mixers;
213
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215 * don't forget NULL
216 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200217 */
218 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Takashi Iwai16ded522005-06-10 19:58:24 +0200220 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
223
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200224 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 struct hda_pcm_stream *stream_digital_playback;
226 struct hda_pcm_stream *stream_digital_capture;
227
228 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200229 struct hda_multi_out multiout; /* playback set-up
230 * max_channels, dacs must be set
231 * dig_out_nid and hp_nid are optional
232 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 /* capture */
235 unsigned int num_adc_nids;
236 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200237 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
239 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200240 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 const struct hda_input_mux *input_mux;
242 unsigned int cur_mux[3];
243
244 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100245 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200247 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100250 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200251
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200252 /* dynamic controls, init_verbs and input_mux */
253 struct auto_pin_cfg autocfg;
254 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100255 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200256 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200257 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100258
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100259 /* hooks */
260 void (*init_hook)(struct hda_codec *codec);
261 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
262
Takashi Iwai834be882006-03-01 14:16:17 +0100263 /* for pin sensing */
264 unsigned int sense_updated: 1;
265 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200266
Takashi Iwai2134ea42008-01-10 16:53:55 +0100267 /* for virtual master */
268 hda_nid_t vmaster_nid;
269 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200270#ifdef CONFIG_SND_HDA_POWER_SAVE
271 struct hda_loopback_check loopback;
272#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100273};
274
275/*
276 * configuration template - to be copied to the spec instance
277 */
278struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279 struct snd_kcontrol_new *mixers[5]; /* should be identical size
280 * with spec
281 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100282 const struct hda_verb *init_verbs[5];
283 unsigned int num_dacs;
284 hda_nid_t *dac_nids;
285 hda_nid_t dig_out_nid; /* optional */
286 hda_nid_t hp_nid; /* optional */
287 unsigned int num_adc_nids;
288 hda_nid_t *adc_nids;
289 hda_nid_t dig_in_nid;
290 unsigned int num_channel_mode;
291 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200292 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200293 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100294 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100295 void (*unsol_event)(struct hda_codec *, unsigned int);
296 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200297#ifdef CONFIG_SND_HDA_POWER_SAVE
298 struct hda_amp_list *loopbacks;
299#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300};
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303/*
304 * input MUX handling
305 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200306static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
307 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308{
309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
310 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200311 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
312 if (mux_idx >= spec->num_mux_defs)
313 mux_idx = 0;
314 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
316
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200317static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
318 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
321 struct alc_spec *spec = codec->spec;
322 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
323
324 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
325 return 0;
326}
327
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200328static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
329 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
332 struct alc_spec *spec = codec->spec;
333 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200334 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
335 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200336 spec->adc_nids[adc_idx],
337 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341/*
342 * channel mode setting
343 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200344static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346{
347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100349 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
350 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351}
352
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200353static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
356 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
357 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359 spec->num_channel_mode,
360 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361}
362
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365{
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
369 spec->num_channel_mode,
370 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200371 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200372 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
373 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100377 * Control the mode of pin widget settings via the mixer. "pc" is used
378 * instead of "%" to avoid consequences of accidently treating the % as
379 * being part of a format specifier. Maximum allowed length of a value is
380 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100381 *
382 * Note: some retasking pin complexes seem to ignore requests for input
383 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
384 * are requested. Therefore order this list so that this behaviour will not
385 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200386 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
387 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200388 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100390 "Mic 50pc bias", "Mic 80pc bias",
391 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392};
393static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100394 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100395};
396/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200397 * in the pin being assumed to be exclusively an input or an output pin. In
398 * addition, "input" pins may or may not process the mic bias option
399 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
400 * accept requests for bias as of chip versions up to March 2006) and/or
401 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100402 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200403#define ALC_PIN_DIR_IN 0x00
404#define ALC_PIN_DIR_OUT 0x01
405#define ALC_PIN_DIR_INOUT 0x02
406#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
407#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100408
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200409/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410 * For each direction the minimum and maximum values are given.
411 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200412static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 { 0, 2 }, /* ALC_PIN_DIR_IN */
414 { 3, 4 }, /* ALC_PIN_DIR_OUT */
415 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
417 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418};
419#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
420#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
421#define alc_pin_mode_n_items(_dir) \
422 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
423
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200426{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427 unsigned int item_num = uinfo->value.enumerated.item;
428 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
429
430 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200431 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
433
434 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
435 item_num = alc_pin_mode_min(dir);
436 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200437 return 0;
438}
439
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200442{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100443 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
445 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
449 AC_VERB_GET_PIN_WIDGET_CONTROL,
450 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200451
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100452 /* Find enumerated value for current pinctl setting */
453 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100455 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457 return 0;
458}
459
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462{
463 signed int change;
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 hda_nid_t nid = kcontrol->private_value & 0xffff;
466 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
467 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
469 AC_VERB_GET_PIN_WIDGET_CONTROL,
470 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200472 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 val = alc_pin_mode_min(dir);
474
475 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100476 if (change) {
477 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200478 snd_hda_codec_write_cache(codec, nid, 0,
479 AC_VERB_SET_PIN_WIDGET_CONTROL,
480 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100481
482 /* Also enable the retasking pin's input/output as required
483 * for the requested pin mode. Enum values of 2 or less are
484 * input modes.
485 *
486 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200487 * reduces noise slightly (particularly on input) so we'll
488 * do it. However, having both input and output buffers
489 * enabled simultaneously doesn't seem to be problematic if
490 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100491 */
492 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200493 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
494 HDA_AMP_MUTE, HDA_AMP_MUTE);
495 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
496 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100497 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
499 HDA_AMP_MUTE, HDA_AMP_MUTE);
500 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
501 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100502 }
503 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200504 return change;
505}
506
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200508 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509 .info = alc_pin_mode_info, \
510 .get = alc_pin_mode_get, \
511 .put = alc_pin_mode_put, \
512 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100513
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100514/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
515 * together using a mask with more than one bit set. This control is
516 * currently used only by the ALC260 test model. At this stage they are not
517 * needed for any "production" models.
518 */
519#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200520#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200521
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100524{
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 hda_nid_t nid = kcontrol->private_value & 0xffff;
527 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
528 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 unsigned int val = snd_hda_codec_read(codec, nid, 0,
530 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100531
532 *valp = (val & mask) != 0;
533 return 0;
534}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100537{
538 signed int change;
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 hda_nid_t nid = kcontrol->private_value & 0xffff;
541 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
542 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
544 AC_VERB_GET_GPIO_DATA,
545 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100546
547 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
549 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100550 gpio_data &= ~mask;
551 else
552 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200553 snd_hda_codec_write_cache(codec, nid, 0,
554 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100555
556 return change;
557}
558#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
559 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
560 .info = alc_gpio_data_info, \
561 .get = alc_gpio_data_get, \
562 .put = alc_gpio_data_put, \
563 .private_value = nid | (mask<<16) }
564#endif /* CONFIG_SND_DEBUG */
565
Jonathan Woithe92621f12006-02-28 11:47:47 +0100566/* A switch control to allow the enabling of the digital IO pins on the
567 * ALC260. This is incredibly simplistic; the intention of this control is
568 * to provide something in the test model allowing digital outputs to be
569 * identified if present. If models are found which can utilise these
570 * outputs a more complete mixer control can be devised for those models if
571 * necessary.
572 */
573#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200574#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200575
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
577 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100578{
579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 hda_nid_t nid = kcontrol->private_value & 0xffff;
581 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
582 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100584 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100585
586 *valp = (val & mask) != 0;
587 return 0;
588}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100591{
592 signed int change;
593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 hda_nid_t nid = kcontrol->private_value & 0xffff;
595 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
596 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100598 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100600
601 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100603 if (val==0)
604 ctrl_data &= ~mask;
605 else
606 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200607 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
608 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100609
610 return change;
611}
612#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
613 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
614 .info = alc_spdif_ctrl_info, \
615 .get = alc_spdif_ctrl_get, \
616 .put = alc_spdif_ctrl_put, \
617 .private_value = nid | (mask<<16) }
618#endif /* CONFIG_SND_DEBUG */
619
Jonathan Woithef8225f62008-01-08 12:16:54 +0100620/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
621 * Again, this is only used in the ALC26x test models to help identify when
622 * the EAPD line must be asserted for features to work.
623 */
624#ifdef CONFIG_SND_DEBUG
625#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
626
627static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 hda_nid_t nid = kcontrol->private_value & 0xffff;
632 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
633 long *valp = ucontrol->value.integer.value;
634 unsigned int val = snd_hda_codec_read(codec, nid, 0,
635 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
636
637 *valp = (val & mask) != 0;
638 return 0;
639}
640
641static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 int change;
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long val = *ucontrol->value.integer.value;
649 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_EAPD_BTLENABLE,
651 0x00);
652
653 /* Set/unset the masked control bit(s) as needed */
654 change = (!val ? 0 : mask) != (ctrl_data & mask);
655 if (!val)
656 ctrl_data &= ~mask;
657 else
658 ctrl_data |= mask;
659 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
660 ctrl_data);
661
662 return change;
663}
664
665#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
666 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
667 .info = alc_eapd_ctrl_info, \
668 .get = alc_eapd_ctrl_get, \
669 .put = alc_eapd_ctrl_put, \
670 .private_value = nid | (mask<<16) }
671#endif /* CONFIG_SND_DEBUG */
672
Kailang Yangdf694da2005-12-05 19:42:22 +0100673/*
674 * set up from the preset table
675 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200676static void setup_preset(struct alc_spec *spec,
677 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100678{
679 int i;
680
681 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
682 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200683 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
684 i++)
685 spec->init_verbs[spec->num_init_verbs++] =
686 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100687
688 spec->channel_mode = preset->channel_mode;
689 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200690 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100691
692 spec->multiout.max_channels = spec->channel_mode[0].channels;
693
694 spec->multiout.num_dacs = preset->num_dacs;
695 spec->multiout.dac_nids = preset->dac_nids;
696 spec->multiout.dig_out_nid = preset->dig_out_nid;
697 spec->multiout.hp_nid = preset->hp_nid;
698
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200699 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200700 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200701 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100702 spec->input_mux = preset->input_mux;
703
704 spec->num_adc_nids = preset->num_adc_nids;
705 spec->adc_nids = preset->adc_nids;
706 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100707
708 spec->unsol_event = preset->unsol_event;
709 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200710#ifdef CONFIG_SND_HDA_POWER_SAVE
711 spec->loopback.amplist = preset->loopbacks;
712#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100713}
714
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200715/* Enable GPIO mask and set output */
716static struct hda_verb alc_gpio1_init_verbs[] = {
717 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
718 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
719 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
720 { }
721};
722
723static struct hda_verb alc_gpio2_init_verbs[] = {
724 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
725 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
726 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
727 { }
728};
729
Kailang Yangbdd148a2007-05-08 15:19:08 +0200730static struct hda_verb alc_gpio3_init_verbs[] = {
731 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
732 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
733 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
734 { }
735};
736
Kailang Yangc9b58002007-10-16 14:30:01 +0200737static void alc_sku_automute(struct hda_codec *codec)
738{
739 struct alc_spec *spec = codec->spec;
740 unsigned int mute;
741 unsigned int present;
742 unsigned int hp_nid = spec->autocfg.hp_pins[0];
743 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
744
745 /* need to execute and sync at first */
746 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
747 present = snd_hda_codec_read(codec, hp_nid, 0,
748 AC_VERB_GET_PIN_SENSE, 0);
749 spec->jack_present = (present & 0x80000000) != 0;
750 if (spec->jack_present) {
751 /* mute internal speaker */
752 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
753 HDA_AMP_MUTE, HDA_AMP_MUTE);
754 } else {
755 /* unmute internal speaker if necessary */
756 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
757 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
758 HDA_AMP_MUTE, mute);
759 }
760}
761
762/* unsolicited event for HP jack sensing */
763static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
764{
765 if (codec->vendor_id == 0x10ec0880)
766 res >>= 28;
767 else
768 res >>= 26;
769 if (res != ALC880_HP_EVENT)
770 return;
771
772 alc_sku_automute(codec);
773}
774
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200775/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
776 * 31 ~ 16 : Manufacture ID
777 * 15 ~ 8 : SKU ID
778 * 7 ~ 0 : Assembly ID
779 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
780 */
781static void alc_subsystem_id(struct hda_codec *codec,
782 unsigned int porta, unsigned int porte,
783 unsigned int portd)
784{
Kailang Yangc9b58002007-10-16 14:30:01 +0200785 unsigned int ass, tmp, i;
786 unsigned nid;
787 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200788
Kailang Yangc9b58002007-10-16 14:30:01 +0200789 ass = codec->subsystem_id & 0xffff;
790 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
791 goto do_sku;
792
793 /*
794 * 31~30 : port conetcivity
795 * 29~21 : reserve
796 * 20 : PCBEEP input
797 * 19~16 : Check sum (15:1)
798 * 15~1 : Custom
799 * 0 : override
800 */
801 nid = 0x1d;
802 if (codec->vendor_id == 0x10ec0260)
803 nid = 0x17;
804 ass = snd_hda_codec_read(codec, nid, 0,
805 AC_VERB_GET_CONFIG_DEFAULT, 0);
806 if (!(ass & 1) && !(ass & 0x100000))
807 return;
808 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200809 return;
810
Kailang Yangc9b58002007-10-16 14:30:01 +0200811 /* check sum */
812 tmp = 0;
813 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100814 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200815 tmp++;
816 }
817 if (((ass >> 16) & 0xf) != tmp)
818 return;
819do_sku:
820 /*
821 * 0 : override
822 * 1 : Swap Jack
823 * 2 : 0 --> Desktop, 1 --> Laptop
824 * 3~5 : External Amplifier control
825 * 7~6 : Reserved
826 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200827 tmp = (ass & 0x38) >> 3; /* external Amp control */
828 switch (tmp) {
829 case 1:
830 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
831 break;
832 case 3:
833 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
834 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200835 case 7:
836 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
837 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200838 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200839 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200840 case 0x10ec0260:
841 snd_hda_codec_write(codec, 0x0f, 0,
842 AC_VERB_SET_EAPD_BTLENABLE, 2);
843 snd_hda_codec_write(codec, 0x10, 0,
844 AC_VERB_SET_EAPD_BTLENABLE, 2);
845 break;
846 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200847 case 0x10ec0267:
848 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200849 case 0x10ec0269:
850 case 0x10ec0862:
851 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200852 snd_hda_codec_write(codec, 0x14, 0,
853 AC_VERB_SET_EAPD_BTLENABLE, 2);
854 snd_hda_codec_write(codec, 0x15, 0,
855 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200856 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200857 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200858 switch (codec->vendor_id) {
859 case 0x10ec0260:
860 snd_hda_codec_write(codec, 0x1a, 0,
861 AC_VERB_SET_COEF_INDEX, 7);
862 tmp = snd_hda_codec_read(codec, 0x1a, 0,
863 AC_VERB_GET_PROC_COEF, 0);
864 snd_hda_codec_write(codec, 0x1a, 0,
865 AC_VERB_SET_COEF_INDEX, 7);
866 snd_hda_codec_write(codec, 0x1a, 0,
867 AC_VERB_SET_PROC_COEF,
868 tmp | 0x2010);
869 break;
870 case 0x10ec0262:
871 case 0x10ec0880:
872 case 0x10ec0882:
873 case 0x10ec0883:
874 case 0x10ec0885:
875 case 0x10ec0888:
876 snd_hda_codec_write(codec, 0x20, 0,
877 AC_VERB_SET_COEF_INDEX, 7);
878 tmp = snd_hda_codec_read(codec, 0x20, 0,
879 AC_VERB_GET_PROC_COEF, 0);
880 snd_hda_codec_write(codec, 0x20, 0,
881 AC_VERB_SET_COEF_INDEX, 7);
882 snd_hda_codec_write(codec, 0x20, 0,
883 AC_VERB_SET_PROC_COEF,
884 tmp | 0x2010);
885 break;
886 case 0x10ec0267:
887 case 0x10ec0268:
888 snd_hda_codec_write(codec, 0x20, 0,
889 AC_VERB_SET_COEF_INDEX, 7);
890 tmp = snd_hda_codec_read(codec, 0x20, 0,
891 AC_VERB_GET_PROC_COEF, 0);
892 snd_hda_codec_write(codec, 0x20, 0,
893 AC_VERB_SET_COEF_INDEX, 7);
894 snd_hda_codec_write(codec, 0x20, 0,
895 AC_VERB_SET_PROC_COEF,
896 tmp | 0x3000);
897 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200898 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200899 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200900 break;
901 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200902
Kailang Yang8c427222008-01-10 13:03:59 +0100903 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200904 * when the external headphone out jack is plugged"
905 */
Kailang Yang8c427222008-01-10 13:03:59 +0100906 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 return;
908 /*
909 * 10~8 : Jack location
910 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
911 * 14~13: Resvered
912 * 15 : 1 --> enable the function "Mute internal speaker
913 * when the external headphone out jack is plugged"
914 */
915 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100916 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200917 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100918 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 else
920 return;
921 }
922
923 if (!spec->autocfg.hp_pins[0]) {
924 tmp = (ass >> 11) & 0x3; /* HP to chassis */
925 if (tmp == 0)
926 spec->autocfg.hp_pins[0] = porta;
927 else if (tmp == 1)
928 spec->autocfg.hp_pins[0] = porte;
929 else if (tmp == 2)
930 spec->autocfg.hp_pins[0] = portd;
931 else
932 return;
933 }
934
935 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
936 AC_VERB_SET_UNSOLICITED_ENABLE,
937 AC_USRSP_EN | ALC880_HP_EVENT);
938 spec->unsol_event = alc_sku_unsol_event;
939 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200940}
941
Takashi Iwai41e41f12005-06-08 14:48:49 +0200942/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200943 * Fix-up pin default configurations
944 */
945
946struct alc_pincfg {
947 hda_nid_t nid;
948 u32 val;
949};
950
951static void alc_fix_pincfg(struct hda_codec *codec,
952 const struct snd_pci_quirk *quirk,
953 const struct alc_pincfg **pinfix)
954{
955 const struct alc_pincfg *cfg;
956
957 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
958 if (!quirk)
959 return;
960
961 cfg = pinfix[quirk->value];
962 for (; cfg->nid; cfg++) {
963 int i;
964 u32 val = cfg->val;
965 for (i = 0; i < 4; i++) {
966 snd_hda_codec_write(codec, cfg->nid, 0,
967 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
968 val & 0xff);
969 val >>= 8;
970 }
971 }
972}
973
974/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200975 * ALC880 3-stack model
976 *
977 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200978 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
979 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 */
981
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200982static hda_nid_t alc880_dac_nids[4] = {
983 /* front, rear, clfe, rear_surr */
984 0x02, 0x05, 0x04, 0x03
985};
986
987static hda_nid_t alc880_adc_nids[3] = {
988 /* ADC0-2 */
989 0x07, 0x08, 0x09,
990};
991
992/* The datasheet says the node 0x07 is connected from inputs,
993 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100994 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200996static hda_nid_t alc880_adc_nids_alt[2] = {
997 /* ADC1-2 */
998 0x08, 0x09,
999};
1000
1001#define ALC880_DIGOUT_NID 0x06
1002#define ALC880_DIGIN_NID 0x0a
1003
1004static struct hda_input_mux alc880_capture_source = {
1005 .num_items = 4,
1006 .items = {
1007 { "Mic", 0x0 },
1008 { "Front Mic", 0x3 },
1009 { "Line", 0x2 },
1010 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001012};
1013
1014/* channel source setting (2/6 channel selection for 3-stack) */
1015/* 2ch mode */
1016static struct hda_verb alc880_threestack_ch2_init[] = {
1017 /* set line-in to input, mute it */
1018 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1019 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1020 /* set mic-in to input vref 80%, mute it */
1021 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1022 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 { } /* end */
1024};
1025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001026/* 6ch mode */
1027static struct hda_verb alc880_threestack_ch6_init[] = {
1028 /* set line-in to output, unmute it */
1029 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1030 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1031 /* set mic-in to output, unmute it */
1032 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1033 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1034 { } /* end */
1035};
1036
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001037static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001038 { 2, alc880_threestack_ch2_init },
1039 { 6, alc880_threestack_ch6_init },
1040};
1041
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001042static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001045 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001046 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1048 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001049 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1050 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1052 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1053 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1054 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1058 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1059 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1060 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 {
1063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1064 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001065 .info = alc_ch_mode_info,
1066 .get = alc_ch_mode_get,
1067 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068 },
1069 { } /* end */
1070};
1071
1072/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001073static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1075 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1076 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1080 {
1081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1082 /* The multiple "Capture Source" controls confuse alsamixer
1083 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001084 */
1085 /* .name = "Capture Source", */
1086 .name = "Input Source",
1087 .count = 3,
1088 .info = alc_mux_enum_info,
1089 .get = alc_mux_enum_get,
1090 .put = alc_mux_enum_put,
1091 },
1092 { } /* end */
1093};
1094
1095/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001096static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001097 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1098 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1099 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1100 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 {
1102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1103 /* The multiple "Capture Source" controls confuse alsamixer
1104 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 */
1106 /* .name = "Capture Source", */
1107 .name = "Input Source",
1108 .count = 2,
1109 .info = alc_mux_enum_info,
1110 .get = alc_mux_enum_get,
1111 .put = alc_mux_enum_put,
1112 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 { } /* end */
1114};
1115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116
1117
1118/*
1119 * ALC880 5-stack model
1120 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001121 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1122 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001123 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1124 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1125 */
1126
1127/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001128static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001129 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001130 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 { } /* end */
1132};
1133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134/* channel source setting (6/8 channel selection for 5-stack) */
1135/* 6ch mode */
1136static struct hda_verb alc880_fivestack_ch6_init[] = {
1137 /* set line-in to input, mute it */
1138 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1139 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001140 { } /* end */
1141};
1142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001143/* 8ch mode */
1144static struct hda_verb alc880_fivestack_ch8_init[] = {
1145 /* set line-in to output, unmute it */
1146 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1147 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1148 { } /* end */
1149};
1150
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001151static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001152 { 6, alc880_fivestack_ch6_init },
1153 { 8, alc880_fivestack_ch8_init },
1154};
1155
1156
1157/*
1158 * ALC880 6-stack model
1159 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001160 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1161 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001162 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1163 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1164 */
1165
1166static hda_nid_t alc880_6st_dac_nids[4] = {
1167 /* front, rear, clfe, rear_surr */
1168 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001169};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170
1171static struct hda_input_mux alc880_6stack_capture_source = {
1172 .num_items = 4,
1173 .items = {
1174 { "Mic", 0x0 },
1175 { "Front Mic", 0x1 },
1176 { "Line", 0x2 },
1177 { "CD", 0x4 },
1178 },
1179};
1180
1181/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001182static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001183 { 8, NULL },
1184};
1185
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001186static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001195 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001196 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1205 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1206 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001207 {
1208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1209 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001210 .info = alc_ch_mode_info,
1211 .get = alc_ch_mode_get,
1212 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001213 },
1214 { } /* end */
1215};
1216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001217
1218/*
1219 * ALC880 W810 model
1220 *
1221 * W810 has rear IO for:
1222 * Front (DAC 02)
1223 * Surround (DAC 03)
1224 * Center/LFE (DAC 04)
1225 * Digital out (06)
1226 *
1227 * The system also has a pair of internal speakers, and a headphone jack.
1228 * These are both connected to Line2 on the codec, hence to DAC 02.
1229 *
1230 * There is a variable resistor to control the speaker or headphone
1231 * volume. This is a hardware-only device without a software API.
1232 *
1233 * Plugging headphones in will disable the internal speakers. This is
1234 * implemented in hardware, not via the driver using jack sense. In
1235 * a similar fashion, plugging into the rear socket marked "front" will
1236 * disable both the speakers and headphones.
1237 *
1238 * For input, there's a microphone jack, and an "audio in" jack.
1239 * These may not do anything useful with this driver yet, because I
1240 * haven't setup any initialization verbs for these yet...
1241 */
1242
1243static hda_nid_t alc880_w810_dac_nids[3] = {
1244 /* front, rear/surround, clfe */
1245 0x02, 0x03, 0x04
1246};
1247
1248/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001249static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001250 { 6, NULL }
1251};
1252
1253/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001254static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001256 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001258 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1262 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1264 { } /* end */
1265};
1266
1267
1268/*
1269 * Z710V model
1270 *
1271 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001272 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1273 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001274 */
1275
1276static hda_nid_t alc880_z71v_dac_nids[1] = {
1277 0x02
1278};
1279#define ALC880_Z71V_HP_DAC 0x03
1280
1281/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001282static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 { 2, NULL }
1284};
1285
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001286static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001289 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001290 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1292 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1295 { } /* end */
1296};
1297
1298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299/*
1300 * ALC880 F1734 model
1301 *
1302 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1303 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1304 */
1305
1306static hda_nid_t alc880_f1734_dac_nids[1] = {
1307 0x03
1308};
1309#define ALC880_F1734_HP_DAC 0x02
1310
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001311static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001312 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001313 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001314 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1315 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001320 { } /* end */
1321};
1322
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001323
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001324/*
1325 * ALC880 ASUS model
1326 *
1327 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1328 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1329 * Mic = 0x18, Line = 0x1a
1330 */
1331
1332#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1333#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1334
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001335static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001337 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001338 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001339 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001340 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1341 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001342 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1343 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001344 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1345 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1346 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1347 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001350 {
1351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1352 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001353 .info = alc_ch_mode_info,
1354 .get = alc_ch_mode_get,
1355 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001356 },
1357 { } /* end */
1358};
1359
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001360/*
1361 * ALC880 ASUS W1V model
1362 *
1363 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1364 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1365 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1366 */
1367
1368/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001369static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001370 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1371 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001372 { } /* end */
1373};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001375/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001376static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001377 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1378 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1379 { } /* end */
1380};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381
Kailang Yangdf694da2005-12-05 19:42:22 +01001382/* TCL S700 */
1383static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1384 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1388 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1391 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1392 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1393 {
1394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1395 /* The multiple "Capture Source" controls confuse alsamixer
1396 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001397 */
1398 /* .name = "Capture Source", */
1399 .name = "Input Source",
1400 .count = 1,
1401 .info = alc_mux_enum_info,
1402 .get = alc_mux_enum_get,
1403 .put = alc_mux_enum_put,
1404 },
1405 { } /* end */
1406};
1407
Kailang Yangccc656c2006-10-17 12:32:26 +02001408/* Uniwill */
1409static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001410 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1411 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1412 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1413 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001414 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1415 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1417 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1426 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1427 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1428 {
1429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1430 .name = "Channel Mode",
1431 .info = alc_ch_mode_info,
1432 .get = alc_ch_mode_get,
1433 .put = alc_ch_mode_put,
1434 },
1435 { } /* end */
1436};
1437
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001438static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1440 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1441 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1442 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1443 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1444 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1446 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1447 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1448 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1449 { } /* end */
1450};
1451
Kailang Yangccc656c2006-10-17 12:32:26 +02001452static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001453 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1454 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1455 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1456 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1459 { } /* end */
1460};
1461
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001463 * virtual master controls
1464 */
1465
1466/*
1467 * slave controls for virtual master
1468 */
1469static const char *alc_slave_vols[] = {
1470 "Front Playback Volume",
1471 "Surround Playback Volume",
1472 "Center Playback Volume",
1473 "LFE Playback Volume",
1474 "Side Playback Volume",
1475 "Headphone Playback Volume",
1476 "Speaker Playback Volume",
1477 "Mono Playback Volume",
1478 "iSpeaker Playback Volume",
1479 "Line-Out Playback Volume",
1480 NULL,
1481};
1482
1483static const char *alc_slave_sws[] = {
1484 "Front Playback Switch",
1485 "Surround Playback Switch",
1486 "Center Playback Switch",
1487 "LFE Playback Switch",
1488 "Side Playback Switch",
1489 "Headphone Playback Switch",
1490 "Speaker Playback Switch",
1491 "Mono Playback Switch",
1492 "iSpeaker Playback Switch",
1493 NULL,
1494};
1495
1496/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001497 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 */
1499static int alc_build_controls(struct hda_codec *codec)
1500{
1501 struct alc_spec *spec = codec->spec;
1502 int err;
1503 int i;
1504
1505 for (i = 0; i < spec->num_mixers; i++) {
1506 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1507 if (err < 0)
1508 return err;
1509 }
1510
1511 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001512 err = snd_hda_create_spdif_out_ctls(codec,
1513 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 if (err < 0)
1515 return err;
1516 }
1517 if (spec->dig_in_nid) {
1518 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1519 if (err < 0)
1520 return err;
1521 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001522
1523 /* if we have no master control, let's create it */
1524 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1525 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1526 HDA_OUTPUT, spec->vmaster_tlv);
1527 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1528 spec->vmaster_tlv, alc_slave_vols);
1529 if (err < 0)
1530 return err;
1531 }
1532 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1533 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1534 NULL, alc_slave_sws);
1535 if (err < 0)
1536 return err;
1537 }
1538
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 return 0;
1540}
1541
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001542
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543/*
1544 * initialize the codec volumes, etc
1545 */
1546
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001547/*
1548 * generic initialization of ADC, input mixers and output mixers
1549 */
1550static struct hda_verb alc880_volume_init_verbs[] = {
1551 /*
1552 * Unmute ADC0-2 and set the default input to mic-in
1553 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001554 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001556 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001558 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001561 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1562 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001563 * Note: PASD motherboards uses the Line In 2 as the input for front
1564 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001566 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001575 /*
1576 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 /* set vol=0 to output mixers */
1579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1582 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 /* set up input amps for analog loopback */
1584 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593
1594 { }
1595};
1596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001597/*
1598 * 3-stack pin configuration:
1599 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1600 */
1601static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1602 /*
1603 * preset connection lists of input pins
1604 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1605 */
1606 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1607 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1608 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1609
1610 /*
1611 * Set pin mode and muting
1612 */
1613 /* set front pin widgets 0x14 for output */
1614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1615 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1616 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1619 /* Mic2 (as headphone out) for HP output */
1620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1621 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1622 /* Line In pin widget for input */
1623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1625 /* Line2 (as front mic) pin widget for input and vref at 80% */
1626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* CD pin widget for input */
1629 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1630
1631 { }
1632};
1633
1634/*
1635 * 5-stack pin configuration:
1636 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1637 * line-in/side = 0x1a, f-mic = 0x1b
1638 */
1639static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1640 /*
1641 * preset connection lists of input pins
1642 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1643 */
1644 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1645 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1646
1647 /*
1648 * Set pin mode and muting
1649 */
1650 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1654 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 /* unmute pins for output (no gain on this amp) */
1656 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1664 /* Mic2 (as headphone out) for HP output */
1665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001667 /* Line In pin widget for input */
1668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1670 /* Line2 (as front mic) pin widget for input and vref at 80% */
1671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* CD pin widget for input */
1674 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675
1676 { }
1677};
1678
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679/*
1680 * W810 pin configuration:
1681 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1682 */
1683static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684 /* hphone/speaker input selector: front DAC */
1685 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1686
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1692 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693
1694 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697 { }
1698};
1699
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001700/*
1701 * Z71V pin configuration:
1702 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1703 */
1704static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001709
Takashi Iwai16ded522005-06-10 19:58:24 +02001710 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001714
1715 { }
1716};
1717
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001718/*
1719 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001720 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1721 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001722 */
1723static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1725
Takashi Iwai16ded522005-06-10 19:58:24 +02001726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001732 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734
Takashi Iwai16ded522005-06-10 19:58:24 +02001735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001738 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001739 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001743 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 { }
1746};
Takashi Iwai16ded522005-06-10 19:58:24 +02001747
Kailang Yangccc656c2006-10-17 12:32:26 +02001748/*
1749 * Uniwill pin configuration:
1750 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1751 * line = 0x1a
1752 */
1753static struct hda_verb alc880_uniwill_init_verbs[] = {
1754 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1755
1756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1760 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1762 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1763 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1770
1771 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1773 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1774 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1775 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1777 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1778 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1780
1781 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1782 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1783
1784 { }
1785};
1786
1787/*
1788* Uniwill P53
1789* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1790 */
1791static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1792 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1793
1794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1796 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1806
1807 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1808 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1809 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1811 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1813
1814 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1815 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1816
1817 { }
1818};
1819
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001820static struct hda_verb alc880_beep_init_verbs[] = {
1821 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1822 { }
1823};
1824
Kailang Yangccc656c2006-10-17 12:32:26 +02001825/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001826static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001827{
1828 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001829 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001830
1831 present = snd_hda_codec_read(codec, 0x14, 0,
1832 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001833 bits = present ? HDA_AMP_MUTE : 0;
1834 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1835 HDA_AMP_MUTE, bits);
1836 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1837 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001838}
1839
1840/* auto-toggle front mic */
1841static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1842{
1843 unsigned int present;
1844 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001845
1846 present = snd_hda_codec_read(codec, 0x18, 0,
1847 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001848 bits = present ? HDA_AMP_MUTE : 0;
1849 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001850}
1851
1852static void alc880_uniwill_automute(struct hda_codec *codec)
1853{
1854 alc880_uniwill_hp_automute(codec);
1855 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001856}
1857
1858static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1859 unsigned int res)
1860{
1861 /* Looks like the unsol event is incompatible with the standard
1862 * definition. 4bit tag is placed at 28 bit!
1863 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001864 switch (res >> 28) {
1865 case ALC880_HP_EVENT:
1866 alc880_uniwill_hp_automute(codec);
1867 break;
1868 case ALC880_MIC_EVENT:
1869 alc880_uniwill_mic_automute(codec);
1870 break;
1871 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001872}
1873
1874static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1875{
1876 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001877 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001878
1879 present = snd_hda_codec_read(codec, 0x14, 0,
1880 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001881 bits = present ? HDA_AMP_MUTE : 0;
1882 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001883}
1884
1885static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1886{
1887 unsigned int present;
1888
1889 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001890 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1891 present &= HDA_AMP_VOLMASK;
1892 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1893 HDA_AMP_VOLMASK, present);
1894 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1895 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001896}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001897
Kailang Yangccc656c2006-10-17 12:32:26 +02001898static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1899 unsigned int res)
1900{
1901 /* Looks like the unsol event is incompatible with the standard
1902 * definition. 4bit tag is placed at 28 bit!
1903 */
1904 if ((res >> 28) == ALC880_HP_EVENT)
1905 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001906 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001907 alc880_uniwill_p53_dcvol_automute(codec);
1908}
1909
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001910/*
1911 * F1734 pin configuration:
1912 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1913 */
1914static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1915 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1916 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1917 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1918 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1919
1920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1921 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1924
1925 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1927 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001934
1935 { }
1936};
1937
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938/*
1939 * ASUS pin configuration:
1940 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1941 */
1942static struct hda_verb alc880_pin_asus_init_verbs[] = {
1943 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1944 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1945 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1947
1948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1956
1957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1966
1967 { }
1968};
1969
1970/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001971#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1972#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001973
Kailang Yangdf694da2005-12-05 19:42:22 +01001974/* Clevo m520g init */
1975static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1976 /* headphone output */
1977 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1978 /* line-out */
1979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1981 /* Line-in */
1982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* CD */
1985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* Mic1 (rear panel) */
1988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic2 (front panel) */
1991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* headphone */
1994 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1995 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* change to EAPD mode */
1997 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1998 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1999
2000 { }
2001};
2002
2003static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002004 /* change to EAPD mode */
2005 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2006 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2007
Kailang Yangdf694da2005-12-05 19:42:22 +01002008 /* Headphone output */
2009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2010 /* Front output*/
2011 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2012 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2013
2014 /* Line In pin widget for input */
2015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2016 /* CD pin widget for input */
2017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2018 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2020
2021 /* change to EAPD mode */
2022 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2023 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2024
2025 { }
2026};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002027
2028/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002029 * LG m1 express dual
2030 *
2031 * Pin assignment:
2032 * Rear Line-In/Out (blue): 0x14
2033 * Build-in Mic-In: 0x15
2034 * Speaker-out: 0x17
2035 * HP-Out (green): 0x1b
2036 * Mic-In/Out (red): 0x19
2037 * SPDIF-Out: 0x1e
2038 */
2039
2040/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2041static hda_nid_t alc880_lg_dac_nids[3] = {
2042 0x05, 0x02, 0x03
2043};
2044
2045/* seems analog CD is not working */
2046static struct hda_input_mux alc880_lg_capture_source = {
2047 .num_items = 3,
2048 .items = {
2049 { "Mic", 0x1 },
2050 { "Line", 0x5 },
2051 { "Internal Mic", 0x6 },
2052 },
2053};
2054
2055/* 2,4,6 channel modes */
2056static struct hda_verb alc880_lg_ch2_init[] = {
2057 /* set line-in and mic-in to input */
2058 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2059 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2060 { }
2061};
2062
2063static struct hda_verb alc880_lg_ch4_init[] = {
2064 /* set line-in to out and mic-in to input */
2065 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2066 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2067 { }
2068};
2069
2070static struct hda_verb alc880_lg_ch6_init[] = {
2071 /* set line-in and mic-in to output */
2072 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2073 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2074 { }
2075};
2076
2077static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2078 { 2, alc880_lg_ch2_init },
2079 { 4, alc880_lg_ch4_init },
2080 { 6, alc880_lg_ch6_init },
2081};
2082
2083static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2085 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002086 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2087 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2088 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2089 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2096 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2097 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2098 {
2099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2100 .name = "Channel Mode",
2101 .info = alc_ch_mode_info,
2102 .get = alc_ch_mode_get,
2103 .put = alc_ch_mode_put,
2104 },
2105 { } /* end */
2106};
2107
2108static struct hda_verb alc880_lg_init_verbs[] = {
2109 /* set capture source to mic-in */
2110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2112 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2113 /* mute all amp mixer inputs */
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002117 /* line-in to input */
2118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2120 /* built-in mic */
2121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* speaker-out */
2124 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2125 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* mic-in to input */
2127 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2128 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2130 /* HP-out */
2131 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2132 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2133 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2134 /* jack sense */
2135 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2136 { }
2137};
2138
2139/* toggle speaker-output according to the hp-jack state */
2140static void alc880_lg_automute(struct hda_codec *codec)
2141{
2142 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002143 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002144
2145 present = snd_hda_codec_read(codec, 0x1b, 0,
2146 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002147 bits = present ? HDA_AMP_MUTE : 0;
2148 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2149 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002150}
2151
2152static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2153{
2154 /* Looks like the unsol event is incompatible with the standard
2155 * definition. 4bit tag is placed at 28 bit!
2156 */
2157 if ((res >> 28) == 0x01)
2158 alc880_lg_automute(codec);
2159}
2160
2161/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002162 * LG LW20
2163 *
2164 * Pin assignment:
2165 * Speaker-out: 0x14
2166 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002167 * Built-in Mic-In: 0x19
2168 * Line-In: 0x1b
2169 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002170 * SPDIF-Out: 0x1e
2171 */
2172
Takashi Iwaid6815182006-03-23 16:06:23 +01002173static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002174 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002175 .items = {
2176 { "Mic", 0x0 },
2177 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002178 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002179 },
2180};
2181
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002182#define alc880_lg_lw_modes alc880_threestack_modes
2183
Takashi Iwaid6815182006-03-23 16:06:23 +01002184static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2188 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2193 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2194 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2198 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002199 {
2200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2201 .name = "Channel Mode",
2202 .info = alc_ch_mode_info,
2203 .get = alc_ch_mode_get,
2204 .put = alc_ch_mode_put,
2205 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002206 { } /* end */
2207};
2208
2209static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002210 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2211 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2212 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2213
Takashi Iwaid6815182006-03-23 16:06:23 +01002214 /* set capture source to mic-in */
2215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2216 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2217 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002219 /* speaker-out */
2220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* mic-in to input */
2226 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* built-in mic */
2229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* jack sense */
2232 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2233 { }
2234};
2235
2236/* toggle speaker-output according to the hp-jack state */
2237static void alc880_lg_lw_automute(struct hda_codec *codec)
2238{
2239 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002240 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002241
2242 present = snd_hda_codec_read(codec, 0x1b, 0,
2243 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002244 bits = present ? HDA_AMP_MUTE : 0;
2245 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2246 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002247}
2248
2249static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2250{
2251 /* Looks like the unsol event is incompatible with the standard
2252 * definition. 4bit tag is placed at 28 bit!
2253 */
2254 if ((res >> 28) == 0x01)
2255 alc880_lg_lw_automute(codec);
2256}
2257
Takashi Iwaicb53c622007-08-10 17:21:45 +02002258#ifdef CONFIG_SND_HDA_POWER_SAVE
2259static struct hda_amp_list alc880_loopbacks[] = {
2260 { 0x0b, HDA_INPUT, 0 },
2261 { 0x0b, HDA_INPUT, 1 },
2262 { 0x0b, HDA_INPUT, 2 },
2263 { 0x0b, HDA_INPUT, 3 },
2264 { 0x0b, HDA_INPUT, 4 },
2265 { } /* end */
2266};
2267
2268static struct hda_amp_list alc880_lg_loopbacks[] = {
2269 { 0x0b, HDA_INPUT, 1 },
2270 { 0x0b, HDA_INPUT, 6 },
2271 { 0x0b, HDA_INPUT, 7 },
2272 { } /* end */
2273};
2274#endif
2275
Takashi Iwaid6815182006-03-23 16:06:23 +01002276/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002277 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002279
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280static int alc_init(struct hda_codec *codec)
2281{
2282 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283 unsigned int i;
2284
2285 for (i = 0; i < spec->num_init_verbs; i++)
2286 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002287
2288 if (spec->init_hook)
2289 spec->init_hook(codec);
2290
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 return 0;
2292}
2293
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002294static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2295{
2296 struct alc_spec *spec = codec->spec;
2297
2298 if (spec->unsol_event)
2299 spec->unsol_event(codec, res);
2300}
2301
Takashi Iwaicb53c622007-08-10 17:21:45 +02002302#ifdef CONFIG_SND_HDA_POWER_SAVE
2303static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2304{
2305 struct alc_spec *spec = codec->spec;
2306 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2307}
2308#endif
2309
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310/*
2311 * Analog playback callbacks
2312 */
2313static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2314 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002315 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316{
2317 struct alc_spec *spec = codec->spec;
2318 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2319}
2320
2321static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
2323 unsigned int stream_tag,
2324 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002325 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326{
2327 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002328 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2329 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330}
2331
2332static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335{
2336 struct alc_spec *spec = codec->spec;
2337 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2338}
2339
2340/*
2341 * Digital out
2342 */
2343static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2344 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346{
2347 struct alc_spec *spec = codec->spec;
2348 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2349}
2350
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002351static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
2353 unsigned int stream_tag,
2354 unsigned int format,
2355 struct snd_pcm_substream *substream)
2356{
2357 struct alc_spec *spec = codec->spec;
2358 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2359 stream_tag, format, substream);
2360}
2361
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2363 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365{
2366 struct alc_spec *spec = codec->spec;
2367 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2368}
2369
2370/*
2371 * Analog capture
2372 */
2373static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2374 struct hda_codec *codec,
2375 unsigned int stream_tag,
2376 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002377 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378{
2379 struct alc_spec *spec = codec->spec;
2380
2381 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2382 stream_tag, 0, format);
2383 return 0;
2384}
2385
2386static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2387 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002388 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389{
2390 struct alc_spec *spec = codec->spec;
2391
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002392 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2393 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 return 0;
2395}
2396
2397
2398/*
2399 */
2400static struct hda_pcm_stream alc880_pcm_analog_playback = {
2401 .substreams = 1,
2402 .channels_min = 2,
2403 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002404 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 .ops = {
2406 .open = alc880_playback_pcm_open,
2407 .prepare = alc880_playback_pcm_prepare,
2408 .cleanup = alc880_playback_pcm_cleanup
2409 },
2410};
2411
2412static struct hda_pcm_stream alc880_pcm_analog_capture = {
2413 .substreams = 2,
2414 .channels_min = 2,
2415 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002416 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 .ops = {
2418 .prepare = alc880_capture_pcm_prepare,
2419 .cleanup = alc880_capture_pcm_cleanup
2420 },
2421};
2422
2423static struct hda_pcm_stream alc880_pcm_digital_playback = {
2424 .substreams = 1,
2425 .channels_min = 2,
2426 .channels_max = 2,
2427 /* NID is set in alc_build_pcms */
2428 .ops = {
2429 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002430 .close = alc880_dig_playback_pcm_close,
2431 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 },
2433};
2434
2435static struct hda_pcm_stream alc880_pcm_digital_capture = {
2436 .substreams = 1,
2437 .channels_min = 2,
2438 .channels_max = 2,
2439 /* NID is set in alc_build_pcms */
2440};
2441
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002442/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2443static struct hda_pcm_stream alc_pcm_null_playback = {
2444 .substreams = 0,
2445 .channels_min = 0,
2446 .channels_max = 0,
2447};
2448
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449static int alc_build_pcms(struct hda_codec *codec)
2450{
2451 struct alc_spec *spec = codec->spec;
2452 struct hda_pcm *info = spec->pcm_rec;
2453 int i;
2454
2455 codec->num_pcms = 1;
2456 codec->pcm_info = info;
2457
2458 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002459 if (spec->stream_analog_playback) {
2460 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2461 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2462 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2463 }
2464 if (spec->stream_analog_capture) {
2465 snd_assert(spec->adc_nids, return -EINVAL);
2466 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2467 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2468 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469
Takashi Iwai4a471b72005-12-07 13:56:29 +01002470 if (spec->channel_mode) {
2471 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2472 for (i = 0; i < spec->num_channel_mode; i++) {
2473 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2474 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2475 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 }
2477 }
2478
Takashi Iwaie08a0072006-09-07 17:52:14 +02002479 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002481 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002482 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002484 if (spec->multiout.dig_out_nid &&
2485 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2487 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2488 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002489 if (spec->dig_in_nid &&
2490 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2492 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2493 }
2494 }
2495
Takashi Iwaie08a0072006-09-07 17:52:14 +02002496 /* If the use of more than one ADC is requested for the current
2497 * model, configure a second analog capture-only PCM.
2498 */
2499 /* Additional Analaog capture for index #2 */
2500 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2501 spec->adc_nids) {
2502 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002503 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002504 info->name = spec->stream_name_analog;
2505 /* No playback stream for second PCM */
2506 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2507 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2508 if (spec->stream_analog_capture) {
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2511 }
2512 }
2513
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 return 0;
2515}
2516
2517static void alc_free(struct hda_codec *codec)
2518{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002519 struct alc_spec *spec = codec->spec;
2520 unsigned int i;
2521
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002522 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523 return;
2524
2525 if (spec->kctl_alloc) {
2526 for (i = 0; i < spec->num_kctl_used; i++)
2527 kfree(spec->kctl_alloc[i].name);
2528 kfree(spec->kctl_alloc);
2529 }
2530 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531}
2532
2533/*
2534 */
2535static struct hda_codec_ops alc_patch_ops = {
2536 .build_controls = alc_build_controls,
2537 .build_pcms = alc_build_pcms,
2538 .init = alc_init,
2539 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002540 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002541#ifdef CONFIG_SND_HDA_POWER_SAVE
2542 .check_power_status = alc_check_power_status,
2543#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544};
2545
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002546
2547/*
2548 * Test configuration for debugging
2549 *
2550 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2551 * enum controls.
2552 */
2553#ifdef CONFIG_SND_DEBUG
2554static hda_nid_t alc880_test_dac_nids[4] = {
2555 0x02, 0x03, 0x04, 0x05
2556};
2557
2558static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002559 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002560 .items = {
2561 { "In-1", 0x0 },
2562 { "In-2", 0x1 },
2563 { "In-3", 0x2 },
2564 { "In-4", 0x3 },
2565 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002566 { "Front", 0x5 },
2567 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002568 },
2569};
2570
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002571static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002572 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002573 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002574 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002575 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002576};
2577
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002578static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2579 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002580{
2581 static char *texts[] = {
2582 "N/A", "Line Out", "HP Out",
2583 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2584 };
2585 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2586 uinfo->count = 1;
2587 uinfo->value.enumerated.items = 8;
2588 if (uinfo->value.enumerated.item >= 8)
2589 uinfo->value.enumerated.item = 7;
2590 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2591 return 0;
2592}
2593
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002594static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2595 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002596{
2597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2598 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2599 unsigned int pin_ctl, item = 0;
2600
2601 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2602 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2603 if (pin_ctl & AC_PINCTL_OUT_EN) {
2604 if (pin_ctl & AC_PINCTL_HP_EN)
2605 item = 2;
2606 else
2607 item = 1;
2608 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2609 switch (pin_ctl & AC_PINCTL_VREFEN) {
2610 case AC_PINCTL_VREF_HIZ: item = 3; break;
2611 case AC_PINCTL_VREF_50: item = 4; break;
2612 case AC_PINCTL_VREF_GRD: item = 5; break;
2613 case AC_PINCTL_VREF_80: item = 6; break;
2614 case AC_PINCTL_VREF_100: item = 7; break;
2615 }
2616 }
2617 ucontrol->value.enumerated.item[0] = item;
2618 return 0;
2619}
2620
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002621static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2622 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002623{
2624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2625 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2626 static unsigned int ctls[] = {
2627 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2628 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2629 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2630 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2631 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2632 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2633 };
2634 unsigned int old_ctl, new_ctl;
2635
2636 old_ctl = snd_hda_codec_read(codec, nid, 0,
2637 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2638 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2639 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002640 int val;
2641 snd_hda_codec_write_cache(codec, nid, 0,
2642 AC_VERB_SET_PIN_WIDGET_CONTROL,
2643 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002644 val = ucontrol->value.enumerated.item[0] >= 3 ?
2645 HDA_AMP_MUTE : 0;
2646 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2647 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002648 return 1;
2649 }
2650 return 0;
2651}
2652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002653static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002655{
2656 static char *texts[] = {
2657 "Front", "Surround", "CLFE", "Side"
2658 };
2659 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2660 uinfo->count = 1;
2661 uinfo->value.enumerated.items = 4;
2662 if (uinfo->value.enumerated.item >= 4)
2663 uinfo->value.enumerated.item = 3;
2664 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2665 return 0;
2666}
2667
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002668static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2669 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002670{
2671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2672 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2673 unsigned int sel;
2674
2675 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2676 ucontrol->value.enumerated.item[0] = sel & 3;
2677 return 0;
2678}
2679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002680static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2681 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002682{
2683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2684 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2685 unsigned int sel;
2686
2687 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2688 if (ucontrol->value.enumerated.item[0] != sel) {
2689 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002690 snd_hda_codec_write_cache(codec, nid, 0,
2691 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002692 return 1;
2693 }
2694 return 0;
2695}
2696
2697#define PIN_CTL_TEST(xname,nid) { \
2698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2699 .name = xname, \
2700 .info = alc_test_pin_ctl_info, \
2701 .get = alc_test_pin_ctl_get, \
2702 .put = alc_test_pin_ctl_put, \
2703 .private_value = nid \
2704 }
2705
2706#define PIN_SRC_TEST(xname,nid) { \
2707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2708 .name = xname, \
2709 .info = alc_test_pin_src_info, \
2710 .get = alc_test_pin_src_get, \
2711 .put = alc_test_pin_src_put, \
2712 .private_value = nid \
2713 }
2714
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002715static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2717 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2718 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2719 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2721 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2722 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2723 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002724 PIN_CTL_TEST("Front Pin Mode", 0x14),
2725 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2726 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2727 PIN_CTL_TEST("Side Pin Mode", 0x17),
2728 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2729 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2730 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2731 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2732 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2733 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2734 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2735 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2736 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2737 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2738 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2739 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2740 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2741 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2742 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2743 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2744 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2745 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002746 {
2747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2748 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002749 .info = alc_ch_mode_info,
2750 .get = alc_ch_mode_get,
2751 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002752 },
2753 { } /* end */
2754};
2755
2756static struct hda_verb alc880_test_init_verbs[] = {
2757 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002766 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2770 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002771 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2774 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2775 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002776 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2780 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002781 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2783 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002784 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2785 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2786 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002787 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2790 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2791 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002792 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002794 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002796 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002798 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002799 /* Analog input/passthru */
2800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002805 { }
2806};
2807#endif
2808
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809/*
2810 */
2811
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002812static const char *alc880_models[ALC880_MODEL_LAST] = {
2813 [ALC880_3ST] = "3stack",
2814 [ALC880_TCL_S700] = "tcl",
2815 [ALC880_3ST_DIG] = "3stack-digout",
2816 [ALC880_CLEVO] = "clevo",
2817 [ALC880_5ST] = "5stack",
2818 [ALC880_5ST_DIG] = "5stack-digout",
2819 [ALC880_W810] = "w810",
2820 [ALC880_Z71V] = "z71v",
2821 [ALC880_6ST] = "6stack",
2822 [ALC880_6ST_DIG] = "6stack-digout",
2823 [ALC880_ASUS] = "asus",
2824 [ALC880_ASUS_W1V] = "asus-w1v",
2825 [ALC880_ASUS_DIG] = "asus-dig",
2826 [ALC880_ASUS_DIG2] = "asus-dig2",
2827 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002828 [ALC880_UNIWILL_P53] = "uniwill-p53",
2829 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002830 [ALC880_F1734] = "F1734",
2831 [ALC880_LG] = "lg",
2832 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002833#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002834 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002835#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002836 [ALC880_AUTO] = "auto",
2837};
2838
2839static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002840 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002841 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2842 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2843 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2844 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2845 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2846 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2847 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2848 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002849 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2850 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002851 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2852 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2853 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2854 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2855 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2856 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2857 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2858 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2859 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2860 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002861 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002862 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2863 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2864 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002865 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002866 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002867 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2868 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002869 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2870 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002871 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2872 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2873 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2874 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002875 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2876 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002877 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002878 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002879 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002880 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002881 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2882 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002883 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2884 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002885 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002886 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002887 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002888 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002889 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002890 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2891 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002892 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002893 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2894 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2895 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2896 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002897 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2898 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002899 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002900 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002901 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2902 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002903 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2904 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2905 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002906 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2907 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2908 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909 {}
2910};
2911
Takashi Iwai16ded522005-06-10 19:58:24 +02002912/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002913 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002914 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002915static struct alc_config_preset alc880_presets[] = {
2916 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002917 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002918 .init_verbs = { alc880_volume_init_verbs,
2919 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002920 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002921 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002922 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2923 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002924 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002925 .input_mux = &alc880_capture_source,
2926 },
2927 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002929 .init_verbs = { alc880_volume_init_verbs,
2930 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002931 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002932 .dac_nids = alc880_dac_nids,
2933 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002934 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2935 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002936 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002937 .input_mux = &alc880_capture_source,
2938 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002939 [ALC880_TCL_S700] = {
2940 .mixers = { alc880_tcl_s700_mixer },
2941 .init_verbs = { alc880_volume_init_verbs,
2942 alc880_pin_tcl_S700_init_verbs,
2943 alc880_gpio2_init_verbs },
2944 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2945 .dac_nids = alc880_dac_nids,
2946 .hp_nid = 0x03,
2947 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2948 .channel_mode = alc880_2_jack_modes,
2949 .input_mux = &alc880_capture_source,
2950 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002951 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002952 .mixers = { alc880_three_stack_mixer,
2953 alc880_five_stack_mixer},
2954 .init_verbs = { alc880_volume_init_verbs,
2955 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002956 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2957 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002958 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2959 .channel_mode = alc880_fivestack_modes,
2960 .input_mux = &alc880_capture_source,
2961 },
2962 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002963 .mixers = { alc880_three_stack_mixer,
2964 alc880_five_stack_mixer },
2965 .init_verbs = { alc880_volume_init_verbs,
2966 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002967 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2968 .dac_nids = alc880_dac_nids,
2969 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2971 .channel_mode = alc880_fivestack_modes,
2972 .input_mux = &alc880_capture_source,
2973 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002974 [ALC880_6ST] = {
2975 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002976 .init_verbs = { alc880_volume_init_verbs,
2977 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002978 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2979 .dac_nids = alc880_6st_dac_nids,
2980 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2981 .channel_mode = alc880_sixstack_modes,
2982 .input_mux = &alc880_6stack_capture_source,
2983 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002984 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002988 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2989 .dac_nids = alc880_6st_dac_nids,
2990 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002991 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2992 .channel_mode = alc880_sixstack_modes,
2993 .input_mux = &alc880_6stack_capture_source,
2994 },
2995 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002999 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3001 .dac_nids = alc880_w810_dac_nids,
3002 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003003 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3004 .channel_mode = alc880_w810_modes,
3005 .input_mux = &alc880_capture_source,
3006 },
3007 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003008 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003009 .init_verbs = { alc880_volume_init_verbs,
3010 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003011 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3012 .dac_nids = alc880_z71v_dac_nids,
3013 .dig_out_nid = ALC880_DIGOUT_NID,
3014 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003015 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3016 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003017 .input_mux = &alc880_capture_source,
3018 },
3019 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003020 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003021 .init_verbs = { alc880_volume_init_verbs,
3022 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3024 .dac_nids = alc880_f1734_dac_nids,
3025 .hp_nid = 0x02,
3026 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3027 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003028 .input_mux = &alc880_capture_source,
3029 },
3030 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003031 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003032 .init_verbs = { alc880_volume_init_verbs,
3033 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 alc880_gpio1_init_verbs },
3035 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3036 .dac_nids = alc880_asus_dac_nids,
3037 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3038 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003039 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003040 .input_mux = &alc880_capture_source,
3041 },
3042 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003043 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003044 .init_verbs = { alc880_volume_init_verbs,
3045 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 alc880_gpio1_init_verbs },
3047 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3048 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3051 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003052 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003053 .input_mux = &alc880_capture_source,
3054 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003055 [ALC880_ASUS_DIG2] = {
3056 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003057 .init_verbs = { alc880_volume_init_verbs,
3058 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003059 alc880_gpio2_init_verbs }, /* use GPIO2 */
3060 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3061 .dac_nids = alc880_asus_dac_nids,
3062 .dig_out_nid = ALC880_DIGOUT_NID,
3063 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3064 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003065 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003066 .input_mux = &alc880_capture_source,
3067 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003068 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003070 .init_verbs = { alc880_volume_init_verbs,
3071 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072 alc880_gpio1_init_verbs },
3073 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3074 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003075 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3077 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003078 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003079 .input_mux = &alc880_capture_source,
3080 },
3081 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003082 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003083 .init_verbs = { alc880_volume_init_verbs,
3084 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3086 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003087 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3089 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003090 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003091 .input_mux = &alc880_capture_source,
3092 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003093 [ALC880_UNIWILL] = {
3094 .mixers = { alc880_uniwill_mixer },
3095 .init_verbs = { alc880_volume_init_verbs,
3096 alc880_uniwill_init_verbs },
3097 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3098 .dac_nids = alc880_asus_dac_nids,
3099 .dig_out_nid = ALC880_DIGOUT_NID,
3100 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3101 .channel_mode = alc880_threestack_modes,
3102 .need_dac_fix = 1,
3103 .input_mux = &alc880_capture_source,
3104 .unsol_event = alc880_uniwill_unsol_event,
3105 .init_hook = alc880_uniwill_automute,
3106 },
3107 [ALC880_UNIWILL_P53] = {
3108 .mixers = { alc880_uniwill_p53_mixer },
3109 .init_verbs = { alc880_volume_init_verbs,
3110 alc880_uniwill_p53_init_verbs },
3111 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3112 .dac_nids = alc880_asus_dac_nids,
3113 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003114 .channel_mode = alc880_threestack_modes,
3115 .input_mux = &alc880_capture_source,
3116 .unsol_event = alc880_uniwill_p53_unsol_event,
3117 .init_hook = alc880_uniwill_p53_hp_automute,
3118 },
3119 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003120 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003121 alc880_pcbeep_mixer, },
3122 .init_verbs = { alc880_volume_init_verbs,
3123 alc880_uniwill_p53_init_verbs,
3124 alc880_beep_init_verbs },
3125 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3126 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003127 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003128 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3129 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003130 .input_mux = &alc880_capture_source,
3131 .unsol_event = alc880_uniwill_p53_unsol_event,
3132 .init_hook = alc880_uniwill_p53_hp_automute,
3133 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003134 [ALC880_CLEVO] = {
3135 .mixers = { alc880_three_stack_mixer },
3136 .init_verbs = { alc880_volume_init_verbs,
3137 alc880_pin_clevo_init_verbs },
3138 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3139 .dac_nids = alc880_dac_nids,
3140 .hp_nid = 0x03,
3141 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3142 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003143 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003144 .input_mux = &alc880_capture_source,
3145 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003146 [ALC880_LG] = {
3147 .mixers = { alc880_lg_mixer },
3148 .init_verbs = { alc880_volume_init_verbs,
3149 alc880_lg_init_verbs },
3150 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3151 .dac_nids = alc880_lg_dac_nids,
3152 .dig_out_nid = ALC880_DIGOUT_NID,
3153 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3154 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003155 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003156 .input_mux = &alc880_lg_capture_source,
3157 .unsol_event = alc880_lg_unsol_event,
3158 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003159#ifdef CONFIG_SND_HDA_POWER_SAVE
3160 .loopbacks = alc880_lg_loopbacks,
3161#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003162 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003163 [ALC880_LG_LW] = {
3164 .mixers = { alc880_lg_lw_mixer },
3165 .init_verbs = { alc880_volume_init_verbs,
3166 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003167 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003168 .dac_nids = alc880_dac_nids,
3169 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003170 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3171 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003172 .input_mux = &alc880_lg_lw_capture_source,
3173 .unsol_event = alc880_lg_lw_unsol_event,
3174 .init_hook = alc880_lg_lw_automute,
3175 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003176#ifdef CONFIG_SND_DEBUG
3177 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003178 .mixers = { alc880_test_mixer },
3179 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003180 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3181 .dac_nids = alc880_test_dac_nids,
3182 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003183 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3184 .channel_mode = alc880_test_modes,
3185 .input_mux = &alc880_test_capture_source,
3186 },
3187#endif
3188};
3189
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003190/*
3191 * Automatic parse of I/O pins from the BIOS configuration
3192 */
3193
3194#define NUM_CONTROL_ALLOC 32
3195#define NUM_VERB_ALLOC 32
3196
3197enum {
3198 ALC_CTL_WIDGET_VOL,
3199 ALC_CTL_WIDGET_MUTE,
3200 ALC_CTL_BIND_MUTE,
3201};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003202static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3204 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003205 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206};
3207
3208/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003209static int add_control(struct alc_spec *spec, int type, const char *name,
3210 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003212 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213
3214 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3215 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3216
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003217 /* array + terminator */
3218 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3219 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220 return -ENOMEM;
3221 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003222 memcpy(knew, spec->kctl_alloc,
3223 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 kfree(spec->kctl_alloc);
3225 }
3226 spec->kctl_alloc = knew;
3227 spec->num_kctl_alloc = num;
3228 }
3229
3230 knew = &spec->kctl_alloc[spec->num_kctl_used];
3231 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003232 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003233 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003234 return -ENOMEM;
3235 knew->private_value = val;
3236 spec->num_kctl_used++;
3237 return 0;
3238}
3239
3240#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3241#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3242#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3243#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3244#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3245#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3246#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3247#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3248#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3249#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3250#define ALC880_PIN_CD_NID 0x1c
3251
3252/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003253static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3254 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255{
3256 hda_nid_t nid;
3257 int assigned[4];
3258 int i, j;
3259
3260 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003261 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262
3263 /* check the pins hardwired to audio widget */
3264 for (i = 0; i < cfg->line_outs; i++) {
3265 nid = cfg->line_out_pins[i];
3266 if (alc880_is_fixed_pin(nid)) {
3267 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003268 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 assigned[idx] = 1;
3270 }
3271 }
3272 /* left pins can be connect to any audio widget */
3273 for (i = 0; i < cfg->line_outs; i++) {
3274 nid = cfg->line_out_pins[i];
3275 if (alc880_is_fixed_pin(nid))
3276 continue;
3277 /* search for an empty channel */
3278 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003279 if (!assigned[j]) {
3280 spec->multiout.dac_nids[i] =
3281 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 assigned[j] = 1;
3283 break;
3284 }
3285 }
3286 }
3287 spec->multiout.num_dacs = cfg->line_outs;
3288 return 0;
3289}
3290
3291/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003292static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3293 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294{
3295 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003296 static const char *chname[4] = {
3297 "Front", "Surround", NULL /*CLFE*/, "Side"
3298 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299 hda_nid_t nid;
3300 int i, err;
3301
3302 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003303 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003304 continue;
3305 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3306 if (i == 2) {
3307 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3309 "Center Playback Volume",
3310 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3311 HDA_OUTPUT));
3312 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003314 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3315 "LFE Playback Volume",
3316 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3317 HDA_OUTPUT));
3318 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003319 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003320 err = add_control(spec, ALC_CTL_BIND_MUTE,
3321 "Center Playback Switch",
3322 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3323 HDA_INPUT));
3324 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003326 err = add_control(spec, ALC_CTL_BIND_MUTE,
3327 "LFE Playback Switch",
3328 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3329 HDA_INPUT));
3330 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 return err;
3332 } else {
3333 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003334 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3335 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3336 HDA_OUTPUT));
3337 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003338 return err;
3339 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003340 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3341 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3342 HDA_INPUT));
3343 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003344 return err;
3345 }
3346 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003347 return 0;
3348}
3349
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003350/* add playback controls for speaker and HP outputs */
3351static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3352 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353{
3354 hda_nid_t nid;
3355 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003356 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003358 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003359 return 0;
3360
3361 if (alc880_is_fixed_pin(pin)) {
3362 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003363 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003364 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003366 else
3367 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368 /* control HP volume/switch on the output mixer amp */
3369 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003370 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003371 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3372 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3373 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003375 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003376 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3377 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3378 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 return err;
3380 } else if (alc880_is_multi_pin(pin)) {
3381 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003383 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003384 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3385 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3386 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003387 return err;
3388 }
3389 return 0;
3390}
3391
3392/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003393static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3394 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003395 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396{
3397 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003398 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003399
3400 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003401 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3402 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3403 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 return err;
3405 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003406 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3407 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3408 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 return err;
3410 return 0;
3411}
3412
3413/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003414static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3415 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003418 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419
3420 for (i = 0; i < AUTO_PIN_LAST; i++) {
3421 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003422 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003423 err = new_analog_input(spec, cfg->input_pins[i],
3424 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003425 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426 if (err < 0)
3427 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003428 imux->items[imux->num_items].label =
3429 auto_pin_cfg_labels[i];
3430 imux->items[imux->num_items].index =
3431 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432 imux->num_items++;
3433 }
3434 }
3435 return 0;
3436}
3437
Kailang Yangdf694da2005-12-05 19:42:22 +01003438static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3439 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 int dac_idx)
3441{
3442 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003443 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3444 pin_type);
3445 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3446 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447 /* need the manual connection? */
3448 if (alc880_is_multi_pin(nid)) {
3449 struct alc_spec *spec = codec->spec;
3450 int idx = alc880_multi_pin_idx(nid);
3451 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3452 AC_VERB_SET_CONNECT_SEL,
3453 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3454 }
3455}
3456
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003457static int get_pin_type(int line_out_type)
3458{
3459 if (line_out_type == AUTO_PIN_HP_OUT)
3460 return PIN_HP;
3461 else
3462 return PIN_OUT;
3463}
3464
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465static void alc880_auto_init_multi_out(struct hda_codec *codec)
3466{
3467 struct alc_spec *spec = codec->spec;
3468 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003469
3470 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003471 for (i = 0; i < spec->autocfg.line_outs; i++) {
3472 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003473 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3474 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 }
3476}
3477
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003478static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003479{
3480 struct alc_spec *spec = codec->spec;
3481 hda_nid_t pin;
3482
Takashi Iwai82bc9552006-03-21 11:24:42 +01003483 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003484 if (pin) /* connect to front */
3485 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003486 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003487 if (pin) /* connect to front */
3488 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3489}
3490
3491static void alc880_auto_init_analog_input(struct hda_codec *codec)
3492{
3493 struct alc_spec *spec = codec->spec;
3494 int i;
3495
3496 for (i = 0; i < AUTO_PIN_LAST; i++) {
3497 hda_nid_t nid = spec->autocfg.input_pins[i];
3498 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003499 snd_hda_codec_write(codec, nid, 0,
3500 AC_VERB_SET_PIN_WIDGET_CONTROL,
3501 i <= AUTO_PIN_FRONT_MIC ?
3502 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003504 snd_hda_codec_write(codec, nid, 0,
3505 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003506 AMP_OUT_MUTE);
3507 }
3508 }
3509}
3510
3511/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003512/* return 1 if successful, 0 if the proper config is not found,
3513 * or a negative error code
3514 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515static int alc880_parse_auto_config(struct hda_codec *codec)
3516{
3517 struct alc_spec *spec = codec->spec;
3518 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003519 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003521 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3522 alc880_ignore);
3523 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003524 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003525 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003526 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003527
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3529 if (err < 0)
3530 return err;
3531 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3532 if (err < 0)
3533 return err;
3534 err = alc880_auto_create_extra_out(spec,
3535 spec->autocfg.speaker_pins[0],
3536 "Speaker");
3537 if (err < 0)
3538 return err;
3539 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3540 "Headphone");
3541 if (err < 0)
3542 return err;
3543 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3544 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 return err;
3546
3547 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3548
3549 if (spec->autocfg.dig_out_pin)
3550 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3551 if (spec->autocfg.dig_in_pin)
3552 spec->dig_in_nid = ALC880_DIGIN_NID;
3553
3554 if (spec->kctl_alloc)
3555 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3556
3557 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3558
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003559 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003560 spec->input_mux = &spec->private_imux;
3561
3562 return 1;
3563}
3564
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003565/* additional initialization for auto-configuration model */
3566static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003568 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003569 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571}
3572
3573/*
3574 * OK, here we have finally the patch for ALC880
3575 */
3576
Linus Torvalds1da177e2005-04-16 15:20:36 -07003577static int patch_alc880(struct hda_codec *codec)
3578{
3579 struct alc_spec *spec;
3580 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003581 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003583 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003584 if (spec == NULL)
3585 return -ENOMEM;
3586
3587 codec->spec = spec;
3588
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003589 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3590 alc880_models,
3591 alc880_cfg_tbl);
3592 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003593 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3594 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596 }
3597
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003598 if (board_config == ALC880_AUTO) {
3599 /* automatic parse from the BIOS config */
3600 err = alc880_parse_auto_config(codec);
3601 if (err < 0) {
3602 alc_free(codec);
3603 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003604 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003605 printk(KERN_INFO
3606 "hda_codec: Cannot set up configuration "
3607 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003608 board_config = ALC880_3ST;
3609 }
3610 }
3611
Kailang Yangdf694da2005-12-05 19:42:22 +01003612 if (board_config != ALC880_AUTO)
3613 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614
3615 spec->stream_name_analog = "ALC880 Analog";
3616 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3617 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3618
3619 spec->stream_name_digital = "ALC880 Digital";
3620 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3621 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003623 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003624 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003625 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003626 /* get type */
3627 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628 if (wcap != AC_WID_AUD_IN) {
3629 spec->adc_nids = alc880_adc_nids_alt;
3630 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003631 spec->mixers[spec->num_mixers] =
3632 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003633 spec->num_mixers++;
3634 } else {
3635 spec->adc_nids = alc880_adc_nids;
3636 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3637 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3638 spec->num_mixers++;
3639 }
3640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641
Takashi Iwai2134ea42008-01-10 16:53:55 +01003642 spec->vmaster_nid = 0x0c;
3643
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003645 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003646 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003647#ifdef CONFIG_SND_HDA_POWER_SAVE
3648 if (!spec->loopback.amplist)
3649 spec->loopback.amplist = alc880_loopbacks;
3650#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003651
3652 return 0;
3653}
3654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003655
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656/*
3657 * ALC260 support
3658 */
3659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003660static hda_nid_t alc260_dac_nids[1] = {
3661 /* front */
3662 0x02,
3663};
3664
3665static hda_nid_t alc260_adc_nids[1] = {
3666 /* ADC0 */
3667 0x04,
3668};
3669
Kailang Yangdf694da2005-12-05 19:42:22 +01003670static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003671 /* ADC1 */
3672 0x05,
3673};
3674
Kailang Yangdf694da2005-12-05 19:42:22 +01003675static hda_nid_t alc260_hp_adc_nids[2] = {
3676 /* ADC1, 0 */
3677 0x05, 0x04
3678};
3679
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003680/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3681 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3682 */
3683static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003684 /* ADC0, ADC1 */
3685 0x04, 0x05
3686};
3687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688#define ALC260_DIGOUT_NID 0x03
3689#define ALC260_DIGIN_NID 0x06
3690
3691static struct hda_input_mux alc260_capture_source = {
3692 .num_items = 4,
3693 .items = {
3694 { "Mic", 0x0 },
3695 { "Front Mic", 0x1 },
3696 { "Line", 0x2 },
3697 { "CD", 0x4 },
3698 },
3699};
3700
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003701/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003702 * headphone jack and the internal CD lines since these are the only pins at
3703 * which audio can appear. For flexibility, also allow the option of
3704 * recording the mixer output on the second ADC (ADC0 doesn't have a
3705 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003706 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003707static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3708 {
3709 .num_items = 3,
3710 .items = {
3711 { "Mic/Line", 0x0 },
3712 { "CD", 0x4 },
3713 { "Headphone", 0x2 },
3714 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003715 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003716 {
3717 .num_items = 4,
3718 .items = {
3719 { "Mic/Line", 0x0 },
3720 { "CD", 0x4 },
3721 { "Headphone", 0x2 },
3722 { "Mixer", 0x5 },
3723 },
3724 },
3725
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003726};
3727
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003728/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3729 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003730 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003731static struct hda_input_mux alc260_acer_capture_sources[2] = {
3732 {
3733 .num_items = 4,
3734 .items = {
3735 { "Mic", 0x0 },
3736 { "Line", 0x2 },
3737 { "CD", 0x4 },
3738 { "Headphone", 0x5 },
3739 },
3740 },
3741 {
3742 .num_items = 5,
3743 .items = {
3744 { "Mic", 0x0 },
3745 { "Line", 0x2 },
3746 { "CD", 0x4 },
3747 { "Headphone", 0x6 },
3748 { "Mixer", 0x5 },
3749 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003750 },
3751};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003752/*
3753 * This is just place-holder, so there's something for alc_build_pcms to look
3754 * at when it calculates the maximum number of channels. ALC260 has no mixer
3755 * element which allows changing the channel mode, so the verb list is
3756 * never used.
3757 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003758static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003759 { 2, NULL },
3760};
3761
Kailang Yangdf694da2005-12-05 19:42:22 +01003762
3763/* Mixer combinations
3764 *
3765 * basic: base_output + input + pc_beep + capture
3766 * HP: base_output + input + capture_alt
3767 * HP_3013: hp_3013 + input + capture
3768 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003769 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003770 */
3771
3772static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003773 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003774 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003775 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3776 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3777 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3778 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3779 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003780};
Kailang Yangdf694da2005-12-05 19:42:22 +01003781
3782static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003783 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3784 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3785 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3786 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3788 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003791 { } /* end */
3792};
3793
Kailang Yangdf694da2005-12-05 19:42:22 +01003794static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3795 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3796 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3797 { } /* end */
3798};
3799
3800static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3801 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3802 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3803 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3804 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3807 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3808 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003809 { } /* end */
3810};
3811
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003812/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3813 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3814 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003815static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003816 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003817 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003818 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003819 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3820 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3821 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003823 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003824 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3825 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3826 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003827 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003828 { } /* end */
3829};
3830
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003831/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3832 * versions of the ALC260 don't act on requests to enable mic bias from NID
3833 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3834 * datasheet doesn't mention this restriction. At this stage it's not clear
3835 * whether this behaviour is intentional or is a hardware bug in chip
3836 * revisions available in early 2006. Therefore for now allow the
3837 * "Headphone Jack Mode" control to span all choices, but if it turns out
3838 * that the lack of mic bias for this NID is intentional we could change the
3839 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3840 *
3841 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3842 * don't appear to make the mic bias available from the "line" jack, even
3843 * though the NID used for this jack (0x14) can supply it. The theory is
3844 * that perhaps Acer have included blocking capacitors between the ALC260
3845 * and the output jack. If this turns out to be the case for all such
3846 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3847 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003848 *
3849 * The C20x Tablet series have a mono internal speaker which is controlled
3850 * via the chip's Mono sum widget and pin complex, so include the necessary
3851 * controls for such models. On models without a "mono speaker" the control
3852 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003853 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003854static struct snd_kcontrol_new alc260_acer_mixer[] = {
3855 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3856 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003857 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003858 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3859 HDA_OUTPUT),
3860 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3861 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003862 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3863 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3865 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3866 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3867 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3868 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3869 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3870 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3871 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3872 { } /* end */
3873};
3874
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003875/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3876 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3877 */
3878static struct snd_kcontrol_new alc260_will_mixer[] = {
3879 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3880 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3882 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3883 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3884 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3885 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3886 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3887 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3888 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3889 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3890 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3891 { } /* end */
3892};
3893
3894/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3895 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3896 */
3897static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3898 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3899 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3901 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3902 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3903 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3904 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3905 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3906 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3907 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3908 { } /* end */
3909};
3910
Kailang Yangdf694da2005-12-05 19:42:22 +01003911/* capture mixer elements */
3912static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003913 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3914 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003915 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3916 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003917 {
3918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003919 /* The multiple "Capture Source" controls confuse alsamixer
3920 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003921 */
3922 /* .name = "Capture Source", */
3923 .name = "Input Source",
3924 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003925 .info = alc_mux_enum_info,
3926 .get = alc_mux_enum_get,
3927 .put = alc_mux_enum_put,
3928 },
3929 { } /* end */
3930};
3931
Kailang Yangdf694da2005-12-05 19:42:22 +01003932static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3933 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3934 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3935 {
3936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3937 /* The multiple "Capture Source" controls confuse alsamixer
3938 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003939 */
3940 /* .name = "Capture Source", */
3941 .name = "Input Source",
3942 .count = 1,
3943 .info = alc_mux_enum_info,
3944 .get = alc_mux_enum_get,
3945 .put = alc_mux_enum_put,
3946 },
3947 { } /* end */
3948};
3949
3950/*
3951 * initialization verbs
3952 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003953static struct hda_verb alc260_init_verbs[] = {
3954 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003958 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003959 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003961 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003962 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003965 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003966 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003967 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003969 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003970 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003971 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3972 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003973 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974 /* set connection select to line in (default select for this ADC) */
3975 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003976 /* mute capture amp left and right */
3977 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3978 /* set connection select to line in (default select for this ADC) */
3979 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003980 /* set vol=0 Line-Out mixer amp left and right */
3981 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3982 /* unmute pin widget amp left and right (no gain on this amp) */
3983 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3984 /* set vol=0 HP mixer amp left and right */
3985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3986 /* unmute pin widget amp left and right (no gain on this amp) */
3987 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3988 /* set vol=0 Mono mixer amp left and right */
3989 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 /* unmute pin widget amp left and right (no gain on this amp) */
3991 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3992 /* unmute LINE-2 out pin */
3993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003994 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3995 * Line In 2 = 0x03
3996 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003997 /* mute analog inputs */
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004003 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004004 /* mute Front out path */
4005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4007 /* mute Headphone out path */
4008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4010 /* mute Mono out path */
4011 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4012 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004013 { }
4014};
4015
Takashi Iwai474167d2006-05-17 17:17:43 +02004016#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004017static struct hda_verb alc260_hp_init_verbs[] = {
4018 /* Headphone and output */
4019 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4020 /* mono output */
4021 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4022 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4023 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4024 /* Mic2 (front panel) pin widget for input and vref at 80% */
4025 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4026 /* Line In pin widget for input */
4027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4028 /* Line-2 pin widget for output */
4029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4030 /* CD pin widget for input */
4031 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4032 /* unmute amp left and right */
4033 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4034 /* set connection select to line in (default select for this ADC) */
4035 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4036 /* unmute Line-Out mixer amp left and right (volume = 0) */
4037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4038 /* mute pin widget amp left and right (no gain on this amp) */
4039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4040 /* unmute HP mixer amp left and right (volume = 0) */
4041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4042 /* mute pin widget amp left and right (no gain on this amp) */
4043 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004044 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4045 * Line In 2 = 0x03
4046 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004047 /* mute analog inputs */
4048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004053 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4054 /* Unmute Front out path */
4055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4057 /* Unmute Headphone out path */
4058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4060 /* Unmute Mono out path */
4061 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4062 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4063 { }
4064};
Takashi Iwai474167d2006-05-17 17:17:43 +02004065#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004066
4067static struct hda_verb alc260_hp_3013_init_verbs[] = {
4068 /* Line out and output */
4069 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4070 /* mono output */
4071 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4072 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4073 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4074 /* Mic2 (front panel) pin widget for input and vref at 80% */
4075 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4076 /* Line In pin widget for input */
4077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4078 /* Headphone pin widget for output */
4079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4080 /* CD pin widget for input */
4081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4082 /* unmute amp left and right */
4083 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4084 /* set connection select to line in (default select for this ADC) */
4085 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4086 /* unmute Line-Out mixer amp left and right (volume = 0) */
4087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4088 /* mute pin widget amp left and right (no gain on this amp) */
4089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4090 /* unmute HP mixer amp left and right (volume = 0) */
4091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4092 /* mute pin widget amp left and right (no gain on this amp) */
4093 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004094 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4095 * Line In 2 = 0x03
4096 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004097 /* mute analog inputs */
4098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4102 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004103 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4104 /* Unmute Front out path */
4105 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4107 /* Unmute Headphone out path */
4108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4110 /* Unmute Mono out path */
4111 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4112 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4113 { }
4114};
4115
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004116/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004117 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4118 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004119 */
4120static struct hda_verb alc260_fujitsu_init_verbs[] = {
4121 /* Disable all GPIOs */
4122 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4123 /* Internal speaker is connected to headphone pin */
4124 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4125 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004127 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4128 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4129 /* Ensure all other unused pins are disabled and muted. */
4130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4131 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004132 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004133 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004134 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004135 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4136 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004138
Jonathan Woithef7ace402006-02-28 11:46:14 +01004139 /* Disable digital (SPDIF) pins */
4140 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4141 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004142
Jonathan Woithef7ace402006-02-28 11:46:14 +01004143 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4144 * when acting as an output.
4145 */
4146 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4147
4148 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004149 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4155 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4156 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4157 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004158
Jonathan Woithef7ace402006-02-28 11:46:14 +01004159 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4160 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4161 /* Unmute Line1 pin widget output buffer since it starts as an output.
4162 * If the pin mode is changed by the user the pin mode control will
4163 * take care of enabling the pin's input/output buffers as needed.
4164 * Therefore there's no need to enable the input buffer at this
4165 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004166 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004167 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004168 /* Unmute input buffer of pin widget used for Line-in (no equiv
4169 * mixer ctrl)
4170 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004171 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004172
Jonathan Woithef7ace402006-02-28 11:46:14 +01004173 /* Mute capture amp left and right */
4174 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4175 /* Set ADC connection select to match default mixer setting - line
4176 * in (on mic1 pin)
4177 */
4178 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004179
Jonathan Woithef7ace402006-02-28 11:46:14 +01004180 /* Do the same for the second ADC: mute capture input amp and
4181 * set ADC connection to line in (on mic1 pin)
4182 */
4183 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4184 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004185
Jonathan Woithef7ace402006-02-28 11:46:14 +01004186 /* Mute all inputs to mixer widget (even unconnected ones) */
4187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004195
4196 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004197};
4198
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004199/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4200 * similar laptops (adapted from Fujitsu init verbs).
4201 */
4202static struct hda_verb alc260_acer_init_verbs[] = {
4203 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4204 * the headphone jack. Turn this on and rely on the standard mute
4205 * methods whenever the user wants to turn these outputs off.
4206 */
4207 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4208 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4209 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4210 /* Internal speaker/Headphone jack is connected to Line-out pin */
4211 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4212 /* Internal microphone/Mic jack is connected to Mic1 pin */
4213 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4214 /* Line In jack is connected to Line1 pin */
4215 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004216 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4217 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004218 /* Ensure all other unused pins are disabled and muted. */
4219 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4220 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004221 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4222 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 /* Disable digital (SPDIF) pins */
4226 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4227 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4228
4229 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4230 * bus when acting as outputs.
4231 */
4232 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4233 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4234
4235 /* Start with output sum widgets muted and their output gains at min */
4236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4241 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4243 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4244 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4245
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004246 /* Unmute Line-out pin widget amp left and right
4247 * (no equiv mixer ctrl)
4248 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004249 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004250 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4251 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004252 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4253 * inputs. If the pin mode is changed by the user the pin mode control
4254 * will take care of enabling the pin's input/output buffers as needed.
4255 * Therefore there's no need to enable the input buffer at this
4256 * stage.
4257 */
4258 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4260
4261 /* Mute capture amp left and right */
4262 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4263 /* Set ADC connection select to match default mixer setting - mic
4264 * (on mic1 pin)
4265 */
4266 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4267
4268 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004269 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004270 */
4271 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004272 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004273
4274 /* Mute all inputs to mixer widget (even unconnected ones) */
4275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4283
4284 { }
4285};
4286
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004287static struct hda_verb alc260_will_verbs[] = {
4288 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4289 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4290 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4291 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4292 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4293 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4294 {}
4295};
4296
4297static struct hda_verb alc260_replacer_672v_verbs[] = {
4298 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4299 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4300 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4301
4302 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4303 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4304 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4305
4306 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4307 {}
4308};
4309
4310/* toggle speaker-output according to the hp-jack state */
4311static void alc260_replacer_672v_automute(struct hda_codec *codec)
4312{
4313 unsigned int present;
4314
4315 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4316 present = snd_hda_codec_read(codec, 0x0f, 0,
4317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4318 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004319 snd_hda_codec_write_cache(codec, 0x01, 0,
4320 AC_VERB_SET_GPIO_DATA, 1);
4321 snd_hda_codec_write_cache(codec, 0x0f, 0,
4322 AC_VERB_SET_PIN_WIDGET_CONTROL,
4323 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004324 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004325 snd_hda_codec_write_cache(codec, 0x01, 0,
4326 AC_VERB_SET_GPIO_DATA, 0);
4327 snd_hda_codec_write_cache(codec, 0x0f, 0,
4328 AC_VERB_SET_PIN_WIDGET_CONTROL,
4329 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004330 }
4331}
4332
4333static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4334 unsigned int res)
4335{
4336 if ((res >> 26) == ALC880_HP_EVENT)
4337 alc260_replacer_672v_automute(codec);
4338}
4339
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004340/* Test configuration for debugging, modelled after the ALC880 test
4341 * configuration.
4342 */
4343#ifdef CONFIG_SND_DEBUG
4344static hda_nid_t alc260_test_dac_nids[1] = {
4345 0x02,
4346};
4347static hda_nid_t alc260_test_adc_nids[2] = {
4348 0x04, 0x05,
4349};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004350/* For testing the ALC260, each input MUX needs its own definition since
4351 * the signal assignments are different. This assumes that the first ADC
4352 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004353 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004354static struct hda_input_mux alc260_test_capture_sources[2] = {
4355 {
4356 .num_items = 7,
4357 .items = {
4358 { "MIC1 pin", 0x0 },
4359 { "MIC2 pin", 0x1 },
4360 { "LINE1 pin", 0x2 },
4361 { "LINE2 pin", 0x3 },
4362 { "CD pin", 0x4 },
4363 { "LINE-OUT pin", 0x5 },
4364 { "HP-OUT pin", 0x6 },
4365 },
4366 },
4367 {
4368 .num_items = 8,
4369 .items = {
4370 { "MIC1 pin", 0x0 },
4371 { "MIC2 pin", 0x1 },
4372 { "LINE1 pin", 0x2 },
4373 { "LINE2 pin", 0x3 },
4374 { "CD pin", 0x4 },
4375 { "Mixer", 0x5 },
4376 { "LINE-OUT pin", 0x6 },
4377 { "HP-OUT pin", 0x7 },
4378 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004379 },
4380};
4381static struct snd_kcontrol_new alc260_test_mixer[] = {
4382 /* Output driver widgets */
4383 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4384 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4385 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4386 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4387 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4388 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4389
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004390 /* Modes for retasking pin widgets
4391 * Note: the ALC260 doesn't seem to act on requests to enable mic
4392 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4393 * mention this restriction. At this stage it's not clear whether
4394 * this behaviour is intentional or is a hardware bug in chip
4395 * revisions available at least up until early 2006. Therefore for
4396 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4397 * choices, but if it turns out that the lack of mic bias for these
4398 * NIDs is intentional we could change their modes from
4399 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4400 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004401 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4402 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4403 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4404 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4405 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4406 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4407
4408 /* Loopback mixer controls */
4409 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4410 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4411 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4412 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4413 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4414 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4415 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4416 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4417 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4418 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4419 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4420 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4421 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4422 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4423 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4424 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004425
4426 /* Controls for GPIO pins, assuming they are configured as outputs */
4427 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4428 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4429 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4430 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4431
Jonathan Woithe92621f12006-02-28 11:47:47 +01004432 /* Switches to allow the digital IO pins to be enabled. The datasheet
4433 * is ambigious as to which NID is which; testing on laptops which
4434 * make this output available should provide clarification.
4435 */
4436 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4437 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4438
Jonathan Woithef8225f62008-01-08 12:16:54 +01004439 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4440 * this output to turn on an external amplifier.
4441 */
4442 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4443 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4444
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004445 { } /* end */
4446};
4447static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004448 /* Enable all GPIOs as outputs with an initial value of 0 */
4449 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4450 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4451 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4452
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004453 /* Enable retasking pins as output, initially without power amp */
4454 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4455 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4458 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4460
Jonathan Woithe92621f12006-02-28 11:47:47 +01004461 /* Disable digital (SPDIF) pins initially, but users can enable
4462 * them via a mixer switch. In the case of SPDIF-out, this initverb
4463 * payload also sets the generation to 0, output to be in "consumer"
4464 * PCM format, copyright asserted, no pre-emphasis and no validity
4465 * control.
4466 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004467 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4468 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4469
Jonathan Woithef7ace402006-02-28 11:46:14 +01004470 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004471 * OUT1 sum bus when acting as an output.
4472 */
4473 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4474 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4475 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4476 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4477
4478 /* Start with output sum widgets muted and their output gains at min */
4479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4486 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4487 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004489 /* Unmute retasking pin widget output buffers since the default
4490 * state appears to be output. As the pin mode is changed by the
4491 * user the pin mode control will take care of enabling the pin's
4492 * input/output buffers as needed.
4493 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4495 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4498 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4499 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4500 /* Also unmute the mono-out pin widget */
4501 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4502
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004503 /* Mute capture amp left and right */
4504 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004505 /* Set ADC connection select to match default mixer setting (mic1
4506 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004507 */
4508 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4509
4510 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004511 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004512 */
4513 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4514 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4515
4516 /* Mute all inputs to mixer widget (even unconnected ones) */
4517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4525
4526 { }
4527};
4528#endif
4529
Linus Torvalds1da177e2005-04-16 15:20:36 -07004530static struct hda_pcm_stream alc260_pcm_analog_playback = {
4531 .substreams = 1,
4532 .channels_min = 2,
4533 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004534};
4535
4536static struct hda_pcm_stream alc260_pcm_analog_capture = {
4537 .substreams = 1,
4538 .channels_min = 2,
4539 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004540};
4541
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004542#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4543#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4544
Kailang Yangdf694da2005-12-05 19:42:22 +01004545/*
4546 * for BIOS auto-configuration
4547 */
4548
4549static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4550 const char *pfx)
4551{
4552 hda_nid_t nid_vol;
4553 unsigned long vol_val, sw_val;
4554 char name[32];
4555 int err;
4556
4557 if (nid >= 0x0f && nid < 0x11) {
4558 nid_vol = nid - 0x7;
4559 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4560 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4561 } else if (nid == 0x11) {
4562 nid_vol = nid - 0x7;
4563 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4564 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4565 } else if (nid >= 0x12 && nid <= 0x15) {
4566 nid_vol = 0x08;
4567 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4568 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4569 } else
4570 return 0; /* N/A */
4571
4572 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004573 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4574 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004575 return err;
4576 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004577 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4578 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004579 return err;
4580 return 1;
4581}
4582
4583/* add playback controls from the parsed DAC table */
4584static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4585 const struct auto_pin_cfg *cfg)
4586{
4587 hda_nid_t nid;
4588 int err;
4589
4590 spec->multiout.num_dacs = 1;
4591 spec->multiout.dac_nids = spec->private_dac_nids;
4592 spec->multiout.dac_nids[0] = 0x02;
4593
4594 nid = cfg->line_out_pins[0];
4595 if (nid) {
4596 err = alc260_add_playback_controls(spec, nid, "Front");
4597 if (err < 0)
4598 return err;
4599 }
4600
Takashi Iwai82bc9552006-03-21 11:24:42 +01004601 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004602 if (nid) {
4603 err = alc260_add_playback_controls(spec, nid, "Speaker");
4604 if (err < 0)
4605 return err;
4606 }
4607
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004608 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 if (nid) {
4610 err = alc260_add_playback_controls(spec, nid, "Headphone");
4611 if (err < 0)
4612 return err;
4613 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004614 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004615}
4616
4617/* create playback/capture controls for input pins */
4618static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4619 const struct auto_pin_cfg *cfg)
4620{
Kailang Yangdf694da2005-12-05 19:42:22 +01004621 struct hda_input_mux *imux = &spec->private_imux;
4622 int i, err, idx;
4623
4624 for (i = 0; i < AUTO_PIN_LAST; i++) {
4625 if (cfg->input_pins[i] >= 0x12) {
4626 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004627 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 auto_pin_cfg_labels[i], idx,
4629 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004630 if (err < 0)
4631 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 imux->items[imux->num_items].label =
4633 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004634 imux->items[imux->num_items].index = idx;
4635 imux->num_items++;
4636 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004637 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004638 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004639 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 auto_pin_cfg_labels[i], idx,
4641 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004642 if (err < 0)
4643 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004644 imux->items[imux->num_items].label =
4645 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004646 imux->items[imux->num_items].index = idx;
4647 imux->num_items++;
4648 }
4649 }
4650 return 0;
4651}
4652
4653static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4654 hda_nid_t nid, int pin_type,
4655 int sel_idx)
4656{
4657 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004658 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4659 pin_type);
4660 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4661 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004662 /* need the manual connection? */
4663 if (nid >= 0x12) {
4664 int idx = nid - 0x12;
4665 snd_hda_codec_write(codec, idx + 0x0b, 0,
4666 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004667 }
4668}
4669
4670static void alc260_auto_init_multi_out(struct hda_codec *codec)
4671{
4672 struct alc_spec *spec = codec->spec;
4673 hda_nid_t nid;
4674
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004675 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004677 if (nid) {
4678 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4679 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4680 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004681
Takashi Iwai82bc9552006-03-21 11:24:42 +01004682 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004683 if (nid)
4684 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4685
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004686 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004688 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004689}
Kailang Yangdf694da2005-12-05 19:42:22 +01004690
4691#define ALC260_PIN_CD_NID 0x16
4692static void alc260_auto_init_analog_input(struct hda_codec *codec)
4693{
4694 struct alc_spec *spec = codec->spec;
4695 int i;
4696
4697 for (i = 0; i < AUTO_PIN_LAST; i++) {
4698 hda_nid_t nid = spec->autocfg.input_pins[i];
4699 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004700 snd_hda_codec_write(codec, nid, 0,
4701 AC_VERB_SET_PIN_WIDGET_CONTROL,
4702 i <= AUTO_PIN_FRONT_MIC ?
4703 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004704 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004705 snd_hda_codec_write(codec, nid, 0,
4706 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004707 AMP_OUT_MUTE);
4708 }
4709 }
4710}
4711
4712/*
4713 * generic initialization of ADC, input mixers and output mixers
4714 */
4715static struct hda_verb alc260_volume_init_verbs[] = {
4716 /*
4717 * Unmute ADC0-1 and set the default input to mic-in
4718 */
4719 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4720 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4721 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4722 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4723
4724 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4725 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004726 * Note: PASD motherboards uses the Line In 2 as the input for
4727 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004728 */
4729 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004730 /* mute analog inputs */
4731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004736
4737 /*
4738 * Set up output mixers (0x08 - 0x0a)
4739 */
4740 /* set vol=0 to output mixers */
4741 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4742 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4743 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4744 /* set up input amps for analog loopback */
4745 /* Amp Indices: DAC = 0, mixer = 1 */
4746 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4748 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4751 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4752
4753 { }
4754};
4755
4756static int alc260_parse_auto_config(struct hda_codec *codec)
4757{
4758 struct alc_spec *spec = codec->spec;
4759 unsigned int wcap;
4760 int err;
4761 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4762
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004763 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4764 alc260_ignore);
4765 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004766 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004767 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4768 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004769 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004770 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004771 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004772 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4773 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004774 return err;
4775
4776 spec->multiout.max_channels = 2;
4777
4778 if (spec->autocfg.dig_out_pin)
4779 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4780 if (spec->kctl_alloc)
4781 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4782
4783 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4784
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004785 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004786 spec->input_mux = &spec->private_imux;
4787
4788 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004789 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004790 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4791 if (wcap != AC_WID_AUD_IN) {
4792 spec->adc_nids = alc260_adc_nids_alt;
4793 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4794 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004795 } else {
4796 spec->adc_nids = alc260_adc_nids;
4797 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4798 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004799 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004800 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004801
4802 return 1;
4803}
4804
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004805/* additional initialization for auto-configuration model */
4806static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004807{
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 alc260_auto_init_multi_out(codec);
4809 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004810}
4811
Takashi Iwaicb53c622007-08-10 17:21:45 +02004812#ifdef CONFIG_SND_HDA_POWER_SAVE
4813static struct hda_amp_list alc260_loopbacks[] = {
4814 { 0x07, HDA_INPUT, 0 },
4815 { 0x07, HDA_INPUT, 1 },
4816 { 0x07, HDA_INPUT, 2 },
4817 { 0x07, HDA_INPUT, 3 },
4818 { 0x07, HDA_INPUT, 4 },
4819 { } /* end */
4820};
4821#endif
4822
Kailang Yangdf694da2005-12-05 19:42:22 +01004823/*
4824 * ALC260 configurations
4825 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004826static const char *alc260_models[ALC260_MODEL_LAST] = {
4827 [ALC260_BASIC] = "basic",
4828 [ALC260_HP] = "hp",
4829 [ALC260_HP_3013] = "hp-3013",
4830 [ALC260_FUJITSU_S702X] = "fujitsu",
4831 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004832 [ALC260_WILL] = "will",
4833 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004834#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004835 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004836#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004837 [ALC260_AUTO] = "auto",
4838};
4839
4840static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004841 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004842 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004843 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004844 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004845 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4846 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4847 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4848 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4849 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4850 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4851 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4852 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4853 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4854 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4855 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4856 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004857 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004858 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004859 {}
4860};
4861
Kailang Yangdf694da2005-12-05 19:42:22 +01004862static struct alc_config_preset alc260_presets[] = {
4863 [ALC260_BASIC] = {
4864 .mixers = { alc260_base_output_mixer,
4865 alc260_input_mixer,
4866 alc260_pc_beep_mixer,
4867 alc260_capture_mixer },
4868 .init_verbs = { alc260_init_verbs },
4869 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4870 .dac_nids = alc260_dac_nids,
4871 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4872 .adc_nids = alc260_adc_nids,
4873 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4874 .channel_mode = alc260_modes,
4875 .input_mux = &alc260_capture_source,
4876 },
4877 [ALC260_HP] = {
4878 .mixers = { alc260_base_output_mixer,
4879 alc260_input_mixer,
4880 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004881 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004882 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4883 .dac_nids = alc260_dac_nids,
4884 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4885 .adc_nids = alc260_hp_adc_nids,
4886 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4887 .channel_mode = alc260_modes,
4888 .input_mux = &alc260_capture_source,
4889 },
4890 [ALC260_HP_3013] = {
4891 .mixers = { alc260_hp_3013_mixer,
4892 alc260_input_mixer,
4893 alc260_capture_alt_mixer },
4894 .init_verbs = { alc260_hp_3013_init_verbs },
4895 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4896 .dac_nids = alc260_dac_nids,
4897 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4898 .adc_nids = alc260_hp_adc_nids,
4899 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4900 .channel_mode = alc260_modes,
4901 .input_mux = &alc260_capture_source,
4902 },
4903 [ALC260_FUJITSU_S702X] = {
4904 .mixers = { alc260_fujitsu_mixer,
4905 alc260_capture_mixer },
4906 .init_verbs = { alc260_fujitsu_init_verbs },
4907 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4908 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004909 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4910 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004911 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4912 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004913 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4914 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004915 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004916 [ALC260_ACER] = {
4917 .mixers = { alc260_acer_mixer,
4918 alc260_capture_mixer },
4919 .init_verbs = { alc260_acer_init_verbs },
4920 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4921 .dac_nids = alc260_dac_nids,
4922 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4923 .adc_nids = alc260_dual_adc_nids,
4924 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4925 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004926 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4927 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004928 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004929 [ALC260_WILL] = {
4930 .mixers = { alc260_will_mixer,
4931 alc260_capture_mixer },
4932 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4933 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4934 .dac_nids = alc260_dac_nids,
4935 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4936 .adc_nids = alc260_adc_nids,
4937 .dig_out_nid = ALC260_DIGOUT_NID,
4938 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4939 .channel_mode = alc260_modes,
4940 .input_mux = &alc260_capture_source,
4941 },
4942 [ALC260_REPLACER_672V] = {
4943 .mixers = { alc260_replacer_672v_mixer,
4944 alc260_capture_mixer },
4945 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4946 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4947 .dac_nids = alc260_dac_nids,
4948 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4949 .adc_nids = alc260_adc_nids,
4950 .dig_out_nid = ALC260_DIGOUT_NID,
4951 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4952 .channel_mode = alc260_modes,
4953 .input_mux = &alc260_capture_source,
4954 .unsol_event = alc260_replacer_672v_unsol_event,
4955 .init_hook = alc260_replacer_672v_automute,
4956 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004957#ifdef CONFIG_SND_DEBUG
4958 [ALC260_TEST] = {
4959 .mixers = { alc260_test_mixer,
4960 alc260_capture_mixer },
4961 .init_verbs = { alc260_test_init_verbs },
4962 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4963 .dac_nids = alc260_test_dac_nids,
4964 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4965 .adc_nids = alc260_test_adc_nids,
4966 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4967 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004968 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4969 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004970 },
4971#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004972};
4973
Linus Torvalds1da177e2005-04-16 15:20:36 -07004974static int patch_alc260(struct hda_codec *codec)
4975{
4976 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004977 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004978
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004979 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004980 if (spec == NULL)
4981 return -ENOMEM;
4982
4983 codec->spec = spec;
4984
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004985 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4986 alc260_models,
4987 alc260_cfg_tbl);
4988 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004989 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4990 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004991 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004992 }
4993
Kailang Yangdf694da2005-12-05 19:42:22 +01004994 if (board_config == ALC260_AUTO) {
4995 /* automatic parse from the BIOS config */
4996 err = alc260_parse_auto_config(codec);
4997 if (err < 0) {
4998 alc_free(codec);
4999 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005000 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005001 printk(KERN_INFO
5002 "hda_codec: Cannot set up configuration "
5003 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005004 board_config = ALC260_BASIC;
5005 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005006 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005007
Kailang Yangdf694da2005-12-05 19:42:22 +01005008 if (board_config != ALC260_AUTO)
5009 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005010
5011 spec->stream_name_analog = "ALC260 Analog";
5012 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5013 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5014
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005015 spec->stream_name_digital = "ALC260 Digital";
5016 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5017 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5018
Takashi Iwai2134ea42008-01-10 16:53:55 +01005019 spec->vmaster_nid = 0x08;
5020
Linus Torvalds1da177e2005-04-16 15:20:36 -07005021 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005022 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005023 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005024#ifdef CONFIG_SND_HDA_POWER_SAVE
5025 if (!spec->loopback.amplist)
5026 spec->loopback.amplist = alc260_loopbacks;
5027#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005028
5029 return 0;
5030}
5031
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005032
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033/*
5034 * ALC882 support
5035 *
5036 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5037 * configuration. Each pin widget can choose any input DACs and a mixer.
5038 * Each ADC is connected from a mixer of all inputs. This makes possible
5039 * 6-channel independent captures.
5040 *
5041 * In addition, an independent DAC for the multi-playback (not used in this
5042 * driver yet).
5043 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005044#define ALC882_DIGOUT_NID 0x06
5045#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005046
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005047static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005048 { 8, NULL }
5049};
5050
5051static hda_nid_t alc882_dac_nids[4] = {
5052 /* front, rear, clfe, rear_surr */
5053 0x02, 0x03, 0x04, 0x05
5054};
5055
Kailang Yangdf694da2005-12-05 19:42:22 +01005056/* identical with ALC880 */
5057#define alc882_adc_nids alc880_adc_nids
5058#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005059
5060/* input MUX */
5061/* FIXME: should be a matrix-type input source selection */
5062
5063static struct hda_input_mux alc882_capture_source = {
5064 .num_items = 4,
5065 .items = {
5066 { "Mic", 0x0 },
5067 { "Front Mic", 0x1 },
5068 { "Line", 0x2 },
5069 { "CD", 0x4 },
5070 },
5071};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005072#define alc882_mux_enum_info alc_mux_enum_info
5073#define alc882_mux_enum_get alc_mux_enum_get
5074
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005075static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5076 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005077{
5078 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5079 struct alc_spec *spec = codec->spec;
5080 const struct hda_input_mux *imux = spec->input_mux;
5081 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5082 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5083 hda_nid_t nid = capture_mixers[adc_idx];
5084 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5085 unsigned int i, idx;
5086
5087 idx = ucontrol->value.enumerated.item[0];
5088 if (idx >= imux->num_items)
5089 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005090 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005091 return 0;
5092 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005093 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5094 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005095 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005096 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005097 }
5098 *cur_val = idx;
5099 return 1;
5100}
5101
Kailang Yangdf694da2005-12-05 19:42:22 +01005102/*
Kailang Yang272a5272007-05-14 11:00:38 +02005103 * 2ch mode
5104 */
5105static struct hda_verb alc882_3ST_ch2_init[] = {
5106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5108 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5109 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5110 { } /* end */
5111};
5112
5113/*
5114 * 6ch mode
5115 */
5116static struct hda_verb alc882_3ST_ch6_init[] = {
5117 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5118 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5119 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5120 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5121 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5122 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5123 { } /* end */
5124};
5125
5126static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5127 { 2, alc882_3ST_ch2_init },
5128 { 6, alc882_3ST_ch6_init },
5129};
5130
5131/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005132 * 6ch mode
5133 */
5134static struct hda_verb alc882_sixstack_ch6_init[] = {
5135 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5136 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5137 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5138 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5139 { } /* end */
5140};
5141
5142/*
5143 * 8ch mode
5144 */
5145static struct hda_verb alc882_sixstack_ch8_init[] = {
5146 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5147 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5148 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5149 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5150 { } /* end */
5151};
5152
5153static struct hda_channel_mode alc882_sixstack_modes[2] = {
5154 { 6, alc882_sixstack_ch6_init },
5155 { 8, alc882_sixstack_ch8_init },
5156};
5157
Takashi Iwai87350ad2007-08-16 18:19:38 +02005158/*
5159 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5160 */
5161
5162/*
5163 * 2ch mode
5164 */
5165static struct hda_verb alc885_mbp_ch2_init[] = {
5166 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5167 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5168 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5169 { } /* end */
5170};
5171
5172/*
5173 * 6ch mode
5174 */
5175static struct hda_verb alc885_mbp_ch6_init[] = {
5176 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5177 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5178 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5179 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5180 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5181 { } /* end */
5182};
5183
5184static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5185 { 2, alc885_mbp_ch2_init },
5186 { 6, alc885_mbp_ch6_init },
5187};
5188
5189
Linus Torvalds1da177e2005-04-16 15:20:36 -07005190/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5191 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5192 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005193static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005194 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005195 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005196 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005197 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005198 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5199 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005200 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5201 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005202 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005203 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005213 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5215 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5216 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005217 { } /* end */
5218};
5219
Takashi Iwai87350ad2007-08-16 18:19:38 +02005220static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5222 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5223 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5224 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5226 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5228 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005229 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5231 { } /* end */
5232};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005233static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5235 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5238 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5239 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5243 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5244 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5245 { } /* end */
5246};
5247
Kailang Yang272a5272007-05-14 11:00:38 +02005248static struct snd_kcontrol_new alc882_targa_mixer[] = {
5249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5250 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5252 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5253 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005258 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005259 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5260 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005261 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005262 { } /* end */
5263};
5264
5265/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5266 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5267 */
5268static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5270 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5272 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5273 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5274 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5277 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5278 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005282 { } /* end */
5283};
5284
Takashi Iwai914759b2007-09-06 14:52:04 +02005285static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5296 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5297 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5298 { } /* end */
5299};
5300
Kailang Yangdf694da2005-12-05 19:42:22 +01005301static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5302 {
5303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5304 .name = "Channel Mode",
5305 .info = alc_ch_mode_info,
5306 .get = alc_ch_mode_get,
5307 .put = alc_ch_mode_put,
5308 },
5309 { } /* end */
5310};
5311
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312static struct hda_verb alc882_init_verbs[] = {
5313 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005317 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5319 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005321 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005325 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005329
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005330 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005333 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005334 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005338 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005339 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005340 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005341 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005342 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005343 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005344 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005345 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005346 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005347 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5349 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5352 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5355 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5356 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5357 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5358 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005359 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005360 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005361
5362 /* FIXME: use matrix-type input source selection */
5363 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5364 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005369 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005374 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5379 /* ADC1: mute amp left and right */
5380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005381 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005382 /* ADC2: mute amp left and right */
5383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005384 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005385 /* ADC3: mute amp left and right */
5386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005387 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388
5389 { }
5390};
5391
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005392static struct hda_verb alc882_eapd_verbs[] = {
5393 /* change to EAPD mode */
5394 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005395 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005396 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005397};
5398
Tobin Davis9102cd12006-12-15 10:02:12 +01005399/* Mac Pro test */
5400static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5404 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5405 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5406 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5407 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5408 { } /* end */
5409};
5410
5411static struct hda_verb alc882_macpro_init_verbs[] = {
5412 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5416 /* Front Pin: output 0 (0x0c) */
5417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5420 /* Front Mic pin: input vref at 80% */
5421 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5423 /* Speaker: output */
5424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5426 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5427 /* Headphone output (output 0 - 0x0c) */
5428 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5429 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5430 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5431
5432 /* FIXME: use matrix-type input source selection */
5433 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5434 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5439 /* Input mixer2 */
5440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5444 /* Input mixer3 */
5445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5449 /* ADC1: mute amp left and right */
5450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5452 /* ADC2: mute amp left and right */
5453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5454 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5455 /* ADC3: mute amp left and right */
5456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5457 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5458
5459 { }
5460};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005461
Takashi Iwai87350ad2007-08-16 18:19:38 +02005462/* Macbook Pro rev3 */
5463static struct hda_verb alc885_mbp3_init_verbs[] = {
5464 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5465 {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)},
5468 /* Rear mixer */
5469 {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)},
5472 /* Front Pin: output 0 (0x0c) */
5473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5475 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5476 /* HP Pin: output 0 (0x0d) */
5477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5480 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5481 /* Mic (rear) pin: input vref at 80% */
5482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5484 /* Front Mic pin: input vref at 80% */
5485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5487 /* Line In pin: use output 1 when in LineOut mode */
5488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5490 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5491
5492 /* FIXME: use matrix-type input source selection */
5493 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5494 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5499 /* Input mixer2 */
5500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5504 /* Input mixer3 */
5505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5509 /* ADC1: mute amp left and right */
5510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5511 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5512 /* ADC2: mute amp left and right */
5513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5514 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5515 /* ADC3: mute amp left and right */
5516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5517 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5518
5519 { }
5520};
5521
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005522/* iMac 24 mixer. */
5523static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5524 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5525 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5526 { } /* end */
5527};
5528
5529/* iMac 24 init verbs. */
5530static struct hda_verb alc885_imac24_init_verbs[] = {
5531 /* Internal speakers: output 0 (0x0c) */
5532 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5534 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5535 /* Internal speakers: output 0 (0x0c) */
5536 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5537 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5538 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5539 /* Headphone: output 0 (0x0c) */
5540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5542 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5543 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5544 /* Front Mic: input vref at 80% */
5545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5547 { }
5548};
5549
5550/* Toggle speaker-output according to the hp-jack state */
5551static void alc885_imac24_automute(struct hda_codec *codec)
5552{
5553 unsigned int present;
5554
5555 present = snd_hda_codec_read(codec, 0x14, 0,
5556 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005557 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5558 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5559 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5560 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005561}
5562
5563/* Processes unsolicited events. */
5564static void alc885_imac24_unsol_event(struct hda_codec *codec,
5565 unsigned int res)
5566{
5567 /* Headphone insertion or removal. */
5568 if ((res >> 26) == ALC880_HP_EVENT)
5569 alc885_imac24_automute(codec);
5570}
5571
Takashi Iwai87350ad2007-08-16 18:19:38 +02005572static void alc885_mbp3_automute(struct hda_codec *codec)
5573{
5574 unsigned int present;
5575
5576 present = snd_hda_codec_read(codec, 0x15, 0,
5577 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5578 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5579 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5580 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5581 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5582
5583}
5584static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5585 unsigned int res)
5586{
5587 /* Headphone insertion or removal. */
5588 if ((res >> 26) == ALC880_HP_EVENT)
5589 alc885_mbp3_automute(codec);
5590}
5591
5592
Kailang Yang272a5272007-05-14 11:00:38 +02005593static struct hda_verb alc882_targa_verbs[] = {
5594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5596
5597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5598 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5599
5600 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5601 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5602 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5603
5604 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5605 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5606 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5607 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5608 { } /* end */
5609};
5610
5611/* toggle speaker-output according to the hp-jack state */
5612static void alc882_targa_automute(struct hda_codec *codec)
5613{
5614 unsigned int present;
5615
5616 present = snd_hda_codec_read(codec, 0x14, 0,
5617 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005618 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5619 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005620 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5621 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005622}
5623
5624static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5625{
5626 /* Looks like the unsol event is incompatible with the standard
5627 * definition. 4bit tag is placed at 26 bit!
5628 */
5629 if (((res >> 26) == ALC880_HP_EVENT)) {
5630 alc882_targa_automute(codec);
5631 }
5632}
5633
5634static struct hda_verb alc882_asus_a7j_verbs[] = {
5635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5637
5638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5641
5642 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5644 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5645
5646 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5647 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5648 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5649 { } /* end */
5650};
5651
Takashi Iwai914759b2007-09-06 14:52:04 +02005652static struct hda_verb alc882_asus_a7m_verbs[] = {
5653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5655
5656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5658 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5659
5660 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5662 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5663
5664 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5665 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5666 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5667 { } /* end */
5668};
5669
Tobin Davis9102cd12006-12-15 10:02:12 +01005670static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5671{
5672 unsigned int gpiostate, gpiomask, gpiodir;
5673
5674 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5675 AC_VERB_GET_GPIO_DATA, 0);
5676
5677 if (!muted)
5678 gpiostate |= (1 << pin);
5679 else
5680 gpiostate &= ~(1 << pin);
5681
5682 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5683 AC_VERB_GET_GPIO_MASK, 0);
5684 gpiomask |= (1 << pin);
5685
5686 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5687 AC_VERB_GET_GPIO_DIRECTION, 0);
5688 gpiodir |= (1 << pin);
5689
5690
5691 snd_hda_codec_write(codec, codec->afg, 0,
5692 AC_VERB_SET_GPIO_MASK, gpiomask);
5693 snd_hda_codec_write(codec, codec->afg, 0,
5694 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5695
5696 msleep(1);
5697
5698 snd_hda_codec_write(codec, codec->afg, 0,
5699 AC_VERB_SET_GPIO_DATA, gpiostate);
5700}
5701
Takashi Iwai7debbe52007-08-16 15:01:03 +02005702/* set up GPIO at initialization */
5703static void alc885_macpro_init_hook(struct hda_codec *codec)
5704{
5705 alc882_gpio_mute(codec, 0, 0);
5706 alc882_gpio_mute(codec, 1, 0);
5707}
5708
5709/* set up GPIO and update auto-muting at initialization */
5710static void alc885_imac24_init_hook(struct hda_codec *codec)
5711{
5712 alc885_macpro_init_hook(codec);
5713 alc885_imac24_automute(codec);
5714}
5715
Kailang Yangdf694da2005-12-05 19:42:22 +01005716/*
5717 * generic initialization of ADC, input mixers and output mixers
5718 */
5719static struct hda_verb alc882_auto_init_verbs[] = {
5720 /*
5721 * Unmute ADC0-2 and set the default input to mic-in
5722 */
5723 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5726 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5727 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5729
Takashi Iwaicb53c622007-08-10 17:21:45 +02005730 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005732 * Note: PASD motherboards uses the Line In 2 as the input for
5733 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005734 */
5735 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005741
5742 /*
5743 * Set up output mixers (0x0c - 0x0f)
5744 */
5745 /* set vol=0 to output mixers */
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5750 /* set up input amps for analog loopback */
5751 /* Amp Indices: DAC = 0, mixer = 1 */
5752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5758 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5760 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5761 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5762
5763 /* FIXME: use matrix-type input source selection */
5764 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5765 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5770 /* Input mixer2 */
5771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5775 /* Input mixer3 */
5776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5780
5781 { }
5782};
5783
5784/* capture mixer elements */
5785static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5786 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5787 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5788 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5789 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5790 {
5791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5792 /* The multiple "Capture Source" controls confuse alsamixer
5793 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005794 */
5795 /* .name = "Capture Source", */
5796 .name = "Input Source",
5797 .count = 2,
5798 .info = alc882_mux_enum_info,
5799 .get = alc882_mux_enum_get,
5800 .put = alc882_mux_enum_put,
5801 },
5802 { } /* end */
5803};
5804
5805static struct snd_kcontrol_new alc882_capture_mixer[] = {
5806 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5807 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5808 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5809 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5810 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5811 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5812 {
5813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5814 /* The multiple "Capture Source" controls confuse alsamixer
5815 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 */
5817 /* .name = "Capture Source", */
5818 .name = "Input Source",
5819 .count = 3,
5820 .info = alc882_mux_enum_info,
5821 .get = alc882_mux_enum_get,
5822 .put = alc882_mux_enum_put,
5823 },
5824 { } /* end */
5825};
5826
Takashi Iwaicb53c622007-08-10 17:21:45 +02005827#ifdef CONFIG_SND_HDA_POWER_SAVE
5828#define alc882_loopbacks alc880_loopbacks
5829#endif
5830
Kailang Yangdf694da2005-12-05 19:42:22 +01005831/* pcm configuration: identiacal with ALC880 */
5832#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5833#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5834#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5835#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5836
5837/*
5838 * configuration and preset
5839 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005840static const char *alc882_models[ALC882_MODEL_LAST] = {
5841 [ALC882_3ST_DIG] = "3stack-dig",
5842 [ALC882_6ST_DIG] = "6stack-dig",
5843 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005844 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005845 [ALC882_TARGA] = "targa",
5846 [ALC882_ASUS_A7J] = "asus-a7j",
5847 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005848 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005849 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005850 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005851 [ALC882_AUTO] = "auto",
5852};
5853
5854static struct snd_pci_quirk alc882_cfg_tbl[] = {
5855 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005856 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005857 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005858 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005859 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005860 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005861 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005862 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5863 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5864 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5865 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 {}
5867};
5868
5869static struct alc_config_preset alc882_presets[] = {
5870 [ALC882_3ST_DIG] = {
5871 .mixers = { alc882_base_mixer },
5872 .init_verbs = { alc882_init_verbs },
5873 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5874 .dac_nids = alc882_dac_nids,
5875 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 .dig_in_nid = ALC882_DIGIN_NID,
5877 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5878 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005879 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005880 .input_mux = &alc882_capture_source,
5881 },
5882 [ALC882_6ST_DIG] = {
5883 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5884 .init_verbs = { alc882_init_verbs },
5885 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5886 .dac_nids = alc882_dac_nids,
5887 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005888 .dig_in_nid = ALC882_DIGIN_NID,
5889 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5890 .channel_mode = alc882_sixstack_modes,
5891 .input_mux = &alc882_capture_source,
5892 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005893 [ALC882_ARIMA] = {
5894 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5895 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5897 .dac_nids = alc882_dac_nids,
5898 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5899 .channel_mode = alc882_sixstack_modes,
5900 .input_mux = &alc882_capture_source,
5901 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005902 [ALC882_W2JC] = {
5903 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5904 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5905 alc880_gpio1_init_verbs },
5906 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5907 .dac_nids = alc882_dac_nids,
5908 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5909 .channel_mode = alc880_threestack_modes,
5910 .need_dac_fix = 1,
5911 .input_mux = &alc882_capture_source,
5912 .dig_out_nid = ALC882_DIGOUT_NID,
5913 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005914 [ALC885_MBP3] = {
5915 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5916 .init_verbs = { alc885_mbp3_init_verbs,
5917 alc880_gpio1_init_verbs },
5918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5919 .dac_nids = alc882_dac_nids,
5920 .channel_mode = alc885_mbp_6ch_modes,
5921 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5922 .input_mux = &alc882_capture_source,
5923 .dig_out_nid = ALC882_DIGOUT_NID,
5924 .dig_in_nid = ALC882_DIGIN_NID,
5925 .unsol_event = alc885_mbp3_unsol_event,
5926 .init_hook = alc885_mbp3_automute,
5927 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005928 [ALC885_MACPRO] = {
5929 .mixers = { alc882_macpro_mixer },
5930 .init_verbs = { alc882_macpro_init_verbs },
5931 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5932 .dac_nids = alc882_dac_nids,
5933 .dig_out_nid = ALC882_DIGOUT_NID,
5934 .dig_in_nid = ALC882_DIGIN_NID,
5935 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5936 .channel_mode = alc882_ch_modes,
5937 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005938 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005939 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005940 [ALC885_IMAC24] = {
5941 .mixers = { alc885_imac24_mixer },
5942 .init_verbs = { alc885_imac24_init_verbs },
5943 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5944 .dac_nids = alc882_dac_nids,
5945 .dig_out_nid = ALC882_DIGOUT_NID,
5946 .dig_in_nid = ALC882_DIGIN_NID,
5947 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5948 .channel_mode = alc882_ch_modes,
5949 .input_mux = &alc882_capture_source,
5950 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005951 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005952 },
Kailang Yang272a5272007-05-14 11:00:38 +02005953 [ALC882_TARGA] = {
5954 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5955 alc882_capture_mixer },
5956 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5957 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5958 .dac_nids = alc882_dac_nids,
5959 .dig_out_nid = ALC882_DIGOUT_NID,
5960 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5961 .adc_nids = alc882_adc_nids,
5962 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5963 .channel_mode = alc882_3ST_6ch_modes,
5964 .need_dac_fix = 1,
5965 .input_mux = &alc882_capture_source,
5966 .unsol_event = alc882_targa_unsol_event,
5967 .init_hook = alc882_targa_automute,
5968 },
5969 [ALC882_ASUS_A7J] = {
5970 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5971 alc882_capture_mixer },
5972 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5973 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5974 .dac_nids = alc882_dac_nids,
5975 .dig_out_nid = ALC882_DIGOUT_NID,
5976 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5977 .adc_nids = alc882_adc_nids,
5978 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5979 .channel_mode = alc882_3ST_6ch_modes,
5980 .need_dac_fix = 1,
5981 .input_mux = &alc882_capture_source,
5982 },
Takashi Iwai914759b2007-09-06 14:52:04 +02005983 [ALC882_ASUS_A7M] = {
5984 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5985 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5986 alc880_gpio1_init_verbs,
5987 alc882_asus_a7m_verbs },
5988 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5989 .dac_nids = alc882_dac_nids,
5990 .dig_out_nid = ALC882_DIGOUT_NID,
5991 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5992 .channel_mode = alc880_threestack_modes,
5993 .need_dac_fix = 1,
5994 .input_mux = &alc882_capture_source,
5995 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005996};
5997
5998
5999/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006000 * Pin config fixes
6001 */
6002enum {
6003 PINFIX_ABIT_AW9D_MAX
6004};
6005
6006static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6007 { 0x15, 0x01080104 }, /* side */
6008 { 0x16, 0x01011012 }, /* rear */
6009 { 0x17, 0x01016011 }, /* clfe */
6010 { }
6011};
6012
6013static const struct alc_pincfg *alc882_pin_fixes[] = {
6014 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6015};
6016
6017static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6018 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6019 {}
6020};
6021
6022/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006023 * BIOS auto configuration
6024 */
6025static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6026 hda_nid_t nid, int pin_type,
6027 int dac_idx)
6028{
6029 /* set as output */
6030 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006031 int idx;
6032
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6034 idx = 4;
6035 else
6036 idx = spec->multiout.dac_nids[dac_idx] - 2;
6037
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006038 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6039 pin_type);
6040 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6041 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006042 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6043
6044}
6045
6046static void alc882_auto_init_multi_out(struct hda_codec *codec)
6047{
6048 struct alc_spec *spec = codec->spec;
6049 int i;
6050
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006051 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006053 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006054 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006056 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006057 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006058 }
6059}
6060
6061static void alc882_auto_init_hp_out(struct hda_codec *codec)
6062{
6063 struct alc_spec *spec = codec->spec;
6064 hda_nid_t pin;
6065
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006066 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006068 /* use dac 0 */
6069 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006070}
6071
6072#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6073#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6074
6075static void alc882_auto_init_analog_input(struct hda_codec *codec)
6076{
6077 struct alc_spec *spec = codec->spec;
6078 int i;
6079
6080 for (i = 0; i < AUTO_PIN_LAST; i++) {
6081 hda_nid_t nid = spec->autocfg.input_pins[i];
6082 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006083 snd_hda_codec_write(codec, nid, 0,
6084 AC_VERB_SET_PIN_WIDGET_CONTROL,
6085 i <= AUTO_PIN_FRONT_MIC ?
6086 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006087 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006088 snd_hda_codec_write(codec, nid, 0,
6089 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 AMP_OUT_MUTE);
6091 }
6092 }
6093}
6094
Takashi Iwai776e1842007-08-29 15:07:11 +02006095/* add mic boosts if needed */
6096static int alc_auto_add_mic_boost(struct hda_codec *codec)
6097{
6098 struct alc_spec *spec = codec->spec;
6099 int err;
6100 hda_nid_t nid;
6101
6102 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006103 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006104 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6105 "Mic Boost",
6106 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6107 if (err < 0)
6108 return err;
6109 }
6110 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006111 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006112 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6113 "Front Mic Boost",
6114 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6115 if (err < 0)
6116 return err;
6117 }
6118 return 0;
6119}
6120
Kailang Yangdf694da2005-12-05 19:42:22 +01006121/* almost identical with ALC880 parser... */
6122static int alc882_parse_auto_config(struct hda_codec *codec)
6123{
6124 struct alc_spec *spec = codec->spec;
6125 int err = alc880_parse_auto_config(codec);
6126
6127 if (err < 0)
6128 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006129 else if (!err)
6130 return 0; /* no config found */
6131
6132 err = alc_auto_add_mic_boost(codec);
6133 if (err < 0)
6134 return err;
6135
6136 /* hack - override the init verbs */
6137 spec->init_verbs[0] = alc882_auto_init_verbs;
6138
6139 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006140}
6141
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006142/* additional initialization for auto-configuration model */
6143static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006144{
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 alc882_auto_init_multi_out(codec);
6146 alc882_auto_init_hp_out(codec);
6147 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006148}
6149
Linus Torvalds1da177e2005-04-16 15:20:36 -07006150static int patch_alc882(struct hda_codec *codec)
6151{
6152 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006153 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006154
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006155 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006156 if (spec == NULL)
6157 return -ENOMEM;
6158
Linus Torvalds1da177e2005-04-16 15:20:36 -07006159 codec->spec = spec;
6160
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006161 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6162 alc882_models,
6163 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006164
Kailang Yangdf694da2005-12-05 19:42:22 +01006165 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006166 /* Pick up systems that don't supply PCI SSID */
6167 switch (codec->subsystem_id) {
6168 case 0x106b0c00: /* Mac Pro */
6169 board_config = ALC885_MACPRO;
6170 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006171 case 0x106b1000: /* iMac 24 */
6172 board_config = ALC885_IMAC24;
6173 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006174 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006175 case 0x106b2c00: /* Macbook Pro rev3 */
6176 board_config = ALC885_MBP3;
6177 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006178 default:
6179 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6180 "trying auto-probe from BIOS...\n");
6181 board_config = ALC882_AUTO;
6182 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006183 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006184
Takashi Iwaif95474e2007-07-10 00:47:43 +02006185 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6186
Kailang Yangdf694da2005-12-05 19:42:22 +01006187 if (board_config == ALC882_AUTO) {
6188 /* automatic parse from the BIOS config */
6189 err = alc882_parse_auto_config(codec);
6190 if (err < 0) {
6191 alc_free(codec);
6192 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006193 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006194 printk(KERN_INFO
6195 "hda_codec: Cannot set up configuration "
6196 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006197 board_config = ALC882_3ST_DIG;
6198 }
6199 }
6200
6201 if (board_config != ALC882_AUTO)
6202 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006203
6204 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6206 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006207
6208 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006209 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6210 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006212 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006214 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006215 /* get type */
6216 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006217 if (wcap != AC_WID_AUD_IN) {
6218 spec->adc_nids = alc882_adc_nids_alt;
6219 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006220 spec->mixers[spec->num_mixers] =
6221 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006222 spec->num_mixers++;
6223 } else {
6224 spec->adc_nids = alc882_adc_nids;
6225 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6226 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6227 spec->num_mixers++;
6228 }
6229 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006230
Takashi Iwai2134ea42008-01-10 16:53:55 +01006231 spec->vmaster_nid = 0x0c;
6232
Linus Torvalds1da177e2005-04-16 15:20:36 -07006233 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006234 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006235 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006236#ifdef CONFIG_SND_HDA_POWER_SAVE
6237 if (!spec->loopback.amplist)
6238 spec->loopback.amplist = alc882_loopbacks;
6239#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006240
6241 return 0;
6242}
6243
6244/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006245 * ALC883 support
6246 *
6247 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6248 * configuration. Each pin widget can choose any input DACs and a mixer.
6249 * Each ADC is connected from a mixer of all inputs. This makes possible
6250 * 6-channel independent captures.
6251 *
6252 * In addition, an independent DAC for the multi-playback (not used in this
6253 * driver yet).
6254 */
6255#define ALC883_DIGOUT_NID 0x06
6256#define ALC883_DIGIN_NID 0x0a
6257
6258static hda_nid_t alc883_dac_nids[4] = {
6259 /* front, rear, clfe, rear_surr */
6260 0x02, 0x04, 0x03, 0x05
6261};
6262
6263static hda_nid_t alc883_adc_nids[2] = {
6264 /* ADC1-2 */
6265 0x08, 0x09,
6266};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006267
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006268/* input MUX */
6269/* FIXME: should be a matrix-type input source selection */
6270
6271static struct hda_input_mux alc883_capture_source = {
6272 .num_items = 4,
6273 .items = {
6274 { "Mic", 0x0 },
6275 { "Front Mic", 0x1 },
6276 { "Line", 0x2 },
6277 { "CD", 0x4 },
6278 },
6279};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006280
6281static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6282 .num_items = 2,
6283 .items = {
6284 { "Mic", 0x1 },
6285 { "Line", 0x2 },
6286 },
6287};
6288
Kailang Yang272a5272007-05-14 11:00:38 +02006289static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6290 .num_items = 4,
6291 .items = {
6292 { "Mic", 0x0 },
6293 { "iMic", 0x1 },
6294 { "Line", 0x2 },
6295 { "CD", 0x4 },
6296 },
6297};
6298
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006299#define alc883_mux_enum_info alc_mux_enum_info
6300#define alc883_mux_enum_get alc_mux_enum_get
6301
6302static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6303 struct snd_ctl_elem_value *ucontrol)
6304{
6305 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6306 struct alc_spec *spec = codec->spec;
6307 const struct hda_input_mux *imux = spec->input_mux;
6308 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6309 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6310 hda_nid_t nid = capture_mixers[adc_idx];
6311 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6312 unsigned int i, idx;
6313
6314 idx = ucontrol->value.enumerated.item[0];
6315 if (idx >= imux->num_items)
6316 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006317 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006318 return 0;
6319 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006320 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6321 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006322 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006323 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006324 }
6325 *cur_val = idx;
6326 return 1;
6327}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006329/*
6330 * 2ch mode
6331 */
6332static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6333 { 2, NULL }
6334};
6335
6336/*
6337 * 2ch mode
6338 */
6339static struct hda_verb alc883_3ST_ch2_init[] = {
6340 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6341 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6342 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6343 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6344 { } /* end */
6345};
6346
6347/*
Tobin Davisb2011312007-09-17 12:45:11 +02006348 * 4ch mode
6349 */
6350static struct hda_verb alc883_3ST_ch4_init[] = {
6351 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6352 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6353 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6354 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6355 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6356 { } /* end */
6357};
6358
6359/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006360 * 6ch mode
6361 */
6362static struct hda_verb alc883_3ST_ch6_init[] = {
6363 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6364 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6365 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6366 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6367 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6368 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6369 { } /* end */
6370};
6371
Tobin Davisb2011312007-09-17 12:45:11 +02006372static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006373 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006374 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006375 { 6, alc883_3ST_ch6_init },
6376};
6377
6378/*
6379 * 6ch mode
6380 */
6381static struct hda_verb alc883_sixstack_ch6_init[] = {
6382 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6386 { } /* end */
6387};
6388
6389/*
6390 * 8ch mode
6391 */
6392static struct hda_verb alc883_sixstack_ch8_init[] = {
6393 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6395 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6397 { } /* end */
6398};
6399
6400static struct hda_channel_mode alc883_sixstack_modes[2] = {
6401 { 6, alc883_sixstack_ch6_init },
6402 { 8, alc883_sixstack_ch8_init },
6403};
6404
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006405static struct hda_verb alc883_medion_eapd_verbs[] = {
6406 /* eanable EAPD on medion laptop */
6407 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6408 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6409 { }
6410};
6411
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006412/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6413 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6414 */
6415
6416static struct snd_kcontrol_new alc883_base_mixer[] = {
6417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6419 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6420 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6421 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6423 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6424 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6425 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6426 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6435 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006436 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6438 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6439 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6440 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6441 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6442 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6443 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6444 {
6445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6446 /* .name = "Capture Source", */
6447 .name = "Input Source",
6448 .count = 2,
6449 .info = alc883_mux_enum_info,
6450 .get = alc883_mux_enum_get,
6451 .put = alc883_mux_enum_put,
6452 },
6453 { } /* end */
6454};
6455
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006456static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6459 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6460 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6461 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6462 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6468 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6470 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6471 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6472 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6473 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6474 {
6475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6476 /* .name = "Capture Source", */
6477 .name = "Input Source",
6478 .count = 2,
6479 .info = alc883_mux_enum_info,
6480 .get = alc883_mux_enum_get,
6481 .put = alc883_mux_enum_put,
6482 },
6483 { } /* end */
6484};
6485
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006486static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6487 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6488 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006495 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006498 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006499 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6500 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6501 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6502 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6503 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6504 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6505 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6506 {
6507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6508 /* .name = "Capture Source", */
6509 .name = "Input Source",
6510 .count = 2,
6511 .info = alc883_mux_enum_info,
6512 .get = alc883_mux_enum_get,
6513 .put = alc883_mux_enum_put,
6514 },
6515 { } /* end */
6516};
6517
6518static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6520 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6521 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6522 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6523 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6525 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6526 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6528 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6529 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6530 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6531 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006536 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6538 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6539 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6540 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6541 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6542 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6543 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6544 {
6545 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6546 /* .name = "Capture Source", */
6547 .name = "Input Source",
6548 .count = 2,
6549 .info = alc883_mux_enum_info,
6550 .get = alc883_mux_enum_get,
6551 .put = alc883_mux_enum_put,
6552 },
6553 { } /* end */
6554};
6555
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006556static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6558 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6559 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6560 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6561 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6562 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6563 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6564 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6566 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6567 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6568 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6569 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6573 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006574 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6576 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6577 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6578 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6579 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6580
6581 {
6582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6583 /* .name = "Capture Source", */
6584 .name = "Input Source",
6585 .count = 1,
6586 .info = alc883_mux_enum_info,
6587 .get = alc883_mux_enum_get,
6588 .put = alc883_mux_enum_put,
6589 },
6590 { } /* end */
6591};
6592
Kailang Yangccc656c2006-10-17 12:32:26 +02006593static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6594 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6596 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6597 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6598 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6599 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6600 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6601 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6602 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6603 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6604 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6605 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6606 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006608 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6610 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6611 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6612 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6613 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6614 {
6615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6616 /* .name = "Capture Source", */
6617 .name = "Input Source",
6618 .count = 2,
6619 .info = alc883_mux_enum_info,
6620 .get = alc883_mux_enum_get,
6621 .put = alc883_mux_enum_put,
6622 },
6623 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006624};
Kailang Yangccc656c2006-10-17 12:32:26 +02006625
6626static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6627 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6629 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006633 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6635 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6636 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6637 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6638 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6639 {
6640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6641 /* .name = "Capture Source", */
6642 .name = "Input Source",
6643 .count = 2,
6644 .info = alc883_mux_enum_info,
6645 .get = alc883_mux_enum_get,
6646 .put = alc883_mux_enum_put,
6647 },
6648 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006649};
Kailang Yangccc656c2006-10-17 12:32:26 +02006650
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006651static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6652 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6653 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6654 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6655 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6658 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6660 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6661 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6662 {
6663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6664 /* .name = "Capture Source", */
6665 .name = "Input Source",
6666 .count = 1,
6667 .info = alc883_mux_enum_info,
6668 .get = alc883_mux_enum_get,
6669 .put = alc883_mux_enum_put,
6670 },
6671 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006672};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006673
Kailang Yang272a5272007-05-14 11:00:38 +02006674static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6676 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6682 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6683 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6684 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6685 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6686 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6687 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6688 {
6689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6690 /* .name = "Capture Source", */
6691 .name = "Input Source",
6692 .count = 2,
6693 .info = alc883_mux_enum_info,
6694 .get = alc883_mux_enum_get,
6695 .put = alc883_mux_enum_put,
6696 },
6697 { } /* end */
6698};
6699
6700static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6703 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6708 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6709 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6710 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6711 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6712 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6713 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6714 {
6715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6716 /* .name = "Capture Source", */
6717 .name = "Input Source",
6718 .count = 2,
6719 .info = alc883_mux_enum_info,
6720 .get = alc883_mux_enum_get,
6721 .put = alc883_mux_enum_put,
6722 },
6723 { } /* end */
6724};
6725
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006726static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6728 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6730 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6733 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6734 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6735 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6736 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6738 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6739 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6746 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6747 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6748 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6749 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6750 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6751 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6752 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6753 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6754 {
6755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6756 /* .name = "Capture Source", */
6757 .name = "Input Source",
6758 .count = 2,
6759 .info = alc883_mux_enum_info,
6760 .get = alc883_mux_enum_get,
6761 .put = alc883_mux_enum_put,
6762 },
6763 { } /* end */
6764};
6765
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006766static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6770 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6771 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6773 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6774 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6778 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6779 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6784 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6786 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6787 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6789 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6790 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6792 {
6793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6794 /* .name = "Capture Source", */
6795 .name = "Input Source",
6796 .count = 2,
6797 .info = alc883_mux_enum_info,
6798 .get = alc883_mux_enum_get,
6799 .put = alc883_mux_enum_put,
6800 },
6801 { } /* end */
6802};
6803
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006804static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6808 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6809 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6810 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6811 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6812 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6813 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6814 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6816 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6817 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6824 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6826 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6827 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6828 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6829 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6830 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6831 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6832 {
6833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6834 /* .name = "Capture Source", */
6835 .name = "Input Source",
6836 .count = 2,
6837 .info = alc883_mux_enum_info,
6838 .get = alc883_mux_enum_get,
6839 .put = alc883_mux_enum_put,
6840 },
6841 { } /* end */
6842};
6843
Tobin Davis2880a862007-08-07 11:50:26 +02006844static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006853 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6854 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6855 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6856 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6857 {
6858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6859 /* .name = "Capture Source", */
6860 .name = "Input Source",
6861 .count = 2,
6862 .info = alc883_mux_enum_info,
6863 .get = alc883_mux_enum_get,
6864 .put = alc883_mux_enum_put,
6865 },
6866 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006867};
Tobin Davis2880a862007-08-07 11:50:26 +02006868
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006869static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6870 {
6871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6872 .name = "Channel Mode",
6873 .info = alc_ch_mode_info,
6874 .get = alc_ch_mode_get,
6875 .put = alc_ch_mode_put,
6876 },
6877 { } /* end */
6878};
6879
6880static struct hda_verb alc883_init_verbs[] = {
6881 /* ADC1: mute amp left and right */
6882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6883 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 /* ADC2: mute amp left and right */
6885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6887 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6891 /* Rear mixer */
6892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6895 /* CLFE mixer */
6896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6899 /* Side mixer */
6900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6903
Takashi Iwaicb53c622007-08-10 17:21:45 +02006904 /* mute analog input loopbacks */
6905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006910
6911 /* Front Pin: output 0 (0x0c) */
6912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6914 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6915 /* Rear Pin: output 1 (0x0d) */
6916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6919 /* CLFE Pin: output 2 (0x0e) */
6920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6922 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6923 /* Side Pin: output 3 (0x0f) */
6924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6927 /* Mic (rear) pin: input vref at 80% */
6928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6930 /* Front Mic pin: input vref at 80% */
6931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6933 /* Line In pin: input */
6934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6936 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6940 /* CD pin widget for input */
6941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6942
6943 /* FIXME: use matrix-type input source selection */
6944 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6945 /* Input mixer2 */
6946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6950 /* Input mixer3 */
6951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6955 { }
6956};
6957
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006958/* toggle speaker-output according to the hp-jack state */
6959static void alc883_mitac_hp_automute(struct hda_codec *codec)
6960{
6961 unsigned int present;
6962
6963 present = snd_hda_codec_read(codec, 0x15, 0,
6964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6965 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6966 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6967 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6968 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6969}
6970
6971/* auto-toggle front mic */
6972/*
6973static void alc883_mitac_mic_automute(struct hda_codec *codec)
6974{
6975 unsigned int present;
6976 unsigned char bits;
6977
6978 present = snd_hda_codec_read(codec, 0x18, 0,
6979 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6980 bits = present ? HDA_AMP_MUTE : 0;
6981 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
6982}
6983*/
6984
6985static void alc883_mitac_automute(struct hda_codec *codec)
6986{
6987 alc883_mitac_hp_automute(codec);
6988 /* alc883_mitac_mic_automute(codec); */
6989}
6990
6991static void alc883_mitac_unsol_event(struct hda_codec *codec,
6992 unsigned int res)
6993{
6994 switch (res >> 26) {
6995 case ALC880_HP_EVENT:
6996 alc883_mitac_hp_automute(codec);
6997 break;
6998 case ALC880_MIC_EVENT:
6999 /* alc883_mitac_mic_automute(codec); */
7000 break;
7001 }
7002}
7003
7004static struct hda_verb alc883_mitac_verbs[] = {
7005 /* HP */
7006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7008 /* Subwoofer */
7009 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7010 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7011
7012 /* enable unsolicited event */
7013 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7014 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7015
7016 { } /* end */
7017};
7018
Kailang Yangccc656c2006-10-17 12:32:26 +02007019static struct hda_verb alc883_tagra_verbs[] = {
7020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022
7023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7025
7026 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7027 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7028 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7029
7030 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007031 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7032 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7033 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007034
7035 { } /* end */
7036};
7037
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007038static struct hda_verb alc883_lenovo_101e_verbs[] = {
7039 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7040 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7041 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7042 { } /* end */
7043};
7044
Kailang Yang272a5272007-05-14 11:00:38 +02007045static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7046 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7048 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7050 { } /* end */
7051};
7052
7053static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7056 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7058 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7059 { } /* end */
7060};
7061
Kailang Yang189609a2007-08-20 11:31:23 +02007062static struct hda_verb alc883_haier_w66_verbs[] = {
7063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7064 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7065
7066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7067
7068 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7071 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7072 { } /* end */
7073};
7074
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007075static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007076 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7078 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7079 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7080 { }
7081};
7082
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007083static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007084 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7085 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7086 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7087 { }
7088};
7089
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007090static struct hda_verb alc888_6st_dell_verbs[] = {
7091 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7092 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7094 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7096 { }
7097};
7098
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007099static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007100 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7101 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7102 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7103 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7104 { }
7105};
7106
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007107static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007108 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7109 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7110 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7111 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7112 { }
7113};
7114
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007115static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7116 { 2, alc888_3st_hp_2ch_init },
7117 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007118};
7119
Kailang Yang272a5272007-05-14 11:00:38 +02007120/* toggle front-jack and RCA according to the hp-jack state */
7121static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7122{
7123 unsigned int present;
7124
7125 present = snd_hda_codec_read(codec, 0x1b, 0,
7126 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007127 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7128 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7129 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7130 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007131}
7132
7133/* toggle RCA according to the front-jack state */
7134static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7135{
7136 unsigned int present;
7137
7138 present = snd_hda_codec_read(codec, 0x14, 0,
7139 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007140 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7141 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007142}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007143
Kailang Yang272a5272007-05-14 11:00:38 +02007144static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7145 unsigned int res)
7146{
7147 if ((res >> 26) == ALC880_HP_EVENT)
7148 alc888_lenovo_ms7195_front_automute(codec);
7149 if ((res >> 26) == ALC880_FRONT_EVENT)
7150 alc888_lenovo_ms7195_rca_automute(codec);
7151}
7152
7153static struct hda_verb alc883_medion_md2_verbs[] = {
7154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7156
7157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7158
7159 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7160 { } /* end */
7161};
7162
7163/* toggle speaker-output according to the hp-jack state */
7164static void alc883_medion_md2_automute(struct hda_codec *codec)
7165{
7166 unsigned int present;
7167
7168 present = snd_hda_codec_read(codec, 0x14, 0,
7169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007170 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7171 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007172}
7173
7174static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7175 unsigned int res)
7176{
7177 if ((res >> 26) == ALC880_HP_EVENT)
7178 alc883_medion_md2_automute(codec);
7179}
7180
Kailang Yangccc656c2006-10-17 12:32:26 +02007181/* toggle speaker-output according to the hp-jack state */
7182static void alc883_tagra_automute(struct hda_codec *codec)
7183{
7184 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007185 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007186
7187 present = snd_hda_codec_read(codec, 0x14, 0,
7188 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007189 bits = present ? HDA_AMP_MUTE : 0;
7190 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7191 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007192 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7193 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007194}
7195
7196static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7197{
7198 if ((res >> 26) == ALC880_HP_EVENT)
7199 alc883_tagra_automute(codec);
7200}
7201
Kailang Yang189609a2007-08-20 11:31:23 +02007202static void alc883_haier_w66_automute(struct hda_codec *codec)
7203{
7204 unsigned int present;
7205 unsigned char bits;
7206
7207 present = snd_hda_codec_read(codec, 0x1b, 0,
7208 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7209 bits = present ? 0x80 : 0;
7210 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7211 0x80, bits);
7212}
7213
7214static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7215 unsigned int res)
7216{
7217 if ((res >> 26) == ALC880_HP_EVENT)
7218 alc883_haier_w66_automute(codec);
7219}
7220
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007221static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7222{
7223 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007224 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007225
7226 present = snd_hda_codec_read(codec, 0x14, 0,
7227 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007228 bits = present ? HDA_AMP_MUTE : 0;
7229 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7230 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007231}
7232
7233static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7234{
7235 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007236 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007237
7238 present = snd_hda_codec_read(codec, 0x1b, 0,
7239 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007240 bits = present ? HDA_AMP_MUTE : 0;
7241 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7242 HDA_AMP_MUTE, bits);
7243 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7244 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007245}
7246
7247static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7248 unsigned int res)
7249{
7250 if ((res >> 26) == ALC880_HP_EVENT)
7251 alc883_lenovo_101e_all_automute(codec);
7252 if ((res >> 26) == ALC880_FRONT_EVENT)
7253 alc883_lenovo_101e_ispeaker_automute(codec);
7254}
7255
Takashi Iwai676a9b52007-08-16 15:23:35 +02007256/* toggle speaker-output according to the hp-jack state */
7257static void alc883_acer_aspire_automute(struct hda_codec *codec)
7258{
7259 unsigned int present;
7260
7261 present = snd_hda_codec_read(codec, 0x14, 0,
7262 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7263 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7264 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7265 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7266 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7267}
7268
7269static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7270 unsigned int res)
7271{
7272 if ((res >> 26) == ALC880_HP_EVENT)
7273 alc883_acer_aspire_automute(codec);
7274}
7275
Kailang Yangd1a991a2007-08-15 16:21:59 +02007276static struct hda_verb alc883_acer_eapd_verbs[] = {
7277 /* HP Pin: output 0 (0x0c) */
7278 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007284 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007285 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7286 /* eanable EAPD on medion laptop */
7287 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7288 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007289 /* enable unsolicited event */
7290 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007291 { }
7292};
7293
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007294static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7295{
7296 unsigned int present;
7297
7298 present = snd_hda_codec_read(codec, 0x1b, 0,
7299 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7300 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7301 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7303 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7304 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7305 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7306 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7307 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7308}
7309
7310static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7311 unsigned int res)
7312{
7313 switch (res >> 26) {
7314 case ALC880_HP_EVENT:
7315 printk("hp_event\n");
7316 alc888_6st_dell_front_automute(codec);
7317 break;
7318 }
7319}
7320
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007321/*
7322 * generic initialization of ADC, input mixers and output mixers
7323 */
7324static struct hda_verb alc883_auto_init_verbs[] = {
7325 /*
7326 * Unmute ADC0-2 and set the default input to mic-in
7327 */
7328 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7330 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7332
Takashi Iwaicb53c622007-08-10 17:21:45 +02007333 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007334 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007335 * Note: PASD motherboards uses the Line In 2 as the input for
7336 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007337 */
7338 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007344
7345 /*
7346 * Set up output mixers (0x0c - 0x0f)
7347 */
7348 /* set vol=0 to output mixers */
7349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7353 /* set up input amps for analog loopback */
7354 /* Amp Indices: DAC = 0, mixer = 1 */
7355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7361 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7362 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7363 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7364 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7365
7366 /* FIXME: use matrix-type input source selection */
7367 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7368 /* Input mixer1 */
7369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007372 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7374 /* Input mixer2 */
7375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007378 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007380
7381 { }
7382};
7383
7384/* capture mixer elements */
7385static struct snd_kcontrol_new alc883_capture_mixer[] = {
7386 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7387 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7390 {
7391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7392 /* The multiple "Capture Source" controls confuse alsamixer
7393 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007394 */
7395 /* .name = "Capture Source", */
7396 .name = "Input Source",
7397 .count = 2,
7398 .info = alc882_mux_enum_info,
7399 .get = alc882_mux_enum_get,
7400 .put = alc882_mux_enum_put,
7401 },
7402 { } /* end */
7403};
7404
Takashi Iwaicb53c622007-08-10 17:21:45 +02007405#ifdef CONFIG_SND_HDA_POWER_SAVE
7406#define alc883_loopbacks alc880_loopbacks
7407#endif
7408
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007409/* pcm configuration: identiacal with ALC880 */
7410#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7411#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7412#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7413#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7414
7415/*
7416 * configuration and preset
7417 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007418static const char *alc883_models[ALC883_MODEL_LAST] = {
7419 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7420 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7421 [ALC883_3ST_6ch] = "3stack-6ch",
7422 [ALC883_6ST_DIG] = "6stack-dig",
7423 [ALC883_TARGA_DIG] = "targa-dig",
7424 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007425 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007426 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007427 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007428 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007429 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007430 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007431 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7432 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007433 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007434 [ALC888_6ST_HP] = "6stack-hp",
7435 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007436 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007437 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007438 [ALC883_AUTO] = "auto",
7439};
7440
7441static struct snd_pci_quirk alc883_cfg_tbl[] = {
7442 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007443 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7444 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7445 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7446 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007447 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007448 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007449 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7450 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7451 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7452 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007453 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007454 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7455 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7456 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007457 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007458 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7459 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7460 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7461 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7462 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7463 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7464 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7465 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7466 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7467 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7468 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7469 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7470 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007471 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7472 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007473 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007474 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007475 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007476 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007477 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7478 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007479 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007480 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007481 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007482 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007483 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7484 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007485 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007486 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007487 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007488 {}
7489};
7490
7491static struct alc_config_preset alc883_presets[] = {
7492 [ALC883_3ST_2ch_DIG] = {
7493 .mixers = { alc883_3ST_2ch_mixer },
7494 .init_verbs = { alc883_init_verbs },
7495 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7496 .dac_nids = alc883_dac_nids,
7497 .dig_out_nid = ALC883_DIGOUT_NID,
7498 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7499 .adc_nids = alc883_adc_nids,
7500 .dig_in_nid = ALC883_DIGIN_NID,
7501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7502 .channel_mode = alc883_3ST_2ch_modes,
7503 .input_mux = &alc883_capture_source,
7504 },
7505 [ALC883_3ST_6ch_DIG] = {
7506 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7507 .init_verbs = { alc883_init_verbs },
7508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7509 .dac_nids = alc883_dac_nids,
7510 .dig_out_nid = ALC883_DIGOUT_NID,
7511 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7512 .adc_nids = alc883_adc_nids,
7513 .dig_in_nid = ALC883_DIGIN_NID,
7514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7515 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007516 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007517 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007518 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007519 [ALC883_3ST_6ch] = {
7520 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7521 .init_verbs = { alc883_init_verbs },
7522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7523 .dac_nids = alc883_dac_nids,
7524 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7525 .adc_nids = alc883_adc_nids,
7526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7527 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007528 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007529 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007530 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007531 [ALC883_6ST_DIG] = {
7532 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7533 .init_verbs = { alc883_init_verbs },
7534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7535 .dac_nids = alc883_dac_nids,
7536 .dig_out_nid = ALC883_DIGOUT_NID,
7537 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7538 .adc_nids = alc883_adc_nids,
7539 .dig_in_nid = ALC883_DIGIN_NID,
7540 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7541 .channel_mode = alc883_sixstack_modes,
7542 .input_mux = &alc883_capture_source,
7543 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007544 [ALC883_TARGA_DIG] = {
7545 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7546 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7548 .dac_nids = alc883_dac_nids,
7549 .dig_out_nid = ALC883_DIGOUT_NID,
7550 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7551 .adc_nids = alc883_adc_nids,
7552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7553 .channel_mode = alc883_3ST_6ch_modes,
7554 .need_dac_fix = 1,
7555 .input_mux = &alc883_capture_source,
7556 .unsol_event = alc883_tagra_unsol_event,
7557 .init_hook = alc883_tagra_automute,
7558 },
7559 [ALC883_TARGA_2ch_DIG] = {
7560 .mixers = { alc883_tagra_2ch_mixer},
7561 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7563 .dac_nids = alc883_dac_nids,
7564 .dig_out_nid = ALC883_DIGOUT_NID,
7565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7566 .adc_nids = alc883_adc_nids,
7567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7568 .channel_mode = alc883_3ST_2ch_modes,
7569 .input_mux = &alc883_capture_source,
7570 .unsol_event = alc883_tagra_unsol_event,
7571 .init_hook = alc883_tagra_automute,
7572 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007573 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007574 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007575 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7576 * and the headphone jack. Turn this on and rely on the
7577 * standard mute methods whenever the user wants to turn
7578 * these outputs off.
7579 */
7580 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7581 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7582 .dac_nids = alc883_dac_nids,
7583 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7584 .adc_nids = alc883_adc_nids,
7585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7586 .channel_mode = alc883_3ST_2ch_modes,
7587 .input_mux = &alc883_capture_source,
7588 },
Tobin Davis2880a862007-08-07 11:50:26 +02007589 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007590 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007591 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007592 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7593 .dac_nids = alc883_dac_nids,
7594 .dig_out_nid = ALC883_DIGOUT_NID,
7595 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7596 .adc_nids = alc883_adc_nids,
7597 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7598 .channel_mode = alc883_3ST_2ch_modes,
7599 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007600 .unsol_event = alc883_acer_aspire_unsol_event,
7601 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007602 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007603 [ALC883_MEDION] = {
7604 .mixers = { alc883_fivestack_mixer,
7605 alc883_chmode_mixer },
7606 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007607 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007608 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7609 .dac_nids = alc883_dac_nids,
7610 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7611 .adc_nids = alc883_adc_nids,
7612 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7613 .channel_mode = alc883_sixstack_modes,
7614 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007615 },
Kailang Yang272a5272007-05-14 11:00:38 +02007616 [ALC883_MEDION_MD2] = {
7617 .mixers = { alc883_medion_md2_mixer},
7618 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7620 .dac_nids = alc883_dac_nids,
7621 .dig_out_nid = ALC883_DIGOUT_NID,
7622 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7623 .adc_nids = alc883_adc_nids,
7624 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7625 .channel_mode = alc883_3ST_2ch_modes,
7626 .input_mux = &alc883_capture_source,
7627 .unsol_event = alc883_medion_md2_unsol_event,
7628 .init_hook = alc883_medion_md2_automute,
7629 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007630 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007631 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007632 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7633 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7634 .dac_nids = alc883_dac_nids,
7635 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7636 .adc_nids = alc883_adc_nids,
7637 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7638 .channel_mode = alc883_3ST_2ch_modes,
7639 .input_mux = &alc883_capture_source,
7640 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007641 [ALC883_LENOVO_101E_2ch] = {
7642 .mixers = { alc883_lenovo_101e_2ch_mixer},
7643 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7644 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7645 .dac_nids = alc883_dac_nids,
7646 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7647 .adc_nids = alc883_adc_nids,
7648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7649 .channel_mode = alc883_3ST_2ch_modes,
7650 .input_mux = &alc883_lenovo_101e_capture_source,
7651 .unsol_event = alc883_lenovo_101e_unsol_event,
7652 .init_hook = alc883_lenovo_101e_all_automute,
7653 },
Kailang Yang272a5272007-05-14 11:00:38 +02007654 [ALC883_LENOVO_NB0763] = {
7655 .mixers = { alc883_lenovo_nb0763_mixer },
7656 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7657 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7658 .dac_nids = alc883_dac_nids,
7659 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7660 .adc_nids = alc883_adc_nids,
7661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7662 .channel_mode = alc883_3ST_2ch_modes,
7663 .need_dac_fix = 1,
7664 .input_mux = &alc883_lenovo_nb0763_capture_source,
7665 .unsol_event = alc883_medion_md2_unsol_event,
7666 .init_hook = alc883_medion_md2_automute,
7667 },
7668 [ALC888_LENOVO_MS7195_DIG] = {
7669 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7670 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7671 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7672 .dac_nids = alc883_dac_nids,
7673 .dig_out_nid = ALC883_DIGOUT_NID,
7674 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7675 .adc_nids = alc883_adc_nids,
7676 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7677 .channel_mode = alc883_3ST_6ch_modes,
7678 .need_dac_fix = 1,
7679 .input_mux = &alc883_capture_source,
7680 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7681 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007682 },
7683 [ALC883_HAIER_W66] = {
7684 .mixers = { alc883_tagra_2ch_mixer},
7685 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7687 .dac_nids = alc883_dac_nids,
7688 .dig_out_nid = ALC883_DIGOUT_NID,
7689 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7690 .adc_nids = alc883_adc_nids,
7691 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7692 .channel_mode = alc883_3ST_2ch_modes,
7693 .input_mux = &alc883_capture_source,
7694 .unsol_event = alc883_haier_w66_unsol_event,
7695 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007696 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007697 [ALC888_6ST_HP] = {
7698 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7699 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7701 .dac_nids = alc883_dac_nids,
7702 .dig_out_nid = ALC883_DIGOUT_NID,
7703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7704 .adc_nids = alc883_adc_nids,
7705 .dig_in_nid = ALC883_DIGIN_NID,
7706 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7707 .channel_mode = alc883_sixstack_modes,
7708 .input_mux = &alc883_capture_source,
7709 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007710 [ALC888_3ST_HP] = {
7711 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7712 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7714 .dac_nids = alc883_dac_nids,
7715 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7716 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007717 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7718 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007719 .need_dac_fix = 1,
7720 .input_mux = &alc883_capture_source,
7721 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007722 [ALC888_6ST_DELL] = {
7723 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7724 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7725 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7726 .dac_nids = alc883_dac_nids,
7727 .dig_out_nid = ALC883_DIGOUT_NID,
7728 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7729 .adc_nids = alc883_adc_nids,
7730 .dig_in_nid = ALC883_DIGIN_NID,
7731 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7732 .channel_mode = alc883_sixstack_modes,
7733 .input_mux = &alc883_capture_source,
7734 .unsol_event = alc888_6st_dell_unsol_event,
7735 .init_hook = alc888_6st_dell_front_automute,
7736 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007737 [ALC883_MITAC] = {
7738 .mixers = { alc883_mitac_mixer },
7739 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7740 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7741 .dac_nids = alc883_dac_nids,
7742 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7743 .adc_nids = alc883_adc_nids,
7744 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7745 .channel_mode = alc883_3ST_2ch_modes,
7746 .input_mux = &alc883_capture_source,
7747 .unsol_event = alc883_mitac_unsol_event,
7748 .init_hook = alc883_mitac_automute,
7749 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007750};
7751
7752
7753/*
7754 * BIOS auto configuration
7755 */
7756static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7757 hda_nid_t nid, int pin_type,
7758 int dac_idx)
7759{
7760 /* set as output */
7761 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007762 int idx;
7763
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007764 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7765 idx = 4;
7766 else
7767 idx = spec->multiout.dac_nids[dac_idx] - 2;
7768
7769 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7770 pin_type);
7771 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7772 AMP_OUT_UNMUTE);
7773 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7774
7775}
7776
7777static void alc883_auto_init_multi_out(struct hda_codec *codec)
7778{
7779 struct alc_spec *spec = codec->spec;
7780 int i;
7781
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007782 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007783 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007784 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007785 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007787 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007788 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007789 }
7790}
7791
7792static void alc883_auto_init_hp_out(struct hda_codec *codec)
7793{
7794 struct alc_spec *spec = codec->spec;
7795 hda_nid_t pin;
7796
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007797 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007798 if (pin) /* connect to front */
7799 /* use dac 0 */
7800 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7801}
7802
7803#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7804#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7805
7806static void alc883_auto_init_analog_input(struct hda_codec *codec)
7807{
7808 struct alc_spec *spec = codec->spec;
7809 int i;
7810
7811 for (i = 0; i < AUTO_PIN_LAST; i++) {
7812 hda_nid_t nid = spec->autocfg.input_pins[i];
7813 if (alc883_is_input_pin(nid)) {
7814 snd_hda_codec_write(codec, nid, 0,
7815 AC_VERB_SET_PIN_WIDGET_CONTROL,
7816 (i <= AUTO_PIN_FRONT_MIC ?
7817 PIN_VREF80 : PIN_IN));
7818 if (nid != ALC883_PIN_CD_NID)
7819 snd_hda_codec_write(codec, nid, 0,
7820 AC_VERB_SET_AMP_GAIN_MUTE,
7821 AMP_OUT_MUTE);
7822 }
7823 }
7824}
7825
7826/* almost identical with ALC880 parser... */
7827static int alc883_parse_auto_config(struct hda_codec *codec)
7828{
7829 struct alc_spec *spec = codec->spec;
7830 int err = alc880_parse_auto_config(codec);
7831
7832 if (err < 0)
7833 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007834 else if (!err)
7835 return 0; /* no config found */
7836
7837 err = alc_auto_add_mic_boost(codec);
7838 if (err < 0)
7839 return err;
7840
7841 /* hack - override the init verbs */
7842 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007843 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7844 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007845
7846 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007847}
7848
7849/* additional initialization for auto-configuration model */
7850static void alc883_auto_init(struct hda_codec *codec)
7851{
7852 alc883_auto_init_multi_out(codec);
7853 alc883_auto_init_hp_out(codec);
7854 alc883_auto_init_analog_input(codec);
7855}
7856
7857static int patch_alc883(struct hda_codec *codec)
7858{
7859 struct alc_spec *spec;
7860 int err, board_config;
7861
7862 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7863 if (spec == NULL)
7864 return -ENOMEM;
7865
7866 codec->spec = spec;
7867
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007868 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7869 alc883_models,
7870 alc883_cfg_tbl);
7871 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007872 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7873 "trying auto-probe from BIOS...\n");
7874 board_config = ALC883_AUTO;
7875 }
7876
7877 if (board_config == ALC883_AUTO) {
7878 /* automatic parse from the BIOS config */
7879 err = alc883_parse_auto_config(codec);
7880 if (err < 0) {
7881 alc_free(codec);
7882 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007883 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007884 printk(KERN_INFO
7885 "hda_codec: Cannot set up configuration "
7886 "from BIOS. Using base mode...\n");
7887 board_config = ALC883_3ST_2ch_DIG;
7888 }
7889 }
7890
7891 if (board_config != ALC883_AUTO)
7892 setup_preset(spec, &alc883_presets[board_config]);
7893
7894 spec->stream_name_analog = "ALC883 Analog";
7895 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7896 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7897
7898 spec->stream_name_digital = "ALC883 Digital";
7899 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7900 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7901
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007902 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007903 spec->adc_nids = alc883_adc_nids;
7904 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7905 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007906
Takashi Iwai2134ea42008-01-10 16:53:55 +01007907 spec->vmaster_nid = 0x0c;
7908
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007909 codec->patch_ops = alc_patch_ops;
7910 if (board_config == ALC883_AUTO)
7911 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007912#ifdef CONFIG_SND_HDA_POWER_SAVE
7913 if (!spec->loopback.amplist)
7914 spec->loopback.amplist = alc883_loopbacks;
7915#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007916
7917 return 0;
7918}
7919
7920/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007921 * ALC262 support
7922 */
7923
7924#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7925#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7926
7927#define alc262_dac_nids alc260_dac_nids
7928#define alc262_adc_nids alc882_adc_nids
7929#define alc262_adc_nids_alt alc882_adc_nids_alt
7930
7931#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007932#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007933
7934static struct snd_kcontrol_new alc262_base_mixer[] = {
7935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7936 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007946 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007947 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7948 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7949 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007953 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007954};
7955
Kailang Yangccc656c2006-10-17 12:32:26 +02007956static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7958 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7959 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7960 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7962 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007965 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007966 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7967 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007968 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007969 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7970 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7971 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7973 { } /* end */
7974};
7975
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007976static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7978 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7982
7983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007988 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7993 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7994 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7995 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7996 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7997 { } /* end */
7998};
7999
Kailang Yangcd7509a2007-01-26 18:33:17 +01008000static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8001 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8002 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8008 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008009 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8013 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8014 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8015 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8016 { } /* end */
8017};
8018
8019static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8020 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8021 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008022 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008023 { } /* end */
8024};
8025
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008026static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8027 .ops = &snd_hda_bind_vol,
8028 .values = {
8029 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8030 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8031 0
8032 },
8033};
8034
8035static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8036 .ops = &snd_hda_bind_sw,
8037 .values = {
8038 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8039 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8040 0
8041 },
8042};
8043
8044/* mute/unmute internal speaker according to the hp jack and mute state */
8045static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8046{
8047 struct alc_spec *spec = codec->spec;
8048 unsigned int mute;
8049
8050 if (force || !spec->sense_updated) {
8051 unsigned int present;
8052 present = snd_hda_codec_read(codec, 0x15, 0,
8053 AC_VERB_GET_PIN_SENSE, 0);
8054 spec->jack_present = (present & 0x80000000) != 0;
8055 spec->sense_updated = 1;
8056 }
8057 if (spec->jack_present)
8058 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8059 else /* unmute internal speaker if necessary */
8060 mute = (0x7000 | ((0)<<8));
8061 snd_hda_codec_write(codec, 0x0c, 0,
8062 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8063}
8064
8065static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8066 unsigned int res)
8067{
8068 if ((res >> 26) != ALC880_HP_EVENT)
8069 return;
8070 alc262_hp_t5735_automute(codec, 1);
8071}
8072
8073static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8074{
8075 alc262_hp_t5735_automute(codec, 1);
8076}
8077
8078static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8079 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8080 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8081 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8082 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8083 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8084 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8090 { } /* end */
8091};
8092
8093static struct hda_verb alc262_hp_t5735_verbs[] = {
8094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8096
8097 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8098 { }
8099};
8100
Kailang Yang8c427222008-01-10 13:03:59 +01008101static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8102 .ops = &snd_hda_bind_vol,
8103 .values = {
8104 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8105 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8106 0
8107 },
8108};
8109
8110static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8111 .ops = &snd_hda_bind_sw,
8112 .values = {
8113 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8114 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8115 0
8116 },
8117};
8118
8119static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8120 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8121 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8122 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8124 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8125 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8128 { } /* end */
8129};
8130
8131static struct hda_verb alc262_hp_rp5700_verbs[] = {
8132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8136 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8141 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8142 {}
8143};
8144
8145static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8146 .num_items = 1,
8147 .items = {
8148 { "Line", 0x1 },
8149 },
8150};
8151
Takashi Iwai0724ea22007-08-23 00:31:43 +02008152/* bind hp and internal speaker mute (with plug check) */
8153static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8154 struct snd_ctl_elem_value *ucontrol)
8155{
8156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8157 long *valp = ucontrol->value.integer.value;
8158 int change;
8159
8160 /* change hp mute */
8161 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8162 HDA_AMP_MUTE,
8163 valp[0] ? 0 : HDA_AMP_MUTE);
8164 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8165 HDA_AMP_MUTE,
8166 valp[1] ? 0 : HDA_AMP_MUTE);
8167 if (change) {
8168 /* change speaker according to HP jack state */
8169 struct alc_spec *spec = codec->spec;
8170 unsigned int mute;
8171 if (spec->jack_present)
8172 mute = HDA_AMP_MUTE;
8173 else
8174 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8175 HDA_OUTPUT, 0);
8176 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8177 HDA_AMP_MUTE, mute);
8178 }
8179 return change;
8180}
Takashi Iwai5b319542007-07-26 11:49:22 +02008181
Kailang Yang272a5272007-05-14 11:00:38 +02008182static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008183 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8184 {
8185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8186 .name = "Master Playback Switch",
8187 .info = snd_hda_mixer_amp_switch_info,
8188 .get = snd_hda_mixer_amp_switch_get,
8189 .put = alc262_sony_master_sw_put,
8190 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8191 },
Kailang Yang272a5272007-05-14 11:00:38 +02008192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8194 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8195 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8196 { } /* end */
8197};
8198
Kailang Yang83c34212007-07-05 11:43:05 +02008199static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8201 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8205 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8206 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8207 { } /* end */
8208};
Kailang Yang272a5272007-05-14 11:00:38 +02008209
Kailang Yangdf694da2005-12-05 19:42:22 +01008210#define alc262_capture_mixer alc882_capture_mixer
8211#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8212
8213/*
8214 * generic initialization of ADC, input mixers and output mixers
8215 */
8216static struct hda_verb alc262_init_verbs[] = {
8217 /*
8218 * Unmute ADC0-2 and set the default input to mic-in
8219 */
8220 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8224 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8226
Takashi Iwaicb53c622007-08-10 17:21:45 +02008227 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008228 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008229 * Note: PASD motherboards uses the Line In 2 as the input for
8230 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008231 */
8232 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008238
8239 /*
8240 * Set up output mixers (0x0c - 0x0e)
8241 */
8242 /* set vol=0 to output mixers */
8243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8246 /* set up input amps for analog loopback */
8247 /* Amp Indices: DAC = 0, mixer = 1 */
8248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8254
8255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8257 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8260 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8261
8262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8267
8268 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8270
8271 /* FIXME: use matrix-type input source selection */
8272 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8273 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8278 /* Input mixer2 */
8279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8283 /* Input mixer3 */
8284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008288
8289 { }
8290};
8291
Kailang Yangccc656c2006-10-17 12:32:26 +02008292static struct hda_verb alc262_hippo_unsol_verbs[] = {
8293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8295 {}
8296};
8297
8298static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8300 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8301 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8302
8303 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8305 {}
8306};
8307
Kailang Yang272a5272007-05-14 11:00:38 +02008308static struct hda_verb alc262_sony_unsol_verbs[] = {
8309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8312
8313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8315};
8316
Kailang Yangccc656c2006-10-17 12:32:26 +02008317/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008318static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008319{
8320 struct alc_spec *spec = codec->spec;
8321 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008322 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008323
Takashi Iwai5b319542007-07-26 11:49:22 +02008324 /* need to execute and sync at first */
8325 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8326 present = snd_hda_codec_read(codec, 0x15, 0,
8327 AC_VERB_GET_PIN_SENSE, 0);
8328 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008329 if (spec->jack_present) {
8330 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008331 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8332 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008333 } else {
8334 /* unmute internal speaker if necessary */
8335 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008336 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8337 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008338 }
8339}
8340
8341/* unsolicited event for HP jack sensing */
8342static void alc262_hippo_unsol_event(struct hda_codec *codec,
8343 unsigned int res)
8344{
8345 if ((res >> 26) != ALC880_HP_EVENT)
8346 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008347 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008348}
8349
Takashi Iwai5b319542007-07-26 11:49:22 +02008350static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008351{
Kailang Yangccc656c2006-10-17 12:32:26 +02008352 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008353 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008354
Takashi Iwai5b319542007-07-26 11:49:22 +02008355 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8356 present = snd_hda_codec_read(codec, 0x1b, 0,
8357 AC_VERB_GET_PIN_SENSE, 0);
8358 present = (present & 0x80000000) != 0;
8359 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008360 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008361 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8362 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008363 } else {
8364 /* unmute internal speaker if necessary */
8365 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008366 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8367 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008368 }
8369}
8370
8371/* unsolicited event for HP jack sensing */
8372static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8373 unsigned int res)
8374{
8375 if ((res >> 26) != ALC880_HP_EVENT)
8376 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008377 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008378}
8379
Takashi Iwai834be882006-03-01 14:16:17 +01008380/*
8381 * fujitsu model
8382 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8383 */
8384
8385#define ALC_HP_EVENT 0x37
8386
8387static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8388 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8390 {}
8391};
8392
8393static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008394 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008395 .items = {
8396 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008397 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008398 { "CD", 0x4 },
8399 },
8400};
8401
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008402static struct hda_input_mux alc262_HP_capture_source = {
8403 .num_items = 5,
8404 .items = {
8405 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008406 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008407 { "Line", 0x2 },
8408 { "CD", 0x4 },
8409 { "AUX IN", 0x6 },
8410 },
8411};
8412
zhejiangaccbe492007-08-31 12:36:05 +02008413static struct hda_input_mux alc262_HP_D7000_capture_source = {
8414 .num_items = 4,
8415 .items = {
8416 { "Mic", 0x0 },
8417 { "Front Mic", 0x2 },
8418 { "Line", 0x1 },
8419 { "CD", 0x4 },
8420 },
8421};
8422
Takashi Iwai834be882006-03-01 14:16:17 +01008423/* mute/unmute internal speaker according to the hp jack and mute state */
8424static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8425{
8426 struct alc_spec *spec = codec->spec;
8427 unsigned int mute;
8428
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008429 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008430 unsigned int present;
8431 /* need to execute and sync at first */
8432 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8433 present = snd_hda_codec_read(codec, 0x14, 0,
8434 AC_VERB_GET_PIN_SENSE, 0);
8435 spec->jack_present = (present & 0x80000000) != 0;
8436 spec->sense_updated = 1;
8437 }
8438 if (spec->jack_present) {
8439 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008440 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8441 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008442 } else {
8443 /* unmute internal speaker if necessary */
8444 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008445 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8446 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008447 }
8448}
8449
8450/* unsolicited event for HP jack sensing */
8451static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8452 unsigned int res)
8453{
8454 if ((res >> 26) != ALC_HP_EVENT)
8455 return;
8456 alc262_fujitsu_automute(codec, 1);
8457}
8458
8459/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008460static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8461 .ops = &snd_hda_bind_vol,
8462 .values = {
8463 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8464 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8465 0
8466 },
8467};
Takashi Iwai834be882006-03-01 14:16:17 +01008468
8469/* bind hp and internal speaker mute (with plug check) */
8470static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8471 struct snd_ctl_elem_value *ucontrol)
8472{
8473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8474 long *valp = ucontrol->value.integer.value;
8475 int change;
8476
8477 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008478 HDA_AMP_MUTE,
8479 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008480 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008481 HDA_AMP_MUTE,
8482 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008483 if (change)
8484 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008485 return change;
8486}
8487
8488static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008489 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008490 {
8491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8492 .name = "Master Playback Switch",
8493 .info = snd_hda_mixer_amp_switch_info,
8494 .get = snd_hda_mixer_amp_switch_get,
8495 .put = alc262_fujitsu_master_sw_put,
8496 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8497 },
8498 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8499 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8500 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008503 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8504 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8505 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008506 { } /* end */
8507};
8508
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008509/* additional init verbs for Benq laptops */
8510static struct hda_verb alc262_EAPD_verbs[] = {
8511 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8512 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8513 {}
8514};
8515
Kailang Yang83c34212007-07-05 11:43:05 +02008516static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8519
8520 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8521 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8522 {}
8523};
8524
Tobin Davisf651b502007-10-26 12:40:47 +02008525/* Samsung Q1 Ultra Vista model setup */
8526static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8528 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8532 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8533 { } /* end */
8534};
8535
8536static struct hda_verb alc262_ultra_verbs[] = {
8537 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8539 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8540 /* Mic is on Node 0x19 */
8541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8542 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8544 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8546 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8548 {}
8549};
8550
8551static struct hda_input_mux alc262_ultra_capture_source = {
8552 .num_items = 1,
8553 .items = {
8554 { "Mic", 0x1 },
8555 },
8556};
8557
8558/* mute/unmute internal speaker according to the hp jack and mute state */
8559static void alc262_ultra_automute(struct hda_codec *codec)
8560{
8561 struct alc_spec *spec = codec->spec;
8562 unsigned int mute;
8563 unsigned int present;
8564
8565 /* need to execute and sync at first */
8566 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8567 present = snd_hda_codec_read(codec, 0x15, 0,
8568 AC_VERB_GET_PIN_SENSE, 0);
8569 spec->jack_present = (present & 0x80000000) != 0;
8570 if (spec->jack_present) {
8571 /* mute internal speaker */
8572 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8573 HDA_AMP_MUTE, HDA_AMP_MUTE);
8574 } else {
8575 /* unmute internal speaker if necessary */
8576 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8577 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8578 HDA_AMP_MUTE, mute);
8579 }
8580}
8581
8582/* unsolicited event for HP jack sensing */
8583static void alc262_ultra_unsol_event(struct hda_codec *codec,
8584 unsigned int res)
8585{
8586 if ((res >> 26) != ALC880_HP_EVENT)
8587 return;
8588 alc262_ultra_automute(codec);
8589}
8590
Kailang Yangdf694da2005-12-05 19:42:22 +01008591/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008592static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8593 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008594{
8595 hda_nid_t nid;
8596 int err;
8597
8598 spec->multiout.num_dacs = 1; /* only use one dac */
8599 spec->multiout.dac_nids = spec->private_dac_nids;
8600 spec->multiout.dac_nids[0] = 2;
8601
8602 nid = cfg->line_out_pins[0];
8603 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008604 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8605 "Front Playback Volume",
8606 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8607 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008608 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008609 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8610 "Front Playback Switch",
8611 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8612 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008613 return err;
8614 }
8615
Takashi Iwai82bc9552006-03-21 11:24:42 +01008616 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008617 if (nid) {
8618 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008619 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8620 "Speaker Playback Volume",
8621 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8622 HDA_OUTPUT));
8623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008624 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008625 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8626 "Speaker Playback Switch",
8627 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8628 HDA_OUTPUT));
8629 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008630 return err;
8631 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008632 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8633 "Speaker Playback Switch",
8634 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8635 HDA_OUTPUT));
8636 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008637 return err;
8638 }
8639 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008640 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008641 if (nid) {
8642 /* spec->multiout.hp_nid = 2; */
8643 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008644 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8645 "Headphone Playback Volume",
8646 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8647 HDA_OUTPUT));
8648 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008649 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008650 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8651 "Headphone Playback Switch",
8652 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8653 HDA_OUTPUT));
8654 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008655 return err;
8656 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008657 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8658 "Headphone Playback Switch",
8659 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8660 HDA_OUTPUT));
8661 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008662 return err;
8663 }
8664 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008665 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008666}
8667
8668/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008669#define alc262_auto_create_analog_input_ctls \
8670 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008671
8672/*
8673 * generic initialization of ADC, input mixers and output mixers
8674 */
8675static struct hda_verb alc262_volume_init_verbs[] = {
8676 /*
8677 * Unmute ADC0-2 and set the default input to mic-in
8678 */
8679 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8683 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8685
Takashi Iwaicb53c622007-08-10 17:21:45 +02008686 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008687 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008688 * Note: PASD motherboards uses the Line In 2 as the input for
8689 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008690 */
8691 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008697
8698 /*
8699 * Set up output mixers (0x0c - 0x0f)
8700 */
8701 /* set vol=0 to output mixers */
8702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8703 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8705
8706 /* set up input amps for analog loopback */
8707 /* Amp Indices: DAC = 0, mixer = 1 */
8708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8714
8715 /* FIXME: use matrix-type input source selection */
8716 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8717 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8722 /* Input mixer2 */
8723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8727 /* Input mixer3 */
8728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8732
8733 { }
8734};
8735
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008736static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8737 /*
8738 * Unmute ADC0-2 and set the default input to mic-in
8739 */
8740 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746
Takashi Iwaicb53c622007-08-10 17:21:45 +02008747 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008748 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008749 * Note: PASD motherboards uses the Line In 2 as the input for
8750 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008751 */
8752 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008760
8761 /*
8762 * Set up output mixers (0x0c - 0x0e)
8763 */
8764 /* set vol=0 to output mixers */
8765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8768
8769 /* set up input amps for analog loopback */
8770 /* Amp Indices: DAC = 0, mixer = 1 */
8771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8774 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8776 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8777
8778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8780 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8781
8782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8784
8785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8787
8788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8789 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8790 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8792 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8793
8794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8798 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8799 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8800
8801
8802 /* FIXME: use matrix-type input source selection */
8803 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8804 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8808 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8809 /* Input mixer2 */
8810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8813 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8814 /* Input mixer3 */
8815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8819
8820 { }
8821};
8822
Kailang Yangcd7509a2007-01-26 18:33:17 +01008823static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8824 /*
8825 * Unmute ADC0-2 and set the default input to mic-in
8826 */
8827 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8831 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8832 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8833
Takashi Iwaicb53c622007-08-10 17:21:45 +02008834 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008835 * mixer widget
8836 * Note: PASD motherboards uses the Line In 2 as the input for front
8837 * panel mic (mic 2)
8838 */
8839 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008848 /*
8849 * Set up output mixers (0x0c - 0x0e)
8850 */
8851 /* set vol=0 to output mixers */
8852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8854 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8855
8856 /* set up input amps for analog loopback */
8857 /* Amp Indices: DAC = 0, mixer = 1 */
8858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8864
8865
8866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8872 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8873
8874 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8876
8877 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8878 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8879
8880 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8881 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8884 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8885 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8886
8887 /* FIXME: use matrix-type input source selection */
8888 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8889 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8895 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8897 /* Input mixer2 */
8898 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8903 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8905 /* Input mixer3 */
8906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8911 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8913
8914 { }
8915};
8916
Takashi Iwaicb53c622007-08-10 17:21:45 +02008917#ifdef CONFIG_SND_HDA_POWER_SAVE
8918#define alc262_loopbacks alc880_loopbacks
8919#endif
8920
Kailang Yangdf694da2005-12-05 19:42:22 +01008921/* pcm configuration: identiacal with ALC880 */
8922#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8923#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8924#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8925#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8926
8927/*
8928 * BIOS auto configuration
8929 */
8930static int alc262_parse_auto_config(struct hda_codec *codec)
8931{
8932 struct alc_spec *spec = codec->spec;
8933 int err;
8934 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8935
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008936 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8937 alc262_ignore);
8938 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008939 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008940 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008941 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008942 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8943 if (err < 0)
8944 return err;
8945 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8946 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008947 return err;
8948
8949 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8950
8951 if (spec->autocfg.dig_out_pin)
8952 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8953 if (spec->autocfg.dig_in_pin)
8954 spec->dig_in_nid = ALC262_DIGIN_NID;
8955
8956 if (spec->kctl_alloc)
8957 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8958
8959 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008960 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008961 spec->input_mux = &spec->private_imux;
8962
Takashi Iwai776e1842007-08-29 15:07:11 +02008963 err = alc_auto_add_mic_boost(codec);
8964 if (err < 0)
8965 return err;
8966
Kailang Yangdf694da2005-12-05 19:42:22 +01008967 return 1;
8968}
8969
8970#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8971#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8972#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8973
8974
8975/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008976static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008977{
Kailang Yangdf694da2005-12-05 19:42:22 +01008978 alc262_auto_init_multi_out(codec);
8979 alc262_auto_init_hp_out(codec);
8980 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008981}
8982
8983/*
8984 * configuration and preset
8985 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008986static const char *alc262_models[ALC262_MODEL_LAST] = {
8987 [ALC262_BASIC] = "basic",
8988 [ALC262_HIPPO] = "hippo",
8989 [ALC262_HIPPO_1] = "hippo_1",
8990 [ALC262_FUJITSU] = "fujitsu",
8991 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008992 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01008993 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01008994 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008995 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008996 [ALC262_BENQ_T31] = "benq-t31",
8997 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02008998 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008999 [ALC262_AUTO] = "auto",
9000};
9001
9002static struct snd_pci_quirk alc262_cfg_tbl[] = {
9003 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9004 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009005 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009006 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9007 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009008 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009009 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009010 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009011 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009012 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009013 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009014 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009015 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009016 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009017 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009018 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009019 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009020 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9021 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9022 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009023 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9024 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009025 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009026 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009027 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009028 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9029 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9030 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009031 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009032 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009033 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009034 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009035 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009036 {}
9037};
9038
9039static struct alc_config_preset alc262_presets[] = {
9040 [ALC262_BASIC] = {
9041 .mixers = { alc262_base_mixer },
9042 .init_verbs = { alc262_init_verbs },
9043 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9044 .dac_nids = alc262_dac_nids,
9045 .hp_nid = 0x03,
9046 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9047 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009048 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009049 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009050 [ALC262_HIPPO] = {
9051 .mixers = { alc262_base_mixer },
9052 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9053 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9054 .dac_nids = alc262_dac_nids,
9055 .hp_nid = 0x03,
9056 .dig_out_nid = ALC262_DIGOUT_NID,
9057 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9058 .channel_mode = alc262_modes,
9059 .input_mux = &alc262_capture_source,
9060 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009061 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009062 },
9063 [ALC262_HIPPO_1] = {
9064 .mixers = { alc262_hippo1_mixer },
9065 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9066 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9067 .dac_nids = alc262_dac_nids,
9068 .hp_nid = 0x02,
9069 .dig_out_nid = ALC262_DIGOUT_NID,
9070 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9071 .channel_mode = alc262_modes,
9072 .input_mux = &alc262_capture_source,
9073 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009074 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009075 },
Takashi Iwai834be882006-03-01 14:16:17 +01009076 [ALC262_FUJITSU] = {
9077 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009078 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9079 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009080 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9081 .dac_nids = alc262_dac_nids,
9082 .hp_nid = 0x03,
9083 .dig_out_nid = ALC262_DIGOUT_NID,
9084 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9085 .channel_mode = alc262_modes,
9086 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009087 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009088 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009089 [ALC262_HP_BPC] = {
9090 .mixers = { alc262_HP_BPC_mixer },
9091 .init_verbs = { alc262_HP_BPC_init_verbs },
9092 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9093 .dac_nids = alc262_dac_nids,
9094 .hp_nid = 0x03,
9095 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9096 .channel_mode = alc262_modes,
9097 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009098 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009099 [ALC262_HP_BPC_D7000_WF] = {
9100 .mixers = { alc262_HP_BPC_WildWest_mixer },
9101 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9102 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9103 .dac_nids = alc262_dac_nids,
9104 .hp_nid = 0x03,
9105 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9106 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009107 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009108 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009109 [ALC262_HP_BPC_D7000_WL] = {
9110 .mixers = { alc262_HP_BPC_WildWest_mixer,
9111 alc262_HP_BPC_WildWest_option_mixer },
9112 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9113 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9114 .dac_nids = alc262_dac_nids,
9115 .hp_nid = 0x03,
9116 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9117 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009118 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009119 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009120 [ALC262_HP_TC_T5735] = {
9121 .mixers = { alc262_hp_t5735_mixer },
9122 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9123 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9124 .dac_nids = alc262_dac_nids,
9125 .hp_nid = 0x03,
9126 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9127 .channel_mode = alc262_modes,
9128 .input_mux = &alc262_capture_source,
9129 .unsol_event = alc262_hp_t5735_unsol_event,
9130 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009131 },
9132 [ALC262_HP_RP5700] = {
9133 .mixers = { alc262_hp_rp5700_mixer },
9134 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9135 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9136 .dac_nids = alc262_dac_nids,
9137 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9138 .channel_mode = alc262_modes,
9139 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009140 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009141 [ALC262_BENQ_ED8] = {
9142 .mixers = { alc262_base_mixer },
9143 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9144 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9145 .dac_nids = alc262_dac_nids,
9146 .hp_nid = 0x03,
9147 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9148 .channel_mode = alc262_modes,
9149 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009150 },
Kailang Yang272a5272007-05-14 11:00:38 +02009151 [ALC262_SONY_ASSAMD] = {
9152 .mixers = { alc262_sony_mixer },
9153 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9154 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9155 .dac_nids = alc262_dac_nids,
9156 .hp_nid = 0x02,
9157 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9158 .channel_mode = alc262_modes,
9159 .input_mux = &alc262_capture_source,
9160 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009161 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009162 },
9163 [ALC262_BENQ_T31] = {
9164 .mixers = { alc262_benq_t31_mixer },
9165 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9166 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9167 .dac_nids = alc262_dac_nids,
9168 .hp_nid = 0x03,
9169 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9170 .channel_mode = alc262_modes,
9171 .input_mux = &alc262_capture_source,
9172 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009173 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009174 },
Tobin Davisf651b502007-10-26 12:40:47 +02009175 [ALC262_ULTRA] = {
9176 .mixers = { alc262_ultra_mixer },
9177 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9178 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9179 .dac_nids = alc262_dac_nids,
9180 .hp_nid = 0x03,
9181 .dig_out_nid = ALC262_DIGOUT_NID,
9182 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9183 .channel_mode = alc262_modes,
9184 .input_mux = &alc262_ultra_capture_source,
9185 .unsol_event = alc262_ultra_unsol_event,
9186 .init_hook = alc262_ultra_automute,
9187 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009188};
9189
9190static int patch_alc262(struct hda_codec *codec)
9191{
9192 struct alc_spec *spec;
9193 int board_config;
9194 int err;
9195
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009196 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009197 if (spec == NULL)
9198 return -ENOMEM;
9199
9200 codec->spec = spec;
9201#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009202 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9203 * under-run
9204 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009205 {
9206 int tmp;
9207 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9208 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9209 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9210 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9211 }
9212#endif
9213
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009214 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9215 alc262_models,
9216 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009217
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009218 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009219 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9220 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009221 board_config = ALC262_AUTO;
9222 }
9223
9224 if (board_config == ALC262_AUTO) {
9225 /* automatic parse from the BIOS config */
9226 err = alc262_parse_auto_config(codec);
9227 if (err < 0) {
9228 alc_free(codec);
9229 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009230 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009231 printk(KERN_INFO
9232 "hda_codec: Cannot set up configuration "
9233 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009234 board_config = ALC262_BASIC;
9235 }
9236 }
9237
9238 if (board_config != ALC262_AUTO)
9239 setup_preset(spec, &alc262_presets[board_config]);
9240
9241 spec->stream_name_analog = "ALC262 Analog";
9242 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9243 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9244
9245 spec->stream_name_digital = "ALC262 Digital";
9246 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9247 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9248
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009249 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009250 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009251 unsigned int wcap = get_wcaps(codec, 0x07);
9252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009253 /* get type */
9254 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009255 if (wcap != AC_WID_AUD_IN) {
9256 spec->adc_nids = alc262_adc_nids_alt;
9257 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009258 spec->mixers[spec->num_mixers] =
9259 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009260 spec->num_mixers++;
9261 } else {
9262 spec->adc_nids = alc262_adc_nids;
9263 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9264 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9265 spec->num_mixers++;
9266 }
9267 }
9268
Takashi Iwai2134ea42008-01-10 16:53:55 +01009269 spec->vmaster_nid = 0x0c;
9270
Kailang Yangdf694da2005-12-05 19:42:22 +01009271 codec->patch_ops = alc_patch_ops;
9272 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009273 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009274#ifdef CONFIG_SND_HDA_POWER_SAVE
9275 if (!spec->loopback.amplist)
9276 spec->loopback.amplist = alc262_loopbacks;
9277#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009278
Kailang Yangdf694da2005-12-05 19:42:22 +01009279 return 0;
9280}
9281
Kailang Yangdf694da2005-12-05 19:42:22 +01009282/*
Kailang Yanga361d842007-06-05 12:30:55 +02009283 * ALC268 channel source setting (2 channel)
9284 */
9285#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9286#define alc268_modes alc260_modes
9287
9288static hda_nid_t alc268_dac_nids[2] = {
9289 /* front, hp */
9290 0x02, 0x03
9291};
9292
9293static hda_nid_t alc268_adc_nids[2] = {
9294 /* ADC0-1 */
9295 0x08, 0x07
9296};
9297
9298static hda_nid_t alc268_adc_nids_alt[1] = {
9299 /* ADC0 */
9300 0x08
9301};
9302
9303static struct snd_kcontrol_new alc268_base_mixer[] = {
9304 /* output mixer control */
9305 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9306 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9307 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9310 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9311 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009312 { }
9313};
9314
Kailang Yangd1a991a2007-08-15 16:21:59 +02009315static struct hda_verb alc268_eapd_verbs[] = {
9316 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9317 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9318 { }
9319};
9320
Takashi Iwaid2738092007-08-16 14:59:45 +02009321/* Toshiba specific */
9322#define alc268_toshiba_automute alc262_hippo_automute
9323
9324static struct hda_verb alc268_toshiba_verbs[] = {
9325 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9326 { } /* end */
9327};
9328
9329/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009330/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009331static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9332 .ops = &snd_hda_bind_vol,
9333 .values = {
9334 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9335 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9336 0
9337 },
9338};
9339
Takashi Iwai889c4392007-08-23 18:56:52 +02009340/* mute/unmute internal speaker according to the hp jack and mute state */
9341static void alc268_acer_automute(struct hda_codec *codec, int force)
9342{
9343 struct alc_spec *spec = codec->spec;
9344 unsigned int mute;
9345
9346 if (force || !spec->sense_updated) {
9347 unsigned int present;
9348 present = snd_hda_codec_read(codec, 0x14, 0,
9349 AC_VERB_GET_PIN_SENSE, 0);
9350 spec->jack_present = (present & 0x80000000) != 0;
9351 spec->sense_updated = 1;
9352 }
9353 if (spec->jack_present)
9354 mute = HDA_AMP_MUTE; /* mute internal speaker */
9355 else /* unmute internal speaker if necessary */
9356 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9357 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9358 HDA_AMP_MUTE, mute);
9359}
9360
9361
9362/* bind hp and internal speaker mute (with plug check) */
9363static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9364 struct snd_ctl_elem_value *ucontrol)
9365{
9366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9367 long *valp = ucontrol->value.integer.value;
9368 int change;
9369
9370 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9371 HDA_AMP_MUTE,
9372 valp[0] ? 0 : HDA_AMP_MUTE);
9373 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9374 HDA_AMP_MUTE,
9375 valp[1] ? 0 : HDA_AMP_MUTE);
9376 if (change)
9377 alc268_acer_automute(codec, 0);
9378 return change;
9379}
Takashi Iwaid2738092007-08-16 14:59:45 +02009380
9381static struct snd_kcontrol_new alc268_acer_mixer[] = {
9382 /* output mixer control */
9383 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9384 {
9385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9386 .name = "Master Playback Switch",
9387 .info = snd_hda_mixer_amp_switch_info,
9388 .get = snd_hda_mixer_amp_switch_get,
9389 .put = alc268_acer_master_sw_put,
9390 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9391 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9393 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9394 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009395 { }
9396};
9397
9398static struct hda_verb alc268_acer_verbs[] = {
9399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9400 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9401
9402 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9403 { }
9404};
9405
9406/* unsolicited event for HP jack sensing */
9407static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9408 unsigned int res)
9409{
Takashi Iwai889c4392007-08-23 18:56:52 +02009410 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009411 return;
9412 alc268_toshiba_automute(codec);
9413}
9414
9415static void alc268_acer_unsol_event(struct hda_codec *codec,
9416 unsigned int res)
9417{
Takashi Iwai889c4392007-08-23 18:56:52 +02009418 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009419 return;
9420 alc268_acer_automute(codec, 1);
9421}
9422
Takashi Iwai889c4392007-08-23 18:56:52 +02009423static void alc268_acer_init_hook(struct hda_codec *codec)
9424{
9425 alc268_acer_automute(codec, 1);
9426}
9427
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009428static struct snd_kcontrol_new alc268_dell_mixer[] = {
9429 /* output mixer control */
9430 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9431 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9432 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9434 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9435 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9436 { }
9437};
9438
9439static struct hda_verb alc268_dell_verbs[] = {
9440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9442 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9443 { }
9444};
9445
9446/* mute/unmute internal speaker according to the hp jack and mute state */
9447static void alc268_dell_automute(struct hda_codec *codec)
9448{
9449 unsigned int present;
9450 unsigned int mute;
9451
9452 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9453 if (present & 0x80000000)
9454 mute = HDA_AMP_MUTE;
9455 else
9456 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9457 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9458 HDA_AMP_MUTE, mute);
9459}
9460
9461static void alc268_dell_unsol_event(struct hda_codec *codec,
9462 unsigned int res)
9463{
9464 if ((res >> 26) != ALC880_HP_EVENT)
9465 return;
9466 alc268_dell_automute(codec);
9467}
9468
9469#define alc268_dell_init_hook alc268_dell_automute
9470
Kailang Yanga361d842007-06-05 12:30:55 +02009471/*
9472 * generic initialization of ADC, input mixers and output mixers
9473 */
9474static struct hda_verb alc268_base_init_verbs[] = {
9475 /* Unmute DAC0-1 and set vol = 0 */
9476 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9477 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9478 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9479 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9480 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9481 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9482
9483 /*
9484 * Set up output mixers (0x0c - 0x0e)
9485 */
9486 /* set vol=0 to output mixers */
9487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9488 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9490 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9491
9492 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9494
9495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9499 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9502 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9503
9504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9510 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9511 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9512
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009513 /* Unmute Selector 23h,24h and set the default input to mic-in */
9514
9515 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9517 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009519
Kailang Yanga361d842007-06-05 12:30:55 +02009520 { }
9521};
9522
9523/*
9524 * generic initialization of ADC, input mixers and output mixers
9525 */
9526static struct hda_verb alc268_volume_init_verbs[] = {
9527 /* set output DAC */
9528 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9529 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9530 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9531 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9532
9533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9537 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9538
9539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9543 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9544
9545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9548 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9549
9550 /* set PCBEEP vol = 0 */
9551 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9552
9553 { }
9554};
9555
9556#define alc268_mux_enum_info alc_mux_enum_info
9557#define alc268_mux_enum_get alc_mux_enum_get
9558
9559static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9560 struct snd_ctl_elem_value *ucontrol)
9561{
9562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9563 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009564
Kailang Yanga361d842007-06-05 12:30:55 +02009565 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9566 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9567 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009568
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009569 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9570 nid,
9571 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009572}
9573
9574static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9575 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9576 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9577 {
9578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9579 /* The multiple "Capture Source" controls confuse alsamixer
9580 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009581 */
9582 /* .name = "Capture Source", */
9583 .name = "Input Source",
9584 .count = 1,
9585 .info = alc268_mux_enum_info,
9586 .get = alc268_mux_enum_get,
9587 .put = alc268_mux_enum_put,
9588 },
9589 { } /* end */
9590};
9591
9592static struct snd_kcontrol_new alc268_capture_mixer[] = {
9593 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9594 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9595 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9596 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9597 {
9598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9599 /* The multiple "Capture Source" controls confuse alsamixer
9600 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009601 */
9602 /* .name = "Capture Source", */
9603 .name = "Input Source",
9604 .count = 2,
9605 .info = alc268_mux_enum_info,
9606 .get = alc268_mux_enum_get,
9607 .put = alc268_mux_enum_put,
9608 },
9609 { } /* end */
9610};
9611
9612static struct hda_input_mux alc268_capture_source = {
9613 .num_items = 4,
9614 .items = {
9615 { "Mic", 0x0 },
9616 { "Front Mic", 0x1 },
9617 { "Line", 0x2 },
9618 { "CD", 0x3 },
9619 },
9620};
9621
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009622#ifdef CONFIG_SND_DEBUG
9623static struct snd_kcontrol_new alc268_test_mixer[] = {
9624 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9625 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9626 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9627 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9628
9629 /* Volume widgets */
9630 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9631 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9632 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9633 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9634 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9635 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9636 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9637 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9638 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9639 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9640 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9641 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9642 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009643 /* The below appears problematic on some hardwares */
9644 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009645 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9646 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9647 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9648 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9649
9650 /* Modes for retasking pin widgets */
9651 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9652 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9653 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9654 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9655
9656 /* Controls for GPIO pins, assuming they are configured as outputs */
9657 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9658 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9659 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9660 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9661
9662 /* Switches to allow the digital SPDIF output pin to be enabled.
9663 * The ALC268 does not have an SPDIF input.
9664 */
9665 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9666
9667 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9668 * this output to turn on an external amplifier.
9669 */
9670 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9671 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9672
9673 { } /* end */
9674};
9675#endif
9676
Kailang Yanga361d842007-06-05 12:30:55 +02009677/* create input playback/capture controls for the given pin */
9678static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9679 const char *ctlname, int idx)
9680{
9681 char name[32];
9682 int err;
9683
9684 sprintf(name, "%s Playback Volume", ctlname);
9685 if (nid == 0x14) {
9686 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9687 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9688 HDA_OUTPUT));
9689 if (err < 0)
9690 return err;
9691 } else if (nid == 0x15) {
9692 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9693 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9694 HDA_OUTPUT));
9695 if (err < 0)
9696 return err;
9697 } else
9698 return -1;
9699 sprintf(name, "%s Playback Switch", ctlname);
9700 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9701 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9702 if (err < 0)
9703 return err;
9704 return 0;
9705}
9706
9707/* add playback controls from the parsed DAC table */
9708static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9709 const struct auto_pin_cfg *cfg)
9710{
9711 hda_nid_t nid;
9712 int err;
9713
9714 spec->multiout.num_dacs = 2; /* only use one dac */
9715 spec->multiout.dac_nids = spec->private_dac_nids;
9716 spec->multiout.dac_nids[0] = 2;
9717 spec->multiout.dac_nids[1] = 3;
9718
9719 nid = cfg->line_out_pins[0];
9720 if (nid)
9721 alc268_new_analog_output(spec, nid, "Front", 0);
9722
9723 nid = cfg->speaker_pins[0];
9724 if (nid == 0x1d) {
9725 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9726 "Speaker Playback Volume",
9727 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9728 if (err < 0)
9729 return err;
9730 }
9731 nid = cfg->hp_pins[0];
9732 if (nid)
9733 alc268_new_analog_output(spec, nid, "Headphone", 0);
9734
9735 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9736 if (nid == 0x16) {
9737 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9738 "Mono Playback Switch",
9739 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9740 if (err < 0)
9741 return err;
9742 }
9743 return 0;
9744}
9745
9746/* create playback/capture controls for input pins */
9747static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9748 const struct auto_pin_cfg *cfg)
9749{
9750 struct hda_input_mux *imux = &spec->private_imux;
9751 int i, idx1;
9752
9753 for (i = 0; i < AUTO_PIN_LAST; i++) {
9754 switch(cfg->input_pins[i]) {
9755 case 0x18:
9756 idx1 = 0; /* Mic 1 */
9757 break;
9758 case 0x19:
9759 idx1 = 1; /* Mic 2 */
9760 break;
9761 case 0x1a:
9762 idx1 = 2; /* Line In */
9763 break;
9764 case 0x1c:
9765 idx1 = 3; /* CD */
9766 break;
9767 default:
9768 continue;
9769 }
9770 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9771 imux->items[imux->num_items].index = idx1;
9772 imux->num_items++;
9773 }
9774 return 0;
9775}
9776
9777static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9778{
9779 struct alc_spec *spec = codec->spec;
9780 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9781 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9782 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9783 unsigned int dac_vol1, dac_vol2;
9784
9785 if (speaker_nid) {
9786 snd_hda_codec_write(codec, speaker_nid, 0,
9787 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9788 snd_hda_codec_write(codec, 0x0f, 0,
9789 AC_VERB_SET_AMP_GAIN_MUTE,
9790 AMP_IN_UNMUTE(1));
9791 snd_hda_codec_write(codec, 0x10, 0,
9792 AC_VERB_SET_AMP_GAIN_MUTE,
9793 AMP_IN_UNMUTE(1));
9794 } else {
9795 snd_hda_codec_write(codec, 0x0f, 0,
9796 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9797 snd_hda_codec_write(codec, 0x10, 0,
9798 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9799 }
9800
9801 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9802 if (line_nid == 0x14)
9803 dac_vol2 = AMP_OUT_ZERO;
9804 else if (line_nid == 0x15)
9805 dac_vol1 = AMP_OUT_ZERO;
9806 if (hp_nid == 0x14)
9807 dac_vol2 = AMP_OUT_ZERO;
9808 else if (hp_nid == 0x15)
9809 dac_vol1 = AMP_OUT_ZERO;
9810 if (line_nid != 0x16 || hp_nid != 0x16 ||
9811 spec->autocfg.line_out_pins[1] != 0x16 ||
9812 spec->autocfg.line_out_pins[2] != 0x16)
9813 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9814
9815 snd_hda_codec_write(codec, 0x02, 0,
9816 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9817 snd_hda_codec_write(codec, 0x03, 0,
9818 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9819}
9820
9821/* pcm configuration: identiacal with ALC880 */
9822#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9823#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9824#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9825
9826/*
9827 * BIOS auto configuration
9828 */
9829static int alc268_parse_auto_config(struct hda_codec *codec)
9830{
9831 struct alc_spec *spec = codec->spec;
9832 int err;
9833 static hda_nid_t alc268_ignore[] = { 0 };
9834
9835 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9836 alc268_ignore);
9837 if (err < 0)
9838 return err;
9839 if (!spec->autocfg.line_outs)
9840 return 0; /* can't find valid BIOS pin config */
9841
9842 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9843 if (err < 0)
9844 return err;
9845 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9846 if (err < 0)
9847 return err;
9848
9849 spec->multiout.max_channels = 2;
9850
9851 /* digital only support output */
9852 if (spec->autocfg.dig_out_pin)
9853 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9854
9855 if (spec->kctl_alloc)
9856 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9857
9858 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9859 spec->num_mux_defs = 1;
9860 spec->input_mux = &spec->private_imux;
9861
Takashi Iwai776e1842007-08-29 15:07:11 +02009862 err = alc_auto_add_mic_boost(codec);
9863 if (err < 0)
9864 return err;
9865
Kailang Yanga361d842007-06-05 12:30:55 +02009866 return 1;
9867}
9868
9869#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9870#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9871#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9872
9873/* init callback for auto-configuration model -- overriding the default init */
9874static void alc268_auto_init(struct hda_codec *codec)
9875{
9876 alc268_auto_init_multi_out(codec);
9877 alc268_auto_init_hp_out(codec);
9878 alc268_auto_init_mono_speaker_out(codec);
9879 alc268_auto_init_analog_input(codec);
9880}
9881
9882/*
9883 * configuration and preset
9884 */
9885static const char *alc268_models[ALC268_MODEL_LAST] = {
9886 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009887 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009888 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009889 [ALC268_DELL] = "dell",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009890#ifdef CONFIG_SND_DEBUG
9891 [ALC268_TEST] = "test",
9892#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009893 [ALC268_AUTO] = "auto",
9894};
9895
9896static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009897 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9898 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009899 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009900 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009901 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009902 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009903 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009904 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009905 {}
9906};
9907
9908static struct alc_config_preset alc268_presets[] = {
9909 [ALC268_3ST] = {
9910 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9911 .init_verbs = { alc268_base_init_verbs },
9912 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9913 .dac_nids = alc268_dac_nids,
9914 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9915 .adc_nids = alc268_adc_nids_alt,
9916 .hp_nid = 0x03,
9917 .dig_out_nid = ALC268_DIGOUT_NID,
9918 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9919 .channel_mode = alc268_modes,
9920 .input_mux = &alc268_capture_source,
9921 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009922 [ALC268_TOSHIBA] = {
9923 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009924 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9925 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009926 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9927 .dac_nids = alc268_dac_nids,
9928 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9929 .adc_nids = alc268_adc_nids_alt,
9930 .hp_nid = 0x03,
9931 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9932 .channel_mode = alc268_modes,
9933 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009934 .unsol_event = alc268_toshiba_unsol_event,
9935 .init_hook = alc268_toshiba_automute,
9936 },
9937 [ALC268_ACER] = {
9938 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9939 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9940 alc268_acer_verbs },
9941 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9942 .dac_nids = alc268_dac_nids,
9943 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9944 .adc_nids = alc268_adc_nids_alt,
9945 .hp_nid = 0x02,
9946 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9947 .channel_mode = alc268_modes,
9948 .input_mux = &alc268_capture_source,
9949 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009950 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009951 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009952 [ALC268_DELL] = {
9953 .mixers = { alc268_dell_mixer },
9954 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9955 alc268_dell_verbs },
9956 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9957 .dac_nids = alc268_dac_nids,
9958 .hp_nid = 0x02,
9959 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9960 .channel_mode = alc268_modes,
9961 .unsol_event = alc268_dell_unsol_event,
9962 .init_hook = alc268_dell_init_hook,
9963 .input_mux = &alc268_capture_source,
9964 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009965#ifdef CONFIG_SND_DEBUG
9966 [ALC268_TEST] = {
9967 .mixers = { alc268_test_mixer, alc268_capture_mixer },
9968 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9969 alc268_volume_init_verbs },
9970 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9971 .dac_nids = alc268_dac_nids,
9972 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9973 .adc_nids = alc268_adc_nids_alt,
9974 .hp_nid = 0x03,
9975 .dig_out_nid = ALC268_DIGOUT_NID,
9976 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9977 .channel_mode = alc268_modes,
9978 .input_mux = &alc268_capture_source,
9979 },
9980#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009981};
9982
9983static int patch_alc268(struct hda_codec *codec)
9984{
9985 struct alc_spec *spec;
9986 int board_config;
9987 int err;
9988
9989 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9990 if (spec == NULL)
9991 return -ENOMEM;
9992
9993 codec->spec = spec;
9994
9995 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9996 alc268_models,
9997 alc268_cfg_tbl);
9998
9999 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10000 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10001 "trying auto-probe from BIOS...\n");
10002 board_config = ALC268_AUTO;
10003 }
10004
10005 if (board_config == ALC268_AUTO) {
10006 /* automatic parse from the BIOS config */
10007 err = alc268_parse_auto_config(codec);
10008 if (err < 0) {
10009 alc_free(codec);
10010 return err;
10011 } else if (!err) {
10012 printk(KERN_INFO
10013 "hda_codec: Cannot set up configuration "
10014 "from BIOS. Using base mode...\n");
10015 board_config = ALC268_3ST;
10016 }
10017 }
10018
10019 if (board_config != ALC268_AUTO)
10020 setup_preset(spec, &alc268_presets[board_config]);
10021
10022 spec->stream_name_analog = "ALC268 Analog";
10023 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10024 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10025
10026 spec->stream_name_digital = "ALC268 Digital";
10027 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10028
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010029 if (!spec->adc_nids && spec->input_mux) {
10030 /* check whether NID 0x07 is valid */
10031 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010032
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010033 /* get type */
10034 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10035 if (wcap != AC_WID_AUD_IN) {
10036 spec->adc_nids = alc268_adc_nids_alt;
10037 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10038 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010039 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010040 spec->num_mixers++;
10041 } else {
10042 spec->adc_nids = alc268_adc_nids;
10043 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10044 spec->mixers[spec->num_mixers] =
10045 alc268_capture_mixer;
10046 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010047 }
10048 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010049
10050 spec->vmaster_nid = 0x02;
10051
Kailang Yanga361d842007-06-05 12:30:55 +020010052 codec->patch_ops = alc_patch_ops;
10053 if (board_config == ALC268_AUTO)
10054 spec->init_hook = alc268_auto_init;
10055
10056 return 0;
10057}
10058
10059/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010060 * ALC269 channel source setting (2 channel)
10061 */
10062#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10063
10064#define alc269_dac_nids alc260_dac_nids
10065
10066static hda_nid_t alc269_adc_nids[1] = {
10067 /* ADC1 */
10068 0x07,
10069};
10070
10071#define alc269_modes alc260_modes
10072#define alc269_capture_source alc880_lg_lw_capture_source
10073
10074static struct snd_kcontrol_new alc269_base_mixer[] = {
10075 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10076 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10082 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10083 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10086 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10087 { } /* end */
10088};
10089
10090/* capture mixer elements */
10091static struct snd_kcontrol_new alc269_capture_mixer[] = {
10092 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10093 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10094 {
10095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10096 /* The multiple "Capture Source" controls confuse alsamixer
10097 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010098 */
10099 /* .name = "Capture Source", */
10100 .name = "Input Source",
10101 .count = 1,
10102 .info = alc_mux_enum_info,
10103 .get = alc_mux_enum_get,
10104 .put = alc_mux_enum_put,
10105 },
10106 { } /* end */
10107};
10108
10109/*
10110 * generic initialization of ADC, input mixers and output mixers
10111 */
10112static struct hda_verb alc269_init_verbs[] = {
10113 /*
10114 * Unmute ADC0 and set the default input to mic-in
10115 */
10116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10117
10118 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10119 * analog-loopback mixer widget
10120 * Note: PASD motherboards uses the Line In 2 as the input for
10121 * front panel mic (mic 2)
10122 */
10123 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10129
10130 /*
10131 * Set up output mixers (0x0c - 0x0e)
10132 */
10133 /* set vol=0 to output mixers */
10134 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10135 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10136
10137 /* set up input amps for analog loopback */
10138 /* Amp Indices: DAC = 0, mixer = 1 */
10139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10145
10146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10152 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10153
10154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10156 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10157 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10159 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10161
10162 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10163 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10164
10165 /* FIXME: use matrix-type input source selection */
10166 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10167 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10172
10173 /* set EAPD */
10174 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10175 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10176 { }
10177};
10178
10179/* add playback controls from the parsed DAC table */
10180static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10181 const struct auto_pin_cfg *cfg)
10182{
10183 hda_nid_t nid;
10184 int err;
10185
10186 spec->multiout.num_dacs = 1; /* only use one dac */
10187 spec->multiout.dac_nids = spec->private_dac_nids;
10188 spec->multiout.dac_nids[0] = 2;
10189
10190 nid = cfg->line_out_pins[0];
10191 if (nid) {
10192 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10193 "Front Playback Volume",
10194 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10195 if (err < 0)
10196 return err;
10197 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10198 "Front Playback Switch",
10199 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10200 if (err < 0)
10201 return err;
10202 }
10203
10204 nid = cfg->speaker_pins[0];
10205 if (nid) {
10206 if (!cfg->line_out_pins[0]) {
10207 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10208 "Speaker Playback Volume",
10209 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10210 HDA_OUTPUT));
10211 if (err < 0)
10212 return err;
10213 }
10214 if (nid == 0x16) {
10215 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10216 "Speaker Playback Switch",
10217 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10218 HDA_OUTPUT));
10219 if (err < 0)
10220 return err;
10221 } else {
10222 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10223 "Speaker Playback Switch",
10224 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10225 HDA_OUTPUT));
10226 if (err < 0)
10227 return err;
10228 }
10229 }
10230 nid = cfg->hp_pins[0];
10231 if (nid) {
10232 /* spec->multiout.hp_nid = 2; */
10233 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10234 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10235 "Headphone Playback Volume",
10236 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10237 HDA_OUTPUT));
10238 if (err < 0)
10239 return err;
10240 }
10241 if (nid == 0x16) {
10242 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10243 "Headphone Playback Switch",
10244 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10245 HDA_OUTPUT));
10246 if (err < 0)
10247 return err;
10248 } else {
10249 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10250 "Headphone Playback Switch",
10251 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10252 HDA_OUTPUT));
10253 if (err < 0)
10254 return err;
10255 }
10256 }
10257 return 0;
10258}
10259
10260#define alc269_auto_create_analog_input_ctls \
10261 alc880_auto_create_analog_input_ctls
10262
10263#ifdef CONFIG_SND_HDA_POWER_SAVE
10264#define alc269_loopbacks alc880_loopbacks
10265#endif
10266
10267/* pcm configuration: identiacal with ALC880 */
10268#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10269#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10270#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10271#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10272
10273/*
10274 * BIOS auto configuration
10275 */
10276static int alc269_parse_auto_config(struct hda_codec *codec)
10277{
10278 struct alc_spec *spec = codec->spec;
10279 int err;
10280 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10281
10282 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10283 alc269_ignore);
10284 if (err < 0)
10285 return err;
10286
10287 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10288 if (err < 0)
10289 return err;
10290 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10291 if (err < 0)
10292 return err;
10293
10294 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10295
10296 if (spec->autocfg.dig_out_pin)
10297 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10298
10299 if (spec->kctl_alloc)
10300 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10301
10302 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10303 spec->num_mux_defs = 1;
10304 spec->input_mux = &spec->private_imux;
10305
10306 err = alc_auto_add_mic_boost(codec);
10307 if (err < 0)
10308 return err;
10309
10310 return 1;
10311}
10312
10313#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10314#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10315#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10316
10317
10318/* init callback for auto-configuration model -- overriding the default init */
10319static void alc269_auto_init(struct hda_codec *codec)
10320{
10321 alc269_auto_init_multi_out(codec);
10322 alc269_auto_init_hp_out(codec);
10323 alc269_auto_init_analog_input(codec);
10324}
10325
10326/*
10327 * configuration and preset
10328 */
10329static const char *alc269_models[ALC269_MODEL_LAST] = {
10330 [ALC269_BASIC] = "basic",
10331};
10332
10333static struct snd_pci_quirk alc269_cfg_tbl[] = {
10334 {}
10335};
10336
10337static struct alc_config_preset alc269_presets[] = {
10338 [ALC269_BASIC] = {
10339 .mixers = { alc269_base_mixer },
10340 .init_verbs = { alc269_init_verbs },
10341 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10342 .dac_nids = alc269_dac_nids,
10343 .hp_nid = 0x03,
10344 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10345 .channel_mode = alc269_modes,
10346 .input_mux = &alc269_capture_source,
10347 },
10348};
10349
10350static int patch_alc269(struct hda_codec *codec)
10351{
10352 struct alc_spec *spec;
10353 int board_config;
10354 int err;
10355
10356 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10357 if (spec == NULL)
10358 return -ENOMEM;
10359
10360 codec->spec = spec;
10361
10362 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10363 alc269_models,
10364 alc269_cfg_tbl);
10365
10366 if (board_config < 0) {
10367 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10368 "trying auto-probe from BIOS...\n");
10369 board_config = ALC269_AUTO;
10370 }
10371
10372 if (board_config == ALC269_AUTO) {
10373 /* automatic parse from the BIOS config */
10374 err = alc269_parse_auto_config(codec);
10375 if (err < 0) {
10376 alc_free(codec);
10377 return err;
10378 } else if (!err) {
10379 printk(KERN_INFO
10380 "hda_codec: Cannot set up configuration "
10381 "from BIOS. Using base mode...\n");
10382 board_config = ALC269_BASIC;
10383 }
10384 }
10385
10386 if (board_config != ALC269_AUTO)
10387 setup_preset(spec, &alc269_presets[board_config]);
10388
10389 spec->stream_name_analog = "ALC269 Analog";
10390 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10391 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10392
10393 spec->stream_name_digital = "ALC269 Digital";
10394 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10395 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10396
10397 spec->adc_nids = alc269_adc_nids;
10398 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10399 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10400 spec->num_mixers++;
10401
10402 codec->patch_ops = alc_patch_ops;
10403 if (board_config == ALC269_AUTO)
10404 spec->init_hook = alc269_auto_init;
10405#ifdef CONFIG_SND_HDA_POWER_SAVE
10406 if (!spec->loopback.amplist)
10407 spec->loopback.amplist = alc269_loopbacks;
10408#endif
10409
10410 return 0;
10411}
10412
10413/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010414 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10415 */
10416
10417/*
10418 * set the path ways for 2 channel output
10419 * need to set the codec line out and mic 1 pin widgets to inputs
10420 */
10421static struct hda_verb alc861_threestack_ch2_init[] = {
10422 /* set pin widget 1Ah (line in) for input */
10423 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010424 /* set pin widget 18h (mic1/2) for input, for mic also enable
10425 * the vref
10426 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010427 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10428
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010429 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10430#if 0
10431 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10432 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10433#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010434 { } /* end */
10435};
10436/*
10437 * 6ch mode
10438 * need to set the codec line out and mic 1 pin widgets to outputs
10439 */
10440static struct hda_verb alc861_threestack_ch6_init[] = {
10441 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10442 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10443 /* set pin widget 18h (mic1) for output (CLFE)*/
10444 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10445
10446 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010447 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010448
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010449 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10450#if 0
10451 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10452 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10453#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010454 { } /* end */
10455};
10456
10457static struct hda_channel_mode alc861_threestack_modes[2] = {
10458 { 2, alc861_threestack_ch2_init },
10459 { 6, alc861_threestack_ch6_init },
10460};
Takashi Iwai22309c32006-08-09 16:57:28 +020010461/* Set mic1 as input and unmute the mixer */
10462static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10463 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10464 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10465 { } /* end */
10466};
10467/* Set mic1 as output and mute mixer */
10468static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10469 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10471 { } /* end */
10472};
10473
10474static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10475 { 2, alc861_uniwill_m31_ch2_init },
10476 { 4, alc861_uniwill_m31_ch4_init },
10477};
Kailang Yangdf694da2005-12-05 19:42:22 +010010478
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010479/* Set mic1 and line-in as input and unmute the mixer */
10480static struct hda_verb alc861_asus_ch2_init[] = {
10481 /* set pin widget 1Ah (line in) for input */
10482 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010483 /* set pin widget 18h (mic1/2) for input, for mic also enable
10484 * the vref
10485 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010486 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10487
10488 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10489#if 0
10490 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10491 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10492#endif
10493 { } /* end */
10494};
10495/* Set mic1 nad line-in as output and mute mixer */
10496static struct hda_verb alc861_asus_ch6_init[] = {
10497 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10498 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10499 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10500 /* set pin widget 18h (mic1) for output (CLFE)*/
10501 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10502 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10503 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10504 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10505
10506 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10507#if 0
10508 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10509 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10510#endif
10511 { } /* end */
10512};
10513
10514static struct hda_channel_mode alc861_asus_modes[2] = {
10515 { 2, alc861_asus_ch2_init },
10516 { 6, alc861_asus_ch6_init },
10517};
10518
Kailang Yangdf694da2005-12-05 19:42:22 +010010519/* patch-ALC861 */
10520
10521static struct snd_kcontrol_new alc861_base_mixer[] = {
10522 /* output mixer control */
10523 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10524 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10525 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10526 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10527 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10528
10529 /*Input mixer control */
10530 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10531 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10532 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10533 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10534 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10535 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10537 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10538 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010540
Kailang Yangdf694da2005-12-05 19:42:22 +010010541 /* Capture mixer control */
10542 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10543 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10544 {
10545 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10546 .name = "Capture Source",
10547 .count = 1,
10548 .info = alc_mux_enum_info,
10549 .get = alc_mux_enum_get,
10550 .put = alc_mux_enum_put,
10551 },
10552 { } /* end */
10553};
10554
10555static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10556 /* output mixer control */
10557 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10558 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10560 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10561 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10562
10563 /* Input mixer control */
10564 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10566 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10567 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10568 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10569 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10571 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010574
Kailang Yangdf694da2005-12-05 19:42:22 +010010575 /* Capture mixer control */
10576 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10577 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10578 {
10579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10580 .name = "Capture Source",
10581 .count = 1,
10582 .info = alc_mux_enum_info,
10583 .get = alc_mux_enum_get,
10584 .put = alc_mux_enum_put,
10585 },
10586 {
10587 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10588 .name = "Channel Mode",
10589 .info = alc_ch_mode_info,
10590 .get = alc_ch_mode_get,
10591 .put = alc_ch_mode_put,
10592 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10593 },
10594 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010595};
10596
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010597static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010598 /* output mixer control */
10599 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10601 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10602
10603 /*Capture mixer control */
10604 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10605 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10606 {
10607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10608 .name = "Capture Source",
10609 .count = 1,
10610 .info = alc_mux_enum_info,
10611 .get = alc_mux_enum_get,
10612 .put = alc_mux_enum_put,
10613 },
10614
10615 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010616};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010617
Takashi Iwai22309c32006-08-09 16:57:28 +020010618static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10619 /* output mixer control */
10620 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10621 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10622 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10623 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10624 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10625
10626 /* Input mixer control */
10627 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10628 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10629 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10630 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10631 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10632 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10634 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10635 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637
Takashi Iwai22309c32006-08-09 16:57:28 +020010638 /* Capture mixer control */
10639 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10640 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10641 {
10642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10643 .name = "Capture Source",
10644 .count = 1,
10645 .info = alc_mux_enum_info,
10646 .get = alc_mux_enum_get,
10647 .put = alc_mux_enum_put,
10648 },
10649 {
10650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10651 .name = "Channel Mode",
10652 .info = alc_ch_mode_info,
10653 .get = alc_ch_mode_get,
10654 .put = alc_ch_mode_put,
10655 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10656 },
10657 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010658};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010659
10660static struct snd_kcontrol_new alc861_asus_mixer[] = {
10661 /* output mixer control */
10662 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10663 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10664 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10665 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10666 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10667
10668 /* Input mixer control */
10669 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10670 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10671 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10672 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10674 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10676 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10679
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010680 /* Capture mixer control */
10681 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10682 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10683 {
10684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10685 .name = "Capture Source",
10686 .count = 1,
10687 .info = alc_mux_enum_info,
10688 .get = alc_mux_enum_get,
10689 .put = alc_mux_enum_put,
10690 },
10691 {
10692 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10693 .name = "Channel Mode",
10694 .info = alc_ch_mode_info,
10695 .get = alc_ch_mode_get,
10696 .put = alc_ch_mode_put,
10697 .private_value = ARRAY_SIZE(alc861_asus_modes),
10698 },
10699 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010700};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010701
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010702/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010703static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010704 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10705 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10706 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10707 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10708 { }
10709};
10710
Kailang Yangdf694da2005-12-05 19:42:22 +010010711/*
10712 * generic initialization of ADC, input mixers and output mixers
10713 */
10714static struct hda_verb alc861_base_init_verbs[] = {
10715 /*
10716 * Unmute ADC0 and set the default input to mic-in
10717 */
10718 /* port-A for surround (rear panel) */
10719 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10720 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10721 /* port-B for mic-in (rear panel) with vref */
10722 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10723 /* port-C for line-in (rear panel) */
10724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10725 /* port-D for Front */
10726 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10727 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10728 /* port-E for HP out (front panel) */
10729 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10730 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010731 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010732 /* port-F for mic-in (front panel) with vref */
10733 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10734 /* port-G for CLFE (rear panel) */
10735 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10736 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10737 /* port-H for side (rear panel) */
10738 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10739 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10740 /* CD-in */
10741 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10742 /* route front mic to ADC1*/
10743 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10745
10746 /* Unmute DAC0~3 & spdif out*/
10747 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10748 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10749 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10750 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10752
10753 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10754 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10755 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10756 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10757 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10758
10759 /* Unmute Stereo Mixer 15 */
10760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010764
10765 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10767 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10768 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10769 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10770 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10771 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010773 /* hp used DAC 3 (Front) */
10774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10776
10777 { }
10778};
10779
10780static struct hda_verb alc861_threestack_init_verbs[] = {
10781 /*
10782 * Unmute ADC0 and set the default input to mic-in
10783 */
10784 /* port-A for surround (rear panel) */
10785 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10786 /* port-B for mic-in (rear panel) with vref */
10787 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10788 /* port-C for line-in (rear panel) */
10789 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10790 /* port-D for Front */
10791 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10792 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10793 /* port-E for HP out (front panel) */
10794 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10795 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010796 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010797 /* port-F for mic-in (front panel) with vref */
10798 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10799 /* port-G for CLFE (rear panel) */
10800 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10801 /* port-H for side (rear panel) */
10802 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10803 /* CD-in */
10804 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10805 /* route front mic to ADC1*/
10806 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10808 /* Unmute DAC0~3 & spdif out*/
10809 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10810 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10811 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10812 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10814
10815 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10816 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10817 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10818 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10819 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10820
10821 /* Unmute Stereo Mixer 15 */
10822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010826
10827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10831 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10832 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10833 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010835 /* hp used DAC 3 (Front) */
10836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010837 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10838 { }
10839};
Takashi Iwai22309c32006-08-09 16:57:28 +020010840
10841static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10842 /*
10843 * Unmute ADC0 and set the default input to mic-in
10844 */
10845 /* port-A for surround (rear panel) */
10846 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10847 /* port-B for mic-in (rear panel) with vref */
10848 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10849 /* port-C for line-in (rear panel) */
10850 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10851 /* port-D for Front */
10852 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10853 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10854 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 /* this has to be set to VREF80 */
10856 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010857 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010858 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010859 /* port-F for mic-in (front panel) with vref */
10860 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10861 /* port-G for CLFE (rear panel) */
10862 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10863 /* port-H for side (rear panel) */
10864 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10865 /* CD-in */
10866 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10867 /* route front mic to ADC1*/
10868 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10870 /* Unmute DAC0~3 & spdif out*/
10871 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10872 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10873 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10874 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10876
10877 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10878 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10879 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10880 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10881 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10882
10883 /* Unmute Stereo Mixer 15 */
10884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010888
10889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10894 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010897 /* hp used DAC 3 (Front) */
10898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10900 { }
10901};
10902
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010903static struct hda_verb alc861_asus_init_verbs[] = {
10904 /*
10905 * Unmute ADC0 and set the default input to mic-in
10906 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010907 /* port-A for surround (rear panel)
10908 * according to codec#0 this is the HP jack
10909 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010910 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10911 /* route front PCM to HP */
10912 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10913 /* port-B for mic-in (rear panel) with vref */
10914 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10915 /* port-C for line-in (rear panel) */
10916 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10917 /* port-D for Front */
10918 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10919 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10920 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010921 /* this has to be set to VREF80 */
10922 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010923 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010924 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010925 /* port-F for mic-in (front panel) with vref */
10926 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10927 /* port-G for CLFE (rear panel) */
10928 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10929 /* port-H for side (rear panel) */
10930 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10931 /* CD-in */
10932 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10933 /* route front mic to ADC1*/
10934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10936 /* Unmute DAC0~3 & spdif out*/
10937 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10938 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10939 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10940 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10942 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10943 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10944 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10945 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10946 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10947
10948 /* Unmute Stereo Mixer 15 */
10949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010952 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010953
10954 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10956 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10957 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10959 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10961 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010962 /* hp used DAC 3 (Front) */
10963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010964 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10965 { }
10966};
10967
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010968/* additional init verbs for ASUS laptops */
10969static struct hda_verb alc861_asus_laptop_init_verbs[] = {
10970 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
10971 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
10972 { }
10973};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010974
Kailang Yangdf694da2005-12-05 19:42:22 +010010975/*
10976 * generic initialization of ADC, input mixers and output mixers
10977 */
10978static struct hda_verb alc861_auto_init_verbs[] = {
10979 /*
10980 * Unmute ADC0 and set the default input to mic-in
10981 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010982 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10984
10985 /* Unmute DAC0~3 & spdif out*/
10986 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10987 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10988 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10989 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10991
10992 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10993 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10995 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10996 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10997
10998 /* Unmute Stereo Mixer 15 */
10999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11003
11004 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11005 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11006 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11009 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11010 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11012
11013 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011021
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011022 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011023
11024 { }
11025};
11026
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011027static struct hda_verb alc861_toshiba_init_verbs[] = {
11028 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011029
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011030 { }
11031};
11032
11033/* toggle speaker-output according to the hp-jack state */
11034static void alc861_toshiba_automute(struct hda_codec *codec)
11035{
11036 unsigned int present;
11037
11038 present = snd_hda_codec_read(codec, 0x0f, 0,
11039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011040 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11041 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11042 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11043 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011044}
11045
11046static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11047 unsigned int res)
11048{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011049 if ((res >> 26) == ALC880_HP_EVENT)
11050 alc861_toshiba_automute(codec);
11051}
11052
Kailang Yangdf694da2005-12-05 19:42:22 +010011053/* pcm configuration: identiacal with ALC880 */
11054#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11055#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11056#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11057#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11058
11059
11060#define ALC861_DIGOUT_NID 0x07
11061
11062static struct hda_channel_mode alc861_8ch_modes[1] = {
11063 { 8, NULL }
11064};
11065
11066static hda_nid_t alc861_dac_nids[4] = {
11067 /* front, surround, clfe, side */
11068 0x03, 0x06, 0x05, 0x04
11069};
11070
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011071static hda_nid_t alc660_dac_nids[3] = {
11072 /* front, clfe, surround */
11073 0x03, 0x05, 0x06
11074};
11075
Kailang Yangdf694da2005-12-05 19:42:22 +010011076static hda_nid_t alc861_adc_nids[1] = {
11077 /* ADC0-2 */
11078 0x08,
11079};
11080
11081static struct hda_input_mux alc861_capture_source = {
11082 .num_items = 5,
11083 .items = {
11084 { "Mic", 0x0 },
11085 { "Front Mic", 0x3 },
11086 { "Line", 0x1 },
11087 { "CD", 0x4 },
11088 { "Mixer", 0x5 },
11089 },
11090};
11091
11092/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011093static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11094 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011095{
11096 int i;
11097 hda_nid_t nid;
11098
11099 spec->multiout.dac_nids = spec->private_dac_nids;
11100 for (i = 0; i < cfg->line_outs; i++) {
11101 nid = cfg->line_out_pins[i];
11102 if (nid) {
11103 if (i >= ARRAY_SIZE(alc861_dac_nids))
11104 continue;
11105 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11106 }
11107 }
11108 spec->multiout.num_dacs = cfg->line_outs;
11109 return 0;
11110}
11111
11112/* add playback controls from the parsed DAC table */
11113static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11114 const struct auto_pin_cfg *cfg)
11115{
11116 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011117 static const char *chname[4] = {
11118 "Front", "Surround", NULL /*CLFE*/, "Side"
11119 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011120 hda_nid_t nid;
11121 int i, idx, err;
11122
11123 for (i = 0; i < cfg->line_outs; i++) {
11124 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011125 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011126 continue;
11127 if (nid == 0x05) {
11128 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011129 err = add_control(spec, ALC_CTL_BIND_MUTE,
11130 "Center Playback Switch",
11131 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11132 HDA_OUTPUT));
11133 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011134 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011135 err = add_control(spec, ALC_CTL_BIND_MUTE,
11136 "LFE Playback Switch",
11137 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11138 HDA_OUTPUT));
11139 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011140 return err;
11141 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011142 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11143 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011144 if (nid == alc861_dac_nids[idx])
11145 break;
11146 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011147 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11148 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11149 HDA_OUTPUT));
11150 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011151 return err;
11152 }
11153 }
11154 return 0;
11155}
11156
11157static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11158{
11159 int err;
11160 hda_nid_t nid;
11161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011162 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011163 return 0;
11164
11165 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11166 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11168 "Headphone Playback Switch",
11169 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11170 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011171 return err;
11172 spec->multiout.hp_nid = nid;
11173 }
11174 return 0;
11175}
11176
11177/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011178static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11179 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011180{
Kailang Yangdf694da2005-12-05 19:42:22 +010011181 struct hda_input_mux *imux = &spec->private_imux;
11182 int i, err, idx, idx1;
11183
11184 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011185 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011186 case 0x0c:
11187 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011188 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011189 break;
11190 case 0x0f:
11191 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011192 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011193 break;
11194 case 0x0d:
11195 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011196 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011197 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011198 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011199 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011201 break;
11202 case 0x11:
11203 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011204 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 break;
11206 default:
11207 continue;
11208 }
11209
Takashi Iwai4a471b72005-12-07 13:56:29 +010011210 err = new_analog_input(spec, cfg->input_pins[i],
11211 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011212 if (err < 0)
11213 return err;
11214
Takashi Iwai4a471b72005-12-07 13:56:29 +010011215 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011216 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011217 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011218 }
11219 return 0;
11220}
11221
11222static struct snd_kcontrol_new alc861_capture_mixer[] = {
11223 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11224 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11225
11226 {
11227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11228 /* The multiple "Capture Source" controls confuse alsamixer
11229 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011230 */
11231 /* .name = "Capture Source", */
11232 .name = "Input Source",
11233 .count = 1,
11234 .info = alc_mux_enum_info,
11235 .get = alc_mux_enum_get,
11236 .put = alc_mux_enum_put,
11237 },
11238 { } /* end */
11239};
11240
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011241static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11242 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011243 int pin_type, int dac_idx)
11244{
11245 /* set as output */
11246
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011247 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11248 pin_type);
11249 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11250 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011251
11252}
11253
11254static void alc861_auto_init_multi_out(struct hda_codec *codec)
11255{
11256 struct alc_spec *spec = codec->spec;
11257 int i;
11258
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011259 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011260 for (i = 0; i < spec->autocfg.line_outs; i++) {
11261 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011262 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011264 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011265 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011266 }
11267}
11268
11269static void alc861_auto_init_hp_out(struct hda_codec *codec)
11270{
11271 struct alc_spec *spec = codec->spec;
11272 hda_nid_t pin;
11273
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011274 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011275 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011276 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11277 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011278}
11279
11280static void alc861_auto_init_analog_input(struct hda_codec *codec)
11281{
11282 struct alc_spec *spec = codec->spec;
11283 int i;
11284
11285 for (i = 0; i < AUTO_PIN_LAST; i++) {
11286 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011287 if (nid >= 0x0c && nid <= 0x11) {
11288 snd_hda_codec_write(codec, nid, 0,
11289 AC_VERB_SET_PIN_WIDGET_CONTROL,
11290 i <= AUTO_PIN_FRONT_MIC ?
11291 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011292 }
11293 }
11294}
11295
11296/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011297/* return 1 if successful, 0 if the proper config is not found,
11298 * or a negative error code
11299 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011300static int alc861_parse_auto_config(struct hda_codec *codec)
11301{
11302 struct alc_spec *spec = codec->spec;
11303 int err;
11304 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11305
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011306 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11307 alc861_ignore);
11308 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011309 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011310 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011311 return 0; /* can't find valid BIOS pin config */
11312
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011313 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11314 if (err < 0)
11315 return err;
11316 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11317 if (err < 0)
11318 return err;
11319 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11320 if (err < 0)
11321 return err;
11322 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11323 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011324 return err;
11325
11326 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11327
11328 if (spec->autocfg.dig_out_pin)
11329 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11330
11331 if (spec->kctl_alloc)
11332 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11333
11334 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11335
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011336 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011337 spec->input_mux = &spec->private_imux;
11338
11339 spec->adc_nids = alc861_adc_nids;
11340 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11341 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11342 spec->num_mixers++;
11343
11344 return 1;
11345}
11346
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011347/* additional initialization for auto-configuration model */
11348static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011349{
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 alc861_auto_init_multi_out(codec);
11351 alc861_auto_init_hp_out(codec);
11352 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011353}
11354
Takashi Iwaicb53c622007-08-10 17:21:45 +020011355#ifdef CONFIG_SND_HDA_POWER_SAVE
11356static struct hda_amp_list alc861_loopbacks[] = {
11357 { 0x15, HDA_INPUT, 0 },
11358 { 0x15, HDA_INPUT, 1 },
11359 { 0x15, HDA_INPUT, 2 },
11360 { 0x15, HDA_INPUT, 3 },
11361 { } /* end */
11362};
11363#endif
11364
Kailang Yangdf694da2005-12-05 19:42:22 +010011365
11366/*
11367 * configuration and preset
11368 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011369static const char *alc861_models[ALC861_MODEL_LAST] = {
11370 [ALC861_3ST] = "3stack",
11371 [ALC660_3ST] = "3stack-660",
11372 [ALC861_3ST_DIG] = "3stack-dig",
11373 [ALC861_6ST_DIG] = "6stack-dig",
11374 [ALC861_UNIWILL_M31] = "uniwill-m31",
11375 [ALC861_TOSHIBA] = "toshiba",
11376 [ALC861_ASUS] = "asus",
11377 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11378 [ALC861_AUTO] = "auto",
11379};
11380
11381static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011382 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011383 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11384 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11385 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011386 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011387 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011388 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011389 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11390 * Any other models that need this preset?
11391 */
11392 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011393 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11394 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011395 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11396 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11397 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11398 /* FIXME: the below seems conflict */
11399 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11400 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11401 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011402 {}
11403};
11404
11405static struct alc_config_preset alc861_presets[] = {
11406 [ALC861_3ST] = {
11407 .mixers = { alc861_3ST_mixer },
11408 .init_verbs = { alc861_threestack_init_verbs },
11409 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11410 .dac_nids = alc861_dac_nids,
11411 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11412 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011413 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011414 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11415 .adc_nids = alc861_adc_nids,
11416 .input_mux = &alc861_capture_source,
11417 },
11418 [ALC861_3ST_DIG] = {
11419 .mixers = { alc861_base_mixer },
11420 .init_verbs = { alc861_threestack_init_verbs },
11421 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11422 .dac_nids = alc861_dac_nids,
11423 .dig_out_nid = ALC861_DIGOUT_NID,
11424 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11425 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011426 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011427 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11428 .adc_nids = alc861_adc_nids,
11429 .input_mux = &alc861_capture_source,
11430 },
11431 [ALC861_6ST_DIG] = {
11432 .mixers = { alc861_base_mixer },
11433 .init_verbs = { alc861_base_init_verbs },
11434 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11435 .dac_nids = alc861_dac_nids,
11436 .dig_out_nid = ALC861_DIGOUT_NID,
11437 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11438 .channel_mode = alc861_8ch_modes,
11439 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11440 .adc_nids = alc861_adc_nids,
11441 .input_mux = &alc861_capture_source,
11442 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011443 [ALC660_3ST] = {
11444 .mixers = { alc861_3ST_mixer },
11445 .init_verbs = { alc861_threestack_init_verbs },
11446 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11447 .dac_nids = alc660_dac_nids,
11448 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11449 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011450 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011451 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11452 .adc_nids = alc861_adc_nids,
11453 .input_mux = &alc861_capture_source,
11454 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011455 [ALC861_UNIWILL_M31] = {
11456 .mixers = { alc861_uniwill_m31_mixer },
11457 .init_verbs = { alc861_uniwill_m31_init_verbs },
11458 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11459 .dac_nids = alc861_dac_nids,
11460 .dig_out_nid = ALC861_DIGOUT_NID,
11461 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11462 .channel_mode = alc861_uniwill_m31_modes,
11463 .need_dac_fix = 1,
11464 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11465 .adc_nids = alc861_adc_nids,
11466 .input_mux = &alc861_capture_source,
11467 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011468 [ALC861_TOSHIBA] = {
11469 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011470 .init_verbs = { alc861_base_init_verbs,
11471 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011472 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11473 .dac_nids = alc861_dac_nids,
11474 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11475 .channel_mode = alc883_3ST_2ch_modes,
11476 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11477 .adc_nids = alc861_adc_nids,
11478 .input_mux = &alc861_capture_source,
11479 .unsol_event = alc861_toshiba_unsol_event,
11480 .init_hook = alc861_toshiba_automute,
11481 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011482 [ALC861_ASUS] = {
11483 .mixers = { alc861_asus_mixer },
11484 .init_verbs = { alc861_asus_init_verbs },
11485 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11486 .dac_nids = alc861_dac_nids,
11487 .dig_out_nid = ALC861_DIGOUT_NID,
11488 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11489 .channel_mode = alc861_asus_modes,
11490 .need_dac_fix = 1,
11491 .hp_nid = 0x06,
11492 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11493 .adc_nids = alc861_adc_nids,
11494 .input_mux = &alc861_capture_source,
11495 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011496 [ALC861_ASUS_LAPTOP] = {
11497 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11498 .init_verbs = { alc861_asus_init_verbs,
11499 alc861_asus_laptop_init_verbs },
11500 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11501 .dac_nids = alc861_dac_nids,
11502 .dig_out_nid = ALC861_DIGOUT_NID,
11503 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11504 .channel_mode = alc883_3ST_2ch_modes,
11505 .need_dac_fix = 1,
11506 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11507 .adc_nids = alc861_adc_nids,
11508 .input_mux = &alc861_capture_source,
11509 },
11510};
Kailang Yangdf694da2005-12-05 19:42:22 +010011511
11512
11513static int patch_alc861(struct hda_codec *codec)
11514{
11515 struct alc_spec *spec;
11516 int board_config;
11517 int err;
11518
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011519 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011520 if (spec == NULL)
11521 return -ENOMEM;
11522
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011523 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011524
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011525 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11526 alc861_models,
11527 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011528
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011529 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011530 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11531 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011532 board_config = ALC861_AUTO;
11533 }
11534
11535 if (board_config == ALC861_AUTO) {
11536 /* automatic parse from the BIOS config */
11537 err = alc861_parse_auto_config(codec);
11538 if (err < 0) {
11539 alc_free(codec);
11540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011541 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011542 printk(KERN_INFO
11543 "hda_codec: Cannot set up configuration "
11544 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011545 board_config = ALC861_3ST_DIG;
11546 }
11547 }
11548
11549 if (board_config != ALC861_AUTO)
11550 setup_preset(spec, &alc861_presets[board_config]);
11551
11552 spec->stream_name_analog = "ALC861 Analog";
11553 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11554 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11555
11556 spec->stream_name_digital = "ALC861 Digital";
11557 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11558 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11559
Takashi Iwai2134ea42008-01-10 16:53:55 +010011560 spec->vmaster_nid = 0x03;
11561
Kailang Yangdf694da2005-12-05 19:42:22 +010011562 codec->patch_ops = alc_patch_ops;
11563 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011564 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011565#ifdef CONFIG_SND_HDA_POWER_SAVE
11566 if (!spec->loopback.amplist)
11567 spec->loopback.amplist = alc861_loopbacks;
11568#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011569
11570 return 0;
11571}
11572
11573/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011574 * ALC861-VD support
11575 *
11576 * Based on ALC882
11577 *
11578 * In addition, an independent DAC
11579 */
11580#define ALC861VD_DIGOUT_NID 0x06
11581
11582static hda_nid_t alc861vd_dac_nids[4] = {
11583 /* front, surr, clfe, side surr */
11584 0x02, 0x03, 0x04, 0x05
11585};
11586
11587/* dac_nids for ALC660vd are in a different order - according to
11588 * Realtek's driver.
11589 * This should probably tesult in a different mixer for 6stack models
11590 * of ALC660vd codecs, but for now there is only 3stack mixer
11591 * - and it is the same as in 861vd.
11592 * adc_nids in ALC660vd are (is) the same as in 861vd
11593 */
11594static hda_nid_t alc660vd_dac_nids[3] = {
11595 /* front, rear, clfe, rear_surr */
11596 0x02, 0x04, 0x03
11597};
11598
11599static hda_nid_t alc861vd_adc_nids[1] = {
11600 /* ADC0 */
11601 0x09,
11602};
11603
11604/* input MUX */
11605/* FIXME: should be a matrix-type input source selection */
11606static struct hda_input_mux alc861vd_capture_source = {
11607 .num_items = 4,
11608 .items = {
11609 { "Mic", 0x0 },
11610 { "Front Mic", 0x1 },
11611 { "Line", 0x2 },
11612 { "CD", 0x4 },
11613 },
11614};
11615
Kailang Yang272a5272007-05-14 11:00:38 +020011616static struct hda_input_mux alc861vd_dallas_capture_source = {
11617 .num_items = 3,
11618 .items = {
11619 { "Front Mic", 0x0 },
11620 { "ATAPI Mic", 0x1 },
11621 { "Line In", 0x5 },
11622 },
11623};
11624
Kailang Yangd1a991a2007-08-15 16:21:59 +020011625static struct hda_input_mux alc861vd_hp_capture_source = {
11626 .num_items = 2,
11627 .items = {
11628 { "Front Mic", 0x0 },
11629 { "ATAPI Mic", 0x1 },
11630 },
11631};
11632
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011633#define alc861vd_mux_enum_info alc_mux_enum_info
11634#define alc861vd_mux_enum_get alc_mux_enum_get
11635
11636static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11637 struct snd_ctl_elem_value *ucontrol)
11638{
11639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11640 struct alc_spec *spec = codec->spec;
11641 const struct hda_input_mux *imux = spec->input_mux;
11642 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11643 static hda_nid_t capture_mixers[1] = { 0x22 };
11644 hda_nid_t nid = capture_mixers[adc_idx];
11645 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11646 unsigned int i, idx;
11647
11648 idx = ucontrol->value.enumerated.item[0];
11649 if (idx >= imux->num_items)
11650 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011651 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011652 return 0;
11653 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011654 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11655 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11656 imux->items[i].index,
11657 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011658 }
11659 *cur_val = idx;
11660 return 1;
11661}
11662
11663/*
11664 * 2ch mode
11665 */
11666static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11667 { 2, NULL }
11668};
11669
11670/*
11671 * 6ch mode
11672 */
11673static struct hda_verb alc861vd_6stack_ch6_init[] = {
11674 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11675 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11676 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11677 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11678 { } /* end */
11679};
11680
11681/*
11682 * 8ch mode
11683 */
11684static struct hda_verb alc861vd_6stack_ch8_init[] = {
11685 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11686 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11687 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11688 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11689 { } /* end */
11690};
11691
11692static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11693 { 6, alc861vd_6stack_ch6_init },
11694 { 8, alc861vd_6stack_ch8_init },
11695};
11696
11697static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11698 {
11699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11700 .name = "Channel Mode",
11701 .info = alc_ch_mode_info,
11702 .get = alc_ch_mode_get,
11703 .put = alc_ch_mode_put,
11704 },
11705 { } /* end */
11706};
11707
11708static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11709 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11710 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11711
11712 {
11713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11714 /* The multiple "Capture Source" controls confuse alsamixer
11715 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011716 */
11717 /* .name = "Capture Source", */
11718 .name = "Input Source",
11719 .count = 1,
11720 .info = alc861vd_mux_enum_info,
11721 .get = alc861vd_mux_enum_get,
11722 .put = alc861vd_mux_enum_put,
11723 },
11724 { } /* end */
11725};
11726
11727/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11728 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11729 */
11730static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11731 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11732 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11733
11734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11735 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11736
11737 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11738 HDA_OUTPUT),
11739 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11740 HDA_OUTPUT),
11741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11743
11744 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11745 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11746
11747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11748
11749 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11752
11753 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11755 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11756
11757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11759
11760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11762
11763 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11764 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11765
11766 { } /* end */
11767};
11768
11769static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11770 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11771 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11772
11773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11774
11775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11778
11779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11780 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11782
11783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11785
11786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11788
11789 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11790 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11791
11792 { } /* end */
11793};
11794
Kailang Yangbdd148a2007-05-08 15:19:08 +020011795static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11796 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11797 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11798 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11799
11800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11801
11802 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11805
11806 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11809
11810 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11811 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11812
11813 { } /* end */
11814};
11815
Kailang Yang272a5272007-05-14 11:00:38 +020011816/* Pin assignment: Front=0x14, HP = 0x15,
11817 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11818 */
11819static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11820 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11821 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11822 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11823 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11824 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11826 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11827 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11828 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11829 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011830 { } /* end */
11831};
11832
Kailang Yangd1a991a2007-08-15 16:21:59 +020011833/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11834 * Front Mic=0x18, ATAPI Mic = 0x19,
11835 */
11836static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11838 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11840 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11843 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11844 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11845
11846 { } /* end */
11847};
11848
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011849/*
11850 * generic initialization of ADC, input mixers and output mixers
11851 */
11852static struct hda_verb alc861vd_volume_init_verbs[] = {
11853 /*
11854 * Unmute ADC0 and set the default input to mic-in
11855 */
11856 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11858
11859 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11860 * the analog-loopback mixer widget
11861 */
11862 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011868
11869 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011874
11875 /*
11876 * Set up output mixers (0x02 - 0x05)
11877 */
11878 /* set vol=0 to output mixers */
11879 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11880 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11881 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11882 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11883
11884 /* set up input amps for analog loopback */
11885 /* Amp Indices: DAC = 0, mixer = 1 */
11886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11892 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11894
11895 { }
11896};
11897
11898/*
11899 * 3-stack pin configuration:
11900 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11901 */
11902static struct hda_verb alc861vd_3stack_init_verbs[] = {
11903 /*
11904 * Set pin mode and muting
11905 */
11906 /* set front pin widgets 0x14 for output */
11907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11909 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11910
11911 /* Mic (rear) pin: input vref at 80% */
11912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11914 /* Front Mic pin: input vref at 80% */
11915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11917 /* Line In pin: input */
11918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11920 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11923 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11924 /* CD pin widget for input */
11925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11926
11927 { }
11928};
11929
11930/*
11931 * 6-stack pin configuration:
11932 */
11933static struct hda_verb alc861vd_6stack_init_verbs[] = {
11934 /*
11935 * Set pin mode and muting
11936 */
11937 /* set front pin widgets 0x14 for output */
11938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11939 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11940 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11941
11942 /* Rear Pin: output 1 (0x0d) */
11943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11946 /* CLFE Pin: output 2 (0x0e) */
11947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11949 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11950 /* Side Pin: output 3 (0x0f) */
11951 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11953 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11954
11955 /* Mic (rear) pin: input vref at 80% */
11956 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11958 /* Front Mic pin: input vref at 80% */
11959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11961 /* Line In pin: input */
11962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11964 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11967 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11968 /* CD pin widget for input */
11969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11970
11971 { }
11972};
11973
Kailang Yangbdd148a2007-05-08 15:19:08 +020011974static struct hda_verb alc861vd_eapd_verbs[] = {
11975 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11976 { }
11977};
11978
11979static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
11980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11983 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11984 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11985 {}
11986};
11987
11988/* toggle speaker-output according to the hp-jack state */
11989static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
11990{
11991 unsigned int present;
11992 unsigned char bits;
11993
11994 present = snd_hda_codec_read(codec, 0x1b, 0,
11995 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011996 bits = present ? HDA_AMP_MUTE : 0;
11997 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11998 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011999}
12000
12001static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12002{
12003 unsigned int present;
12004 unsigned char bits;
12005
12006 present = snd_hda_codec_read(codec, 0x18, 0,
12007 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012008 bits = present ? HDA_AMP_MUTE : 0;
12009 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12010 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012011}
12012
12013static void alc861vd_lenovo_automute(struct hda_codec *codec)
12014{
12015 alc861vd_lenovo_hp_automute(codec);
12016 alc861vd_lenovo_mic_automute(codec);
12017}
12018
12019static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12020 unsigned int res)
12021{
12022 switch (res >> 26) {
12023 case ALC880_HP_EVENT:
12024 alc861vd_lenovo_hp_automute(codec);
12025 break;
12026 case ALC880_MIC_EVENT:
12027 alc861vd_lenovo_mic_automute(codec);
12028 break;
12029 }
12030}
12031
Kailang Yang272a5272007-05-14 11:00:38 +020012032static struct hda_verb alc861vd_dallas_verbs[] = {
12033 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12035 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12037
12038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12044 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12046
12047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12052 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12053 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12055
12056 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12062 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12063 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12064
12065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12069
12070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12072 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12073
12074 { } /* end */
12075};
12076
12077/* toggle speaker-output according to the hp-jack state */
12078static void alc861vd_dallas_automute(struct hda_codec *codec)
12079{
12080 unsigned int present;
12081
12082 present = snd_hda_codec_read(codec, 0x15, 0,
12083 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012084 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12085 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012086}
12087
12088static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12089{
12090 if ((res >> 26) == ALC880_HP_EVENT)
12091 alc861vd_dallas_automute(codec);
12092}
12093
Takashi Iwaicb53c622007-08-10 17:21:45 +020012094#ifdef CONFIG_SND_HDA_POWER_SAVE
12095#define alc861vd_loopbacks alc880_loopbacks
12096#endif
12097
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012098/* pcm configuration: identiacal with ALC880 */
12099#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12100#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12101#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12102#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12103
12104/*
12105 * configuration and preset
12106 */
12107static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12108 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012109 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012110 [ALC861VD_3ST] = "3stack",
12111 [ALC861VD_3ST_DIG] = "3stack-digout",
12112 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012113 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012114 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012115 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012116 [ALC861VD_AUTO] = "auto",
12117};
12118
12119static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012120 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12121 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012122 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012123 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012124 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012125 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012126 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012127 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012128 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012129 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012130 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012131 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12132 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012133 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012134 {}
12135};
12136
12137static struct alc_config_preset alc861vd_presets[] = {
12138 [ALC660VD_3ST] = {
12139 .mixers = { alc861vd_3st_mixer },
12140 .init_verbs = { alc861vd_volume_init_verbs,
12141 alc861vd_3stack_init_verbs },
12142 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12143 .dac_nids = alc660vd_dac_nids,
12144 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12145 .adc_nids = alc861vd_adc_nids,
12146 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12147 .channel_mode = alc861vd_3stack_2ch_modes,
12148 .input_mux = &alc861vd_capture_source,
12149 },
Mike Crash6963f842007-06-25 12:12:51 +020012150 [ALC660VD_3ST_DIG] = {
12151 .mixers = { alc861vd_3st_mixer },
12152 .init_verbs = { alc861vd_volume_init_verbs,
12153 alc861vd_3stack_init_verbs },
12154 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12155 .dac_nids = alc660vd_dac_nids,
12156 .dig_out_nid = ALC861VD_DIGOUT_NID,
12157 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12158 .adc_nids = alc861vd_adc_nids,
12159 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12160 .channel_mode = alc861vd_3stack_2ch_modes,
12161 .input_mux = &alc861vd_capture_source,
12162 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012163 [ALC861VD_3ST] = {
12164 .mixers = { alc861vd_3st_mixer },
12165 .init_verbs = { alc861vd_volume_init_verbs,
12166 alc861vd_3stack_init_verbs },
12167 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12168 .dac_nids = alc861vd_dac_nids,
12169 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12170 .channel_mode = alc861vd_3stack_2ch_modes,
12171 .input_mux = &alc861vd_capture_source,
12172 },
12173 [ALC861VD_3ST_DIG] = {
12174 .mixers = { alc861vd_3st_mixer },
12175 .init_verbs = { alc861vd_volume_init_verbs,
12176 alc861vd_3stack_init_verbs },
12177 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12178 .dac_nids = alc861vd_dac_nids,
12179 .dig_out_nid = ALC861VD_DIGOUT_NID,
12180 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12181 .channel_mode = alc861vd_3stack_2ch_modes,
12182 .input_mux = &alc861vd_capture_source,
12183 },
12184 [ALC861VD_6ST_DIG] = {
12185 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12186 .init_verbs = { alc861vd_volume_init_verbs,
12187 alc861vd_6stack_init_verbs },
12188 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12189 .dac_nids = alc861vd_dac_nids,
12190 .dig_out_nid = ALC861VD_DIGOUT_NID,
12191 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12192 .channel_mode = alc861vd_6stack_modes,
12193 .input_mux = &alc861vd_capture_source,
12194 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012195 [ALC861VD_LENOVO] = {
12196 .mixers = { alc861vd_lenovo_mixer },
12197 .init_verbs = { alc861vd_volume_init_verbs,
12198 alc861vd_3stack_init_verbs,
12199 alc861vd_eapd_verbs,
12200 alc861vd_lenovo_unsol_verbs },
12201 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12202 .dac_nids = alc660vd_dac_nids,
12203 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12204 .adc_nids = alc861vd_adc_nids,
12205 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12206 .channel_mode = alc861vd_3stack_2ch_modes,
12207 .input_mux = &alc861vd_capture_source,
12208 .unsol_event = alc861vd_lenovo_unsol_event,
12209 .init_hook = alc861vd_lenovo_automute,
12210 },
Kailang Yang272a5272007-05-14 11:00:38 +020012211 [ALC861VD_DALLAS] = {
12212 .mixers = { alc861vd_dallas_mixer },
12213 .init_verbs = { alc861vd_dallas_verbs },
12214 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12215 .dac_nids = alc861vd_dac_nids,
12216 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12217 .adc_nids = alc861vd_adc_nids,
12218 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12219 .channel_mode = alc861vd_3stack_2ch_modes,
12220 .input_mux = &alc861vd_dallas_capture_source,
12221 .unsol_event = alc861vd_dallas_unsol_event,
12222 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012223 },
12224 [ALC861VD_HP] = {
12225 .mixers = { alc861vd_hp_mixer },
12226 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12227 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12228 .dac_nids = alc861vd_dac_nids,
12229 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12230 .dig_out_nid = ALC861VD_DIGOUT_NID,
12231 .adc_nids = alc861vd_adc_nids,
12232 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12233 .channel_mode = alc861vd_3stack_2ch_modes,
12234 .input_mux = &alc861vd_hp_capture_source,
12235 .unsol_event = alc861vd_dallas_unsol_event,
12236 .init_hook = alc861vd_dallas_automute,
12237 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012238};
12239
12240/*
12241 * BIOS auto configuration
12242 */
12243static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12244 hda_nid_t nid, int pin_type, int dac_idx)
12245{
12246 /* set as output */
12247 snd_hda_codec_write(codec, nid, 0,
12248 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12249 snd_hda_codec_write(codec, nid, 0,
12250 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12251}
12252
12253static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12254{
12255 struct alc_spec *spec = codec->spec;
12256 int i;
12257
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012258 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012259 for (i = 0; i <= HDA_SIDE; i++) {
12260 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012261 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012262 if (nid)
12263 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012264 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012265 }
12266}
12267
12268
12269static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12270{
12271 struct alc_spec *spec = codec->spec;
12272 hda_nid_t pin;
12273
12274 pin = spec->autocfg.hp_pins[0];
12275 if (pin) /* connect to front and use dac 0 */
12276 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12277}
12278
12279#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12280#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12281
12282static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12283{
12284 struct alc_spec *spec = codec->spec;
12285 int i;
12286
12287 for (i = 0; i < AUTO_PIN_LAST; i++) {
12288 hda_nid_t nid = spec->autocfg.input_pins[i];
12289 if (alc861vd_is_input_pin(nid)) {
12290 snd_hda_codec_write(codec, nid, 0,
12291 AC_VERB_SET_PIN_WIDGET_CONTROL,
12292 i <= AUTO_PIN_FRONT_MIC ?
12293 PIN_VREF80 : PIN_IN);
12294 if (nid != ALC861VD_PIN_CD_NID)
12295 snd_hda_codec_write(codec, nid, 0,
12296 AC_VERB_SET_AMP_GAIN_MUTE,
12297 AMP_OUT_MUTE);
12298 }
12299 }
12300}
12301
12302#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12303#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12304
12305/* add playback controls from the parsed DAC table */
12306/* Based on ALC880 version. But ALC861VD has separate,
12307 * different NIDs for mute/unmute switch and volume control */
12308static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12309 const struct auto_pin_cfg *cfg)
12310{
12311 char name[32];
12312 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12313 hda_nid_t nid_v, nid_s;
12314 int i, err;
12315
12316 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012317 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012318 continue;
12319 nid_v = alc861vd_idx_to_mixer_vol(
12320 alc880_dac_to_idx(
12321 spec->multiout.dac_nids[i]));
12322 nid_s = alc861vd_idx_to_mixer_switch(
12323 alc880_dac_to_idx(
12324 spec->multiout.dac_nids[i]));
12325
12326 if (i == 2) {
12327 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012328 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12329 "Center Playback Volume",
12330 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12331 HDA_OUTPUT));
12332 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012333 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012334 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12335 "LFE Playback Volume",
12336 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12337 HDA_OUTPUT));
12338 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012339 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012340 err = add_control(spec, ALC_CTL_BIND_MUTE,
12341 "Center Playback Switch",
12342 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12343 HDA_INPUT));
12344 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012346 err = add_control(spec, ALC_CTL_BIND_MUTE,
12347 "LFE Playback Switch",
12348 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12349 HDA_INPUT));
12350 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012351 return err;
12352 } else {
12353 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012354 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12355 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12356 HDA_OUTPUT));
12357 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012358 return err;
12359 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012360 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012361 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012362 HDA_INPUT));
12363 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012364 return err;
12365 }
12366 }
12367 return 0;
12368}
12369
12370/* add playback controls for speaker and HP outputs */
12371/* Based on ALC880 version. But ALC861VD has separate,
12372 * different NIDs for mute/unmute switch and volume control */
12373static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12374 hda_nid_t pin, const char *pfx)
12375{
12376 hda_nid_t nid_v, nid_s;
12377 int err;
12378 char name[32];
12379
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012380 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012381 return 0;
12382
12383 if (alc880_is_fixed_pin(pin)) {
12384 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12385 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012386 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012387 spec->multiout.hp_nid = nid_v;
12388 else
12389 spec->multiout.extra_out_nid[0] = nid_v;
12390 /* control HP volume/switch on the output mixer amp */
12391 nid_v = alc861vd_idx_to_mixer_vol(
12392 alc880_fixed_pin_idx(pin));
12393 nid_s = alc861vd_idx_to_mixer_switch(
12394 alc880_fixed_pin_idx(pin));
12395
12396 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012397 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12398 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12399 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012400 return err;
12401 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012402 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12403 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12404 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012405 return err;
12406 } else if (alc880_is_multi_pin(pin)) {
12407 /* set manual connection */
12408 /* we have only a switch on HP-out PIN */
12409 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012410 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12411 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12412 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012413 return err;
12414 }
12415 return 0;
12416}
12417
12418/* parse the BIOS configuration and set up the alc_spec
12419 * return 1 if successful, 0 if the proper config is not found,
12420 * or a negative error code
12421 * Based on ALC880 version - had to change it to override
12422 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12423static int alc861vd_parse_auto_config(struct hda_codec *codec)
12424{
12425 struct alc_spec *spec = codec->spec;
12426 int err;
12427 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12428
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012429 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12430 alc861vd_ignore);
12431 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012432 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012433 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012434 return 0; /* can't find valid BIOS pin config */
12435
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012436 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12437 if (err < 0)
12438 return err;
12439 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12440 if (err < 0)
12441 return err;
12442 err = alc861vd_auto_create_extra_out(spec,
12443 spec->autocfg.speaker_pins[0],
12444 "Speaker");
12445 if (err < 0)
12446 return err;
12447 err = alc861vd_auto_create_extra_out(spec,
12448 spec->autocfg.hp_pins[0],
12449 "Headphone");
12450 if (err < 0)
12451 return err;
12452 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12453 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012454 return err;
12455
12456 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12457
12458 if (spec->autocfg.dig_out_pin)
12459 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12460
12461 if (spec->kctl_alloc)
12462 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12463
12464 spec->init_verbs[spec->num_init_verbs++]
12465 = alc861vd_volume_init_verbs;
12466
12467 spec->num_mux_defs = 1;
12468 spec->input_mux = &spec->private_imux;
12469
Takashi Iwai776e1842007-08-29 15:07:11 +020012470 err = alc_auto_add_mic_boost(codec);
12471 if (err < 0)
12472 return err;
12473
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012474 return 1;
12475}
12476
12477/* additional initialization for auto-configuration model */
12478static void alc861vd_auto_init(struct hda_codec *codec)
12479{
12480 alc861vd_auto_init_multi_out(codec);
12481 alc861vd_auto_init_hp_out(codec);
12482 alc861vd_auto_init_analog_input(codec);
12483}
12484
12485static int patch_alc861vd(struct hda_codec *codec)
12486{
12487 struct alc_spec *spec;
12488 int err, board_config;
12489
12490 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12491 if (spec == NULL)
12492 return -ENOMEM;
12493
12494 codec->spec = spec;
12495
12496 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12497 alc861vd_models,
12498 alc861vd_cfg_tbl);
12499
12500 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12501 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12502 "ALC861VD, trying auto-probe from BIOS...\n");
12503 board_config = ALC861VD_AUTO;
12504 }
12505
12506 if (board_config == ALC861VD_AUTO) {
12507 /* automatic parse from the BIOS config */
12508 err = alc861vd_parse_auto_config(codec);
12509 if (err < 0) {
12510 alc_free(codec);
12511 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012512 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012513 printk(KERN_INFO
12514 "hda_codec: Cannot set up configuration "
12515 "from BIOS. Using base mode...\n");
12516 board_config = ALC861VD_3ST;
12517 }
12518 }
12519
12520 if (board_config != ALC861VD_AUTO)
12521 setup_preset(spec, &alc861vd_presets[board_config]);
12522
12523 spec->stream_name_analog = "ALC861VD Analog";
12524 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12525 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12526
12527 spec->stream_name_digital = "ALC861VD Digital";
12528 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12529 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12530
12531 spec->adc_nids = alc861vd_adc_nids;
12532 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12533
12534 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12535 spec->num_mixers++;
12536
Takashi Iwai2134ea42008-01-10 16:53:55 +010012537 spec->vmaster_nid = 0x02;
12538
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012539 codec->patch_ops = alc_patch_ops;
12540
12541 if (board_config == ALC861VD_AUTO)
12542 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012543#ifdef CONFIG_SND_HDA_POWER_SAVE
12544 if (!spec->loopback.amplist)
12545 spec->loopback.amplist = alc861vd_loopbacks;
12546#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012547
12548 return 0;
12549}
12550
12551/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012552 * ALC662 support
12553 *
12554 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12555 * configuration. Each pin widget can choose any input DACs and a mixer.
12556 * Each ADC is connected from a mixer of all inputs. This makes possible
12557 * 6-channel independent captures.
12558 *
12559 * In addition, an independent DAC for the multi-playback (not used in this
12560 * driver yet).
12561 */
12562#define ALC662_DIGOUT_NID 0x06
12563#define ALC662_DIGIN_NID 0x0a
12564
12565static hda_nid_t alc662_dac_nids[4] = {
12566 /* front, rear, clfe, rear_surr */
12567 0x02, 0x03, 0x04
12568};
12569
12570static hda_nid_t alc662_adc_nids[1] = {
12571 /* ADC1-2 */
12572 0x09,
12573};
12574/* input MUX */
12575/* FIXME: should be a matrix-type input source selection */
12576
12577static struct hda_input_mux alc662_capture_source = {
12578 .num_items = 4,
12579 .items = {
12580 { "Mic", 0x0 },
12581 { "Front Mic", 0x1 },
12582 { "Line", 0x2 },
12583 { "CD", 0x4 },
12584 },
12585};
12586
12587static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12588 .num_items = 2,
12589 .items = {
12590 { "Mic", 0x1 },
12591 { "Line", 0x2 },
12592 },
12593};
Kailang Yang291702f2007-10-16 14:28:03 +020012594
12595static struct hda_input_mux alc662_eeepc_capture_source = {
12596 .num_items = 2,
12597 .items = {
12598 { "i-Mic", 0x1 },
12599 { "e-Mic", 0x0 },
12600 },
12601};
12602
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012603#define alc662_mux_enum_info alc_mux_enum_info
12604#define alc662_mux_enum_get alc_mux_enum_get
12605
12606static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12607 struct snd_ctl_elem_value *ucontrol)
12608{
12609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12610 struct alc_spec *spec = codec->spec;
12611 const struct hda_input_mux *imux = spec->input_mux;
12612 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012613 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012614 hda_nid_t nid = capture_mixers[adc_idx];
12615 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12616 unsigned int i, idx;
12617
12618 idx = ucontrol->value.enumerated.item[0];
12619 if (idx >= imux->num_items)
12620 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012621 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012622 return 0;
12623 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012624 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12625 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12626 imux->items[i].index,
12627 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012628 }
12629 *cur_val = idx;
12630 return 1;
12631}
12632/*
12633 * 2ch mode
12634 */
12635static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12636 { 2, NULL }
12637};
12638
12639/*
12640 * 2ch mode
12641 */
12642static struct hda_verb alc662_3ST_ch2_init[] = {
12643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12645 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12646 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12647 { } /* end */
12648};
12649
12650/*
12651 * 6ch mode
12652 */
12653static struct hda_verb alc662_3ST_ch6_init[] = {
12654 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12655 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12656 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12657 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12658 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12659 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12660 { } /* end */
12661};
12662
12663static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12664 { 2, alc662_3ST_ch2_init },
12665 { 6, alc662_3ST_ch6_init },
12666};
12667
12668/*
12669 * 2ch mode
12670 */
12671static struct hda_verb alc662_sixstack_ch6_init[] = {
12672 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12673 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12674 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12675 { } /* end */
12676};
12677
12678/*
12679 * 6ch mode
12680 */
12681static struct hda_verb alc662_sixstack_ch8_init[] = {
12682 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12683 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12684 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12685 { } /* end */
12686};
12687
12688static struct hda_channel_mode alc662_5stack_modes[2] = {
12689 { 2, alc662_sixstack_ch6_init },
12690 { 6, alc662_sixstack_ch8_init },
12691};
12692
12693/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12694 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12695 */
12696
12697static struct snd_kcontrol_new alc662_base_mixer[] = {
12698 /* output mixer control */
12699 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12700 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12701 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12702 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12703 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12704 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12705 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12706 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12708
12709 /*Input mixer control */
12710 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12711 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12712 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12713 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12714 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12715 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12716 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12717 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012718 { } /* end */
12719};
12720
12721static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12722 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12723 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12725 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12726 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12727 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12728 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12731 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12732 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12733 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12734 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012735 { } /* end */
12736};
12737
12738static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12739 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12740 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12741 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12742 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12743 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12744 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12745 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12746 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12748 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12749 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12751 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12755 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12756 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12757 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012758 { } /* end */
12759};
12760
12761static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12762 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12763 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12764 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12765 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012771 { } /* end */
12772};
12773
Kailang Yang291702f2007-10-16 14:28:03 +020012774static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12775 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12776
12777 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12778 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12779
12780 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12781 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12782 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12783
12784 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12785 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12786 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12787 { } /* end */
12788};
12789
Kailang Yang8c427222008-01-10 13:03:59 +010012790static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12791 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12792 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12794 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12799 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12800 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12805 { } /* end */
12806};
12807
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012808static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12809 {
12810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12811 .name = "Channel Mode",
12812 .info = alc_ch_mode_info,
12813 .get = alc_ch_mode_get,
12814 .put = alc_ch_mode_put,
12815 },
12816 { } /* end */
12817};
12818
12819static struct hda_verb alc662_init_verbs[] = {
12820 /* ADC: mute amp left and right */
12821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12822 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12823 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12824
Takashi Iwaicb53c622007-08-10 17:21:45 +020012825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012830
Kailang Yangb60dd392007-09-20 12:50:29 +020012831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012837
12838 /* Front Pin: output 0 (0x0c) */
12839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12841
12842 /* Rear Pin: output 1 (0x0d) */
12843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12845
12846 /* CLFE Pin: output 2 (0x0e) */
12847 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12849
12850 /* Mic (rear) pin: input vref at 80% */
12851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12853 /* Front Mic pin: input vref at 80% */
12854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12856 /* Line In pin: input */
12857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12859 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12862 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12863 /* CD pin widget for input */
12864 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12865
12866 /* FIXME: use matrix-type input source selection */
12867 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12868 /* Input mixer */
12869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012873
12874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012878 { }
12879};
12880
12881static struct hda_verb alc662_sue_init_verbs[] = {
12882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12883 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012884 {}
12885};
12886
12887static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12888 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12889 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12890 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012891};
12892
Kailang Yang8c427222008-01-10 13:03:59 +010012893/* Set Unsolicited Event*/
12894static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12896 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12897 {}
12898};
12899
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012900/*
12901 * generic initialization of ADC, input mixers and output mixers
12902 */
12903static struct hda_verb alc662_auto_init_verbs[] = {
12904 /*
12905 * Unmute ADC and set the default input to mic-in
12906 */
12907 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12909
12910 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12911 * mixer widget
12912 * Note: PASD motherboards uses the Line In 2 as the input for front
12913 * panel mic (mic 2)
12914 */
12915 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012921
12922 /*
12923 * Set up output mixers (0x0c - 0x0f)
12924 */
12925 /* set vol=0 to output mixers */
12926 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12927 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12928 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12929
12930 /* set up input amps for analog loopback */
12931 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012938
12939
12940 /* FIXME: use matrix-type input source selection */
12941 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12942 /* Input mixer */
12943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012945 { }
12946};
12947
12948/* capture mixer elements */
12949static struct snd_kcontrol_new alc662_capture_mixer[] = {
12950 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12951 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12952 {
12953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12954 /* The multiple "Capture Source" controls confuse alsamixer
12955 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012956 */
12957 /* .name = "Capture Source", */
12958 .name = "Input Source",
12959 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012960 .info = alc662_mux_enum_info,
12961 .get = alc662_mux_enum_get,
12962 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012963 },
12964 { } /* end */
12965};
12966
12967static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
12968{
12969 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012970 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012971
12972 present = snd_hda_codec_read(codec, 0x14, 0,
12973 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012974 bits = present ? HDA_AMP_MUTE : 0;
12975 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12976 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012977}
12978
12979static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
12980{
12981 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012982 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012983
12984 present = snd_hda_codec_read(codec, 0x1b, 0,
12985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012986 bits = present ? HDA_AMP_MUTE : 0;
12987 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12988 HDA_AMP_MUTE, bits);
12989 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12990 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012991}
12992
12993static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
12994 unsigned int res)
12995{
12996 if ((res >> 26) == ALC880_HP_EVENT)
12997 alc662_lenovo_101e_all_automute(codec);
12998 if ((res >> 26) == ALC880_FRONT_EVENT)
12999 alc662_lenovo_101e_ispeaker_automute(codec);
13000}
13001
Kailang Yang291702f2007-10-16 14:28:03 +020013002static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13003{
13004 unsigned int present;
13005
13006 present = snd_hda_codec_read(codec, 0x18, 0,
13007 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13008 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13009 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13010 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13011 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13012 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13013 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13014 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13015 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13016}
13017
13018/* unsolicited event for HP jack sensing */
13019static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13020 unsigned int res)
13021{
13022 if ((res >> 26) == ALC880_HP_EVENT)
13023 alc262_hippo1_automute( codec );
13024
13025 if ((res >> 26) == ALC880_MIC_EVENT)
13026 alc662_eeepc_mic_automute(codec);
13027}
13028
13029static void alc662_eeepc_inithook(struct hda_codec *codec)
13030{
13031 alc262_hippo1_automute( codec );
13032 alc662_eeepc_mic_automute(codec);
13033}
13034
Kailang Yang8c427222008-01-10 13:03:59 +010013035static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13036{
13037 unsigned int mute;
13038 unsigned int present;
13039
13040 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13041 present = snd_hda_codec_read(codec, 0x14, 0,
13042 AC_VERB_GET_PIN_SENSE, 0);
13043 present = (present & 0x80000000) != 0;
13044 if (present) {
13045 /* mute internal speaker */
13046 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13047 HDA_AMP_MUTE, HDA_AMP_MUTE);
13048 } else {
13049 /* unmute internal speaker if necessary */
13050 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13051 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13052 HDA_AMP_MUTE, mute);
13053 }
13054}
13055
13056/* unsolicited event for HP jack sensing */
13057static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13058 unsigned int res)
13059{
13060 if ((res >> 26) == ALC880_HP_EVENT)
13061 alc662_eeepc_ep20_automute(codec);
13062}
13063
13064static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13065{
13066 alc662_eeepc_ep20_automute(codec);
13067}
13068
Takashi Iwaicb53c622007-08-10 17:21:45 +020013069#ifdef CONFIG_SND_HDA_POWER_SAVE
13070#define alc662_loopbacks alc880_loopbacks
13071#endif
13072
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013073
13074/* pcm configuration: identiacal with ALC880 */
13075#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13076#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13077#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13078#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13079
13080/*
13081 * configuration and preset
13082 */
13083static const char *alc662_models[ALC662_MODEL_LAST] = {
13084 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13085 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13086 [ALC662_3ST_6ch] = "3stack-6ch",
13087 [ALC662_5ST_DIG] = "6stack-dig",
13088 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013089 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013090 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013091 [ALC662_AUTO] = "auto",
13092};
13093
13094static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013095 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013096 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013097 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013098 {}
13099};
13100
13101static struct alc_config_preset alc662_presets[] = {
13102 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013103 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013104 .init_verbs = { alc662_init_verbs },
13105 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13106 .dac_nids = alc662_dac_nids,
13107 .dig_out_nid = ALC662_DIGOUT_NID,
13108 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13109 .adc_nids = alc662_adc_nids,
13110 .dig_in_nid = ALC662_DIGIN_NID,
13111 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13112 .channel_mode = alc662_3ST_2ch_modes,
13113 .input_mux = &alc662_capture_source,
13114 },
13115 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013116 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13117 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013118 .init_verbs = { alc662_init_verbs },
13119 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13120 .dac_nids = alc662_dac_nids,
13121 .dig_out_nid = ALC662_DIGOUT_NID,
13122 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13123 .adc_nids = alc662_adc_nids,
13124 .dig_in_nid = ALC662_DIGIN_NID,
13125 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13126 .channel_mode = alc662_3ST_6ch_modes,
13127 .need_dac_fix = 1,
13128 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013129 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013130 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013131 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13132 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013133 .init_verbs = { alc662_init_verbs },
13134 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13135 .dac_nids = alc662_dac_nids,
13136 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13137 .adc_nids = alc662_adc_nids,
13138 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13139 .channel_mode = alc662_3ST_6ch_modes,
13140 .need_dac_fix = 1,
13141 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013142 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013143 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013144 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13145 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013146 .init_verbs = { alc662_init_verbs },
13147 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13148 .dac_nids = alc662_dac_nids,
13149 .dig_out_nid = ALC662_DIGOUT_NID,
13150 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13151 .adc_nids = alc662_adc_nids,
13152 .dig_in_nid = ALC662_DIGIN_NID,
13153 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13154 .channel_mode = alc662_5stack_modes,
13155 .input_mux = &alc662_capture_source,
13156 },
13157 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013158 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013159 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13160 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13161 .dac_nids = alc662_dac_nids,
13162 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13163 .adc_nids = alc662_adc_nids,
13164 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13165 .channel_mode = alc662_3ST_2ch_modes,
13166 .input_mux = &alc662_lenovo_101e_capture_source,
13167 .unsol_event = alc662_lenovo_101e_unsol_event,
13168 .init_hook = alc662_lenovo_101e_all_automute,
13169 },
Kailang Yang291702f2007-10-16 14:28:03 +020013170 [ALC662_ASUS_EEEPC_P701] = {
13171 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13172 .init_verbs = { alc662_init_verbs,
13173 alc662_eeepc_sue_init_verbs },
13174 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13175 .dac_nids = alc662_dac_nids,
13176 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13177 .adc_nids = alc662_adc_nids,
13178 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13179 .channel_mode = alc662_3ST_2ch_modes,
13180 .input_mux = &alc662_eeepc_capture_source,
13181 .unsol_event = alc662_eeepc_unsol_event,
13182 .init_hook = alc662_eeepc_inithook,
13183 },
Kailang Yang8c427222008-01-10 13:03:59 +010013184 [ALC662_ASUS_EEEPC_EP20] = {
13185 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13186 alc662_chmode_mixer },
13187 .init_verbs = { alc662_init_verbs,
13188 alc662_eeepc_ep20_sue_init_verbs },
13189 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13190 .dac_nids = alc662_dac_nids,
13191 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13192 .adc_nids = alc662_adc_nids,
13193 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13194 .channel_mode = alc662_3ST_6ch_modes,
13195 .input_mux = &alc662_lenovo_101e_capture_source,
13196 .unsol_event = alc662_eeepc_ep20_unsol_event,
13197 .init_hook = alc662_eeepc_ep20_inithook,
13198 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013199
13200};
13201
13202
13203/*
13204 * BIOS auto configuration
13205 */
13206
13207/* add playback controls from the parsed DAC table */
13208static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13209 const struct auto_pin_cfg *cfg)
13210{
13211 char name[32];
13212 static const char *chname[4] = {
13213 "Front", "Surround", NULL /*CLFE*/, "Side"
13214 };
13215 hda_nid_t nid;
13216 int i, err;
13217
13218 for (i = 0; i < cfg->line_outs; i++) {
13219 if (!spec->multiout.dac_nids[i])
13220 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013221 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013222 if (i == 2) {
13223 /* Center/LFE */
13224 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13225 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013226 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13227 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013228 if (err < 0)
13229 return err;
13230 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13231 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013232 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13233 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013234 if (err < 0)
13235 return err;
13236 err = add_control(spec, ALC_CTL_BIND_MUTE,
13237 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013238 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13239 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013240 if (err < 0)
13241 return err;
13242 err = add_control(spec, ALC_CTL_BIND_MUTE,
13243 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013244 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13245 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013246 if (err < 0)
13247 return err;
13248 } else {
13249 sprintf(name, "%s Playback Volume", chname[i]);
13250 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013251 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13252 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013253 if (err < 0)
13254 return err;
13255 sprintf(name, "%s Playback Switch", chname[i]);
13256 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013257 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13258 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013259 if (err < 0)
13260 return err;
13261 }
13262 }
13263 return 0;
13264}
13265
13266/* add playback controls for speaker and HP outputs */
13267static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13268 const char *pfx)
13269{
13270 hda_nid_t nid;
13271 int err;
13272 char name[32];
13273
13274 if (!pin)
13275 return 0;
13276
13277 if (alc880_is_fixed_pin(pin)) {
13278 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13279 /* printk("DAC nid=%x\n",nid); */
13280 /* specify the DAC as the extra output */
13281 if (!spec->multiout.hp_nid)
13282 spec->multiout.hp_nid = nid;
13283 else
13284 spec->multiout.extra_out_nid[0] = nid;
13285 /* control HP volume/switch on the output mixer amp */
13286 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13287 sprintf(name, "%s Playback Volume", pfx);
13288 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13289 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13290 if (err < 0)
13291 return err;
13292 sprintf(name, "%s Playback Switch", pfx);
13293 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13294 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13295 if (err < 0)
13296 return err;
13297 } else if (alc880_is_multi_pin(pin)) {
13298 /* set manual connection */
13299 /* we have only a switch on HP-out PIN */
13300 sprintf(name, "%s Playback Switch", pfx);
13301 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13302 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13303 if (err < 0)
13304 return err;
13305 }
13306 return 0;
13307}
13308
13309/* create playback/capture controls for input pins */
13310static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13311 const struct auto_pin_cfg *cfg)
13312{
13313 struct hda_input_mux *imux = &spec->private_imux;
13314 int i, err, idx;
13315
13316 for (i = 0; i < AUTO_PIN_LAST; i++) {
13317 if (alc880_is_input_pin(cfg->input_pins[i])) {
13318 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13319 err = new_analog_input(spec, cfg->input_pins[i],
13320 auto_pin_cfg_labels[i],
13321 idx, 0x0b);
13322 if (err < 0)
13323 return err;
13324 imux->items[imux->num_items].label =
13325 auto_pin_cfg_labels[i];
13326 imux->items[imux->num_items].index =
13327 alc880_input_pin_idx(cfg->input_pins[i]);
13328 imux->num_items++;
13329 }
13330 }
13331 return 0;
13332}
13333
13334static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13335 hda_nid_t nid, int pin_type,
13336 int dac_idx)
13337{
13338 /* set as output */
13339 snd_hda_codec_write(codec, nid, 0,
13340 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13341 snd_hda_codec_write(codec, nid, 0,
13342 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13343 /* need the manual connection? */
13344 if (alc880_is_multi_pin(nid)) {
13345 struct alc_spec *spec = codec->spec;
13346 int idx = alc880_multi_pin_idx(nid);
13347 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13348 AC_VERB_SET_CONNECT_SEL,
13349 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13350 }
13351}
13352
13353static void alc662_auto_init_multi_out(struct hda_codec *codec)
13354{
13355 struct alc_spec *spec = codec->spec;
13356 int i;
13357
Kailang Yang8c427222008-01-10 13:03:59 +010013358 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013359 for (i = 0; i <= HDA_SIDE; i++) {
13360 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013361 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013362 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013363 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013364 i);
13365 }
13366}
13367
13368static void alc662_auto_init_hp_out(struct hda_codec *codec)
13369{
13370 struct alc_spec *spec = codec->spec;
13371 hda_nid_t pin;
13372
13373 pin = spec->autocfg.hp_pins[0];
13374 if (pin) /* connect to front */
13375 /* use dac 0 */
13376 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13377}
13378
13379#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13380#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13381
13382static void alc662_auto_init_analog_input(struct hda_codec *codec)
13383{
13384 struct alc_spec *spec = codec->spec;
13385 int i;
13386
13387 for (i = 0; i < AUTO_PIN_LAST; i++) {
13388 hda_nid_t nid = spec->autocfg.input_pins[i];
13389 if (alc662_is_input_pin(nid)) {
13390 snd_hda_codec_write(codec, nid, 0,
13391 AC_VERB_SET_PIN_WIDGET_CONTROL,
13392 (i <= AUTO_PIN_FRONT_MIC ?
13393 PIN_VREF80 : PIN_IN));
13394 if (nid != ALC662_PIN_CD_NID)
13395 snd_hda_codec_write(codec, nid, 0,
13396 AC_VERB_SET_AMP_GAIN_MUTE,
13397 AMP_OUT_MUTE);
13398 }
13399 }
13400}
13401
13402static int alc662_parse_auto_config(struct hda_codec *codec)
13403{
13404 struct alc_spec *spec = codec->spec;
13405 int err;
13406 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13407
13408 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13409 alc662_ignore);
13410 if (err < 0)
13411 return err;
13412 if (!spec->autocfg.line_outs)
13413 return 0; /* can't find valid BIOS pin config */
13414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013415 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13416 if (err < 0)
13417 return err;
13418 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13419 if (err < 0)
13420 return err;
13421 err = alc662_auto_create_extra_out(spec,
13422 spec->autocfg.speaker_pins[0],
13423 "Speaker");
13424 if (err < 0)
13425 return err;
13426 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13427 "Headphone");
13428 if (err < 0)
13429 return err;
13430 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13431 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013432 return err;
13433
13434 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13435
13436 if (spec->autocfg.dig_out_pin)
13437 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13438
13439 if (spec->kctl_alloc)
13440 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13441
13442 spec->num_mux_defs = 1;
13443 spec->input_mux = &spec->private_imux;
13444
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013445 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013446 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13447 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013448 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013449}
13450
13451/* additional initialization for auto-configuration model */
13452static void alc662_auto_init(struct hda_codec *codec)
13453{
13454 alc662_auto_init_multi_out(codec);
13455 alc662_auto_init_hp_out(codec);
13456 alc662_auto_init_analog_input(codec);
13457}
13458
13459static int patch_alc662(struct hda_codec *codec)
13460{
13461 struct alc_spec *spec;
13462 int err, board_config;
13463
13464 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13465 if (!spec)
13466 return -ENOMEM;
13467
13468 codec->spec = spec;
13469
13470 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13471 alc662_models,
13472 alc662_cfg_tbl);
13473 if (board_config < 0) {
13474 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13475 "trying auto-probe from BIOS...\n");
13476 board_config = ALC662_AUTO;
13477 }
13478
13479 if (board_config == ALC662_AUTO) {
13480 /* automatic parse from the BIOS config */
13481 err = alc662_parse_auto_config(codec);
13482 if (err < 0) {
13483 alc_free(codec);
13484 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013485 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013486 printk(KERN_INFO
13487 "hda_codec: Cannot set up configuration "
13488 "from BIOS. Using base mode...\n");
13489 board_config = ALC662_3ST_2ch_DIG;
13490 }
13491 }
13492
13493 if (board_config != ALC662_AUTO)
13494 setup_preset(spec, &alc662_presets[board_config]);
13495
13496 spec->stream_name_analog = "ALC662 Analog";
13497 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13498 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13499
13500 spec->stream_name_digital = "ALC662 Digital";
13501 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13502 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13503
13504 if (!spec->adc_nids && spec->input_mux) {
13505 spec->adc_nids = alc662_adc_nids;
13506 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13507 }
13508
Takashi Iwai2134ea42008-01-10 16:53:55 +010013509 spec->vmaster_nid = 0x02;
13510
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013511 codec->patch_ops = alc_patch_ops;
13512 if (board_config == ALC662_AUTO)
13513 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013514#ifdef CONFIG_SND_HDA_POWER_SAVE
13515 if (!spec->loopback.amplist)
13516 spec->loopback.amplist = alc662_loopbacks;
13517#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013518
13519 return 0;
13520}
13521
13522/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013523 * patch entries
13524 */
13525struct hda_codec_preset snd_hda_preset_realtek[] = {
13526 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013527 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013528 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013529 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013530 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013531 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013532 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013533 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13534 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13535 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013536 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13537 .patch = patch_alc883 },
13538 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13539 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013540 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013541 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013542 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013543 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013544 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013545 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013546 {} /* terminator */
13547};