blob: 4df4cb9ef582d09b33bcd91ffb89125209cba062 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020062#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010065 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020066 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010075 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020076 ALC260_WILL,
77 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010078#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020082 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Kailang Yangdf694da2005-12-05 19:42:22 +010085/* ALC262 models */
86enum {
87 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020088 ALC262_HIPPO,
89 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010090 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020091 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010092 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010094 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010095 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020096 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020097 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020098 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +020099 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
Kailang Yanga361d842007-06-05 12:30:55 +0200104/* ALC268 models */
105enum {
106 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200107 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200108 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100109 ALC268_DELL,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115};
116
Kailang Yangf6a92242007-12-13 16:52:54 +0100117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
Kailang Yangdf694da2005-12-05 19:42:22 +0100124/* ALC861 models */
125enum {
126 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200127 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200130 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200131 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200132 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100133 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136};
137
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100138/* ALC861-VD models */
139enum {
140 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200141 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200145 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200146 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200147 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150};
151
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200152/* ALC662 models */
153enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200159 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100160 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163};
164
Kailang Yangdf694da2005-12-05 19:42:22 +0100165/* ALC882 models */
166enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200169 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200170 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200173 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100174 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200175 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200176 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200177 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 ALC882_MODEL_LAST,
179};
180
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200181/* ALC883 models */
182enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200189 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200190 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200191 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200192 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100193 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100200 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100201 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204};
205
Kailang Yangdf694da2005-12-05 19:42:22 +0100206/* for GPIO Poll */
207#define GPIO_MASK 0x03
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209struct alc_spec {
210 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 unsigned int num_mixers;
213
Kailang Yangdf694da2005-12-05 19:42:22 +0100214 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215 * don't forget NULL
216 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200217 */
218 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Takashi Iwai16ded522005-06-10 19:58:24 +0200220 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200226 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
229
230 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
234 */
Takashi Iwai63300792008-01-24 15:31:36 +0100235 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
242 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200243 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
246
247 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100248 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200250 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200254
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100258 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200259 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100261
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
265
Takashi Iwai834be882006-03-01 14:16:17 +0100266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200269
Takashi Iwai2134ea42008-01-10 16:53:55 +0100270 /* for virtual master */
271 hda_nid_t vmaster_nid;
272 u32 vmaster_tlv[4];
Takashi Iwaicb53c622007-08-10 17:21:45 +0200273#ifdef CONFIG_SND_HDA_POWER_SAVE
274 struct hda_loopback_check loopback;
275#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100276};
277
278/*
279 * configuration template - to be copied to the spec instance
280 */
281struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282 struct snd_kcontrol_new *mixers[5]; /* should be identical size
283 * with spec
284 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100285 const struct hda_verb *init_verbs[5];
286 unsigned int num_dacs;
287 hda_nid_t *dac_nids;
288 hda_nid_t dig_out_nid; /* optional */
289 hda_nid_t hp_nid; /* optional */
290 unsigned int num_adc_nids;
291 hda_nid_t *adc_nids;
292 hda_nid_t dig_in_nid;
293 unsigned int num_channel_mode;
294 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200295 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200296 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100297 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100298 void (*unsol_event)(struct hda_codec *, unsigned int);
299 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200300#ifdef CONFIG_SND_HDA_POWER_SAVE
301 struct hda_amp_list *loopbacks;
302#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303};
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306/*
307 * input MUX handling
308 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200309static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311{
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200314 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
315 if (mux_idx >= spec->num_mux_defs)
316 mux_idx = 0;
317 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200320static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
325 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
326
327 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
328 return 0;
329}
330
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200331static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
335 struct alc_spec *spec = codec->spec;
336 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200337 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
338 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 spec->adc_nids[adc_idx],
340 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344/*
345 * channel mode setting
346 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200347static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
351 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100352 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
353 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354}
355
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200356static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358{
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100361 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362 spec->num_channel_mode,
363 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200371 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
372 spec->num_channel_mode,
373 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200374 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200375 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
376 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380 * Control the mode of pin widget settings via the mixer. "pc" is used
381 * instead of "%" to avoid consequences of accidently treating the % as
382 * being part of a format specifier. Maximum allowed length of a value is
383 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100384 *
385 * Note: some retasking pin complexes seem to ignore requests for input
386 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
387 * are requested. Therefore order this list so that this behaviour will not
388 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
390 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200391 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100393 "Mic 50pc bias", "Mic 80pc bias",
394 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100395};
396static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100397 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398};
399/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200400 * in the pin being assumed to be exclusively an input or an output pin. In
401 * addition, "input" pins may or may not process the mic bias option
402 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
403 * accept requests for bias as of chip versions up to March 2006) and/or
404 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200406#define ALC_PIN_DIR_IN 0x00
407#define ALC_PIN_DIR_OUT 0x01
408#define ALC_PIN_DIR_INOUT 0x02
409#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
410#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200412/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 * For each direction the minimum and maximum values are given.
414 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200415static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 { 0, 2 }, /* ALC_PIN_DIR_IN */
417 { 3, 4 }, /* ALC_PIN_DIR_OUT */
418 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200419 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
420 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421};
422#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
423#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
424#define alc_pin_mode_n_items(_dir) \
425 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200429{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100430 unsigned int item_num = uinfo->value.enumerated.item;
431 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
432
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200434 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
436
437 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
438 item_num = alc_pin_mode_min(dir);
439 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200440 return 0;
441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200445{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200450 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200451 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
452 AC_VERB_GET_PIN_WIDGET_CONTROL,
453 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200454
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100455 /* Find enumerated value for current pinctl setting */
456 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100458 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 return 0;
461}
462
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465{
466 signed int change;
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_PIN_WIDGET_CONTROL,
473 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200475 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 val = alc_pin_mode_min(dir);
477
478 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100479 if (change) {
480 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200481 snd_hda_codec_write_cache(codec, nid, 0,
482 AC_VERB_SET_PIN_WIDGET_CONTROL,
483 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100484
485 /* Also enable the retasking pin's input/output as required
486 * for the requested pin mode. Enum values of 2 or less are
487 * input modes.
488 *
489 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200490 * reduces noise slightly (particularly on input) so we'll
491 * do it. However, having both input and output buffers
492 * enabled simultaneously doesn't seem to be problematic if
493 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100494 */
495 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200496 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
497 HDA_AMP_MUTE, HDA_AMP_MUTE);
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
499 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100500 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200501 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
502 HDA_AMP_MUTE, HDA_AMP_MUTE);
503 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
504 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100505 }
506 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200507 return change;
508}
509
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 .info = alc_pin_mode_info, \
513 .get = alc_pin_mode_get, \
514 .put = alc_pin_mode_put, \
515 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100516
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100517/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
518 * together using a mask with more than one bit set. This control is
519 * currently used only by the ALC260 test model. At this stage they are not
520 * needed for any "production" models.
521 */
522#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200523#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 hda_nid_t nid = kcontrol->private_value & 0xffff;
530 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
531 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532 unsigned int val = snd_hda_codec_read(codec, nid, 0,
533 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100534
535 *valp = (val & mask) != 0;
536 return 0;
537}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100540{
541 signed int change;
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 hda_nid_t nid = kcontrol->private_value & 0xffff;
544 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
545 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
547 AC_VERB_GET_GPIO_DATA,
548 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100549
550 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
552 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100553 gpio_data &= ~mask;
554 else
555 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200556 snd_hda_codec_write_cache(codec, nid, 0,
557 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100558
559 return change;
560}
561#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
563 .info = alc_gpio_data_info, \
564 .get = alc_gpio_data_get, \
565 .put = alc_gpio_data_put, \
566 .private_value = nid | (mask<<16) }
567#endif /* CONFIG_SND_DEBUG */
568
Jonathan Woithe92621f12006-02-28 11:47:47 +0100569/* A switch control to allow the enabling of the digital IO pins on the
570 * ALC260. This is incredibly simplistic; the intention of this control is
571 * to provide something in the test model allowing digital outputs to be
572 * identified if present. If models are found which can utilise these
573 * outputs a more complete mixer control can be devised for those models if
574 * necessary.
575 */
576#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200577#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200578
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100581{
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
585 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100587 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100588
589 *valp = (val & mask) != 0;
590 return 0;
591}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100594{
595 signed int change;
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 hda_nid_t nid = kcontrol->private_value & 0xffff;
598 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
599 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200600 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100601 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100603
604 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100606 if (val==0)
607 ctrl_data &= ~mask;
608 else
609 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
611 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100612
613 return change;
614}
615#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
617 .info = alc_spdif_ctrl_info, \
618 .get = alc_spdif_ctrl_get, \
619 .put = alc_spdif_ctrl_put, \
620 .private_value = nid | (mask<<16) }
621#endif /* CONFIG_SND_DEBUG */
622
Jonathan Woithef8225f62008-01-08 12:16:54 +0100623/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
624 * Again, this is only used in the ALC26x test models to help identify when
625 * the EAPD line must be asserted for features to work.
626 */
627#ifdef CONFIG_SND_DEBUG
628#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
629
630static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
639
640 *valp = (val & mask) != 0;
641 return 0;
642}
643
644static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 int change;
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long val = *ucontrol->value.integer.value;
652 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_EAPD_BTLENABLE,
654 0x00);
655
656 /* Set/unset the masked control bit(s) as needed */
657 change = (!val ? 0 : mask) != (ctrl_data & mask);
658 if (!val)
659 ctrl_data &= ~mask;
660 else
661 ctrl_data |= mask;
662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
663 ctrl_data);
664
665 return change;
666}
667
668#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
670 .info = alc_eapd_ctrl_info, \
671 .get = alc_eapd_ctrl_get, \
672 .put = alc_eapd_ctrl_put, \
673 .private_value = nid | (mask<<16) }
674#endif /* CONFIG_SND_DEBUG */
675
Kailang Yangdf694da2005-12-05 19:42:22 +0100676/*
677 * set up from the preset table
678 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static void setup_preset(struct alc_spec *spec,
680 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100681{
682 int i;
683
684 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
685 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200686 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
687 i++)
688 spec->init_verbs[spec->num_init_verbs++] =
689 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100690
691 spec->channel_mode = preset->channel_mode;
692 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200693 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100694
695 spec->multiout.max_channels = spec->channel_mode[0].channels;
696
697 spec->multiout.num_dacs = preset->num_dacs;
698 spec->multiout.dac_nids = preset->dac_nids;
699 spec->multiout.dig_out_nid = preset->dig_out_nid;
700 spec->multiout.hp_nid = preset->hp_nid;
701
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200702 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200703 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200704 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100705 spec->input_mux = preset->input_mux;
706
707 spec->num_adc_nids = preset->num_adc_nids;
708 spec->adc_nids = preset->adc_nids;
709 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100710
711 spec->unsol_event = preset->unsol_event;
712 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200713#ifdef CONFIG_SND_HDA_POWER_SAVE
714 spec->loopback.amplist = preset->loopbacks;
715#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100716}
717
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200718/* Enable GPIO mask and set output */
719static struct hda_verb alc_gpio1_init_verbs[] = {
720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
723 { }
724};
725
726static struct hda_verb alc_gpio2_init_verbs[] = {
727 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
730 { }
731};
732
Kailang Yangbdd148a2007-05-08 15:19:08 +0200733static struct hda_verb alc_gpio3_init_verbs[] = {
734 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
735 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
737 { }
738};
739
Kailang Yangc9b58002007-10-16 14:30:01 +0200740static void alc_sku_automute(struct hda_codec *codec)
741{
742 struct alc_spec *spec = codec->spec;
743 unsigned int mute;
744 unsigned int present;
745 unsigned int hp_nid = spec->autocfg.hp_pins[0];
746 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
747
748 /* need to execute and sync at first */
749 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
750 present = snd_hda_codec_read(codec, hp_nid, 0,
751 AC_VERB_GET_PIN_SENSE, 0);
752 spec->jack_present = (present & 0x80000000) != 0;
753 if (spec->jack_present) {
754 /* mute internal speaker */
755 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
756 HDA_AMP_MUTE, HDA_AMP_MUTE);
757 } else {
758 /* unmute internal speaker if necessary */
759 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
760 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
761 HDA_AMP_MUTE, mute);
762 }
763}
764
765/* unsolicited event for HP jack sensing */
766static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
767{
768 if (codec->vendor_id == 0x10ec0880)
769 res >>= 28;
770 else
771 res >>= 26;
772 if (res != ALC880_HP_EVENT)
773 return;
774
775 alc_sku_automute(codec);
776}
777
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200778/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
779 * 31 ~ 16 : Manufacture ID
780 * 15 ~ 8 : SKU ID
781 * 7 ~ 0 : Assembly ID
782 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
783 */
784static void alc_subsystem_id(struct hda_codec *codec,
785 unsigned int porta, unsigned int porte,
786 unsigned int portd)
787{
Kailang Yangc9b58002007-10-16 14:30:01 +0200788 unsigned int ass, tmp, i;
789 unsigned nid;
790 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200791
Kailang Yangc9b58002007-10-16 14:30:01 +0200792 ass = codec->subsystem_id & 0xffff;
793 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
794 goto do_sku;
795
796 /*
797 * 31~30 : port conetcivity
798 * 29~21 : reserve
799 * 20 : PCBEEP input
800 * 19~16 : Check sum (15:1)
801 * 15~1 : Custom
802 * 0 : override
803 */
804 nid = 0x1d;
805 if (codec->vendor_id == 0x10ec0260)
806 nid = 0x17;
807 ass = snd_hda_codec_read(codec, nid, 0,
808 AC_VERB_GET_CONFIG_DEFAULT, 0);
809 if (!(ass & 1) && !(ass & 0x100000))
810 return;
811 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200812 return;
813
Kailang Yangc9b58002007-10-16 14:30:01 +0200814 /* check sum */
815 tmp = 0;
816 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100817 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200818 tmp++;
819 }
820 if (((ass >> 16) & 0xf) != tmp)
821 return;
822do_sku:
823 /*
824 * 0 : override
825 * 1 : Swap Jack
826 * 2 : 0 --> Desktop, 1 --> Laptop
827 * 3~5 : External Amplifier control
828 * 7~6 : Reserved
829 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200830 tmp = (ass & 0x38) >> 3; /* external Amp control */
831 switch (tmp) {
832 case 1:
833 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
834 break;
835 case 3:
836 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
837 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200838 case 7:
839 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
840 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200841 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200842 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200843 case 0x10ec0260:
844 snd_hda_codec_write(codec, 0x0f, 0,
845 AC_VERB_SET_EAPD_BTLENABLE, 2);
846 snd_hda_codec_write(codec, 0x10, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 break;
849 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200850 case 0x10ec0267:
851 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200852 case 0x10ec0269:
853 case 0x10ec0862:
854 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200855 snd_hda_codec_write(codec, 0x14, 0,
856 AC_VERB_SET_EAPD_BTLENABLE, 2);
857 snd_hda_codec_write(codec, 0x15, 0,
858 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200859 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200860 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200861 switch (codec->vendor_id) {
862 case 0x10ec0260:
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 tmp = snd_hda_codec_read(codec, 0x1a, 0,
866 AC_VERB_GET_PROC_COEF, 0);
867 snd_hda_codec_write(codec, 0x1a, 0,
868 AC_VERB_SET_COEF_INDEX, 7);
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_PROC_COEF,
871 tmp | 0x2010);
872 break;
873 case 0x10ec0262:
874 case 0x10ec0880:
875 case 0x10ec0882:
876 case 0x10ec0883:
877 case 0x10ec0885:
878 case 0x10ec0888:
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 tmp = snd_hda_codec_read(codec, 0x20, 0,
882 AC_VERB_GET_PROC_COEF, 0);
883 snd_hda_codec_write(codec, 0x20, 0,
884 AC_VERB_SET_COEF_INDEX, 7);
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_PROC_COEF,
887 tmp | 0x2010);
888 break;
889 case 0x10ec0267:
890 case 0x10ec0268:
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 tmp = snd_hda_codec_read(codec, 0x20, 0,
894 AC_VERB_GET_PROC_COEF, 0);
895 snd_hda_codec_write(codec, 0x20, 0,
896 AC_VERB_SET_COEF_INDEX, 7);
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_PROC_COEF,
899 tmp | 0x3000);
900 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200901 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200902 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200903 break;
904 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200905
Kailang Yang8c427222008-01-10 13:03:59 +0100906 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 * when the external headphone out jack is plugged"
908 */
Kailang Yang8c427222008-01-10 13:03:59 +0100909 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200910 return;
911 /*
912 * 10~8 : Jack location
913 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
914 * 14~13: Resvered
915 * 15 : 1 --> enable the function "Mute internal speaker
916 * when the external headphone out jack is plugged"
917 */
918 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100919 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200920 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100921 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 else
923 return;
924 }
925
926 if (!spec->autocfg.hp_pins[0]) {
927 tmp = (ass >> 11) & 0x3; /* HP to chassis */
928 if (tmp == 0)
929 spec->autocfg.hp_pins[0] = porta;
930 else if (tmp == 1)
931 spec->autocfg.hp_pins[0] = porte;
932 else if (tmp == 2)
933 spec->autocfg.hp_pins[0] = portd;
934 else
935 return;
936 }
937
938 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
939 AC_VERB_SET_UNSOLICITED_ENABLE,
940 AC_USRSP_EN | ALC880_HP_EVENT);
941 spec->unsol_event = alc_sku_unsol_event;
942 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200943}
944
Takashi Iwai41e41f12005-06-08 14:48:49 +0200945/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200946 * Fix-up pin default configurations
947 */
948
949struct alc_pincfg {
950 hda_nid_t nid;
951 u32 val;
952};
953
954static void alc_fix_pincfg(struct hda_codec *codec,
955 const struct snd_pci_quirk *quirk,
956 const struct alc_pincfg **pinfix)
957{
958 const struct alc_pincfg *cfg;
959
960 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
961 if (!quirk)
962 return;
963
964 cfg = pinfix[quirk->value];
965 for (; cfg->nid; cfg++) {
966 int i;
967 u32 val = cfg->val;
968 for (i = 0; i < 4; i++) {
969 snd_hda_codec_write(codec, cfg->nid, 0,
970 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
971 val & 0xff);
972 val >>= 8;
973 }
974 }
975}
976
977/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200978 * ALC880 3-stack model
979 *
980 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200981 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
982 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 */
984
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200985static hda_nid_t alc880_dac_nids[4] = {
986 /* front, rear, clfe, rear_surr */
987 0x02, 0x05, 0x04, 0x03
988};
989
990static hda_nid_t alc880_adc_nids[3] = {
991 /* ADC0-2 */
992 0x07, 0x08, 0x09,
993};
994
995/* The datasheet says the node 0x07 is connected from inputs,
996 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100997 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200999static hda_nid_t alc880_adc_nids_alt[2] = {
1000 /* ADC1-2 */
1001 0x08, 0x09,
1002};
1003
1004#define ALC880_DIGOUT_NID 0x06
1005#define ALC880_DIGIN_NID 0x0a
1006
1007static struct hda_input_mux alc880_capture_source = {
1008 .num_items = 4,
1009 .items = {
1010 { "Mic", 0x0 },
1011 { "Front Mic", 0x3 },
1012 { "Line", 0x2 },
1013 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001015};
1016
1017/* channel source setting (2/6 channel selection for 3-stack) */
1018/* 2ch mode */
1019static struct hda_verb alc880_threestack_ch2_init[] = {
1020 /* set line-in to input, mute it */
1021 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1022 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1023 /* set mic-in to input vref 80%, mute it */
1024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 { } /* end */
1027};
1028
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001029/* 6ch mode */
1030static struct hda_verb alc880_threestack_ch6_init[] = {
1031 /* set line-in to output, unmute it */
1032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1034 /* set mic-in to output, unmute it */
1035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1037 { } /* end */
1038};
1039
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001040static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 { 2, alc880_threestack_ch2_init },
1042 { 6, alc880_threestack_ch6_init },
1043};
1044
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001045static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001048 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001049 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001050 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001065 {
1066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1067 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001068 .info = alc_ch_mode_info,
1069 .get = alc_ch_mode_get,
1070 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 },
1072 { } /* end */
1073};
1074
1075/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001076static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1083 {
1084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1085 /* The multiple "Capture Source" controls confuse alsamixer
1086 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001087 */
1088 /* .name = "Capture Source", */
1089 .name = "Input Source",
1090 .count = 3,
1091 .info = alc_mux_enum_info,
1092 .get = alc_mux_enum_get,
1093 .put = alc_mux_enum_put,
1094 },
1095 { } /* end */
1096};
1097
1098/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001099static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 {
1105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1106 /* The multiple "Capture Source" controls confuse alsamixer
1107 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 */
1109 /* .name = "Capture Source", */
1110 .name = "Input Source",
1111 .count = 2,
1112 .info = alc_mux_enum_info,
1113 .get = alc_mux_enum_get,
1114 .put = alc_mux_enum_put,
1115 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 { } /* end */
1117};
1118
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001119
1120
1121/*
1122 * ALC880 5-stack model
1123 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001124 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1125 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001126 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1127 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1128 */
1129
1130/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001131static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001133 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 { } /* end */
1135};
1136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137/* channel source setting (6/8 channel selection for 5-stack) */
1138/* 6ch mode */
1139static struct hda_verb alc880_fivestack_ch6_init[] = {
1140 /* set line-in to input, mute it */
1141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001143 { } /* end */
1144};
1145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001146/* 8ch mode */
1147static struct hda_verb alc880_fivestack_ch8_init[] = {
1148 /* set line-in to output, unmute it */
1149 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1150 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1151 { } /* end */
1152};
1153
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001154static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155 { 6, alc880_fivestack_ch6_init },
1156 { 8, alc880_fivestack_ch8_init },
1157};
1158
1159
1160/*
1161 * ALC880 6-stack model
1162 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001163 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1164 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001165 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1166 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1167 */
1168
1169static hda_nid_t alc880_6st_dac_nids[4] = {
1170 /* front, rear, clfe, rear_surr */
1171 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001172};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001173
1174static struct hda_input_mux alc880_6stack_capture_source = {
1175 .num_items = 4,
1176 .items = {
1177 { "Mic", 0x0 },
1178 { "Front Mic", 0x1 },
1179 { "Line", 0x2 },
1180 { "CD", 0x4 },
1181 },
1182};
1183
1184/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001185static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001186 { 8, NULL },
1187};
1188
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001189static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001192 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001193 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1209 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001210 {
1211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1212 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001213 .info = alc_ch_mode_info,
1214 .get = alc_ch_mode_get,
1215 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001216 },
1217 { } /* end */
1218};
1219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220
1221/*
1222 * ALC880 W810 model
1223 *
1224 * W810 has rear IO for:
1225 * Front (DAC 02)
1226 * Surround (DAC 03)
1227 * Center/LFE (DAC 04)
1228 * Digital out (06)
1229 *
1230 * The system also has a pair of internal speakers, and a headphone jack.
1231 * These are both connected to Line2 on the codec, hence to DAC 02.
1232 *
1233 * There is a variable resistor to control the speaker or headphone
1234 * volume. This is a hardware-only device without a software API.
1235 *
1236 * Plugging headphones in will disable the internal speakers. This is
1237 * implemented in hardware, not via the driver using jack sense. In
1238 * a similar fashion, plugging into the rear socket marked "front" will
1239 * disable both the speakers and headphones.
1240 *
1241 * For input, there's a microphone jack, and an "audio in" jack.
1242 * These may not do anything useful with this driver yet, because I
1243 * haven't setup any initialization verbs for these yet...
1244 */
1245
1246static hda_nid_t alc880_w810_dac_nids[3] = {
1247 /* front, rear/surround, clfe */
1248 0x02, 0x03, 0x04
1249};
1250
1251/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001252static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 { 6, NULL }
1254};
1255
1256/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001257static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001260 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1267 { } /* end */
1268};
1269
1270
1271/*
1272 * Z710V model
1273 *
1274 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001275 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1276 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001277 */
1278
1279static hda_nid_t alc880_z71v_dac_nids[1] = {
1280 0x02
1281};
1282#define ALC880_Z71V_HP_DAC 0x03
1283
1284/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001285static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 { 2, NULL }
1287};
1288
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001289static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001293 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1298 { } /* end */
1299};
1300
1301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001302/*
1303 * ALC880 F1734 model
1304 *
1305 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1306 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1307 */
1308
1309static hda_nid_t alc880_f1734_dac_nids[1] = {
1310 0x03
1311};
1312#define ALC880_F1734_HP_DAC 0x02
1313
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001314static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001316 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1318 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001323 { } /* end */
1324};
1325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001327/*
1328 * ALC880 ASUS model
1329 *
1330 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1331 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1332 * Mic = 0x18, Line = 0x1a
1333 */
1334
1335#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1336#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1337
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001338static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001342 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001343 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001345 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001353 {
1354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1355 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001356 .info = alc_ch_mode_info,
1357 .get = alc_ch_mode_get,
1358 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001359 },
1360 { } /* end */
1361};
1362
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001363/*
1364 * ALC880 ASUS W1V model
1365 *
1366 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1367 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1368 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1369 */
1370
1371/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001372static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001373 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1374 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001375 { } /* end */
1376};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001378/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001379static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1382 { } /* end */
1383};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384
Kailang Yangdf694da2005-12-05 19:42:22 +01001385/* TCL S700 */
1386static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1388 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1396 {
1397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1398 /* The multiple "Capture Source" controls confuse alsamixer
1399 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001400 */
1401 /* .name = "Capture Source", */
1402 .name = "Input Source",
1403 .count = 1,
1404 .info = alc_mux_enum_info,
1405 .get = alc_mux_enum_get,
1406 .put = alc_mux_enum_put,
1407 },
1408 { } /* end */
1409};
1410
Kailang Yangccc656c2006-10-17 12:32:26 +02001411/* Uniwill */
1412static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1414 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1430 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1431 {
1432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1433 .name = "Channel Mode",
1434 .info = alc_ch_mode_info,
1435 .get = alc_ch_mode_get,
1436 .put = alc_ch_mode_put,
1437 },
1438 { } /* end */
1439};
1440
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001441static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1449 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1452 { } /* end */
1453};
1454
Kailang Yangccc656c2006-10-17 12:32:26 +02001455static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1462 { } /* end */
1463};
1464
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001466 * virtual master controls
1467 */
1468
1469/*
1470 * slave controls for virtual master
1471 */
1472static const char *alc_slave_vols[] = {
1473 "Front Playback Volume",
1474 "Surround Playback Volume",
1475 "Center Playback Volume",
1476 "LFE Playback Volume",
1477 "Side Playback Volume",
1478 "Headphone Playback Volume",
1479 "Speaker Playback Volume",
1480 "Mono Playback Volume",
1481 "iSpeaker Playback Volume",
1482 "Line-Out Playback Volume",
1483 NULL,
1484};
1485
1486static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
1495 "iSpeaker Playback Switch",
1496 NULL,
1497};
1498
1499/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001500 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 */
1502static int alc_build_controls(struct hda_codec *codec)
1503{
1504 struct alc_spec *spec = codec->spec;
1505 int err;
1506 int i;
1507
1508 for (i = 0; i < spec->num_mixers; i++) {
1509 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1510 if (err < 0)
1511 return err;
1512 }
1513
1514 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001515 err = snd_hda_create_spdif_out_ctls(codec,
1516 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 if (err < 0)
1518 return err;
1519 }
1520 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1522 if (err < 0)
1523 return err;
1524 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001525
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1534 }
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1540 }
1541
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 return 0;
1543}
1544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001545
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546/*
1547 * initialize the codec volumes, etc
1548 */
1549
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001550/*
1551 * generic initialization of ADC, input mixers and output mixers
1552 */
1553static struct hda_verb alc880_volume_init_verbs[] = {
1554 /*
1555 * Unmute ADC0-2 and set the default input to mic-in
1556 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1565 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001566 * Note: PASD motherboards uses the Line In 2 as the input for front
1567 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 /*
1579 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001581 /* set vol=0 to output mixers */
1582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 /* set up input amps for analog loopback */
1587 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596
1597 { }
1598};
1599
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001600/*
1601 * 3-stack pin configuration:
1602 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1603 */
1604static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1605 /*
1606 * preset connection lists of input pins
1607 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1608 */
1609 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1610 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1612
1613 /*
1614 * Set pin mode and muting
1615 */
1616 /* set front pin widgets 0x14 for output */
1617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* Mic2 (as headphone out) for HP output */
1623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Line In pin widget for input */
1626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* Line2 (as front mic) pin widget for input and vref at 80% */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* CD pin widget for input */
1632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1633
1634 { }
1635};
1636
1637/*
1638 * 5-stack pin configuration:
1639 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1640 * line-in/side = 0x1a, f-mic = 0x1b
1641 */
1642static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1643 /*
1644 * preset connection lists of input pins
1645 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1646 */
1647 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1648 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1649
1650 /*
1651 * Set pin mode and muting
1652 */
1653 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 /* unmute pins for output (no gain on this amp) */
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 /* Mic2 (as headphone out) for HP output */
1668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001670 /* Line In pin widget for input */
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* Line2 (as front mic) pin widget for input and vref at 80% */
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* CD pin widget for input */
1677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678
1679 { }
1680};
1681
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001682/*
1683 * W810 pin configuration:
1684 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1685 */
1686static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 /* hphone/speaker input selector: front DAC */
1688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1689
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 { }
1701};
1702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001703/*
1704 * Z71V pin configuration:
1705 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1706 */
1707static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001712
Takashi Iwai16ded522005-06-10 19:58:24 +02001713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001717
1718 { }
1719};
1720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721/*
1722 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001723 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1724 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725 */
1726static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737
Takashi Iwai16ded522005-06-10 19:58:24 +02001738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1747
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 { }
1749};
Takashi Iwai16ded522005-06-10 19:58:24 +02001750
Kailang Yangccc656c2006-10-17 12:32:26 +02001751/*
1752 * Uniwill pin configuration:
1753 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1754 * line = 0x1a
1755 */
1756static struct hda_verb alc880_uniwill_init_verbs[] = {
1757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1758
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1773
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1780 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1781 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1783
1784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1786
1787 { }
1788};
1789
1790/*
1791* Uniwill P53
1792* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1793 */
1794static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1796
1797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1809
1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1816
1817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1819
1820 { }
1821};
1822
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001823static struct hda_verb alc880_beep_init_verbs[] = {
1824 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1825 { }
1826};
1827
Kailang Yangccc656c2006-10-17 12:32:26 +02001828/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001829static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001830{
1831 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001832 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001833
1834 present = snd_hda_codec_read(codec, 0x14, 0,
1835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001836 bits = present ? HDA_AMP_MUTE : 0;
1837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
1839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1840 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001841}
1842
1843/* auto-toggle front mic */
1844static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1845{
1846 unsigned int present;
1847 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001848
1849 present = snd_hda_codec_read(codec, 0x18, 0,
1850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001851 bits = present ? HDA_AMP_MUTE : 0;
1852 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001853}
1854
1855static void alc880_uniwill_automute(struct hda_codec *codec)
1856{
1857 alc880_uniwill_hp_automute(codec);
1858 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001859}
1860
1861static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1862 unsigned int res)
1863{
1864 /* Looks like the unsol event is incompatible with the standard
1865 * definition. 4bit tag is placed at 28 bit!
1866 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001867 switch (res >> 28) {
1868 case ALC880_HP_EVENT:
1869 alc880_uniwill_hp_automute(codec);
1870 break;
1871 case ALC880_MIC_EVENT:
1872 alc880_uniwill_mic_automute(codec);
1873 break;
1874 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001875}
1876
1877static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1878{
1879 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001880 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001881
1882 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001884 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001886}
1887
1888static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1889{
1890 unsigned int present;
1891
1892 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001893 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1894 present &= HDA_AMP_VOLMASK;
1895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
1897 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1898 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001899}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001900
Kailang Yangccc656c2006-10-17 12:32:26 +02001901static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1902 unsigned int res)
1903{
1904 /* Looks like the unsol event is incompatible with the standard
1905 * definition. 4bit tag is placed at 28 bit!
1906 */
1907 if ((res >> 28) == ALC880_HP_EVENT)
1908 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001909 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001910 alc880_uniwill_p53_dcvol_automute(codec);
1911}
1912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001913/*
1914 * F1734 pin configuration:
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */
1917static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1921 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1922
1923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001937
1938 { }
1939};
1940
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001941/*
1942 * ASUS pin configuration:
1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1944 */
1945static struct hda_verb alc880_pin_asus_init_verbs[] = {
1946 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1947 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1948 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1950
1951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959
1960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1969
1970 { }
1971};
1972
1973/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001974#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1975#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001976
Kailang Yangdf694da2005-12-05 19:42:22 +01001977/* Clevo m520g init */
1978static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1979 /* headphone output */
1980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1981 /* line-out */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* Line-in */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* CD */
1988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1989 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic1 (rear panel) */
1991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* Mic2 (front panel) */
1994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* headphone */
1997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* change to EAPD mode */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2002
2003 { }
2004};
2005
2006static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002007 /* change to EAPD mode */
2008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2009 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2010
Kailang Yangdf694da2005-12-05 19:42:22 +01002011 /* Headphone output */
2012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 /* Front output*/
2014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2016
2017 /* Line In pin widget for input */
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* CD pin widget for input */
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2023
2024 /* change to EAPD mode */
2025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2027
2028 { }
2029};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030
2031/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002032 * LG m1 express dual
2033 *
2034 * Pin assignment:
2035 * Rear Line-In/Out (blue): 0x14
2036 * Build-in Mic-In: 0x15
2037 * Speaker-out: 0x17
2038 * HP-Out (green): 0x1b
2039 * Mic-In/Out (red): 0x19
2040 * SPDIF-Out: 0x1e
2041 */
2042
2043/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2044static hda_nid_t alc880_lg_dac_nids[3] = {
2045 0x05, 0x02, 0x03
2046};
2047
2048/* seems analog CD is not working */
2049static struct hda_input_mux alc880_lg_capture_source = {
2050 .num_items = 3,
2051 .items = {
2052 { "Mic", 0x1 },
2053 { "Line", 0x5 },
2054 { "Internal Mic", 0x6 },
2055 },
2056};
2057
2058/* 2,4,6 channel modes */
2059static struct hda_verb alc880_lg_ch2_init[] = {
2060 /* set line-in and mic-in to input */
2061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2062 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2063 { }
2064};
2065
2066static struct hda_verb alc880_lg_ch4_init[] = {
2067 /* set line-in to out and mic-in to input */
2068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2069 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2070 { }
2071};
2072
2073static struct hda_verb alc880_lg_ch6_init[] = {
2074 /* set line-in and mic-in to output */
2075 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2076 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2077 { }
2078};
2079
2080static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2081 { 2, alc880_lg_ch2_init },
2082 { 4, alc880_lg_ch4_init },
2083 { 6, alc880_lg_ch6_init },
2084};
2085
2086static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2100 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2101 {
2102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2103 .name = "Channel Mode",
2104 .info = alc_ch_mode_info,
2105 .get = alc_ch_mode_get,
2106 .put = alc_ch_mode_put,
2107 },
2108 { } /* end */
2109};
2110
2111static struct hda_verb alc880_lg_init_verbs[] = {
2112 /* set capture source to mic-in */
2113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 /* mute all amp mixer inputs */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002120 /* line-in to input */
2121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* built-in mic */
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* speaker-out */
2127 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* mic-in to input */
2130 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* HP-out */
2134 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 /* jack sense */
2138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2139 { }
2140};
2141
2142/* toggle speaker-output according to the hp-jack state */
2143static void alc880_lg_automute(struct hda_codec *codec)
2144{
2145 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002146 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002147
2148 present = snd_hda_codec_read(codec, 0x1b, 0,
2149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002150 bits = present ? HDA_AMP_MUTE : 0;
2151 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2152 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002153}
2154
2155static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2156{
2157 /* Looks like the unsol event is incompatible with the standard
2158 * definition. 4bit tag is placed at 28 bit!
2159 */
2160 if ((res >> 28) == 0x01)
2161 alc880_lg_automute(codec);
2162}
2163
2164/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002165 * LG LW20
2166 *
2167 * Pin assignment:
2168 * Speaker-out: 0x14
2169 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002170 * Built-in Mic-In: 0x19
2171 * Line-In: 0x1b
2172 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002173 * SPDIF-Out: 0x1e
2174 */
2175
Takashi Iwaid6815182006-03-23 16:06:23 +01002176static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002177 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002178 .items = {
2179 { "Mic", 0x0 },
2180 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002181 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002182 },
2183};
2184
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002185#define alc880_lg_lw_modes alc880_threestack_modes
2186
Takashi Iwaid6815182006-03-23 16:06:23 +01002187static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002202 {
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2208 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002209 { } /* end */
2210};
2211
2212static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2214 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2216
Takashi Iwaid6815182006-03-23 16:06:23 +01002217 /* set capture source to mic-in */
2218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002222 /* speaker-out */
2223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* mic-in to input */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* built-in mic */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* jack sense */
2235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2236 { }
2237};
2238
2239/* toggle speaker-output according to the hp-jack state */
2240static void alc880_lg_lw_automute(struct hda_codec *codec)
2241{
2242 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002243 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002244
2245 present = snd_hda_codec_read(codec, 0x1b, 0,
2246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002247 bits = present ? HDA_AMP_MUTE : 0;
2248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2249 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002250}
2251
2252static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2253{
2254 /* Looks like the unsol event is incompatible with the standard
2255 * definition. 4bit tag is placed at 28 bit!
2256 */
2257 if ((res >> 28) == 0x01)
2258 alc880_lg_lw_automute(codec);
2259}
2260
Takashi Iwaicb53c622007-08-10 17:21:45 +02002261#ifdef CONFIG_SND_HDA_POWER_SAVE
2262static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 },
2264 { 0x0b, HDA_INPUT, 1 },
2265 { 0x0b, HDA_INPUT, 2 },
2266 { 0x0b, HDA_INPUT, 3 },
2267 { 0x0b, HDA_INPUT, 4 },
2268 { } /* end */
2269};
2270
2271static struct hda_amp_list alc880_lg_loopbacks[] = {
2272 { 0x0b, HDA_INPUT, 1 },
2273 { 0x0b, HDA_INPUT, 6 },
2274 { 0x0b, HDA_INPUT, 7 },
2275 { } /* end */
2276};
2277#endif
2278
Takashi Iwaid6815182006-03-23 16:06:23 +01002279/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002280 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002281 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002282
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283static int alc_init(struct hda_codec *codec)
2284{
2285 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002286 unsigned int i;
2287
2288 for (i = 0; i < spec->num_init_verbs; i++)
2289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002290
2291 if (spec->init_hook)
2292 spec->init_hook(codec);
2293
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 return 0;
2295}
2296
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002297static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2298{
2299 struct alc_spec *spec = codec->spec;
2300
2301 if (spec->unsol_event)
2302 spec->unsol_event(codec, res);
2303}
2304
Takashi Iwaicb53c622007-08-10 17:21:45 +02002305#ifdef CONFIG_SND_HDA_POWER_SAVE
2306static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2307{
2308 struct alc_spec *spec = codec->spec;
2309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2310}
2311#endif
2312
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313/*
2314 * Analog playback callbacks
2315 */
2316static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002318 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319{
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2322}
2323
2324static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002328 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329{
2330 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2332 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333}
2334
2335static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002337 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338{
2339 struct alc_spec *spec = codec->spec;
2340 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2341}
2342
2343/*
2344 * Digital out
2345 */
2346static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002348 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349{
2350 struct alc_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2352}
2353
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002354static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2359{
2360 struct alc_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2363}
2364
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368{
2369 struct alc_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371}
2372
2373/*
2374 * Analog capture
2375 */
Takashi Iwai63300792008-01-24 15:31:36 +01002376static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002380 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381{
2382 struct alc_spec *spec = codec->spec;
2383
Takashi Iwai63300792008-01-24 15:31:36 +01002384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 stream_tag, 0, format);
2386 return 0;
2387}
2388
Takashi Iwai63300792008-01-24 15:31:36 +01002389static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002391 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392{
2393 struct alc_spec *spec = codec->spec;
2394
Takashi Iwai63300792008-01-24 15:31:36 +01002395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002396 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 return 0;
2398}
2399
2400
2401/*
2402 */
2403static struct hda_pcm_stream alc880_pcm_analog_playback = {
2404 .substreams = 1,
2405 .channels_min = 2,
2406 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 .ops = {
2409 .open = alc880_playback_pcm_open,
2410 .prepare = alc880_playback_pcm_prepare,
2411 .cleanup = alc880_playback_pcm_cleanup
2412 },
2413};
2414
2415static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2420};
2421
2422static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427};
2428
2429static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 .channels_min = 2,
2432 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002433 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002435 .prepare = alc880_alt_capture_pcm_prepare,
2436 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 },
2438};
2439
2440static struct hda_pcm_stream alc880_pcm_digital_playback = {
2441 .substreams = 1,
2442 .channels_min = 2,
2443 .channels_max = 2,
2444 /* NID is set in alc_build_pcms */
2445 .ops = {
2446 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002447 .close = alc880_dig_playback_pcm_close,
2448 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 },
2450};
2451
2452static struct hda_pcm_stream alc880_pcm_digital_capture = {
2453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 /* NID is set in alc_build_pcms */
2457};
2458
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002459/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002460static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002461 .substreams = 0,
2462 .channels_min = 0,
2463 .channels_max = 0,
2464};
2465
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466static int alc_build_pcms(struct hda_codec *codec)
2467{
2468 struct alc_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470 int i;
2471
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2474
2475 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002476 if (spec->stream_analog_playback) {
2477 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2480 }
2481 if (spec->stream_analog_capture) {
2482 snd_assert(spec->adc_nids, return -EINVAL);
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2485 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486
Takashi Iwai4a471b72005-12-07 13:56:29 +01002487 if (spec->channel_mode) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2489 for (i = 0; i < spec->num_channel_mode; i++) {
2490 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2492 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 }
2494 }
2495
Takashi Iwaie08a0072006-09-07 17:52:14 +02002496 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002498 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002499 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002501 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2505 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002506 if (spec->dig_in_nid &&
2507 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2510 }
2511 }
2512
Takashi Iwaie08a0072006-09-07 17:52:14 +02002513 /* If the use of more than one ADC is requested for the current
2514 * model, configure a second analog capture-only PCM.
2515 */
2516 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002519 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002520 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002521 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002522 if (spec->alt_dac_nid) {
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2524 *spec->stream_analog_alt_playback;
2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2526 spec->alt_dac_nid;
2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2531 }
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002543 }
2544 }
2545
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 return 0;
2547}
2548
2549static void alc_free(struct hda_codec *codec)
2550{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551 struct alc_spec *spec = codec->spec;
2552 unsigned int i;
2553
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002554 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 return;
2556
2557 if (spec->kctl_alloc) {
2558 for (i = 0; i < spec->num_kctl_used; i++)
2559 kfree(spec->kctl_alloc[i].name);
2560 kfree(spec->kctl_alloc);
2561 }
2562 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563}
2564
2565/*
2566 */
2567static struct hda_codec_ops alc_patch_ops = {
2568 .build_controls = alc_build_controls,
2569 .build_pcms = alc_build_pcms,
2570 .init = alc_init,
2571 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002572 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002573#ifdef CONFIG_SND_HDA_POWER_SAVE
2574 .check_power_status = alc_check_power_status,
2575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576};
2577
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002578
2579/*
2580 * Test configuration for debugging
2581 *
2582 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2583 * enum controls.
2584 */
2585#ifdef CONFIG_SND_DEBUG
2586static hda_nid_t alc880_test_dac_nids[4] = {
2587 0x02, 0x03, 0x04, 0x05
2588};
2589
2590static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002591 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002592 .items = {
2593 { "In-1", 0x0 },
2594 { "In-2", 0x1 },
2595 { "In-3", 0x2 },
2596 { "In-4", 0x3 },
2597 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002598 { "Front", 0x5 },
2599 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002600 },
2601};
2602
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002603static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002604 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002605 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002606 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002607 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002608};
2609
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002610static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002612{
2613 static char *texts[] = {
2614 "N/A", "Line Out", "HP Out",
2615 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2616 };
2617 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2618 uinfo->count = 1;
2619 uinfo->value.enumerated.items = 8;
2620 if (uinfo->value.enumerated.item >= 8)
2621 uinfo->value.enumerated.item = 7;
2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2623 return 0;
2624}
2625
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002626static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002628{
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2631 unsigned int pin_ctl, item = 0;
2632
2633 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2634 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2635 if (pin_ctl & AC_PINCTL_OUT_EN) {
2636 if (pin_ctl & AC_PINCTL_HP_EN)
2637 item = 2;
2638 else
2639 item = 1;
2640 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2641 switch (pin_ctl & AC_PINCTL_VREFEN) {
2642 case AC_PINCTL_VREF_HIZ: item = 3; break;
2643 case AC_PINCTL_VREF_50: item = 4; break;
2644 case AC_PINCTL_VREF_GRD: item = 5; break;
2645 case AC_PINCTL_VREF_80: item = 6; break;
2646 case AC_PINCTL_VREF_100: item = 7; break;
2647 }
2648 }
2649 ucontrol->value.enumerated.item[0] = item;
2650 return 0;
2651}
2652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002653static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002655{
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2658 static unsigned int ctls[] = {
2659 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2665 };
2666 unsigned int old_ctl, new_ctl;
2667
2668 old_ctl = snd_hda_codec_read(codec, nid, 0,
2669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2670 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2671 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002672 int val;
2673 snd_hda_codec_write_cache(codec, nid, 0,
2674 AC_VERB_SET_PIN_WIDGET_CONTROL,
2675 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002676 val = ucontrol->value.enumerated.item[0] >= 3 ?
2677 HDA_AMP_MUTE : 0;
2678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2679 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002680 return 1;
2681 }
2682 return 0;
2683}
2684
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002687{
2688 static char *texts[] = {
2689 "Front", "Surround", "CLFE", "Side"
2690 };
2691 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2692 uinfo->count = 1;
2693 uinfo->value.enumerated.items = 4;
2694 if (uinfo->value.enumerated.item >= 4)
2695 uinfo->value.enumerated.item = 3;
2696 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2697 return 0;
2698}
2699
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002700static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2701 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002702{
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2705 unsigned int sel;
2706
2707 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2708 ucontrol->value.enumerated.item[0] = sel & 3;
2709 return 0;
2710}
2711
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002712static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2713 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002714{
2715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2716 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2717 unsigned int sel;
2718
2719 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2720 if (ucontrol->value.enumerated.item[0] != sel) {
2721 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002722 snd_hda_codec_write_cache(codec, nid, 0,
2723 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002724 return 1;
2725 }
2726 return 0;
2727}
2728
2729#define PIN_CTL_TEST(xname,nid) { \
2730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2731 .name = xname, \
2732 .info = alc_test_pin_ctl_info, \
2733 .get = alc_test_pin_ctl_get, \
2734 .put = alc_test_pin_ctl_put, \
2735 .private_value = nid \
2736 }
2737
2738#define PIN_SRC_TEST(xname,nid) { \
2739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2740 .name = xname, \
2741 .info = alc_test_pin_src_info, \
2742 .get = alc_test_pin_src_get, \
2743 .put = alc_test_pin_src_put, \
2744 .private_value = nid \
2745 }
2746
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002747static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002748 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002756 PIN_CTL_TEST("Front Pin Mode", 0x14),
2757 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2758 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2759 PIN_CTL_TEST("Side Pin Mode", 0x17),
2760 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2761 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2762 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2763 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2764 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2765 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2766 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2767 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2768 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2775 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002778 {
2779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2780 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002781 .info = alc_ch_mode_info,
2782 .get = alc_ch_mode_get,
2783 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002784 },
2785 { } /* end */
2786};
2787
2788static struct hda_verb alc880_test_init_verbs[] = {
2789 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002798 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002803 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002808 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002813 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002819 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002824 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002831 /* Analog input/passthru */
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002837 { }
2838};
2839#endif
2840
Linus Torvalds1da177e2005-04-16 15:20:36 -07002841/*
2842 */
2843
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002844static const char *alc880_models[ALC880_MODEL_LAST] = {
2845 [ALC880_3ST] = "3stack",
2846 [ALC880_TCL_S700] = "tcl",
2847 [ALC880_3ST_DIG] = "3stack-digout",
2848 [ALC880_CLEVO] = "clevo",
2849 [ALC880_5ST] = "5stack",
2850 [ALC880_5ST_DIG] = "5stack-digout",
2851 [ALC880_W810] = "w810",
2852 [ALC880_Z71V] = "z71v",
2853 [ALC880_6ST] = "6stack",
2854 [ALC880_6ST_DIG] = "6stack-digout",
2855 [ALC880_ASUS] = "asus",
2856 [ALC880_ASUS_W1V] = "asus-w1v",
2857 [ALC880_ASUS_DIG] = "asus-dig",
2858 [ALC880_ASUS_DIG2] = "asus-dig2",
2859 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002860 [ALC880_UNIWILL_P53] = "uniwill-p53",
2861 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002862 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002865#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002866 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002867#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002868 [ALC880_AUTO] = "auto",
2869};
2870
2871static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2890 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2891 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002893 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 {}
2942};
2943
Takashi Iwai16ded522005-06-10 19:58:24 +02002944/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002945 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002946 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002947static struct alc_config_preset alc880_presets[] = {
2948 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002953 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2955 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002956 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002957 .input_mux = &alc880_capture_source,
2958 },
2959 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002960 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002963 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 .dac_nids = alc880_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2967 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002968 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .input_mux = &alc880_capture_source,
2970 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002971 [ALC880_TCL_S700] = {
2972 .mixers = { alc880_tcl_s700_mixer },
2973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_tcl_S700_init_verbs,
2975 alc880_gpio2_init_verbs },
2976 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2977 .dac_nids = alc880_dac_nids,
2978 .hp_nid = 0x03,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
2981 .input_mux = &alc880_capture_source,
2982 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002984 .mixers = { alc880_three_stack_mixer,
2985 alc880_five_stack_mixer},
2986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2989 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002990 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2991 .channel_mode = alc880_fivestack_modes,
2992 .input_mux = &alc880_capture_source,
2993 },
2994 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002995 .mixers = { alc880_three_stack_mixer,
2996 alc880_five_stack_mixer },
2997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3000 .dac_nids = alc880_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3003 .channel_mode = alc880_fivestack_modes,
3004 .input_mux = &alc880_capture_source,
3005 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003006 [ALC880_6ST] = {
3007 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003010 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3011 .dac_nids = alc880_6st_dac_nids,
3012 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3013 .channel_mode = alc880_sixstack_modes,
3014 .input_mux = &alc880_6stack_capture_source,
3015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003018 .init_verbs = { alc880_volume_init_verbs,
3019 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003020 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3021 .dac_nids = alc880_6st_dac_nids,
3022 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003023 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3024 .channel_mode = alc880_sixstack_modes,
3025 .input_mux = &alc880_6stack_capture_source,
3026 },
3027 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003029 .init_verbs = { alc880_volume_init_verbs,
3030 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003031 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003032 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3033 .dac_nids = alc880_w810_dac_nids,
3034 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003035 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3036 .channel_mode = alc880_w810_modes,
3037 .input_mux = &alc880_capture_source,
3038 },
3039 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003041 .init_verbs = { alc880_volume_init_verbs,
3042 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003043 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3044 .dac_nids = alc880_z71v_dac_nids,
3045 .dig_out_nid = ALC880_DIGOUT_NID,
3046 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3048 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .input_mux = &alc880_capture_source,
3050 },
3051 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003053 .init_verbs = { alc880_volume_init_verbs,
3054 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3056 .dac_nids = alc880_f1734_dac_nids,
3057 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 .input_mux = &alc880_capture_source,
3061 },
3062 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003063 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003064 .init_verbs = { alc880_volume_init_verbs,
3065 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 alc880_gpio1_init_verbs },
3067 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3068 .dac_nids = alc880_asus_dac_nids,
3069 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3070 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003071 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003072 .input_mux = &alc880_capture_source,
3073 },
3074 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 .init_verbs = { alc880_volume_init_verbs,
3077 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003078 alc880_gpio1_init_verbs },
3079 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3080 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003081 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3083 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003084 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003085 .input_mux = &alc880_capture_source,
3086 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003087 [ALC880_ASUS_DIG2] = {
3088 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003091 alc880_gpio2_init_verbs }, /* use GPIO2 */
3092 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3093 .dac_nids = alc880_asus_dac_nids,
3094 .dig_out_nid = ALC880_DIGOUT_NID,
3095 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3096 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003097 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003098 .input_mux = &alc880_capture_source,
3099 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003100 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003102 .init_verbs = { alc880_volume_init_verbs,
3103 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 alc880_gpio1_init_verbs },
3105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3106 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003107 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3109 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003110 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003111 .input_mux = &alc880_capture_source,
3112 },
3113 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003114 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3118 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3121 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003122 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .input_mux = &alc880_capture_source,
3124 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003125 [ALC880_UNIWILL] = {
3126 .mixers = { alc880_uniwill_mixer },
3127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_uniwill_init_verbs },
3129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3130 .dac_nids = alc880_asus_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
3132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
3134 .need_dac_fix = 1,
3135 .input_mux = &alc880_capture_source,
3136 .unsol_event = alc880_uniwill_unsol_event,
3137 .init_hook = alc880_uniwill_automute,
3138 },
3139 [ALC880_UNIWILL_P53] = {
3140 .mixers = { alc880_uniwill_p53_mixer },
3141 .init_verbs = { alc880_volume_init_verbs,
3142 alc880_uniwill_p53_init_verbs },
3143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3144 .dac_nids = alc880_asus_dac_nids,
3145 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003146 .channel_mode = alc880_threestack_modes,
3147 .input_mux = &alc880_capture_source,
3148 .unsol_event = alc880_uniwill_p53_unsol_event,
3149 .init_hook = alc880_uniwill_p53_hp_automute,
3150 },
3151 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003152 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003153 alc880_pcbeep_mixer, },
3154 .init_verbs = { alc880_volume_init_verbs,
3155 alc880_uniwill_p53_init_verbs,
3156 alc880_beep_init_verbs },
3157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003159 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003160 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3161 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003162 .input_mux = &alc880_capture_source,
3163 .unsol_event = alc880_uniwill_p53_unsol_event,
3164 .init_hook = alc880_uniwill_p53_hp_automute,
3165 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003166 [ALC880_CLEVO] = {
3167 .mixers = { alc880_three_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_clevo_init_verbs },
3170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .hp_nid = 0x03,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003175 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003176 .input_mux = &alc880_capture_source,
3177 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003178 [ALC880_LG] = {
3179 .mixers = { alc880_lg_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_lg_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3183 .dac_nids = alc880_lg_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3186 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003187 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003188 .input_mux = &alc880_lg_capture_source,
3189 .unsol_event = alc880_lg_unsol_event,
3190 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003191#ifdef CONFIG_SND_HDA_POWER_SAVE
3192 .loopbacks = alc880_lg_loopbacks,
3193#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003194 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003195 [ALC880_LG_LW] = {
3196 .mixers = { alc880_lg_lw_mixer },
3197 .init_verbs = { alc880_volume_init_verbs,
3198 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003199 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003200 .dac_nids = alc880_dac_nids,
3201 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003202 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3203 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003204 .input_mux = &alc880_lg_lw_capture_source,
3205 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute,
3207 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003208#ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 .mixers = { alc880_test_mixer },
3211 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003212 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3213 .dac_nids = alc880_test_dac_nids,
3214 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3216 .channel_mode = alc880_test_modes,
3217 .input_mux = &alc880_test_capture_source,
3218 },
3219#endif
3220};
3221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222/*
3223 * Automatic parse of I/O pins from the BIOS configuration
3224 */
3225
3226#define NUM_CONTROL_ALLOC 32
3227#define NUM_VERB_ALLOC 32
3228
3229enum {
3230 ALC_CTL_WIDGET_VOL,
3231 ALC_CTL_WIDGET_MUTE,
3232 ALC_CTL_BIND_MUTE,
3233};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003234static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3236 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003237 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238};
3239
3240/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003241static int add_control(struct alc_spec *spec, int type, const char *name,
3242 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003244 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003245
3246 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3247 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3248
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 /* array + terminator */
3250 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3251 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 return -ENOMEM;
3253 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254 memcpy(knew, spec->kctl_alloc,
3255 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 kfree(spec->kctl_alloc);
3257 }
3258 spec->kctl_alloc = knew;
3259 spec->num_kctl_alloc = num;
3260 }
3261
3262 knew = &spec->kctl_alloc[spec->num_kctl_used];
3263 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003264 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003265 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 return -ENOMEM;
3267 knew->private_value = val;
3268 spec->num_kctl_used++;
3269 return 0;
3270}
3271
3272#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3273#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3274#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3275#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3276#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3277#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3278#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3279#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3280#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3281#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3282#define ALC880_PIN_CD_NID 0x1c
3283
3284/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003285static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3286 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287{
3288 hda_nid_t nid;
3289 int assigned[4];
3290 int i, j;
3291
3292 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003293 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294
3295 /* check the pins hardwired to audio widget */
3296 for (i = 0; i < cfg->line_outs; i++) {
3297 nid = cfg->line_out_pins[i];
3298 if (alc880_is_fixed_pin(nid)) {
3299 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003300 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003301 assigned[idx] = 1;
3302 }
3303 }
3304 /* left pins can be connect to any audio widget */
3305 for (i = 0; i < cfg->line_outs; i++) {
3306 nid = cfg->line_out_pins[i];
3307 if (alc880_is_fixed_pin(nid))
3308 continue;
3309 /* search for an empty channel */
3310 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003311 if (!assigned[j]) {
3312 spec->multiout.dac_nids[i] =
3313 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003314 assigned[j] = 1;
3315 break;
3316 }
3317 }
3318 }
3319 spec->multiout.num_dacs = cfg->line_outs;
3320 return 0;
3321}
3322
3323/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003324static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3325 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003326{
3327 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003328 static const char *chname[4] = {
3329 "Front", "Surround", NULL /*CLFE*/, "Side"
3330 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 hda_nid_t nid;
3332 int i, err;
3333
3334 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003335 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003336 continue;
3337 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3338 if (i == 2) {
3339 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3341 "Center Playback Volume",
3342 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3343 HDA_OUTPUT));
3344 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3347 "LFE Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3349 HDA_OUTPUT));
3350 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003352 err = add_control(spec, ALC_CTL_BIND_MUTE,
3353 "Center Playback Switch",
3354 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3355 HDA_INPUT));
3356 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003358 err = add_control(spec, ALC_CTL_BIND_MUTE,
3359 "LFE Playback Switch",
3360 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3361 HDA_INPUT));
3362 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003363 return err;
3364 } else {
3365 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 return err;
3371 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003372 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3374 HDA_INPUT));
3375 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 return err;
3377 }
3378 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 return 0;
3380}
3381
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003382/* add playback controls for speaker and HP outputs */
3383static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3384 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385{
3386 hda_nid_t nid;
3387 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003388 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003390 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391 return 0;
3392
3393 if (alc880_is_fixed_pin(pin)) {
3394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003395 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003396 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003397 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003398 else
3399 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400 /* control HP volume/switch on the output mixer amp */
3401 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003402 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3404 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3405 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003407 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3409 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3410 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411 return err;
3412 } else if (alc880_is_multi_pin(pin)) {
3413 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003414 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003415 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003416 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3417 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 return err;
3420 }
3421 return 0;
3422}
3423
3424/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003425static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3426 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003427 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003428{
3429 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003430 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431
3432 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3434 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3435 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 return err;
3437 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003438 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3440 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003441 return err;
3442 return 0;
3443}
3444
3445/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003446static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3447 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003450 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451
3452 for (i = 0; i < AUTO_PIN_LAST; i++) {
3453 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003454 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003455 err = new_analog_input(spec, cfg->input_pins[i],
3456 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003457 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 if (err < 0)
3459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003460 imux->items[imux->num_items].label =
3461 auto_pin_cfg_labels[i];
3462 imux->items[imux->num_items].index =
3463 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464 imux->num_items++;
3465 }
3466 }
3467 return 0;
3468}
3469
Kailang Yangdf694da2005-12-05 19:42:22 +01003470static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3471 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003472 int dac_idx)
3473{
3474 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type);
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003479 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec;
3482 int idx = alc880_multi_pin_idx(nid);
3483 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3484 AC_VERB_SET_CONNECT_SEL,
3485 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3486 }
3487}
3488
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003489static int get_pin_type(int line_out_type)
3490{
3491 if (line_out_type == AUTO_PIN_HP_OUT)
3492 return PIN_HP;
3493 else
3494 return PIN_OUT;
3495}
3496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497static void alc880_auto_init_multi_out(struct hda_codec *codec)
3498{
3499 struct alc_spec *spec = codec->spec;
3500 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003501
3502 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 for (i = 0; i < spec->autocfg.line_outs; i++) {
3504 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003505 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3506 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003507 }
3508}
3509
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003510static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003511{
3512 struct alc_spec *spec = codec->spec;
3513 hda_nid_t pin;
3514
Takashi Iwai82bc9552006-03-21 11:24:42 +01003515 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003516 if (pin) /* connect to front */
3517 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003518 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 if (pin) /* connect to front */
3520 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3521}
3522
3523static void alc880_auto_init_analog_input(struct hda_codec *codec)
3524{
3525 struct alc_spec *spec = codec->spec;
3526 int i;
3527
3528 for (i = 0; i < AUTO_PIN_LAST; i++) {
3529 hda_nid_t nid = spec->autocfg.input_pins[i];
3530 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003531 snd_hda_codec_write(codec, nid, 0,
3532 AC_VERB_SET_PIN_WIDGET_CONTROL,
3533 i <= AUTO_PIN_FRONT_MIC ?
3534 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003535 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003536 snd_hda_codec_write(codec, nid, 0,
3537 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 AMP_OUT_MUTE);
3539 }
3540 }
3541}
3542
3543/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003544/* return 1 if successful, 0 if the proper config is not found,
3545 * or a negative error code
3546 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003547static int alc880_parse_auto_config(struct hda_codec *codec)
3548{
3549 struct alc_spec *spec = codec->spec;
3550 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003551 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3554 alc880_ignore);
3555 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003558 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3561 if (err < 0)
3562 return err;
3563 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3564 if (err < 0)
3565 return err;
3566 err = alc880_auto_create_extra_out(spec,
3567 spec->autocfg.speaker_pins[0],
3568 "Speaker");
3569 if (err < 0)
3570 return err;
3571 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3572 "Headphone");
3573 if (err < 0)
3574 return err;
3575 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3576 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 return err;
3578
3579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3580
3581 if (spec->autocfg.dig_out_pin)
3582 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3583 if (spec->autocfg.dig_in_pin)
3584 spec->dig_in_nid = ALC880_DIGIN_NID;
3585
3586 if (spec->kctl_alloc)
3587 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3588
3589 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3590
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003591 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592 spec->input_mux = &spec->private_imux;
3593
3594 return 1;
3595}
3596
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003597/* additional initialization for auto-configuration model */
3598static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003601 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603}
3604
3605/*
3606 * OK, here we have finally the patch for ALC880
3607 */
3608
Linus Torvalds1da177e2005-04-16 15:20:36 -07003609static int patch_alc880(struct hda_codec *codec)
3610{
3611 struct alc_spec *spec;
3612 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003613 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003616 if (spec == NULL)
3617 return -ENOMEM;
3618
3619 codec->spec = spec;
3620
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003621 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3622 alc880_models,
3623 alc880_cfg_tbl);
3624 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003625 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3626 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628 }
3629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630 if (board_config == ALC880_AUTO) {
3631 /* automatic parse from the BIOS config */
3632 err = alc880_parse_auto_config(codec);
3633 if (err < 0) {
3634 alc_free(codec);
3635 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003636 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637 printk(KERN_INFO
3638 "hda_codec: Cannot set up configuration "
3639 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640 board_config = ALC880_3ST;
3641 }
3642 }
3643
Kailang Yangdf694da2005-12-05 19:42:22 +01003644 if (board_config != ALC880_AUTO)
3645 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646
3647 spec->stream_name_analog = "ALC880 Analog";
3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003651
3652 spec->stream_name_digital = "ALC880 Digital";
3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3654 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003656 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003658 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003659 /* get type */
3660 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003661 if (wcap != AC_WID_AUD_IN) {
3662 spec->adc_nids = alc880_adc_nids_alt;
3663 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 spec->mixers[spec->num_mixers] =
3665 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666 spec->num_mixers++;
3667 } else {
3668 spec->adc_nids = alc880_adc_nids;
3669 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3670 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3671 spec->num_mixers++;
3672 }
3673 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674
Takashi Iwai2134ea42008-01-10 16:53:55 +01003675 spec->vmaster_nid = 0x0c;
3676
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003678 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003679 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003680#ifdef CONFIG_SND_HDA_POWER_SAVE
3681 if (!spec->loopback.amplist)
3682 spec->loopback.amplist = alc880_loopbacks;
3683#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684
3685 return 0;
3686}
3687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689/*
3690 * ALC260 support
3691 */
3692
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003693static hda_nid_t alc260_dac_nids[1] = {
3694 /* front */
3695 0x02,
3696};
3697
3698static hda_nid_t alc260_adc_nids[1] = {
3699 /* ADC0 */
3700 0x04,
3701};
3702
Kailang Yangdf694da2005-12-05 19:42:22 +01003703static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003704 /* ADC1 */
3705 0x05,
3706};
3707
Kailang Yangdf694da2005-12-05 19:42:22 +01003708static hda_nid_t alc260_hp_adc_nids[2] = {
3709 /* ADC1, 0 */
3710 0x05, 0x04
3711};
3712
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003713/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3714 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3715 */
3716static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003717 /* ADC0, ADC1 */
3718 0x04, 0x05
3719};
3720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721#define ALC260_DIGOUT_NID 0x03
3722#define ALC260_DIGIN_NID 0x06
3723
3724static struct hda_input_mux alc260_capture_source = {
3725 .num_items = 4,
3726 .items = {
3727 { "Mic", 0x0 },
3728 { "Front Mic", 0x1 },
3729 { "Line", 0x2 },
3730 { "CD", 0x4 },
3731 },
3732};
3733
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003734/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003735 * headphone jack and the internal CD lines since these are the only pins at
3736 * which audio can appear. For flexibility, also allow the option of
3737 * recording the mixer output on the second ADC (ADC0 doesn't have a
3738 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003739 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003740static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3741 {
3742 .num_items = 3,
3743 .items = {
3744 { "Mic/Line", 0x0 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x2 },
3747 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003748 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003749 {
3750 .num_items = 4,
3751 .items = {
3752 { "Mic/Line", 0x0 },
3753 { "CD", 0x4 },
3754 { "Headphone", 0x2 },
3755 { "Mixer", 0x5 },
3756 },
3757 },
3758
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003759};
3760
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003761/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3762 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003763 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003764static struct hda_input_mux alc260_acer_capture_sources[2] = {
3765 {
3766 .num_items = 4,
3767 .items = {
3768 { "Mic", 0x0 },
3769 { "Line", 0x2 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x5 },
3772 },
3773 },
3774 {
3775 .num_items = 5,
3776 .items = {
3777 { "Mic", 0x0 },
3778 { "Line", 0x2 },
3779 { "CD", 0x4 },
3780 { "Headphone", 0x6 },
3781 { "Mixer", 0x5 },
3782 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003783 },
3784};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003785/*
3786 * This is just place-holder, so there's something for alc_build_pcms to look
3787 * at when it calculates the maximum number of channels. ALC260 has no mixer
3788 * element which allows changing the channel mode, so the verb list is
3789 * never used.
3790 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003791static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792 { 2, NULL },
3793};
3794
Kailang Yangdf694da2005-12-05 19:42:22 +01003795
3796/* Mixer combinations
3797 *
3798 * basic: base_output + input + pc_beep + capture
3799 * HP: base_output + input + capture_alt
3800 * HP_3013: hp_3013 + input + capture
3801 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003802 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003803 */
3804
3805static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003806 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003807 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3812 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003813};
Kailang Yangdf694da2005-12-05 19:42:22 +01003814
3815static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003824 { } /* end */
3825};
3826
Kailang Yangdf694da2005-12-05 19:42:22 +01003827static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3830 { } /* end */
3831};
3832
3833static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3834 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3835 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3836 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3837 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3840 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3841 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003842 { } /* end */
3843};
3844
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003845/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3846 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3847 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003848static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003849 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003850 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003851 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003852 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3853 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3854 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3855 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003856 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003857 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3858 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3859 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003860 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003861 { } /* end */
3862};
3863
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003864/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3865 * versions of the ALC260 don't act on requests to enable mic bias from NID
3866 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3867 * datasheet doesn't mention this restriction. At this stage it's not clear
3868 * whether this behaviour is intentional or is a hardware bug in chip
3869 * revisions available in early 2006. Therefore for now allow the
3870 * "Headphone Jack Mode" control to span all choices, but if it turns out
3871 * that the lack of mic bias for this NID is intentional we could change the
3872 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3873 *
3874 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3875 * don't appear to make the mic bias available from the "line" jack, even
3876 * though the NID used for this jack (0x14) can supply it. The theory is
3877 * that perhaps Acer have included blocking capacitors between the ALC260
3878 * and the output jack. If this turns out to be the case for all such
3879 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3880 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003881 *
3882 * The C20x Tablet series have a mono internal speaker which is controlled
3883 * via the chip's Mono sum widget and pin complex, so include the necessary
3884 * controls for such models. On models without a "mono speaker" the control
3885 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003886 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003887static struct snd_kcontrol_new alc260_acer_mixer[] = {
3888 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3889 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003890 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003891 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3894 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003895 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3896 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3898 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3899 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3900 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3901 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3902 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3903 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3904 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3905 { } /* end */
3906};
3907
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003908/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3909 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3910 */
3911static struct snd_kcontrol_new alc260_will_mixer[] = {
3912 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3913 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3915 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3916 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3917 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3918 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3919 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3920 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3921 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3922 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3923 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3924 { } /* end */
3925};
3926
3927/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3928 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3929 */
3930static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3931 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3932 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3934 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3935 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3936 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3937 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3938 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3939 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3940 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3941 { } /* end */
3942};
3943
Kailang Yangdf694da2005-12-05 19:42:22 +01003944/* capture mixer elements */
3945static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003946 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3947 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003948 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3949 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003950 {
3951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003952 /* The multiple "Capture Source" controls confuse alsamixer
3953 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003954 */
3955 /* .name = "Capture Source", */
3956 .name = "Input Source",
3957 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003958 .info = alc_mux_enum_info,
3959 .get = alc_mux_enum_get,
3960 .put = alc_mux_enum_put,
3961 },
3962 { } /* end */
3963};
3964
Kailang Yangdf694da2005-12-05 19:42:22 +01003965static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3966 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3967 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3968 {
3969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3970 /* The multiple "Capture Source" controls confuse alsamixer
3971 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01003972 */
3973 /* .name = "Capture Source", */
3974 .name = "Input Source",
3975 .count = 1,
3976 .info = alc_mux_enum_info,
3977 .get = alc_mux_enum_get,
3978 .put = alc_mux_enum_put,
3979 },
3980 { } /* end */
3981};
3982
3983/*
3984 * initialization verbs
3985 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003986static struct hda_verb alc260_init_verbs[] = {
3987 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003989 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003992 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003994 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003997 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003998 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004000 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004001 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004002 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004003 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004004 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4005 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004006 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007 /* set connection select to line in (default select for this ADC) */
4008 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004009 /* mute capture amp left and right */
4010 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 /* set connection select to line in (default select for this ADC) */
4012 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004013 /* set vol=0 Line-Out mixer amp left and right */
4014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4015 /* unmute pin widget amp left and right (no gain on this amp) */
4016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 /* set vol=0 HP mixer amp left and right */
4018 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4019 /* unmute pin widget amp left and right (no gain on this amp) */
4020 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4021 /* set vol=0 Mono mixer amp left and right */
4022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4023 /* unmute pin widget amp left and right (no gain on this amp) */
4024 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4025 /* unmute LINE-2 out pin */
4026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004027 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4028 * Line In 2 = 0x03
4029 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004030 /* mute analog inputs */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004037 /* mute Front out path */
4038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 /* mute Headphone out path */
4041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4043 /* mute Mono out path */
4044 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4045 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004046 { }
4047};
4048
Takashi Iwai474167d2006-05-17 17:17:43 +02004049#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004050static struct hda_verb alc260_hp_init_verbs[] = {
4051 /* Headphone and output */
4052 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4053 /* mono output */
4054 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4055 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4056 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4057 /* Mic2 (front panel) pin widget for input and vref at 80% */
4058 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4059 /* Line In pin widget for input */
4060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4061 /* Line-2 pin widget for output */
4062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4063 /* CD pin widget for input */
4064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4065 /* unmute amp left and right */
4066 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4067 /* set connection select to line in (default select for this ADC) */
4068 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4069 /* unmute Line-Out mixer amp left and right (volume = 0) */
4070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4071 /* mute pin widget amp left and right (no gain on this amp) */
4072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4073 /* unmute HP mixer amp left and right (volume = 0) */
4074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4075 /* mute pin widget amp left and right (no gain on this amp) */
4076 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4078 * Line In 2 = 0x03
4079 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004080 /* mute analog inputs */
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004086 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4087 /* Unmute Front out path */
4088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4090 /* Unmute Headphone out path */
4091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4093 /* Unmute Mono out path */
4094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4096 { }
4097};
Takashi Iwai474167d2006-05-17 17:17:43 +02004098#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004099
4100static struct hda_verb alc260_hp_3013_init_verbs[] = {
4101 /* Line out and output */
4102 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4103 /* mono output */
4104 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4105 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4107 /* Mic2 (front panel) pin widget for input and vref at 80% */
4108 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4109 /* Line In pin widget for input */
4110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4111 /* Headphone pin widget for output */
4112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4113 /* CD pin widget for input */
4114 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4115 /* unmute amp left and right */
4116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4117 /* set connection select to line in (default select for this ADC) */
4118 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4119 /* unmute Line-Out mixer amp left and right (volume = 0) */
4120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4121 /* mute pin widget amp left and right (no gain on this amp) */
4122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4123 /* unmute HP mixer amp left and right (volume = 0) */
4124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4125 /* mute pin widget amp left and right (no gain on this amp) */
4126 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004127 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4128 * Line In 2 = 0x03
4129 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004130 /* mute analog inputs */
4131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004136 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4137 /* Unmute Front out path */
4138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4140 /* Unmute Headphone out path */
4141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4143 /* Unmute Mono out path */
4144 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4145 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4146 { }
4147};
4148
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004149/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004150 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4151 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004152 */
4153static struct hda_verb alc260_fujitsu_init_verbs[] = {
4154 /* Disable all GPIOs */
4155 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4156 /* Internal speaker is connected to headphone pin */
4157 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4158 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004160 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4162 /* Ensure all other unused pins are disabled and muted. */
4163 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004165 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004166 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004167 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004168 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004171
Jonathan Woithef7ace402006-02-28 11:46:14 +01004172 /* Disable digital (SPDIF) pins */
4173 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4174 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004175
Jonathan Woithef7ace402006-02-28 11:46:14 +01004176 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4177 * when acting as an output.
4178 */
4179 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4180
4181 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4188 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004191
Jonathan Woithef7ace402006-02-28 11:46:14 +01004192 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4194 /* Unmute Line1 pin widget output buffer since it starts as an output.
4195 * If the pin mode is changed by the user the pin mode control will
4196 * take care of enabling the pin's input/output buffers as needed.
4197 * Therefore there's no need to enable the input buffer at this
4198 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004199 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004201 /* Unmute input buffer of pin widget used for Line-in (no equiv
4202 * mixer ctrl)
4203 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004204 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004205
Jonathan Woithef7ace402006-02-28 11:46:14 +01004206 /* Mute capture amp left and right */
4207 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4208 /* Set ADC connection select to match default mixer setting - line
4209 * in (on mic1 pin)
4210 */
4211 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004212
Jonathan Woithef7ace402006-02-28 11:46:14 +01004213 /* Do the same for the second ADC: mute capture input amp and
4214 * set ADC connection to line in (on mic1 pin)
4215 */
4216 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4217 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004218
Jonathan Woithef7ace402006-02-28 11:46:14 +01004219 /* Mute all inputs to mixer widget (even unconnected ones) */
4220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004228
4229 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004230};
4231
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004232/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4233 * similar laptops (adapted from Fujitsu init verbs).
4234 */
4235static struct hda_verb alc260_acer_init_verbs[] = {
4236 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4237 * the headphone jack. Turn this on and rely on the standard mute
4238 * methods whenever the user wants to turn these outputs off.
4239 */
4240 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4241 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4242 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4243 /* Internal speaker/Headphone jack is connected to Line-out pin */
4244 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4245 /* Internal microphone/Mic jack is connected to Mic1 pin */
4246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4247 /* Line In jack is connected to Line1 pin */
4248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004249 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4250 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004251 /* Ensure all other unused pins are disabled and muted. */
4252 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4253 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004254 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4255 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4258 /* Disable digital (SPDIF) pins */
4259 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4260 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4261
4262 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4263 * bus when acting as outputs.
4264 */
4265 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4266 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4267
4268 /* Start with output sum widgets muted and their output gains at min */
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4275 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4278
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004279 /* Unmute Line-out pin widget amp left and right
4280 * (no equiv mixer ctrl)
4281 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004283 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004285 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4286 * inputs. If the pin mode is changed by the user the pin mode control
4287 * will take care of enabling the pin's input/output buffers as needed.
4288 * Therefore there's no need to enable the input buffer at this
4289 * stage.
4290 */
4291 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4293
4294 /* Mute capture amp left and right */
4295 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4296 /* Set ADC connection select to match default mixer setting - mic
4297 * (on mic1 pin)
4298 */
4299 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4300
4301 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004302 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004303 */
4304 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004305 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004306
4307 /* Mute all inputs to mixer widget (even unconnected ones) */
4308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4316
4317 { }
4318};
4319
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004320static struct hda_verb alc260_will_verbs[] = {
4321 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4322 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4323 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4324 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4325 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4326 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4327 {}
4328};
4329
4330static struct hda_verb alc260_replacer_672v_verbs[] = {
4331 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4332 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4333 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4334
4335 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4336 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4337 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4338
4339 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4340 {}
4341};
4342
4343/* toggle speaker-output according to the hp-jack state */
4344static void alc260_replacer_672v_automute(struct hda_codec *codec)
4345{
4346 unsigned int present;
4347
4348 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4349 present = snd_hda_codec_read(codec, 0x0f, 0,
4350 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4351 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004352 snd_hda_codec_write_cache(codec, 0x01, 0,
4353 AC_VERB_SET_GPIO_DATA, 1);
4354 snd_hda_codec_write_cache(codec, 0x0f, 0,
4355 AC_VERB_SET_PIN_WIDGET_CONTROL,
4356 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004357 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004358 snd_hda_codec_write_cache(codec, 0x01, 0,
4359 AC_VERB_SET_GPIO_DATA, 0);
4360 snd_hda_codec_write_cache(codec, 0x0f, 0,
4361 AC_VERB_SET_PIN_WIDGET_CONTROL,
4362 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004363 }
4364}
4365
4366static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4367 unsigned int res)
4368{
4369 if ((res >> 26) == ALC880_HP_EVENT)
4370 alc260_replacer_672v_automute(codec);
4371}
4372
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004373/* Test configuration for debugging, modelled after the ALC880 test
4374 * configuration.
4375 */
4376#ifdef CONFIG_SND_DEBUG
4377static hda_nid_t alc260_test_dac_nids[1] = {
4378 0x02,
4379};
4380static hda_nid_t alc260_test_adc_nids[2] = {
4381 0x04, 0x05,
4382};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004383/* For testing the ALC260, each input MUX needs its own definition since
4384 * the signal assignments are different. This assumes that the first ADC
4385 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004386 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004387static struct hda_input_mux alc260_test_capture_sources[2] = {
4388 {
4389 .num_items = 7,
4390 .items = {
4391 { "MIC1 pin", 0x0 },
4392 { "MIC2 pin", 0x1 },
4393 { "LINE1 pin", 0x2 },
4394 { "LINE2 pin", 0x3 },
4395 { "CD pin", 0x4 },
4396 { "LINE-OUT pin", 0x5 },
4397 { "HP-OUT pin", 0x6 },
4398 },
4399 },
4400 {
4401 .num_items = 8,
4402 .items = {
4403 { "MIC1 pin", 0x0 },
4404 { "MIC2 pin", 0x1 },
4405 { "LINE1 pin", 0x2 },
4406 { "LINE2 pin", 0x3 },
4407 { "CD pin", 0x4 },
4408 { "Mixer", 0x5 },
4409 { "LINE-OUT pin", 0x6 },
4410 { "HP-OUT pin", 0x7 },
4411 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004412 },
4413};
4414static struct snd_kcontrol_new alc260_test_mixer[] = {
4415 /* Output driver widgets */
4416 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4417 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4418 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4419 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4420 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4421 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4422
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004423 /* Modes for retasking pin widgets
4424 * Note: the ALC260 doesn't seem to act on requests to enable mic
4425 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4426 * mention this restriction. At this stage it's not clear whether
4427 * this behaviour is intentional or is a hardware bug in chip
4428 * revisions available at least up until early 2006. Therefore for
4429 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4430 * choices, but if it turns out that the lack of mic bias for these
4431 * NIDs is intentional we could change their modes from
4432 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4433 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004434 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4435 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4436 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4437 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4438 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4439 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4440
4441 /* Loopback mixer controls */
4442 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4443 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4444 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4445 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4446 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4447 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4448 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4449 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4450 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4451 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4452 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4453 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4454 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4455 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4456 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4457 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004458
4459 /* Controls for GPIO pins, assuming they are configured as outputs */
4460 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4461 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4462 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4463 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4464
Jonathan Woithe92621f12006-02-28 11:47:47 +01004465 /* Switches to allow the digital IO pins to be enabled. The datasheet
4466 * is ambigious as to which NID is which; testing on laptops which
4467 * make this output available should provide clarification.
4468 */
4469 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4470 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4471
Jonathan Woithef8225f62008-01-08 12:16:54 +01004472 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4473 * this output to turn on an external amplifier.
4474 */
4475 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4476 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4477
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004478 { } /* end */
4479};
4480static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004481 /* Enable all GPIOs as outputs with an initial value of 0 */
4482 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4483 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4484 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4485
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004486 /* Enable retasking pins as output, initially without power amp */
4487 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4488 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4491 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4493
Jonathan Woithe92621f12006-02-28 11:47:47 +01004494 /* Disable digital (SPDIF) pins initially, but users can enable
4495 * them via a mixer switch. In the case of SPDIF-out, this initverb
4496 * payload also sets the generation to 0, output to be in "consumer"
4497 * PCM format, copyright asserted, no pre-emphasis and no validity
4498 * control.
4499 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004500 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4501 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4502
Jonathan Woithef7ace402006-02-28 11:46:14 +01004503 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004504 * OUT1 sum bus when acting as an output.
4505 */
4506 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4507 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4508 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4509 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4510
4511 /* Start with output sum widgets muted and their output gains at min */
4512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004522 /* Unmute retasking pin widget output buffers since the default
4523 * state appears to be output. As the pin mode is changed by the
4524 * user the pin mode control will take care of enabling the pin's
4525 * input/output buffers as needed.
4526 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 /* Also unmute the mono-out pin widget */
4534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4535
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004536 /* Mute capture amp left and right */
4537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004538 /* Set ADC connection select to match default mixer setting (mic1
4539 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004540 */
4541 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4542
4543 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004544 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004545 */
4546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4547 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4548
4549 /* Mute all inputs to mixer widget (even unconnected ones) */
4550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4558
4559 { }
4560};
4561#endif
4562
Takashi Iwai63300792008-01-24 15:31:36 +01004563#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4564#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004565
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004566#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4567#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4568
Kailang Yangdf694da2005-12-05 19:42:22 +01004569/*
4570 * for BIOS auto-configuration
4571 */
4572
4573static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4574 const char *pfx)
4575{
4576 hda_nid_t nid_vol;
4577 unsigned long vol_val, sw_val;
4578 char name[32];
4579 int err;
4580
4581 if (nid >= 0x0f && nid < 0x11) {
4582 nid_vol = nid - 0x7;
4583 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4584 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4585 } else if (nid == 0x11) {
4586 nid_vol = nid - 0x7;
4587 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4588 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4589 } else if (nid >= 0x12 && nid <= 0x15) {
4590 nid_vol = 0x08;
4591 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4592 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4593 } else
4594 return 0; /* N/A */
4595
4596 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004597 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4598 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004599 return err;
4600 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004601 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4602 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004603 return err;
4604 return 1;
4605}
4606
4607/* add playback controls from the parsed DAC table */
4608static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4609 const struct auto_pin_cfg *cfg)
4610{
4611 hda_nid_t nid;
4612 int err;
4613
4614 spec->multiout.num_dacs = 1;
4615 spec->multiout.dac_nids = spec->private_dac_nids;
4616 spec->multiout.dac_nids[0] = 0x02;
4617
4618 nid = cfg->line_out_pins[0];
4619 if (nid) {
4620 err = alc260_add_playback_controls(spec, nid, "Front");
4621 if (err < 0)
4622 return err;
4623 }
4624
Takashi Iwai82bc9552006-03-21 11:24:42 +01004625 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004626 if (nid) {
4627 err = alc260_add_playback_controls(spec, nid, "Speaker");
4628 if (err < 0)
4629 return err;
4630 }
4631
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004632 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004633 if (nid) {
4634 err = alc260_add_playback_controls(spec, nid, "Headphone");
4635 if (err < 0)
4636 return err;
4637 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004639}
4640
4641/* create playback/capture controls for input pins */
4642static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4643 const struct auto_pin_cfg *cfg)
4644{
Kailang Yangdf694da2005-12-05 19:42:22 +01004645 struct hda_input_mux *imux = &spec->private_imux;
4646 int i, err, idx;
4647
4648 for (i = 0; i < AUTO_PIN_LAST; i++) {
4649 if (cfg->input_pins[i] >= 0x12) {
4650 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004651 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 auto_pin_cfg_labels[i], idx,
4653 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004654 if (err < 0)
4655 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004656 imux->items[imux->num_items].label =
4657 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004658 imux->items[imux->num_items].index = idx;
4659 imux->num_items++;
4660 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004661 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004662 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004663 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664 auto_pin_cfg_labels[i], idx,
4665 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004666 if (err < 0)
4667 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004668 imux->items[imux->num_items].label =
4669 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004670 imux->items[imux->num_items].index = idx;
4671 imux->num_items++;
4672 }
4673 }
4674 return 0;
4675}
4676
4677static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4678 hda_nid_t nid, int pin_type,
4679 int sel_idx)
4680{
4681 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004682 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4683 pin_type);
4684 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4685 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004686 /* need the manual connection? */
4687 if (nid >= 0x12) {
4688 int idx = nid - 0x12;
4689 snd_hda_codec_write(codec, idx + 0x0b, 0,
4690 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004691 }
4692}
4693
4694static void alc260_auto_init_multi_out(struct hda_codec *codec)
4695{
4696 struct alc_spec *spec = codec->spec;
4697 hda_nid_t nid;
4698
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004699 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004700 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004701 if (nid) {
4702 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4703 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4704 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004705
Takashi Iwai82bc9552006-03-21 11:24:42 +01004706 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004707 if (nid)
4708 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4709
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004710 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004711 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004712 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004713}
Kailang Yangdf694da2005-12-05 19:42:22 +01004714
4715#define ALC260_PIN_CD_NID 0x16
4716static void alc260_auto_init_analog_input(struct hda_codec *codec)
4717{
4718 struct alc_spec *spec = codec->spec;
4719 int i;
4720
4721 for (i = 0; i < AUTO_PIN_LAST; i++) {
4722 hda_nid_t nid = spec->autocfg.input_pins[i];
4723 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004724 snd_hda_codec_write(codec, nid, 0,
4725 AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 i <= AUTO_PIN_FRONT_MIC ?
4727 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004728 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 snd_hda_codec_write(codec, nid, 0,
4730 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 AMP_OUT_MUTE);
4732 }
4733 }
4734}
4735
4736/*
4737 * generic initialization of ADC, input mixers and output mixers
4738 */
4739static struct hda_verb alc260_volume_init_verbs[] = {
4740 /*
4741 * Unmute ADC0-1 and set the default input to mic-in
4742 */
4743 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4744 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4745 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4746 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4747
4748 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4749 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004750 * Note: PASD motherboards uses the Line In 2 as the input for
4751 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004752 */
4753 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004754 /* mute analog inputs */
4755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004760
4761 /*
4762 * Set up output mixers (0x08 - 0x0a)
4763 */
4764 /* set vol=0 to output mixers */
4765 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4767 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4768 /* set up input amps for analog loopback */
4769 /* Amp Indices: DAC = 0, mixer = 1 */
4770 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4772 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4774 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4775 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4776
4777 { }
4778};
4779
4780static int alc260_parse_auto_config(struct hda_codec *codec)
4781{
4782 struct alc_spec *spec = codec->spec;
4783 unsigned int wcap;
4784 int err;
4785 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4786
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004787 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4788 alc260_ignore);
4789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4792 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004793 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004794 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004795 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004796 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4797 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004798 return err;
4799
4800 spec->multiout.max_channels = 2;
4801
4802 if (spec->autocfg.dig_out_pin)
4803 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4804 if (spec->kctl_alloc)
4805 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4806
4807 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4808
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004809 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004810 spec->input_mux = &spec->private_imux;
4811
4812 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004813 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004814 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4815 if (wcap != AC_WID_AUD_IN) {
4816 spec->adc_nids = alc260_adc_nids_alt;
4817 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4818 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004819 } else {
4820 spec->adc_nids = alc260_adc_nids;
4821 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4822 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004823 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004824 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004825
4826 return 1;
4827}
4828
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004829/* additional initialization for auto-configuration model */
4830static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004831{
Kailang Yangdf694da2005-12-05 19:42:22 +01004832 alc260_auto_init_multi_out(codec);
4833 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004834}
4835
Takashi Iwaicb53c622007-08-10 17:21:45 +02004836#ifdef CONFIG_SND_HDA_POWER_SAVE
4837static struct hda_amp_list alc260_loopbacks[] = {
4838 { 0x07, HDA_INPUT, 0 },
4839 { 0x07, HDA_INPUT, 1 },
4840 { 0x07, HDA_INPUT, 2 },
4841 { 0x07, HDA_INPUT, 3 },
4842 { 0x07, HDA_INPUT, 4 },
4843 { } /* end */
4844};
4845#endif
4846
Kailang Yangdf694da2005-12-05 19:42:22 +01004847/*
4848 * ALC260 configurations
4849 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004850static const char *alc260_models[ALC260_MODEL_LAST] = {
4851 [ALC260_BASIC] = "basic",
4852 [ALC260_HP] = "hp",
4853 [ALC260_HP_3013] = "hp-3013",
4854 [ALC260_FUJITSU_S702X] = "fujitsu",
4855 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004856 [ALC260_WILL] = "will",
4857 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004858#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004859 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004860#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004861 [ALC260_AUTO] = "auto",
4862};
4863
4864static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004865 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004866 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004867 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004868 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004869 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4870 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4871 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4872 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4873 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4874 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4875 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4876 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4877 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4878 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4879 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4880 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004881 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004882 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004883 {}
4884};
4885
Kailang Yangdf694da2005-12-05 19:42:22 +01004886static struct alc_config_preset alc260_presets[] = {
4887 [ALC260_BASIC] = {
4888 .mixers = { alc260_base_output_mixer,
4889 alc260_input_mixer,
4890 alc260_pc_beep_mixer,
4891 alc260_capture_mixer },
4892 .init_verbs = { alc260_init_verbs },
4893 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4894 .dac_nids = alc260_dac_nids,
4895 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4896 .adc_nids = alc260_adc_nids,
4897 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4898 .channel_mode = alc260_modes,
4899 .input_mux = &alc260_capture_source,
4900 },
4901 [ALC260_HP] = {
4902 .mixers = { alc260_base_output_mixer,
4903 alc260_input_mixer,
4904 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004905 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004906 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4907 .dac_nids = alc260_dac_nids,
4908 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4909 .adc_nids = alc260_hp_adc_nids,
4910 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4911 .channel_mode = alc260_modes,
4912 .input_mux = &alc260_capture_source,
4913 },
4914 [ALC260_HP_3013] = {
4915 .mixers = { alc260_hp_3013_mixer,
4916 alc260_input_mixer,
4917 alc260_capture_alt_mixer },
4918 .init_verbs = { alc260_hp_3013_init_verbs },
4919 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4920 .dac_nids = alc260_dac_nids,
4921 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4922 .adc_nids = alc260_hp_adc_nids,
4923 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4924 .channel_mode = alc260_modes,
4925 .input_mux = &alc260_capture_source,
4926 },
4927 [ALC260_FUJITSU_S702X] = {
4928 .mixers = { alc260_fujitsu_mixer,
4929 alc260_capture_mixer },
4930 .init_verbs = { alc260_fujitsu_init_verbs },
4931 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4932 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004933 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4934 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004935 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4936 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004937 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4938 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004939 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004940 [ALC260_ACER] = {
4941 .mixers = { alc260_acer_mixer,
4942 alc260_capture_mixer },
4943 .init_verbs = { alc260_acer_init_verbs },
4944 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4945 .dac_nids = alc260_dac_nids,
4946 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4947 .adc_nids = alc260_dual_adc_nids,
4948 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4949 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004950 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4951 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004952 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004953 [ALC260_WILL] = {
4954 .mixers = { alc260_will_mixer,
4955 alc260_capture_mixer },
4956 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4957 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4958 .dac_nids = alc260_dac_nids,
4959 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4960 .adc_nids = alc260_adc_nids,
4961 .dig_out_nid = ALC260_DIGOUT_NID,
4962 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4963 .channel_mode = alc260_modes,
4964 .input_mux = &alc260_capture_source,
4965 },
4966 [ALC260_REPLACER_672V] = {
4967 .mixers = { alc260_replacer_672v_mixer,
4968 alc260_capture_mixer },
4969 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4970 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4971 .dac_nids = alc260_dac_nids,
4972 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4973 .adc_nids = alc260_adc_nids,
4974 .dig_out_nid = ALC260_DIGOUT_NID,
4975 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4976 .channel_mode = alc260_modes,
4977 .input_mux = &alc260_capture_source,
4978 .unsol_event = alc260_replacer_672v_unsol_event,
4979 .init_hook = alc260_replacer_672v_automute,
4980 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004981#ifdef CONFIG_SND_DEBUG
4982 [ALC260_TEST] = {
4983 .mixers = { alc260_test_mixer,
4984 alc260_capture_mixer },
4985 .init_verbs = { alc260_test_init_verbs },
4986 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4987 .dac_nids = alc260_test_dac_nids,
4988 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4989 .adc_nids = alc260_test_adc_nids,
4990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4991 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004992 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4993 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004994 },
4995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004996};
4997
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998static int patch_alc260(struct hda_codec *codec)
4999{
5000 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005001 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005002
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005004 if (spec == NULL)
5005 return -ENOMEM;
5006
5007 codec->spec = spec;
5008
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005009 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5010 alc260_models,
5011 alc260_cfg_tbl);
5012 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005013 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5014 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005015 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005016 }
5017
Kailang Yangdf694da2005-12-05 19:42:22 +01005018 if (board_config == ALC260_AUTO) {
5019 /* automatic parse from the BIOS config */
5020 err = alc260_parse_auto_config(codec);
5021 if (err < 0) {
5022 alc_free(codec);
5023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005024 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005025 printk(KERN_INFO
5026 "hda_codec: Cannot set up configuration "
5027 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005028 board_config = ALC260_BASIC;
5029 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005030 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005031
Kailang Yangdf694da2005-12-05 19:42:22 +01005032 if (board_config != ALC260_AUTO)
5033 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005034
5035 spec->stream_name_analog = "ALC260 Analog";
5036 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5037 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5038
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005039 spec->stream_name_digital = "ALC260 Digital";
5040 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5041 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5042
Takashi Iwai2134ea42008-01-10 16:53:55 +01005043 spec->vmaster_nid = 0x08;
5044
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005046 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005047 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005048#ifdef CONFIG_SND_HDA_POWER_SAVE
5049 if (!spec->loopback.amplist)
5050 spec->loopback.amplist = alc260_loopbacks;
5051#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005052
5053 return 0;
5054}
5055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005056
Linus Torvalds1da177e2005-04-16 15:20:36 -07005057/*
5058 * ALC882 support
5059 *
5060 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5061 * configuration. Each pin widget can choose any input DACs and a mixer.
5062 * Each ADC is connected from a mixer of all inputs. This makes possible
5063 * 6-channel independent captures.
5064 *
5065 * In addition, an independent DAC for the multi-playback (not used in this
5066 * driver yet).
5067 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005068#define ALC882_DIGOUT_NID 0x06
5069#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005070
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005071static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005072 { 8, NULL }
5073};
5074
5075static hda_nid_t alc882_dac_nids[4] = {
5076 /* front, rear, clfe, rear_surr */
5077 0x02, 0x03, 0x04, 0x05
5078};
5079
Kailang Yangdf694da2005-12-05 19:42:22 +01005080/* identical with ALC880 */
5081#define alc882_adc_nids alc880_adc_nids
5082#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005083
5084/* input MUX */
5085/* FIXME: should be a matrix-type input source selection */
5086
5087static struct hda_input_mux alc882_capture_source = {
5088 .num_items = 4,
5089 .items = {
5090 { "Mic", 0x0 },
5091 { "Front Mic", 0x1 },
5092 { "Line", 0x2 },
5093 { "CD", 0x4 },
5094 },
5095};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096#define alc882_mux_enum_info alc_mux_enum_info
5097#define alc882_mux_enum_get alc_mux_enum_get
5098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5100 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005101{
5102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5103 struct alc_spec *spec = codec->spec;
5104 const struct hda_input_mux *imux = spec->input_mux;
5105 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5106 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5107 hda_nid_t nid = capture_mixers[adc_idx];
5108 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5109 unsigned int i, idx;
5110
5111 idx = ucontrol->value.enumerated.item[0];
5112 if (idx >= imux->num_items)
5113 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005114 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005115 return 0;
5116 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005117 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5118 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005119 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005120 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005121 }
5122 *cur_val = idx;
5123 return 1;
5124}
5125
Kailang Yangdf694da2005-12-05 19:42:22 +01005126/*
Kailang Yang272a5272007-05-14 11:00:38 +02005127 * 2ch mode
5128 */
5129static struct hda_verb alc882_3ST_ch2_init[] = {
5130 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5131 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5132 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5133 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5134 { } /* end */
5135};
5136
5137/*
5138 * 6ch mode
5139 */
5140static struct hda_verb alc882_3ST_ch6_init[] = {
5141 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5142 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5143 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5146 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5147 { } /* end */
5148};
5149
5150static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5151 { 2, alc882_3ST_ch2_init },
5152 { 6, alc882_3ST_ch6_init },
5153};
5154
5155/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005156 * 6ch mode
5157 */
5158static struct hda_verb alc882_sixstack_ch6_init[] = {
5159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5163 { } /* end */
5164};
5165
5166/*
5167 * 8ch mode
5168 */
5169static struct hda_verb alc882_sixstack_ch8_init[] = {
5170 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5171 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5172 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5173 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5174 { } /* end */
5175};
5176
5177static struct hda_channel_mode alc882_sixstack_modes[2] = {
5178 { 6, alc882_sixstack_ch6_init },
5179 { 8, alc882_sixstack_ch8_init },
5180};
5181
Takashi Iwai87350ad2007-08-16 18:19:38 +02005182/*
5183 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5184 */
5185
5186/*
5187 * 2ch mode
5188 */
5189static struct hda_verb alc885_mbp_ch2_init[] = {
5190 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5191 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5193 { } /* end */
5194};
5195
5196/*
5197 * 6ch mode
5198 */
5199static struct hda_verb alc885_mbp_ch6_init[] = {
5200 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5201 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5202 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5203 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5204 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5205 { } /* end */
5206};
5207
5208static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5209 { 2, alc885_mbp_ch2_init },
5210 { 6, alc885_mbp_ch6_init },
5211};
5212
5213
Linus Torvalds1da177e2005-04-16 15:20:36 -07005214/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5215 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5216 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005217static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005220 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005221 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005222 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005224 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5225 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005226 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005227 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005237 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5239 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5240 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005241 { } /* end */
5242};
5243
Takashi Iwai87350ad2007-08-16 18:19:38 +02005244static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5246 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5247 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5248 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5250 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5252 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005253 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5255 { } /* end */
5256};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005257static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5267 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5268 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5269 { } /* end */
5270};
5271
Kailang Yang272a5272007-05-14 11:00:38 +02005272static struct snd_kcontrol_new alc882_targa_mixer[] = {
5273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005283 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005285 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005286 { } /* end */
5287};
5288
5289/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5290 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5291 */
5292static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5294 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5296 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5297 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5298 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5300 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5301 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5302 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005306 { } /* end */
5307};
5308
Takashi Iwai914759b2007-09-06 14:52:04 +02005309static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5320 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5321 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5322 { } /* end */
5323};
5324
Kailang Yangdf694da2005-12-05 19:42:22 +01005325static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5326 {
5327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5328 .name = "Channel Mode",
5329 .info = alc_ch_mode_info,
5330 .get = alc_ch_mode_get,
5331 .put = alc_ch_mode_put,
5332 },
5333 { } /* end */
5334};
5335
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336static struct hda_verb alc882_init_verbs[] = {
5337 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005341 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005345 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005349 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005354 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005357 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005358 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005362 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005366 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005367 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005368 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005369 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005370 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5373 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5376 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5379 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005383 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005384 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005385
5386 /* FIXME: use matrix-type input source selection */
5387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005393 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005398 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5403 /* ADC1: mute amp left and right */
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005406 /* ADC2: mute amp left and right */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005409 /* ADC3: mute amp left and right */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005411 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005412
5413 { }
5414};
5415
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005416static struct hda_verb alc882_eapd_verbs[] = {
5417 /* change to EAPD mode */
5418 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005419 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005420 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005421};
5422
Tobin Davis9102cd12006-12-15 10:02:12 +01005423/* Mac Pro test */
5424static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5432 { } /* end */
5433};
5434
5435static struct hda_verb alc882_macpro_init_verbs[] = {
5436 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 /* Front Pin: output 0 (0x0c) */
5441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5444 /* Front Mic pin: input vref at 80% */
5445 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5446 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5447 /* Speaker: output */
5448 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5450 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5451 /* Headphone output (output 0 - 0x0c) */
5452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5454 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5455
5456 /* FIXME: use matrix-type input source selection */
5457 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5458 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5463 /* Input mixer2 */
5464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5468 /* Input mixer3 */
5469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5473 /* ADC1: mute amp left and right */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5476 /* ADC2: mute amp left and right */
5477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5479 /* ADC3: mute amp left and right */
5480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5482
5483 { }
5484};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005485
Takashi Iwai87350ad2007-08-16 18:19:38 +02005486/* Macbook Pro rev3 */
5487static struct hda_verb alc885_mbp3_init_verbs[] = {
5488 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 /* Rear mixer */
5493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5496 /* Front Pin: output 0 (0x0c) */
5497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5500 /* HP Pin: output 0 (0x0d) */
5501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5504 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5505 /* Mic (rear) pin: input vref at 80% */
5506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5508 /* Front Mic pin: input vref at 80% */
5509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5511 /* Line In pin: use output 1 when in LineOut mode */
5512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5514 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5515
5516 /* FIXME: use matrix-type input source selection */
5517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5518 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5523 /* Input mixer2 */
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5528 /* Input mixer3 */
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5533 /* ADC1: mute amp left and right */
5534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5536 /* ADC2: mute amp left and right */
5537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5539 /* ADC3: mute amp left and right */
5540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5541 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5542
5543 { }
5544};
5545
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005546/* iMac 24 mixer. */
5547static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5548 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5549 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5550 { } /* end */
5551};
5552
5553/* iMac 24 init verbs. */
5554static struct hda_verb alc885_imac24_init_verbs[] = {
5555 /* Internal speakers: output 0 (0x0c) */
5556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5559 /* Internal speakers: output 0 (0x0c) */
5560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5563 /* Headphone: output 0 (0x0c) */
5564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5566 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5568 /* Front Mic: input vref at 80% */
5569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5571 { }
5572};
5573
5574/* Toggle speaker-output according to the hp-jack state */
5575static void alc885_imac24_automute(struct hda_codec *codec)
5576{
5577 unsigned int present;
5578
5579 present = snd_hda_codec_read(codec, 0x14, 0,
5580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005581 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5582 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5583 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5584 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005585}
5586
5587/* Processes unsolicited events. */
5588static void alc885_imac24_unsol_event(struct hda_codec *codec,
5589 unsigned int res)
5590{
5591 /* Headphone insertion or removal. */
5592 if ((res >> 26) == ALC880_HP_EVENT)
5593 alc885_imac24_automute(codec);
5594}
5595
Takashi Iwai87350ad2007-08-16 18:19:38 +02005596static void alc885_mbp3_automute(struct hda_codec *codec)
5597{
5598 unsigned int present;
5599
5600 present = snd_hda_codec_read(codec, 0x15, 0,
5601 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5605 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5606
5607}
5608static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5609 unsigned int res)
5610{
5611 /* Headphone insertion or removal. */
5612 if ((res >> 26) == ALC880_HP_EVENT)
5613 alc885_mbp3_automute(codec);
5614}
5615
5616
Kailang Yang272a5272007-05-14 11:00:38 +02005617static struct hda_verb alc882_targa_verbs[] = {
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5620
5621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5623
5624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5627
5628 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5629 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5630 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5631 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5632 { } /* end */
5633};
5634
5635/* toggle speaker-output according to the hp-jack state */
5636static void alc882_targa_automute(struct hda_codec *codec)
5637{
5638 unsigned int present;
5639
5640 present = snd_hda_codec_read(codec, 0x14, 0,
5641 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005642 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5643 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005644 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5645 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005646}
5647
5648static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5649{
5650 /* Looks like the unsol event is incompatible with the standard
5651 * definition. 4bit tag is placed at 26 bit!
5652 */
5653 if (((res >> 26) == ALC880_HP_EVENT)) {
5654 alc882_targa_automute(codec);
5655 }
5656}
5657
5658static struct hda_verb alc882_asus_a7j_verbs[] = {
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5661
5662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5665
5666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5669
5670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5673 { } /* end */
5674};
5675
Takashi Iwai914759b2007-09-06 14:52:04 +02005676static struct hda_verb alc882_asus_a7m_verbs[] = {
5677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5679
5680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5683
5684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5686 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5687
5688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5691 { } /* end */
5692};
5693
Tobin Davis9102cd12006-12-15 10:02:12 +01005694static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5695{
5696 unsigned int gpiostate, gpiomask, gpiodir;
5697
5698 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5699 AC_VERB_GET_GPIO_DATA, 0);
5700
5701 if (!muted)
5702 gpiostate |= (1 << pin);
5703 else
5704 gpiostate &= ~(1 << pin);
5705
5706 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5707 AC_VERB_GET_GPIO_MASK, 0);
5708 gpiomask |= (1 << pin);
5709
5710 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5711 AC_VERB_GET_GPIO_DIRECTION, 0);
5712 gpiodir |= (1 << pin);
5713
5714
5715 snd_hda_codec_write(codec, codec->afg, 0,
5716 AC_VERB_SET_GPIO_MASK, gpiomask);
5717 snd_hda_codec_write(codec, codec->afg, 0,
5718 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5719
5720 msleep(1);
5721
5722 snd_hda_codec_write(codec, codec->afg, 0,
5723 AC_VERB_SET_GPIO_DATA, gpiostate);
5724}
5725
Takashi Iwai7debbe52007-08-16 15:01:03 +02005726/* set up GPIO at initialization */
5727static void alc885_macpro_init_hook(struct hda_codec *codec)
5728{
5729 alc882_gpio_mute(codec, 0, 0);
5730 alc882_gpio_mute(codec, 1, 0);
5731}
5732
5733/* set up GPIO and update auto-muting at initialization */
5734static void alc885_imac24_init_hook(struct hda_codec *codec)
5735{
5736 alc885_macpro_init_hook(codec);
5737 alc885_imac24_automute(codec);
5738}
5739
Kailang Yangdf694da2005-12-05 19:42:22 +01005740/*
5741 * generic initialization of ADC, input mixers and output mixers
5742 */
5743static struct hda_verb alc882_auto_init_verbs[] = {
5744 /*
5745 * Unmute ADC0-2 and set the default input to mic-in
5746 */
5747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5753
Takashi Iwaicb53c622007-08-10 17:21:45 +02005754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005755 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005756 * Note: PASD motherboards uses the Line In 2 as the input for
5757 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005758 */
5759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005765
5766 /*
5767 * Set up output mixers (0x0c - 0x0f)
5768 */
5769 /* set vol=0 to output mixers */
5770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5774 /* set up input amps for analog loopback */
5775 /* Amp Indices: DAC = 0, mixer = 1 */
5776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5784 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5785 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5786
5787 /* FIXME: use matrix-type input source selection */
5788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5789 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5794 /* Input mixer2 */
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5799 /* Input mixer3 */
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5804
5805 { }
5806};
5807
5808/* capture mixer elements */
5809static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5810 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5811 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5812 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5813 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5814 {
5815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5816 /* The multiple "Capture Source" controls confuse alsamixer
5817 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 */
5819 /* .name = "Capture Source", */
5820 .name = "Input Source",
5821 .count = 2,
5822 .info = alc882_mux_enum_info,
5823 .get = alc882_mux_enum_get,
5824 .put = alc882_mux_enum_put,
5825 },
5826 { } /* end */
5827};
5828
5829static struct snd_kcontrol_new alc882_capture_mixer[] = {
5830 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5833 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5834 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5835 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5836 {
5837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5838 /* The multiple "Capture Source" controls confuse alsamixer
5839 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 */
5841 /* .name = "Capture Source", */
5842 .name = "Input Source",
5843 .count = 3,
5844 .info = alc882_mux_enum_info,
5845 .get = alc882_mux_enum_get,
5846 .put = alc882_mux_enum_put,
5847 },
5848 { } /* end */
5849};
5850
Takashi Iwaicb53c622007-08-10 17:21:45 +02005851#ifdef CONFIG_SND_HDA_POWER_SAVE
5852#define alc882_loopbacks alc880_loopbacks
5853#endif
5854
Kailang Yangdf694da2005-12-05 19:42:22 +01005855/* pcm configuration: identiacal with ALC880 */
5856#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5857#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5858#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5859#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5860
5861/*
5862 * configuration and preset
5863 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005864static const char *alc882_models[ALC882_MODEL_LAST] = {
5865 [ALC882_3ST_DIG] = "3stack-dig",
5866 [ALC882_6ST_DIG] = "6stack-dig",
5867 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005868 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005869 [ALC882_TARGA] = "targa",
5870 [ALC882_ASUS_A7J] = "asus-a7j",
5871 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005872 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005873 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005874 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005875 [ALC882_AUTO] = "auto",
5876};
5877
5878static struct snd_pci_quirk alc882_cfg_tbl[] = {
5879 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005880 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005881 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005882 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005883 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005884 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005885 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005886 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5887 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5888 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5889 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 {}
5891};
5892
5893static struct alc_config_preset alc882_presets[] = {
5894 [ALC882_3ST_DIG] = {
5895 .mixers = { alc882_base_mixer },
5896 .init_verbs = { alc882_init_verbs },
5897 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5898 .dac_nids = alc882_dac_nids,
5899 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005900 .dig_in_nid = ALC882_DIGIN_NID,
5901 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5902 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005903 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005904 .input_mux = &alc882_capture_source,
5905 },
5906 [ALC882_6ST_DIG] = {
5907 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5908 .init_verbs = { alc882_init_verbs },
5909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5910 .dac_nids = alc882_dac_nids,
5911 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005912 .dig_in_nid = ALC882_DIGIN_NID,
5913 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5914 .channel_mode = alc882_sixstack_modes,
5915 .input_mux = &alc882_capture_source,
5916 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005917 [ALC882_ARIMA] = {
5918 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5919 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5920 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5921 .dac_nids = alc882_dac_nids,
5922 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5923 .channel_mode = alc882_sixstack_modes,
5924 .input_mux = &alc882_capture_source,
5925 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005926 [ALC882_W2JC] = {
5927 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5928 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5929 alc880_gpio1_init_verbs },
5930 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5931 .dac_nids = alc882_dac_nids,
5932 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5933 .channel_mode = alc880_threestack_modes,
5934 .need_dac_fix = 1,
5935 .input_mux = &alc882_capture_source,
5936 .dig_out_nid = ALC882_DIGOUT_NID,
5937 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005938 [ALC885_MBP3] = {
5939 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5940 .init_verbs = { alc885_mbp3_init_verbs,
5941 alc880_gpio1_init_verbs },
5942 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5943 .dac_nids = alc882_dac_nids,
5944 .channel_mode = alc885_mbp_6ch_modes,
5945 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5946 .input_mux = &alc882_capture_source,
5947 .dig_out_nid = ALC882_DIGOUT_NID,
5948 .dig_in_nid = ALC882_DIGIN_NID,
5949 .unsol_event = alc885_mbp3_unsol_event,
5950 .init_hook = alc885_mbp3_automute,
5951 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005952 [ALC885_MACPRO] = {
5953 .mixers = { alc882_macpro_mixer },
5954 .init_verbs = { alc882_macpro_init_verbs },
5955 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5956 .dac_nids = alc882_dac_nids,
5957 .dig_out_nid = ALC882_DIGOUT_NID,
5958 .dig_in_nid = ALC882_DIGIN_NID,
5959 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5960 .channel_mode = alc882_ch_modes,
5961 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005962 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005963 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005964 [ALC885_IMAC24] = {
5965 .mixers = { alc885_imac24_mixer },
5966 .init_verbs = { alc885_imac24_init_verbs },
5967 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5968 .dac_nids = alc882_dac_nids,
5969 .dig_out_nid = ALC882_DIGOUT_NID,
5970 .dig_in_nid = ALC882_DIGIN_NID,
5971 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5972 .channel_mode = alc882_ch_modes,
5973 .input_mux = &alc882_capture_source,
5974 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005975 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005976 },
Kailang Yang272a5272007-05-14 11:00:38 +02005977 [ALC882_TARGA] = {
5978 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5979 alc882_capture_mixer },
5980 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5981 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5982 .dac_nids = alc882_dac_nids,
5983 .dig_out_nid = ALC882_DIGOUT_NID,
5984 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5985 .adc_nids = alc882_adc_nids,
5986 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5987 .channel_mode = alc882_3ST_6ch_modes,
5988 .need_dac_fix = 1,
5989 .input_mux = &alc882_capture_source,
5990 .unsol_event = alc882_targa_unsol_event,
5991 .init_hook = alc882_targa_automute,
5992 },
5993 [ALC882_ASUS_A7J] = {
5994 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5995 alc882_capture_mixer },
5996 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5997 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5998 .dac_nids = alc882_dac_nids,
5999 .dig_out_nid = ALC882_DIGOUT_NID,
6000 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6001 .adc_nids = alc882_adc_nids,
6002 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6003 .channel_mode = alc882_3ST_6ch_modes,
6004 .need_dac_fix = 1,
6005 .input_mux = &alc882_capture_source,
6006 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006007 [ALC882_ASUS_A7M] = {
6008 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6009 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6010 alc880_gpio1_init_verbs,
6011 alc882_asus_a7m_verbs },
6012 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6013 .dac_nids = alc882_dac_nids,
6014 .dig_out_nid = ALC882_DIGOUT_NID,
6015 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6016 .channel_mode = alc880_threestack_modes,
6017 .need_dac_fix = 1,
6018 .input_mux = &alc882_capture_source,
6019 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006020};
6021
6022
6023/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006024 * Pin config fixes
6025 */
6026enum {
6027 PINFIX_ABIT_AW9D_MAX
6028};
6029
6030static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6031 { 0x15, 0x01080104 }, /* side */
6032 { 0x16, 0x01011012 }, /* rear */
6033 { 0x17, 0x01016011 }, /* clfe */
6034 { }
6035};
6036
6037static const struct alc_pincfg *alc882_pin_fixes[] = {
6038 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6039};
6040
6041static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6042 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6043 {}
6044};
6045
6046/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 * BIOS auto configuration
6048 */
6049static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6050 hda_nid_t nid, int pin_type,
6051 int dac_idx)
6052{
6053 /* set as output */
6054 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006055 int idx;
6056
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6058 idx = 4;
6059 else
6060 idx = spec->multiout.dac_nids[dac_idx] - 2;
6061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006062 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6063 pin_type);
6064 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6065 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6067
6068}
6069
6070static void alc882_auto_init_multi_out(struct hda_codec *codec)
6071{
6072 struct alc_spec *spec = codec->spec;
6073 int i;
6074
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006075 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006076 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006077 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006078 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006079 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006080 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006081 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006082 }
6083}
6084
6085static void alc882_auto_init_hp_out(struct hda_codec *codec)
6086{
6087 struct alc_spec *spec = codec->spec;
6088 hda_nid_t pin;
6089
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006090 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006091 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006092 /* use dac 0 */
6093 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006094}
6095
6096#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6097#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6098
6099static void alc882_auto_init_analog_input(struct hda_codec *codec)
6100{
6101 struct alc_spec *spec = codec->spec;
6102 int i;
6103
6104 for (i = 0; i < AUTO_PIN_LAST; i++) {
6105 hda_nid_t nid = spec->autocfg.input_pins[i];
6106 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006107 snd_hda_codec_write(codec, nid, 0,
6108 AC_VERB_SET_PIN_WIDGET_CONTROL,
6109 i <= AUTO_PIN_FRONT_MIC ?
6110 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006112 snd_hda_codec_write(codec, nid, 0,
6113 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006114 AMP_OUT_MUTE);
6115 }
6116 }
6117}
6118
Takashi Iwai776e1842007-08-29 15:07:11 +02006119/* add mic boosts if needed */
6120static int alc_auto_add_mic_boost(struct hda_codec *codec)
6121{
6122 struct alc_spec *spec = codec->spec;
6123 int err;
6124 hda_nid_t nid;
6125
6126 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006127 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006128 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6129 "Mic Boost",
6130 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6131 if (err < 0)
6132 return err;
6133 }
6134 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006135 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006136 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6137 "Front Mic Boost",
6138 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6139 if (err < 0)
6140 return err;
6141 }
6142 return 0;
6143}
6144
Kailang Yangdf694da2005-12-05 19:42:22 +01006145/* almost identical with ALC880 parser... */
6146static int alc882_parse_auto_config(struct hda_codec *codec)
6147{
6148 struct alc_spec *spec = codec->spec;
6149 int err = alc880_parse_auto_config(codec);
6150
6151 if (err < 0)
6152 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006153 else if (!err)
6154 return 0; /* no config found */
6155
6156 err = alc_auto_add_mic_boost(codec);
6157 if (err < 0)
6158 return err;
6159
6160 /* hack - override the init verbs */
6161 spec->init_verbs[0] = alc882_auto_init_verbs;
6162
6163 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006164}
6165
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006166/* additional initialization for auto-configuration model */
6167static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006168{
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 alc882_auto_init_multi_out(codec);
6170 alc882_auto_init_hp_out(codec);
6171 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006172}
6173
Linus Torvalds1da177e2005-04-16 15:20:36 -07006174static int patch_alc882(struct hda_codec *codec)
6175{
6176 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006177 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006178
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006179 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006180 if (spec == NULL)
6181 return -ENOMEM;
6182
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183 codec->spec = spec;
6184
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006185 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6186 alc882_models,
6187 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188
Kailang Yangdf694da2005-12-05 19:42:22 +01006189 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006190 /* Pick up systems that don't supply PCI SSID */
6191 switch (codec->subsystem_id) {
6192 case 0x106b0c00: /* Mac Pro */
6193 board_config = ALC885_MACPRO;
6194 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006195 case 0x106b1000: /* iMac 24 */
6196 board_config = ALC885_IMAC24;
6197 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006198 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006199 case 0x106b2c00: /* Macbook Pro rev3 */
6200 board_config = ALC885_MBP3;
6201 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006202 default:
6203 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6204 "trying auto-probe from BIOS...\n");
6205 board_config = ALC882_AUTO;
6206 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006207 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006208
Takashi Iwaif95474e2007-07-10 00:47:43 +02006209 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6210
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 if (board_config == ALC882_AUTO) {
6212 /* automatic parse from the BIOS config */
6213 err = alc882_parse_auto_config(codec);
6214 if (err < 0) {
6215 alc_free(codec);
6216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006217 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006218 printk(KERN_INFO
6219 "hda_codec: Cannot set up configuration "
6220 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 board_config = ALC882_3ST_DIG;
6222 }
6223 }
6224
6225 if (board_config != ALC882_AUTO)
6226 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006227
6228 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6230 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006231 /* FIXME: setup DAC5 */
6232 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6233 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006234
6235 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006236 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6237 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006238
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006241 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006242 /* get type */
6243 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006244 if (wcap != AC_WID_AUD_IN) {
6245 spec->adc_nids = alc882_adc_nids_alt;
6246 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006247 spec->mixers[spec->num_mixers] =
6248 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006249 spec->num_mixers++;
6250 } else {
6251 spec->adc_nids = alc882_adc_nids;
6252 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6253 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6254 spec->num_mixers++;
6255 }
6256 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006257
Takashi Iwai2134ea42008-01-10 16:53:55 +01006258 spec->vmaster_nid = 0x0c;
6259
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006262 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006263#ifdef CONFIG_SND_HDA_POWER_SAVE
6264 if (!spec->loopback.amplist)
6265 spec->loopback.amplist = alc882_loopbacks;
6266#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006267
6268 return 0;
6269}
6270
6271/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006272 * ALC883 support
6273 *
6274 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6275 * configuration. Each pin widget can choose any input DACs and a mixer.
6276 * Each ADC is connected from a mixer of all inputs. This makes possible
6277 * 6-channel independent captures.
6278 *
6279 * In addition, an independent DAC for the multi-playback (not used in this
6280 * driver yet).
6281 */
6282#define ALC883_DIGOUT_NID 0x06
6283#define ALC883_DIGIN_NID 0x0a
6284
6285static hda_nid_t alc883_dac_nids[4] = {
6286 /* front, rear, clfe, rear_surr */
6287 0x02, 0x04, 0x03, 0x05
6288};
6289
6290static hda_nid_t alc883_adc_nids[2] = {
6291 /* ADC1-2 */
6292 0x08, 0x09,
6293};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006294
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006295/* input MUX */
6296/* FIXME: should be a matrix-type input source selection */
6297
6298static struct hda_input_mux alc883_capture_source = {
6299 .num_items = 4,
6300 .items = {
6301 { "Mic", 0x0 },
6302 { "Front Mic", 0x1 },
6303 { "Line", 0x2 },
6304 { "CD", 0x4 },
6305 },
6306};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006307
6308static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6309 .num_items = 2,
6310 .items = {
6311 { "Mic", 0x1 },
6312 { "Line", 0x2 },
6313 },
6314};
6315
Kailang Yang272a5272007-05-14 11:00:38 +02006316static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6317 .num_items = 4,
6318 .items = {
6319 { "Mic", 0x0 },
6320 { "iMic", 0x1 },
6321 { "Line", 0x2 },
6322 { "CD", 0x4 },
6323 },
6324};
6325
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006326#define alc883_mux_enum_info alc_mux_enum_info
6327#define alc883_mux_enum_get alc_mux_enum_get
6328
6329static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6330 struct snd_ctl_elem_value *ucontrol)
6331{
6332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6333 struct alc_spec *spec = codec->spec;
6334 const struct hda_input_mux *imux = spec->input_mux;
6335 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6336 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6337 hda_nid_t nid = capture_mixers[adc_idx];
6338 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6339 unsigned int i, idx;
6340
6341 idx = ucontrol->value.enumerated.item[0];
6342 if (idx >= imux->num_items)
6343 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006344 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006345 return 0;
6346 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006347 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6348 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006349 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006350 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006351 }
6352 *cur_val = idx;
6353 return 1;
6354}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006355
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006356/*
6357 * 2ch mode
6358 */
6359static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6360 { 2, NULL }
6361};
6362
6363/*
6364 * 2ch mode
6365 */
6366static struct hda_verb alc883_3ST_ch2_init[] = {
6367 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6368 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6369 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6370 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6371 { } /* end */
6372};
6373
6374/*
Tobin Davisb2011312007-09-17 12:45:11 +02006375 * 4ch mode
6376 */
6377static struct hda_verb alc883_3ST_ch4_init[] = {
6378 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6379 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6380 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6381 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6382 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6383 { } /* end */
6384};
6385
6386/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006387 * 6ch mode
6388 */
6389static struct hda_verb alc883_3ST_ch6_init[] = {
6390 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6391 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6392 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6393 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6396 { } /* end */
6397};
6398
Tobin Davisb2011312007-09-17 12:45:11 +02006399static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006400 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006401 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006402 { 6, alc883_3ST_ch6_init },
6403};
6404
6405/*
6406 * 6ch mode
6407 */
6408static struct hda_verb alc883_sixstack_ch6_init[] = {
6409 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6410 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6411 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6412 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6413 { } /* end */
6414};
6415
6416/*
6417 * 8ch mode
6418 */
6419static struct hda_verb alc883_sixstack_ch8_init[] = {
6420 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6421 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6422 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6423 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6424 { } /* end */
6425};
6426
6427static struct hda_channel_mode alc883_sixstack_modes[2] = {
6428 { 6, alc883_sixstack_ch6_init },
6429 { 8, alc883_sixstack_ch8_init },
6430};
6431
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006432static struct hda_verb alc883_medion_eapd_verbs[] = {
6433 /* eanable EAPD on medion laptop */
6434 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6435 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6436 { }
6437};
6438
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006439/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6440 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6441 */
6442
6443static struct snd_kcontrol_new alc883_base_mixer[] = {
6444 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6445 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6446 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6447 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6448 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6449 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6450 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6451 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6452 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6453 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006463 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6465 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6466 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6468 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6469 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6470 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6471 {
6472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6473 /* .name = "Capture Source", */
6474 .name = "Input Source",
6475 .count = 2,
6476 .info = alc883_mux_enum_info,
6477 .get = alc883_mux_enum_get,
6478 .put = alc883_mux_enum_put,
6479 },
6480 { } /* end */
6481};
6482
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006483static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6485 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6486 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6487 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6488 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6489 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6495 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6496 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6498 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6499 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6500 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6501 {
6502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6503 /* .name = "Capture Source", */
6504 .name = "Input Source",
6505 .count = 2,
6506 .info = alc883_mux_enum_info,
6507 .get = alc883_mux_enum_get,
6508 .put = alc883_mux_enum_put,
6509 },
6510 { } /* end */
6511};
6512
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006513static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6518 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006522 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6524 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006525 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6527 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6528 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6529 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6530 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6531 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6532 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6533 {
6534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6535 /* .name = "Capture Source", */
6536 .name = "Input Source",
6537 .count = 2,
6538 .info = alc883_mux_enum_info,
6539 .get = alc883_mux_enum_get,
6540 .put = alc883_mux_enum_put,
6541 },
6542 { } /* end */
6543};
6544
6545static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6547 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6548 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6549 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6550 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6551 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6552 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6553 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6562 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006563 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006564 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6565 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6566 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6568 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6569 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6570 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6571 {
6572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6573 /* .name = "Capture Source", */
6574 .name = "Input Source",
6575 .count = 2,
6576 .info = alc883_mux_enum_info,
6577 .get = alc883_mux_enum_get,
6578 .put = alc883_mux_enum_put,
6579 },
6580 { } /* end */
6581};
6582
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006583static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6585 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6586 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6587 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6588 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6589 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6590 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6591 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006598 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6600 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006601 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6603 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6604 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6605 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6606 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6607
6608 {
6609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6610 /* .name = "Capture Source", */
6611 .name = "Input Source",
6612 .count = 1,
6613 .info = alc883_mux_enum_info,
6614 .get = alc883_mux_enum_get,
6615 .put = alc883_mux_enum_put,
6616 },
6617 { } /* end */
6618};
6619
Kailang Yangccc656c2006-10-17 12:32:26 +02006620static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6623 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6624 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6625 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6637 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6638 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6639 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6640 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6641 {
6642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6643 /* .name = "Capture Source", */
6644 .name = "Input Source",
6645 .count = 2,
6646 .info = alc883_mux_enum_info,
6647 .get = alc883_mux_enum_get,
6648 .put = alc883_mux_enum_put,
6649 },
6650 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006651};
Kailang Yangccc656c2006-10-17 12:32:26 +02006652
6653static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6654 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6656 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6657 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6658 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6662 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6663 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6664 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6665 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6666 {
6667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6668 /* .name = "Capture Source", */
6669 .name = "Input Source",
6670 .count = 2,
6671 .info = alc883_mux_enum_info,
6672 .get = alc883_mux_enum_get,
6673 .put = alc883_mux_enum_put,
6674 },
6675 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006676};
Kailang Yangccc656c2006-10-17 12:32:26 +02006677
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006678static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6679 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6680 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6681 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6682 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6687 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6688 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6689 {
6690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6691 /* .name = "Capture Source", */
6692 .name = "Input Source",
6693 .count = 1,
6694 .info = alc883_mux_enum_info,
6695 .get = alc883_mux_enum_get,
6696 .put = alc883_mux_enum_put,
6697 },
6698 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006699};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006700
Kailang Yang272a5272007-05-14 11:00:38 +02006701static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6702 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6703 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6709 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6710 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6711 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6712 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6713 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6714 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6715 {
6716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6717 /* .name = "Capture Source", */
6718 .name = "Input Source",
6719 .count = 2,
6720 .info = alc883_mux_enum_info,
6721 .get = alc883_mux_enum_get,
6722 .put = alc883_mux_enum_put,
6723 },
6724 { } /* end */
6725};
6726
6727static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6730 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6735 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6736 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6737 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6738 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6739 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6740 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6741 {
6742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6743 /* .name = "Capture Source", */
6744 .name = "Input Source",
6745 .count = 2,
6746 .info = alc883_mux_enum_info,
6747 .get = alc883_mux_enum_get,
6748 .put = alc883_mux_enum_put,
6749 },
6750 { } /* end */
6751};
6752
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006753static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6756 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6757 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6759 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6760 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6761 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6763 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6773 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6774 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6775 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6776 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6777 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6778 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6779 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6780 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6781 {
6782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6783 /* .name = "Capture Source", */
6784 .name = "Input Source",
6785 .count = 2,
6786 .info = alc883_mux_enum_info,
6787 .get = alc883_mux_enum_get,
6788 .put = alc883_mux_enum_put,
6789 },
6790 { } /* end */
6791};
6792
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006793static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6795 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6797 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6813 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6814 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6817 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6818 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6819 {
6820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6821 /* .name = "Capture Source", */
6822 .name = "Input Source",
6823 .count = 2,
6824 .info = alc883_mux_enum_info,
6825 .get = alc883_mux_enum_get,
6826 .put = alc883_mux_enum_put,
6827 },
6828 { } /* end */
6829};
6830
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01006831static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6833 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6835 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6836 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6837 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6838 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6839 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6840 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6841 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6848 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6851 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6853 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6854 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6859 {
6860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6861 /* .name = "Capture Source", */
6862 .name = "Input Source",
6863 .count = 2,
6864 .info = alc883_mux_enum_info,
6865 .get = alc883_mux_enum_get,
6866 .put = alc883_mux_enum_put,
6867 },
6868 { } /* end */
6869};
6870
Tobin Davis2880a862007-08-07 11:50:26 +02006871static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006880 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6881 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6882 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6883 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6884 {
6885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6886 /* .name = "Capture Source", */
6887 .name = "Input Source",
6888 .count = 2,
6889 .info = alc883_mux_enum_info,
6890 .get = alc883_mux_enum_get,
6891 .put = alc883_mux_enum_put,
6892 },
6893 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006894};
Tobin Davis2880a862007-08-07 11:50:26 +02006895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006896static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6897 {
6898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6899 .name = "Channel Mode",
6900 .info = alc_ch_mode_info,
6901 .get = alc_ch_mode_get,
6902 .put = alc_ch_mode_put,
6903 },
6904 { } /* end */
6905};
6906
6907static struct hda_verb alc883_init_verbs[] = {
6908 /* ADC1: mute amp left and right */
6909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6910 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6911 /* ADC2: mute amp left and right */
6912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6913 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6914 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6918 /* Rear mixer */
6919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6922 /* CLFE mixer */
6923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6926 /* Side mixer */
6927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6930
Takashi Iwaicb53c622007-08-10 17:21:45 +02006931 /* mute analog input loopbacks */
6932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006937
6938 /* Front Pin: output 0 (0x0c) */
6939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6941 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6942 /* Rear Pin: output 1 (0x0d) */
6943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6946 /* CLFE Pin: output 2 (0x0e) */
6947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6949 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6950 /* Side Pin: output 3 (0x0f) */
6951 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6953 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6954 /* Mic (rear) pin: input vref at 80% */
6955 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6957 /* Front Mic pin: input vref at 80% */
6958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6960 /* Line In pin: input */
6961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6963 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6965 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6966 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6967 /* CD pin widget for input */
6968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6969
6970 /* FIXME: use matrix-type input source selection */
6971 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6972 /* Input mixer2 */
6973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6977 /* Input mixer3 */
6978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6982 { }
6983};
6984
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006985/* toggle speaker-output according to the hp-jack state */
6986static void alc883_mitac_hp_automute(struct hda_codec *codec)
6987{
6988 unsigned int present;
6989
6990 present = snd_hda_codec_read(codec, 0x15, 0,
6991 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6992 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6993 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6994 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6995 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6996}
6997
6998/* auto-toggle front mic */
6999/*
7000static void alc883_mitac_mic_automute(struct hda_codec *codec)
7001{
7002 unsigned int present;
7003 unsigned char bits;
7004
7005 present = snd_hda_codec_read(codec, 0x18, 0,
7006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7007 bits = present ? HDA_AMP_MUTE : 0;
7008 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7009}
7010*/
7011
7012static void alc883_mitac_automute(struct hda_codec *codec)
7013{
7014 alc883_mitac_hp_automute(codec);
7015 /* alc883_mitac_mic_automute(codec); */
7016}
7017
7018static void alc883_mitac_unsol_event(struct hda_codec *codec,
7019 unsigned int res)
7020{
7021 switch (res >> 26) {
7022 case ALC880_HP_EVENT:
7023 alc883_mitac_hp_automute(codec);
7024 break;
7025 case ALC880_MIC_EVENT:
7026 /* alc883_mitac_mic_automute(codec); */
7027 break;
7028 }
7029}
7030
7031static struct hda_verb alc883_mitac_verbs[] = {
7032 /* HP */
7033 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7035 /* Subwoofer */
7036 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7037 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7038
7039 /* enable unsolicited event */
7040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7041 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7042
7043 { } /* end */
7044};
7045
Kailang Yangccc656c2006-10-17 12:32:26 +02007046static struct hda_verb alc883_tagra_verbs[] = {
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7049
7050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7052
7053 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7054 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7055 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7056
7057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007058 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7059 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7060 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007061
7062 { } /* end */
7063};
7064
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007065static struct hda_verb alc883_lenovo_101e_verbs[] = {
7066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7068 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7069 { } /* end */
7070};
7071
Kailang Yang272a5272007-05-14 11:00:38 +02007072static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7077 { } /* end */
7078};
7079
7080static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7086 { } /* end */
7087};
7088
Kailang Yang189609a2007-08-20 11:31:23 +02007089static struct hda_verb alc883_haier_w66_verbs[] = {
7090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7092
7093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7094
7095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7097 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7099 { } /* end */
7100};
7101
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007102static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007103 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7104 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7105 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7106 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7107 { }
7108};
7109
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007110static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007111 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7112 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7113 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7114 { }
7115};
7116
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007117static struct hda_verb alc888_6st_dell_verbs[] = {
7118 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7119 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7120 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7121 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7122 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7123 { }
7124};
7125
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007126static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007127 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7128 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7129 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7130 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7131 { }
7132};
7133
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007134static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007135 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7136 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7137 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { }
7140};
7141
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007142static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7143 { 2, alc888_3st_hp_2ch_init },
7144 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007145};
7146
Kailang Yang272a5272007-05-14 11:00:38 +02007147/* toggle front-jack and RCA according to the hp-jack state */
7148static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7149{
7150 unsigned int present;
7151
7152 present = snd_hda_codec_read(codec, 0x1b, 0,
7153 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007154 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7155 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7156 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7157 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007158}
7159
7160/* toggle RCA according to the front-jack state */
7161static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7162{
7163 unsigned int present;
7164
7165 present = snd_hda_codec_read(codec, 0x14, 0,
7166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007167 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7168 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007169}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007170
Kailang Yang272a5272007-05-14 11:00:38 +02007171static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7172 unsigned int res)
7173{
7174 if ((res >> 26) == ALC880_HP_EVENT)
7175 alc888_lenovo_ms7195_front_automute(codec);
7176 if ((res >> 26) == ALC880_FRONT_EVENT)
7177 alc888_lenovo_ms7195_rca_automute(codec);
7178}
7179
7180static struct hda_verb alc883_medion_md2_verbs[] = {
7181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7183
7184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7185
7186 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7187 { } /* end */
7188};
7189
7190/* toggle speaker-output according to the hp-jack state */
7191static void alc883_medion_md2_automute(struct hda_codec *codec)
7192{
7193 unsigned int present;
7194
7195 present = snd_hda_codec_read(codec, 0x14, 0,
7196 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007197 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7198 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007199}
7200
7201static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7202 unsigned int res)
7203{
7204 if ((res >> 26) == ALC880_HP_EVENT)
7205 alc883_medion_md2_automute(codec);
7206}
7207
Kailang Yangccc656c2006-10-17 12:32:26 +02007208/* toggle speaker-output according to the hp-jack state */
7209static void alc883_tagra_automute(struct hda_codec *codec)
7210{
7211 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007212 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007213
7214 present = snd_hda_codec_read(codec, 0x14, 0,
7215 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007216 bits = present ? HDA_AMP_MUTE : 0;
7217 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7218 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007219 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7220 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007221}
7222
7223static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7224{
7225 if ((res >> 26) == ALC880_HP_EVENT)
7226 alc883_tagra_automute(codec);
7227}
7228
Kailang Yang189609a2007-08-20 11:31:23 +02007229static void alc883_haier_w66_automute(struct hda_codec *codec)
7230{
7231 unsigned int present;
7232 unsigned char bits;
7233
7234 present = snd_hda_codec_read(codec, 0x1b, 0,
7235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7236 bits = present ? 0x80 : 0;
7237 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7238 0x80, bits);
7239}
7240
7241static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7242 unsigned int res)
7243{
7244 if ((res >> 26) == ALC880_HP_EVENT)
7245 alc883_haier_w66_automute(codec);
7246}
7247
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007248static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7249{
7250 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007251 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007252
7253 present = snd_hda_codec_read(codec, 0x14, 0,
7254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007255 bits = present ? HDA_AMP_MUTE : 0;
7256 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7257 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007258}
7259
7260static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7261{
7262 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007263 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007264
7265 present = snd_hda_codec_read(codec, 0x1b, 0,
7266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007267 bits = present ? HDA_AMP_MUTE : 0;
7268 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7269 HDA_AMP_MUTE, bits);
7270 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7271 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007272}
7273
7274static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7275 unsigned int res)
7276{
7277 if ((res >> 26) == ALC880_HP_EVENT)
7278 alc883_lenovo_101e_all_automute(codec);
7279 if ((res >> 26) == ALC880_FRONT_EVENT)
7280 alc883_lenovo_101e_ispeaker_automute(codec);
7281}
7282
Takashi Iwai676a9b52007-08-16 15:23:35 +02007283/* toggle speaker-output according to the hp-jack state */
7284static void alc883_acer_aspire_automute(struct hda_codec *codec)
7285{
7286 unsigned int present;
7287
7288 present = snd_hda_codec_read(codec, 0x14, 0,
7289 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7290 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7291 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7292 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7293 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7294}
7295
7296static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7297 unsigned int res)
7298{
7299 if ((res >> 26) == ALC880_HP_EVENT)
7300 alc883_acer_aspire_automute(codec);
7301}
7302
Kailang Yangd1a991a2007-08-15 16:21:59 +02007303static struct hda_verb alc883_acer_eapd_verbs[] = {
7304 /* HP Pin: output 0 (0x0c) */
7305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7308 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007312 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7313 /* eanable EAPD on medion laptop */
7314 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7315 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007316 /* enable unsolicited event */
7317 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007318 { }
7319};
7320
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007321static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7322{
7323 unsigned int present;
7324
7325 present = snd_hda_codec_read(codec, 0x1b, 0,
7326 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7327 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7328 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7330 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7331 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7332 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7333 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7334 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7335}
7336
7337static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7338 unsigned int res)
7339{
7340 switch (res >> 26) {
7341 case ALC880_HP_EVENT:
7342 printk("hp_event\n");
7343 alc888_6st_dell_front_automute(codec);
7344 break;
7345 }
7346}
7347
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007348/*
7349 * generic initialization of ADC, input mixers and output mixers
7350 */
7351static struct hda_verb alc883_auto_init_verbs[] = {
7352 /*
7353 * Unmute ADC0-2 and set the default input to mic-in
7354 */
7355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7357 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7359
Takashi Iwaicb53c622007-08-10 17:21:45 +02007360 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007361 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007362 * Note: PASD motherboards uses the Line In 2 as the input for
7363 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007364 */
7365 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007371
7372 /*
7373 * Set up output mixers (0x0c - 0x0f)
7374 */
7375 /* set vol=0 to output mixers */
7376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7380 /* set up input amps for analog loopback */
7381 /* Amp Indices: DAC = 0, mixer = 1 */
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7390 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7391 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7392
7393 /* FIXME: use matrix-type input source selection */
7394 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7395 /* Input mixer1 */
7396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007399 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7401 /* Input mixer2 */
7402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007405 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007407
7408 { }
7409};
7410
7411/* capture mixer elements */
7412static struct snd_kcontrol_new alc883_capture_mixer[] = {
7413 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7414 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7415 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7416 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7417 {
7418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7419 /* The multiple "Capture Source" controls confuse alsamixer
7420 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007421 */
7422 /* .name = "Capture Source", */
7423 .name = "Input Source",
7424 .count = 2,
7425 .info = alc882_mux_enum_info,
7426 .get = alc882_mux_enum_get,
7427 .put = alc882_mux_enum_put,
7428 },
7429 { } /* end */
7430};
7431
Takashi Iwaicb53c622007-08-10 17:21:45 +02007432#ifdef CONFIG_SND_HDA_POWER_SAVE
7433#define alc883_loopbacks alc880_loopbacks
7434#endif
7435
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007436/* pcm configuration: identiacal with ALC880 */
7437#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7438#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007439#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007440#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7441#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7442
7443/*
7444 * configuration and preset
7445 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007446static const char *alc883_models[ALC883_MODEL_LAST] = {
7447 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7448 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7449 [ALC883_3ST_6ch] = "3stack-6ch",
7450 [ALC883_6ST_DIG] = "6stack-dig",
7451 [ALC883_TARGA_DIG] = "targa-dig",
7452 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007453 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007454 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007455 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007456 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007457 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007458 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007459 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7460 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007461 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007462 [ALC888_6ST_HP] = "6stack-hp",
7463 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007464 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007465 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007466 [ALC883_AUTO] = "auto",
7467};
7468
7469static struct snd_pci_quirk alc883_cfg_tbl[] = {
7470 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007471 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7472 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7473 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7474 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007475 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007476 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007477 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7478 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7479 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7480 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007481 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007482 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7483 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7484 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007485 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007486 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7487 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7488 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7489 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7490 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7491 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7492 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7493 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7494 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7495 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7496 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7497 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7498 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007499 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7500 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007501 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007502 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007503 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007504 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007505 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7506 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007507 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007508 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007509 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007510 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007511 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7512 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007513 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007514 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007515 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007516 {}
7517};
7518
7519static struct alc_config_preset alc883_presets[] = {
7520 [ALC883_3ST_2ch_DIG] = {
7521 .mixers = { alc883_3ST_2ch_mixer },
7522 .init_verbs = { alc883_init_verbs },
7523 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7524 .dac_nids = alc883_dac_nids,
7525 .dig_out_nid = ALC883_DIGOUT_NID,
7526 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7527 .adc_nids = alc883_adc_nids,
7528 .dig_in_nid = ALC883_DIGIN_NID,
7529 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7530 .channel_mode = alc883_3ST_2ch_modes,
7531 .input_mux = &alc883_capture_source,
7532 },
7533 [ALC883_3ST_6ch_DIG] = {
7534 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7535 .init_verbs = { alc883_init_verbs },
7536 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7537 .dac_nids = alc883_dac_nids,
7538 .dig_out_nid = ALC883_DIGOUT_NID,
7539 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7540 .adc_nids = alc883_adc_nids,
7541 .dig_in_nid = ALC883_DIGIN_NID,
7542 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7543 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007544 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007545 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007546 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007547 [ALC883_3ST_6ch] = {
7548 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7549 .init_verbs = { alc883_init_verbs },
7550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7551 .dac_nids = alc883_dac_nids,
7552 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7553 .adc_nids = alc883_adc_nids,
7554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7555 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007556 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007557 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007558 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007559 [ALC883_6ST_DIG] = {
7560 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7561 .init_verbs = { alc883_init_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 .dig_in_nid = ALC883_DIGIN_NID,
7568 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7569 .channel_mode = alc883_sixstack_modes,
7570 .input_mux = &alc883_capture_source,
7571 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007572 [ALC883_TARGA_DIG] = {
7573 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7574 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7576 .dac_nids = alc883_dac_nids,
7577 .dig_out_nid = ALC883_DIGOUT_NID,
7578 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7579 .adc_nids = alc883_adc_nids,
7580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7581 .channel_mode = alc883_3ST_6ch_modes,
7582 .need_dac_fix = 1,
7583 .input_mux = &alc883_capture_source,
7584 .unsol_event = alc883_tagra_unsol_event,
7585 .init_hook = alc883_tagra_automute,
7586 },
7587 [ALC883_TARGA_2ch_DIG] = {
7588 .mixers = { alc883_tagra_2ch_mixer},
7589 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7590 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7591 .dac_nids = alc883_dac_nids,
7592 .dig_out_nid = ALC883_DIGOUT_NID,
7593 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7594 .adc_nids = alc883_adc_nids,
7595 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7596 .channel_mode = alc883_3ST_2ch_modes,
7597 .input_mux = &alc883_capture_source,
7598 .unsol_event = alc883_tagra_unsol_event,
7599 .init_hook = alc883_tagra_automute,
7600 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007601 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007602 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007603 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7604 * and the headphone jack. Turn this on and rely on the
7605 * standard mute methods whenever the user wants to turn
7606 * these outputs off.
7607 */
7608 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7610 .dac_nids = alc883_dac_nids,
7611 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7612 .adc_nids = alc883_adc_nids,
7613 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7614 .channel_mode = alc883_3ST_2ch_modes,
7615 .input_mux = &alc883_capture_source,
7616 },
Tobin Davis2880a862007-08-07 11:50:26 +02007617 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007618 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007619 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7621 .dac_nids = alc883_dac_nids,
7622 .dig_out_nid = ALC883_DIGOUT_NID,
7623 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7624 .adc_nids = alc883_adc_nids,
7625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7626 .channel_mode = alc883_3ST_2ch_modes,
7627 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007628 .unsol_event = alc883_acer_aspire_unsol_event,
7629 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007630 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007631 [ALC883_MEDION] = {
7632 .mixers = { alc883_fivestack_mixer,
7633 alc883_chmode_mixer },
7634 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007635 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007636 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7637 .dac_nids = alc883_dac_nids,
7638 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7639 .adc_nids = alc883_adc_nids,
7640 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7641 .channel_mode = alc883_sixstack_modes,
7642 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007643 },
Kailang Yang272a5272007-05-14 11:00:38 +02007644 [ALC883_MEDION_MD2] = {
7645 .mixers = { alc883_medion_md2_mixer},
7646 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7648 .dac_nids = alc883_dac_nids,
7649 .dig_out_nid = ALC883_DIGOUT_NID,
7650 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7651 .adc_nids = alc883_adc_nids,
7652 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7653 .channel_mode = alc883_3ST_2ch_modes,
7654 .input_mux = &alc883_capture_source,
7655 .unsol_event = alc883_medion_md2_unsol_event,
7656 .init_hook = alc883_medion_md2_automute,
7657 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007658 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007659 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007660 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7662 .dac_nids = alc883_dac_nids,
7663 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7664 .adc_nids = alc883_adc_nids,
7665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7666 .channel_mode = alc883_3ST_2ch_modes,
7667 .input_mux = &alc883_capture_source,
7668 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007669 [ALC883_LENOVO_101E_2ch] = {
7670 .mixers = { alc883_lenovo_101e_2ch_mixer},
7671 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7673 .dac_nids = alc883_dac_nids,
7674 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7675 .adc_nids = alc883_adc_nids,
7676 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7677 .channel_mode = alc883_3ST_2ch_modes,
7678 .input_mux = &alc883_lenovo_101e_capture_source,
7679 .unsol_event = alc883_lenovo_101e_unsol_event,
7680 .init_hook = alc883_lenovo_101e_all_automute,
7681 },
Kailang Yang272a5272007-05-14 11:00:38 +02007682 [ALC883_LENOVO_NB0763] = {
7683 .mixers = { alc883_lenovo_nb0763_mixer },
7684 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7685 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7686 .dac_nids = alc883_dac_nids,
7687 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7688 .adc_nids = alc883_adc_nids,
7689 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7690 .channel_mode = alc883_3ST_2ch_modes,
7691 .need_dac_fix = 1,
7692 .input_mux = &alc883_lenovo_nb0763_capture_source,
7693 .unsol_event = alc883_medion_md2_unsol_event,
7694 .init_hook = alc883_medion_md2_automute,
7695 },
7696 [ALC888_LENOVO_MS7195_DIG] = {
7697 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7698 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7700 .dac_nids = alc883_dac_nids,
7701 .dig_out_nid = ALC883_DIGOUT_NID,
7702 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7703 .adc_nids = alc883_adc_nids,
7704 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7705 .channel_mode = alc883_3ST_6ch_modes,
7706 .need_dac_fix = 1,
7707 .input_mux = &alc883_capture_source,
7708 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7709 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007710 },
7711 [ALC883_HAIER_W66] = {
7712 .mixers = { alc883_tagra_2ch_mixer},
7713 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7714 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7715 .dac_nids = alc883_dac_nids,
7716 .dig_out_nid = ALC883_DIGOUT_NID,
7717 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7718 .adc_nids = alc883_adc_nids,
7719 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7720 .channel_mode = alc883_3ST_2ch_modes,
7721 .input_mux = &alc883_capture_source,
7722 .unsol_event = alc883_haier_w66_unsol_event,
7723 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007724 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007725 [ALC888_6ST_HP] = {
7726 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7727 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7729 .dac_nids = alc883_dac_nids,
7730 .dig_out_nid = ALC883_DIGOUT_NID,
7731 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7732 .adc_nids = alc883_adc_nids,
7733 .dig_in_nid = ALC883_DIGIN_NID,
7734 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7735 .channel_mode = alc883_sixstack_modes,
7736 .input_mux = &alc883_capture_source,
7737 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007738 [ALC888_3ST_HP] = {
7739 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7740 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007741 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7742 .dac_nids = alc883_dac_nids,
7743 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7744 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007745 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7746 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007747 .need_dac_fix = 1,
7748 .input_mux = &alc883_capture_source,
7749 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007750 [ALC888_6ST_DELL] = {
7751 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7752 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7753 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7754 .dac_nids = alc883_dac_nids,
7755 .dig_out_nid = ALC883_DIGOUT_NID,
7756 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7757 .adc_nids = alc883_adc_nids,
7758 .dig_in_nid = ALC883_DIGIN_NID,
7759 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7760 .channel_mode = alc883_sixstack_modes,
7761 .input_mux = &alc883_capture_source,
7762 .unsol_event = alc888_6st_dell_unsol_event,
7763 .init_hook = alc888_6st_dell_front_automute,
7764 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007765 [ALC883_MITAC] = {
7766 .mixers = { alc883_mitac_mixer },
7767 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7768 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7769 .dac_nids = alc883_dac_nids,
7770 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7771 .adc_nids = alc883_adc_nids,
7772 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7773 .channel_mode = alc883_3ST_2ch_modes,
7774 .input_mux = &alc883_capture_source,
7775 .unsol_event = alc883_mitac_unsol_event,
7776 .init_hook = alc883_mitac_automute,
7777 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007778};
7779
7780
7781/*
7782 * BIOS auto configuration
7783 */
7784static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7785 hda_nid_t nid, int pin_type,
7786 int dac_idx)
7787{
7788 /* set as output */
7789 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007790 int idx;
7791
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007792 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7793 idx = 4;
7794 else
7795 idx = spec->multiout.dac_nids[dac_idx] - 2;
7796
7797 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7798 pin_type);
7799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7800 AMP_OUT_UNMUTE);
7801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7802
7803}
7804
7805static void alc883_auto_init_multi_out(struct hda_codec *codec)
7806{
7807 struct alc_spec *spec = codec->spec;
7808 int i;
7809
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007810 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007811 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007812 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007813 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007814 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007815 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007816 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007817 }
7818}
7819
7820static void alc883_auto_init_hp_out(struct hda_codec *codec)
7821{
7822 struct alc_spec *spec = codec->spec;
7823 hda_nid_t pin;
7824
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007825 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007826 if (pin) /* connect to front */
7827 /* use dac 0 */
7828 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7829}
7830
7831#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7832#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7833
7834static void alc883_auto_init_analog_input(struct hda_codec *codec)
7835{
7836 struct alc_spec *spec = codec->spec;
7837 int i;
7838
7839 for (i = 0; i < AUTO_PIN_LAST; i++) {
7840 hda_nid_t nid = spec->autocfg.input_pins[i];
7841 if (alc883_is_input_pin(nid)) {
7842 snd_hda_codec_write(codec, nid, 0,
7843 AC_VERB_SET_PIN_WIDGET_CONTROL,
7844 (i <= AUTO_PIN_FRONT_MIC ?
7845 PIN_VREF80 : PIN_IN));
7846 if (nid != ALC883_PIN_CD_NID)
7847 snd_hda_codec_write(codec, nid, 0,
7848 AC_VERB_SET_AMP_GAIN_MUTE,
7849 AMP_OUT_MUTE);
7850 }
7851 }
7852}
7853
7854/* almost identical with ALC880 parser... */
7855static int alc883_parse_auto_config(struct hda_codec *codec)
7856{
7857 struct alc_spec *spec = codec->spec;
7858 int err = alc880_parse_auto_config(codec);
7859
7860 if (err < 0)
7861 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007862 else if (!err)
7863 return 0; /* no config found */
7864
7865 err = alc_auto_add_mic_boost(codec);
7866 if (err < 0)
7867 return err;
7868
7869 /* hack - override the init verbs */
7870 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007871 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7872 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007873
7874 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007875}
7876
7877/* additional initialization for auto-configuration model */
7878static void alc883_auto_init(struct hda_codec *codec)
7879{
7880 alc883_auto_init_multi_out(codec);
7881 alc883_auto_init_hp_out(codec);
7882 alc883_auto_init_analog_input(codec);
7883}
7884
7885static int patch_alc883(struct hda_codec *codec)
7886{
7887 struct alc_spec *spec;
7888 int err, board_config;
7889
7890 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7891 if (spec == NULL)
7892 return -ENOMEM;
7893
7894 codec->spec = spec;
7895
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007896 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7897 alc883_models,
7898 alc883_cfg_tbl);
7899 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007900 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7901 "trying auto-probe from BIOS...\n");
7902 board_config = ALC883_AUTO;
7903 }
7904
7905 if (board_config == ALC883_AUTO) {
7906 /* automatic parse from the BIOS config */
7907 err = alc883_parse_auto_config(codec);
7908 if (err < 0) {
7909 alc_free(codec);
7910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007911 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007912 printk(KERN_INFO
7913 "hda_codec: Cannot set up configuration "
7914 "from BIOS. Using base mode...\n");
7915 board_config = ALC883_3ST_2ch_DIG;
7916 }
7917 }
7918
7919 if (board_config != ALC883_AUTO)
7920 setup_preset(spec, &alc883_presets[board_config]);
7921
7922 spec->stream_name_analog = "ALC883 Analog";
7923 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7924 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007925 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007926
7927 spec->stream_name_digital = "ALC883 Digital";
7928 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7929 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7930
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007931 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007932 spec->adc_nids = alc883_adc_nids;
7933 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7934 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007935
Takashi Iwai2134ea42008-01-10 16:53:55 +01007936 spec->vmaster_nid = 0x0c;
7937
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007938 codec->patch_ops = alc_patch_ops;
7939 if (board_config == ALC883_AUTO)
7940 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007941#ifdef CONFIG_SND_HDA_POWER_SAVE
7942 if (!spec->loopback.amplist)
7943 spec->loopback.amplist = alc883_loopbacks;
7944#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007945
7946 return 0;
7947}
7948
7949/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007950 * ALC262 support
7951 */
7952
7953#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7954#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7955
7956#define alc262_dac_nids alc260_dac_nids
7957#define alc262_adc_nids alc882_adc_nids
7958#define alc262_adc_nids_alt alc882_adc_nids_alt
7959
7960#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007961#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007962
7963static struct snd_kcontrol_new alc262_base_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007973 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007976 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7977 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 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),
Kailang Yangdf694da2005-12-05 19:42:22 +01007982 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007983};
7984
Kailang Yangccc656c2006-10-17 12:32:26 +02007985static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7987 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007998 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7999 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8000 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8002 { } /* end */
8003};
8004
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008005static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8011
8012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008014 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008017 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8023 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8024 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8025 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8026 { } /* end */
8027};
8028
Kailang Yangcd7509a2007-01-26 18:33:17 +01008029static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8036 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008038 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8044 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8045 { } /* end */
8046};
8047
8048static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8049 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008051 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008052 { } /* end */
8053};
8054
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008055static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8056 .ops = &snd_hda_bind_vol,
8057 .values = {
8058 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8059 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8060 0
8061 },
8062};
8063
8064static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8065 .ops = &snd_hda_bind_sw,
8066 .values = {
8067 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8068 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8069 0
8070 },
8071};
8072
8073/* mute/unmute internal speaker according to the hp jack and mute state */
8074static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8075{
8076 struct alc_spec *spec = codec->spec;
8077 unsigned int mute;
8078
8079 if (force || !spec->sense_updated) {
8080 unsigned int present;
8081 present = snd_hda_codec_read(codec, 0x15, 0,
8082 AC_VERB_GET_PIN_SENSE, 0);
8083 spec->jack_present = (present & 0x80000000) != 0;
8084 spec->sense_updated = 1;
8085 }
8086 if (spec->jack_present)
8087 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8088 else /* unmute internal speaker if necessary */
8089 mute = (0x7000 | ((0)<<8));
8090 snd_hda_codec_write(codec, 0x0c, 0,
8091 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8092}
8093
8094static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8095 unsigned int res)
8096{
8097 if ((res >> 26) != ALC880_HP_EVENT)
8098 return;
8099 alc262_hp_t5735_automute(codec, 1);
8100}
8101
8102static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8103{
8104 alc262_hp_t5735_automute(codec, 1);
8105}
8106
8107static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8108 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8109 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8110 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8119 { } /* end */
8120};
8121
8122static struct hda_verb alc262_hp_t5735_verbs[] = {
8123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8125
8126 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8127 { }
8128};
8129
Kailang Yang8c427222008-01-10 13:03:59 +01008130static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8131 .ops = &snd_hda_bind_vol,
8132 .values = {
8133 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8134 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8135 0
8136 },
8137};
8138
8139static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8140 .ops = &snd_hda_bind_sw,
8141 .values = {
8142 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8143 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8144 0
8145 },
8146};
8147
8148static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8149 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8150 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8151 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8152 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8157 { } /* end */
8158};
8159
8160static struct hda_verb alc262_hp_rp5700_verbs[] = {
8161 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8166 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8171 {}
8172};
8173
8174static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8175 .num_items = 1,
8176 .items = {
8177 { "Line", 0x1 },
8178 },
8179};
8180
Takashi Iwai0724ea22007-08-23 00:31:43 +02008181/* bind hp and internal speaker mute (with plug check) */
8182static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8183 struct snd_ctl_elem_value *ucontrol)
8184{
8185 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8186 long *valp = ucontrol->value.integer.value;
8187 int change;
8188
8189 /* change hp mute */
8190 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8191 HDA_AMP_MUTE,
8192 valp[0] ? 0 : HDA_AMP_MUTE);
8193 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8194 HDA_AMP_MUTE,
8195 valp[1] ? 0 : HDA_AMP_MUTE);
8196 if (change) {
8197 /* change speaker according to HP jack state */
8198 struct alc_spec *spec = codec->spec;
8199 unsigned int mute;
8200 if (spec->jack_present)
8201 mute = HDA_AMP_MUTE;
8202 else
8203 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8204 HDA_OUTPUT, 0);
8205 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8206 HDA_AMP_MUTE, mute);
8207 }
8208 return change;
8209}
Takashi Iwai5b319542007-07-26 11:49:22 +02008210
Kailang Yang272a5272007-05-14 11:00:38 +02008211static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008212 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 {
8214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8215 .name = "Master Playback Switch",
8216 .info = snd_hda_mixer_amp_switch_info,
8217 .get = snd_hda_mixer_amp_switch_get,
8218 .put = alc262_sony_master_sw_put,
8219 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8220 },
Kailang Yang272a5272007-05-14 11:00:38 +02008221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8223 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8224 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8225 { } /* end */
8226};
8227
Kailang Yang83c34212007-07-05 11:43:05 +02008228static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8230 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8234 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8235 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8236 { } /* end */
8237};
Kailang Yang272a5272007-05-14 11:00:38 +02008238
Kailang Yangdf694da2005-12-05 19:42:22 +01008239#define alc262_capture_mixer alc882_capture_mixer
8240#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8241
8242/*
8243 * generic initialization of ADC, input mixers and output mixers
8244 */
8245static struct hda_verb alc262_init_verbs[] = {
8246 /*
8247 * Unmute ADC0-2 and set the default input to mic-in
8248 */
8249 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8251 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8253 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
Takashi Iwaicb53c622007-08-10 17:21:45 +02008256 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008257 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008258 * Note: PASD motherboards uses the Line In 2 as the input for
8259 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008260 */
8261 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008267
8268 /*
8269 * Set up output mixers (0x0c - 0x0e)
8270 */
8271 /* set vol=0 to output mixers */
8272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8275 /* set up input amps for analog loopback */
8276 /* Amp Indices: DAC = 0, mixer = 1 */
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8283
8284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8286 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8287 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8290
8291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8296
8297 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8299
8300 /* FIXME: use matrix-type input source selection */
8301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8302 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8307 /* Input mixer2 */
8308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8312 /* Input mixer3 */
8313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008317
8318 { }
8319};
8320
Kailang Yangccc656c2006-10-17 12:32:26 +02008321static struct hda_verb alc262_hippo_unsol_verbs[] = {
8322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8324 {}
8325};
8326
8327static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8329 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8331
8332 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8334 {}
8335};
8336
Kailang Yang272a5272007-05-14 11:00:38 +02008337static struct hda_verb alc262_sony_unsol_verbs[] = {
8338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8341
8342 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8344};
8345
Kailang Yangccc656c2006-10-17 12:32:26 +02008346/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008347static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008348{
8349 struct alc_spec *spec = codec->spec;
8350 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008351 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008352
Takashi Iwai5b319542007-07-26 11:49:22 +02008353 /* need to execute and sync at first */
8354 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8355 present = snd_hda_codec_read(codec, 0x15, 0,
8356 AC_VERB_GET_PIN_SENSE, 0);
8357 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008358 if (spec->jack_present) {
8359 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8361 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008362 } else {
8363 /* unmute internal speaker if necessary */
8364 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008365 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8366 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008367 }
8368}
8369
8370/* unsolicited event for HP jack sensing */
8371static void alc262_hippo_unsol_event(struct hda_codec *codec,
8372 unsigned int res)
8373{
8374 if ((res >> 26) != ALC880_HP_EVENT)
8375 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008376 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008377}
8378
Takashi Iwai5b319542007-07-26 11:49:22 +02008379static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008380{
Kailang Yangccc656c2006-10-17 12:32:26 +02008381 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008382 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008383
Takashi Iwai5b319542007-07-26 11:49:22 +02008384 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8385 present = snd_hda_codec_read(codec, 0x1b, 0,
8386 AC_VERB_GET_PIN_SENSE, 0);
8387 present = (present & 0x80000000) != 0;
8388 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008389 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008390 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8391 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008392 } else {
8393 /* unmute internal speaker if necessary */
8394 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008395 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8396 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008397 }
8398}
8399
8400/* unsolicited event for HP jack sensing */
8401static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8402 unsigned int res)
8403{
8404 if ((res >> 26) != ALC880_HP_EVENT)
8405 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008406 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008407}
8408
Takashi Iwai834be882006-03-01 14:16:17 +01008409/*
8410 * fujitsu model
8411 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8412 */
8413
8414#define ALC_HP_EVENT 0x37
8415
8416static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8417 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8419 {}
8420};
8421
8422static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008423 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008424 .items = {
8425 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008426 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008427 { "CD", 0x4 },
8428 },
8429};
8430
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008431static struct hda_input_mux alc262_HP_capture_source = {
8432 .num_items = 5,
8433 .items = {
8434 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008435 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008436 { "Line", 0x2 },
8437 { "CD", 0x4 },
8438 { "AUX IN", 0x6 },
8439 },
8440};
8441
zhejiangaccbe492007-08-31 12:36:05 +02008442static struct hda_input_mux alc262_HP_D7000_capture_source = {
8443 .num_items = 4,
8444 .items = {
8445 { "Mic", 0x0 },
8446 { "Front Mic", 0x2 },
8447 { "Line", 0x1 },
8448 { "CD", 0x4 },
8449 },
8450};
8451
Takashi Iwai834be882006-03-01 14:16:17 +01008452/* mute/unmute internal speaker according to the hp jack and mute state */
8453static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8454{
8455 struct alc_spec *spec = codec->spec;
8456 unsigned int mute;
8457
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008458 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008459 unsigned int present;
8460 /* need to execute and sync at first */
8461 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8462 present = snd_hda_codec_read(codec, 0x14, 0,
8463 AC_VERB_GET_PIN_SENSE, 0);
8464 spec->jack_present = (present & 0x80000000) != 0;
8465 spec->sense_updated = 1;
8466 }
8467 if (spec->jack_present) {
8468 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008469 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8470 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008471 } else {
8472 /* unmute internal speaker if necessary */
8473 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008474 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8475 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008476 }
8477}
8478
8479/* unsolicited event for HP jack sensing */
8480static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8481 unsigned int res)
8482{
8483 if ((res >> 26) != ALC_HP_EVENT)
8484 return;
8485 alc262_fujitsu_automute(codec, 1);
8486}
8487
8488/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008489static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8490 .ops = &snd_hda_bind_vol,
8491 .values = {
8492 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8493 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8494 0
8495 },
8496};
Takashi Iwai834be882006-03-01 14:16:17 +01008497
8498/* bind hp and internal speaker mute (with plug check) */
8499static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8500 struct snd_ctl_elem_value *ucontrol)
8501{
8502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8503 long *valp = ucontrol->value.integer.value;
8504 int change;
8505
8506 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008507 HDA_AMP_MUTE,
8508 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008509 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008510 HDA_AMP_MUTE,
8511 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008512 if (change)
8513 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008514 return change;
8515}
8516
8517static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008518 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008519 {
8520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8521 .name = "Master Playback Switch",
8522 .info = snd_hda_mixer_amp_switch_info,
8523 .get = snd_hda_mixer_amp_switch_get,
8524 .put = alc262_fujitsu_master_sw_put,
8525 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8526 },
8527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008532 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8533 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8534 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008535 { } /* end */
8536};
8537
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008538/* additional init verbs for Benq laptops */
8539static struct hda_verb alc262_EAPD_verbs[] = {
8540 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8541 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8542 {}
8543};
8544
Kailang Yang83c34212007-07-05 11:43:05 +02008545static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8548
8549 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8550 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8551 {}
8552};
8553
Tobin Davisf651b502007-10-26 12:40:47 +02008554/* Samsung Q1 Ultra Vista model setup */
8555static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8557 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8562 { } /* end */
8563};
8564
8565static struct hda_verb alc262_ultra_verbs[] = {
8566 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8569 /* Mic is on Node 0x19 */
8570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8571 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8573 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8575 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8577 {}
8578};
8579
8580static struct hda_input_mux alc262_ultra_capture_source = {
8581 .num_items = 1,
8582 .items = {
8583 { "Mic", 0x1 },
8584 },
8585};
8586
8587/* mute/unmute internal speaker according to the hp jack and mute state */
8588static void alc262_ultra_automute(struct hda_codec *codec)
8589{
8590 struct alc_spec *spec = codec->spec;
8591 unsigned int mute;
8592 unsigned int present;
8593
8594 /* need to execute and sync at first */
8595 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8596 present = snd_hda_codec_read(codec, 0x15, 0,
8597 AC_VERB_GET_PIN_SENSE, 0);
8598 spec->jack_present = (present & 0x80000000) != 0;
8599 if (spec->jack_present) {
8600 /* mute internal speaker */
8601 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8602 HDA_AMP_MUTE, HDA_AMP_MUTE);
8603 } else {
8604 /* unmute internal speaker if necessary */
8605 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8606 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8607 HDA_AMP_MUTE, mute);
8608 }
8609}
8610
8611/* unsolicited event for HP jack sensing */
8612static void alc262_ultra_unsol_event(struct hda_codec *codec,
8613 unsigned int res)
8614{
8615 if ((res >> 26) != ALC880_HP_EVENT)
8616 return;
8617 alc262_ultra_automute(codec);
8618}
8619
Kailang Yangdf694da2005-12-05 19:42:22 +01008620/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008621static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8622 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008623{
8624 hda_nid_t nid;
8625 int err;
8626
8627 spec->multiout.num_dacs = 1; /* only use one dac */
8628 spec->multiout.dac_nids = spec->private_dac_nids;
8629 spec->multiout.dac_nids[0] = 2;
8630
8631 nid = cfg->line_out_pins[0];
8632 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008633 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8634 "Front Playback Volume",
8635 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8636 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008637 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008638 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8639 "Front Playback Switch",
8640 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8641 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008642 return err;
8643 }
8644
Takashi Iwai82bc9552006-03-21 11:24:42 +01008645 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008646 if (nid) {
8647 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008648 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8649 "Speaker Playback Volume",
8650 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8651 HDA_OUTPUT));
8652 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008653 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008654 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8655 "Speaker Playback Switch",
8656 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8657 HDA_OUTPUT));
8658 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008659 return err;
8660 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008661 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8662 "Speaker Playback Switch",
8663 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8664 HDA_OUTPUT));
8665 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008666 return err;
8667 }
8668 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008669 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008670 if (nid) {
8671 /* spec->multiout.hp_nid = 2; */
8672 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008673 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8674 "Headphone Playback Volume",
8675 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8676 HDA_OUTPUT));
8677 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008678 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008679 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8680 "Headphone Playback Switch",
8681 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8682 HDA_OUTPUT));
8683 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008684 return err;
8685 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008686 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8687 "Headphone Playback Switch",
8688 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8689 HDA_OUTPUT));
8690 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008691 return err;
8692 }
8693 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008694 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008695}
8696
8697/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008698#define alc262_auto_create_analog_input_ctls \
8699 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008700
8701/*
8702 * generic initialization of ADC, input mixers and output mixers
8703 */
8704static struct hda_verb alc262_volume_init_verbs[] = {
8705 /*
8706 * Unmute ADC0-2 and set the default input to mic-in
8707 */
8708 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8710 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8711 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8712 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8714
Takashi Iwaicb53c622007-08-10 17:21:45 +02008715 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008716 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008717 * Note: PASD motherboards uses the Line In 2 as the input for
8718 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008719 */
8720 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008726
8727 /*
8728 * Set up output mixers (0x0c - 0x0f)
8729 */
8730 /* set vol=0 to output mixers */
8731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8734
8735 /* set up input amps for analog loopback */
8736 /* Amp Indices: DAC = 0, mixer = 1 */
8737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8743
8744 /* FIXME: use matrix-type input source selection */
8745 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8746 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8751 /* Input mixer2 */
8752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8756 /* Input mixer3 */
8757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8761
8762 { }
8763};
8764
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008765static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8766 /*
8767 * Unmute ADC0-2 and set the default input to mic-in
8768 */
8769 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8773 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8775
Takashi Iwaicb53c622007-08-10 17:21:45 +02008776 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008777 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008778 * Note: PASD motherboards uses the Line In 2 as the input for
8779 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008780 */
8781 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008789
8790 /*
8791 * Set up output mixers (0x0c - 0x0e)
8792 */
8793 /* set vol=0 to output mixers */
8794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8797
8798 /* set up input amps for analog loopback */
8799 /* Amp Indices: DAC = 0, mixer = 1 */
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8806
8807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8810
8811 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8813
8814 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8816
8817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8819 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8821 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8822
8823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8827 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8828 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8829
8830
8831 /* FIXME: use matrix-type input source selection */
8832 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8833 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8838 /* Input mixer2 */
8839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8843 /* Input mixer3 */
8844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8848
8849 { }
8850};
8851
Kailang Yangcd7509a2007-01-26 18:33:17 +01008852static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8853 /*
8854 * Unmute ADC0-2 and set the default input to mic-in
8855 */
8856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8858 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862
Takashi Iwaicb53c622007-08-10 17:21:45 +02008863 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008864 * mixer widget
8865 * Note: PASD motherboards uses the Line In 2 as the input for front
8866 * panel mic (mic 2)
8867 */
8868 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008877 /*
8878 * Set up output mixers (0x0c - 0x0e)
8879 */
8880 /* set vol=0 to output mixers */
8881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8884
8885 /* set up input amps for analog loopback */
8886 /* Amp Indices: DAC = 0, mixer = 1 */
8887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893
8894
8895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8897 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8899 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8900 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8901 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8902
8903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8905
8906 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8907 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8908
8909 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8913 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8914 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8915
8916 /* FIXME: use matrix-type input source selection */
8917 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8918 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8924 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8926 /* Input mixer2 */
8927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8932 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8934 /* Input mixer3 */
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8940 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8942
8943 { }
8944};
8945
Takashi Iwaicb53c622007-08-10 17:21:45 +02008946#ifdef CONFIG_SND_HDA_POWER_SAVE
8947#define alc262_loopbacks alc880_loopbacks
8948#endif
8949
Kailang Yangdf694da2005-12-05 19:42:22 +01008950/* pcm configuration: identiacal with ALC880 */
8951#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8952#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8953#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8954#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8955
8956/*
8957 * BIOS auto configuration
8958 */
8959static int alc262_parse_auto_config(struct hda_codec *codec)
8960{
8961 struct alc_spec *spec = codec->spec;
8962 int err;
8963 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8964
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008965 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8966 alc262_ignore);
8967 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008968 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008969 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008970 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008971 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8972 if (err < 0)
8973 return err;
8974 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8975 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008976 return err;
8977
8978 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8979
8980 if (spec->autocfg.dig_out_pin)
8981 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8982 if (spec->autocfg.dig_in_pin)
8983 spec->dig_in_nid = ALC262_DIGIN_NID;
8984
8985 if (spec->kctl_alloc)
8986 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8987
8988 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008989 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008990 spec->input_mux = &spec->private_imux;
8991
Takashi Iwai776e1842007-08-29 15:07:11 +02008992 err = alc_auto_add_mic_boost(codec);
8993 if (err < 0)
8994 return err;
8995
Kailang Yangdf694da2005-12-05 19:42:22 +01008996 return 1;
8997}
8998
8999#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9000#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9001#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9002
9003
9004/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009005static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009006{
Kailang Yangdf694da2005-12-05 19:42:22 +01009007 alc262_auto_init_multi_out(codec);
9008 alc262_auto_init_hp_out(codec);
9009 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009010}
9011
9012/*
9013 * configuration and preset
9014 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009015static const char *alc262_models[ALC262_MODEL_LAST] = {
9016 [ALC262_BASIC] = "basic",
9017 [ALC262_HIPPO] = "hippo",
9018 [ALC262_HIPPO_1] = "hippo_1",
9019 [ALC262_FUJITSU] = "fujitsu",
9020 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009021 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009022 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009023 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009024 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009025 [ALC262_BENQ_T31] = "benq-t31",
9026 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009027 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009028 [ALC262_AUTO] = "auto",
9029};
9030
9031static struct snd_pci_quirk alc262_cfg_tbl[] = {
9032 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9033 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009034 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009035 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9036 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009037 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009038 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009039 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009040 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009041 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009042 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009043 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009044 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009045 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009046 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009047 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009048 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009049 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9050 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9051 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009052 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9053 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009054 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009055 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009056 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009057 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9058 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9059 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009060 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009061 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009062 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009063 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009064 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009065 {}
9066};
9067
9068static struct alc_config_preset alc262_presets[] = {
9069 [ALC262_BASIC] = {
9070 .mixers = { alc262_base_mixer },
9071 .init_verbs = { alc262_init_verbs },
9072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9073 .dac_nids = alc262_dac_nids,
9074 .hp_nid = 0x03,
9075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9076 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009077 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009078 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009079 [ALC262_HIPPO] = {
9080 .mixers = { alc262_base_mixer },
9081 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9082 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9083 .dac_nids = alc262_dac_nids,
9084 .hp_nid = 0x03,
9085 .dig_out_nid = ALC262_DIGOUT_NID,
9086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9087 .channel_mode = alc262_modes,
9088 .input_mux = &alc262_capture_source,
9089 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009090 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009091 },
9092 [ALC262_HIPPO_1] = {
9093 .mixers = { alc262_hippo1_mixer },
9094 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9096 .dac_nids = alc262_dac_nids,
9097 .hp_nid = 0x02,
9098 .dig_out_nid = ALC262_DIGOUT_NID,
9099 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9100 .channel_mode = alc262_modes,
9101 .input_mux = &alc262_capture_source,
9102 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009103 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009104 },
Takashi Iwai834be882006-03-01 14:16:17 +01009105 [ALC262_FUJITSU] = {
9106 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009107 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9108 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009109 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9110 .dac_nids = alc262_dac_nids,
9111 .hp_nid = 0x03,
9112 .dig_out_nid = ALC262_DIGOUT_NID,
9113 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9114 .channel_mode = alc262_modes,
9115 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009116 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009117 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118 [ALC262_HP_BPC] = {
9119 .mixers = { alc262_HP_BPC_mixer },
9120 .init_verbs = { alc262_HP_BPC_init_verbs },
9121 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9122 .dac_nids = alc262_dac_nids,
9123 .hp_nid = 0x03,
9124 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9125 .channel_mode = alc262_modes,
9126 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009127 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009128 [ALC262_HP_BPC_D7000_WF] = {
9129 .mixers = { alc262_HP_BPC_WildWest_mixer },
9130 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9131 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9132 .dac_nids = alc262_dac_nids,
9133 .hp_nid = 0x03,
9134 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9135 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009136 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009137 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009138 [ALC262_HP_BPC_D7000_WL] = {
9139 .mixers = { alc262_HP_BPC_WildWest_mixer,
9140 alc262_HP_BPC_WildWest_option_mixer },
9141 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9142 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9143 .dac_nids = alc262_dac_nids,
9144 .hp_nid = 0x03,
9145 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9146 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009147 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009148 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009149 [ALC262_HP_TC_T5735] = {
9150 .mixers = { alc262_hp_t5735_mixer },
9151 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9152 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9153 .dac_nids = alc262_dac_nids,
9154 .hp_nid = 0x03,
9155 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9156 .channel_mode = alc262_modes,
9157 .input_mux = &alc262_capture_source,
9158 .unsol_event = alc262_hp_t5735_unsol_event,
9159 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009160 },
9161 [ALC262_HP_RP5700] = {
9162 .mixers = { alc262_hp_rp5700_mixer },
9163 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9164 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9165 .dac_nids = alc262_dac_nids,
9166 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9167 .channel_mode = alc262_modes,
9168 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009169 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009170 [ALC262_BENQ_ED8] = {
9171 .mixers = { alc262_base_mixer },
9172 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9173 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9174 .dac_nids = alc262_dac_nids,
9175 .hp_nid = 0x03,
9176 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9177 .channel_mode = alc262_modes,
9178 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009179 },
Kailang Yang272a5272007-05-14 11:00:38 +02009180 [ALC262_SONY_ASSAMD] = {
9181 .mixers = { alc262_sony_mixer },
9182 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9183 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9184 .dac_nids = alc262_dac_nids,
9185 .hp_nid = 0x02,
9186 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9187 .channel_mode = alc262_modes,
9188 .input_mux = &alc262_capture_source,
9189 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009190 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009191 },
9192 [ALC262_BENQ_T31] = {
9193 .mixers = { alc262_benq_t31_mixer },
9194 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9195 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9196 .dac_nids = alc262_dac_nids,
9197 .hp_nid = 0x03,
9198 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9199 .channel_mode = alc262_modes,
9200 .input_mux = &alc262_capture_source,
9201 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009202 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009203 },
Tobin Davisf651b502007-10-26 12:40:47 +02009204 [ALC262_ULTRA] = {
9205 .mixers = { alc262_ultra_mixer },
9206 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9207 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9208 .dac_nids = alc262_dac_nids,
9209 .hp_nid = 0x03,
9210 .dig_out_nid = ALC262_DIGOUT_NID,
9211 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9212 .channel_mode = alc262_modes,
9213 .input_mux = &alc262_ultra_capture_source,
9214 .unsol_event = alc262_ultra_unsol_event,
9215 .init_hook = alc262_ultra_automute,
9216 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009217};
9218
9219static int patch_alc262(struct hda_codec *codec)
9220{
9221 struct alc_spec *spec;
9222 int board_config;
9223 int err;
9224
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009226 if (spec == NULL)
9227 return -ENOMEM;
9228
9229 codec->spec = spec;
9230#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009231 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9232 * under-run
9233 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009234 {
9235 int tmp;
9236 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9237 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9238 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9239 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9240 }
9241#endif
9242
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009243 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9244 alc262_models,
9245 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009246
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009247 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009248 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9249 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009250 board_config = ALC262_AUTO;
9251 }
9252
9253 if (board_config == ALC262_AUTO) {
9254 /* automatic parse from the BIOS config */
9255 err = alc262_parse_auto_config(codec);
9256 if (err < 0) {
9257 alc_free(codec);
9258 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009259 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009260 printk(KERN_INFO
9261 "hda_codec: Cannot set up configuration "
9262 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009263 board_config = ALC262_BASIC;
9264 }
9265 }
9266
9267 if (board_config != ALC262_AUTO)
9268 setup_preset(spec, &alc262_presets[board_config]);
9269
9270 spec->stream_name_analog = "ALC262 Analog";
9271 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9272 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9273
9274 spec->stream_name_digital = "ALC262 Digital";
9275 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9276 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009278 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009279 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009280 unsigned int wcap = get_wcaps(codec, 0x07);
9281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009282 /* get type */
9283 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009284 if (wcap != AC_WID_AUD_IN) {
9285 spec->adc_nids = alc262_adc_nids_alt;
9286 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009287 spec->mixers[spec->num_mixers] =
9288 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009289 spec->num_mixers++;
9290 } else {
9291 spec->adc_nids = alc262_adc_nids;
9292 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9293 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9294 spec->num_mixers++;
9295 }
9296 }
9297
Takashi Iwai2134ea42008-01-10 16:53:55 +01009298 spec->vmaster_nid = 0x0c;
9299
Kailang Yangdf694da2005-12-05 19:42:22 +01009300 codec->patch_ops = alc_patch_ops;
9301 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009302 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009303#ifdef CONFIG_SND_HDA_POWER_SAVE
9304 if (!spec->loopback.amplist)
9305 spec->loopback.amplist = alc262_loopbacks;
9306#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009307
Kailang Yangdf694da2005-12-05 19:42:22 +01009308 return 0;
9309}
9310
Kailang Yangdf694da2005-12-05 19:42:22 +01009311/*
Kailang Yanga361d842007-06-05 12:30:55 +02009312 * ALC268 channel source setting (2 channel)
9313 */
9314#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9315#define alc268_modes alc260_modes
9316
9317static hda_nid_t alc268_dac_nids[2] = {
9318 /* front, hp */
9319 0x02, 0x03
9320};
9321
9322static hda_nid_t alc268_adc_nids[2] = {
9323 /* ADC0-1 */
9324 0x08, 0x07
9325};
9326
9327static hda_nid_t alc268_adc_nids_alt[1] = {
9328 /* ADC0 */
9329 0x08
9330};
9331
9332static struct snd_kcontrol_new alc268_base_mixer[] = {
9333 /* output mixer control */
9334 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9335 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9336 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9340 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009341 { }
9342};
9343
Kailang Yangd1a991a2007-08-15 16:21:59 +02009344static struct hda_verb alc268_eapd_verbs[] = {
9345 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9346 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9347 { }
9348};
9349
Takashi Iwaid2738092007-08-16 14:59:45 +02009350/* Toshiba specific */
9351#define alc268_toshiba_automute alc262_hippo_automute
9352
9353static struct hda_verb alc268_toshiba_verbs[] = {
9354 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9355 { } /* end */
9356};
9357
9358/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009359/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009360static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9361 .ops = &snd_hda_bind_vol,
9362 .values = {
9363 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9364 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9365 0
9366 },
9367};
9368
Takashi Iwai889c4392007-08-23 18:56:52 +02009369/* mute/unmute internal speaker according to the hp jack and mute state */
9370static void alc268_acer_automute(struct hda_codec *codec, int force)
9371{
9372 struct alc_spec *spec = codec->spec;
9373 unsigned int mute;
9374
9375 if (force || !spec->sense_updated) {
9376 unsigned int present;
9377 present = snd_hda_codec_read(codec, 0x14, 0,
9378 AC_VERB_GET_PIN_SENSE, 0);
9379 spec->jack_present = (present & 0x80000000) != 0;
9380 spec->sense_updated = 1;
9381 }
9382 if (spec->jack_present)
9383 mute = HDA_AMP_MUTE; /* mute internal speaker */
9384 else /* unmute internal speaker if necessary */
9385 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9386 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9387 HDA_AMP_MUTE, mute);
9388}
9389
9390
9391/* bind hp and internal speaker mute (with plug check) */
9392static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9393 struct snd_ctl_elem_value *ucontrol)
9394{
9395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9396 long *valp = ucontrol->value.integer.value;
9397 int change;
9398
9399 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9400 HDA_AMP_MUTE,
9401 valp[0] ? 0 : HDA_AMP_MUTE);
9402 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9403 HDA_AMP_MUTE,
9404 valp[1] ? 0 : HDA_AMP_MUTE);
9405 if (change)
9406 alc268_acer_automute(codec, 0);
9407 return change;
9408}
Takashi Iwaid2738092007-08-16 14:59:45 +02009409
9410static struct snd_kcontrol_new alc268_acer_mixer[] = {
9411 /* output mixer control */
9412 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9413 {
9414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9415 .name = "Master Playback Switch",
9416 .info = snd_hda_mixer_amp_switch_info,
9417 .get = snd_hda_mixer_amp_switch_get,
9418 .put = alc268_acer_master_sw_put,
9419 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9420 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9422 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9423 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009424 { }
9425};
9426
9427static struct hda_verb alc268_acer_verbs[] = {
9428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9430
9431 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9432 { }
9433};
9434
9435/* unsolicited event for HP jack sensing */
9436static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9437 unsigned int res)
9438{
Takashi Iwai889c4392007-08-23 18:56:52 +02009439 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009440 return;
9441 alc268_toshiba_automute(codec);
9442}
9443
9444static void alc268_acer_unsol_event(struct hda_codec *codec,
9445 unsigned int res)
9446{
Takashi Iwai889c4392007-08-23 18:56:52 +02009447 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009448 return;
9449 alc268_acer_automute(codec, 1);
9450}
9451
Takashi Iwai889c4392007-08-23 18:56:52 +02009452static void alc268_acer_init_hook(struct hda_codec *codec)
9453{
9454 alc268_acer_automute(codec, 1);
9455}
9456
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009457static struct snd_kcontrol_new alc268_dell_mixer[] = {
9458 /* output mixer control */
9459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9460 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9463 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9464 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9465 { }
9466};
9467
9468static struct hda_verb alc268_dell_verbs[] = {
9469 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9472 { }
9473};
9474
9475/* mute/unmute internal speaker according to the hp jack and mute state */
9476static void alc268_dell_automute(struct hda_codec *codec)
9477{
9478 unsigned int present;
9479 unsigned int mute;
9480
9481 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9482 if (present & 0x80000000)
9483 mute = HDA_AMP_MUTE;
9484 else
9485 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9487 HDA_AMP_MUTE, mute);
9488}
9489
9490static void alc268_dell_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) != ALC880_HP_EVENT)
9494 return;
9495 alc268_dell_automute(codec);
9496}
9497
9498#define alc268_dell_init_hook alc268_dell_automute
9499
Kailang Yanga361d842007-06-05 12:30:55 +02009500/*
9501 * generic initialization of ADC, input mixers and output mixers
9502 */
9503static struct hda_verb alc268_base_init_verbs[] = {
9504 /* Unmute DAC0-1 and set vol = 0 */
9505 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9506 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9507 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9508 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9509 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9510 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9511
9512 /*
9513 * Set up output mixers (0x0c - 0x0e)
9514 */
9515 /* set vol=0 to output mixers */
9516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9519 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9520
9521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9522 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9523
9524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9526 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9530 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9531 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9532
9533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9537 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9538 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9539 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9540 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9541
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009542 /* Unmute Selector 23h,24h and set the default input to mic-in */
9543
9544 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9546 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009548
Kailang Yanga361d842007-06-05 12:30:55 +02009549 { }
9550};
9551
9552/*
9553 * generic initialization of ADC, input mixers and output mixers
9554 */
9555static struct hda_verb alc268_volume_init_verbs[] = {
9556 /* set output DAC */
9557 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9558 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9561
9562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9565 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9566 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9567
9568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9571 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9572 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9573
9574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9577 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9578
9579 /* set PCBEEP vol = 0 */
9580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9581
9582 { }
9583};
9584
9585#define alc268_mux_enum_info alc_mux_enum_info
9586#define alc268_mux_enum_get alc_mux_enum_get
9587
9588static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9589 struct snd_ctl_elem_value *ucontrol)
9590{
9591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9592 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009593
Kailang Yanga361d842007-06-05 12:30:55 +02009594 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9595 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9596 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009597
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009598 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9599 nid,
9600 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009601}
9602
9603static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9604 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9606 {
9607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9608 /* The multiple "Capture Source" controls confuse alsamixer
9609 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009610 */
9611 /* .name = "Capture Source", */
9612 .name = "Input Source",
9613 .count = 1,
9614 .info = alc268_mux_enum_info,
9615 .get = alc268_mux_enum_get,
9616 .put = alc268_mux_enum_put,
9617 },
9618 { } /* end */
9619};
9620
9621static struct snd_kcontrol_new alc268_capture_mixer[] = {
9622 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9623 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9624 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9625 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9626 {
9627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9628 /* The multiple "Capture Source" controls confuse alsamixer
9629 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009630 */
9631 /* .name = "Capture Source", */
9632 .name = "Input Source",
9633 .count = 2,
9634 .info = alc268_mux_enum_info,
9635 .get = alc268_mux_enum_get,
9636 .put = alc268_mux_enum_put,
9637 },
9638 { } /* end */
9639};
9640
9641static struct hda_input_mux alc268_capture_source = {
9642 .num_items = 4,
9643 .items = {
9644 { "Mic", 0x0 },
9645 { "Front Mic", 0x1 },
9646 { "Line", 0x2 },
9647 { "CD", 0x3 },
9648 },
9649};
9650
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009651#ifdef CONFIG_SND_DEBUG
9652static struct snd_kcontrol_new alc268_test_mixer[] = {
9653 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9657
9658 /* Volume widgets */
9659 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9660 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9661 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9662 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9663 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9664 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9665 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9666 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9667 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9668 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9669 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9670 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9671 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +01009672 /* The below appears problematic on some hardwares */
9673 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009674 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9675 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9676 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9677 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9678
9679 /* Modes for retasking pin widgets */
9680 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9681 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9682 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9683 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9684
9685 /* Controls for GPIO pins, assuming they are configured as outputs */
9686 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9687 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9688 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9689 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9690
9691 /* Switches to allow the digital SPDIF output pin to be enabled.
9692 * The ALC268 does not have an SPDIF input.
9693 */
9694 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9695
9696 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9697 * this output to turn on an external amplifier.
9698 */
9699 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9700 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9701
9702 { } /* end */
9703};
9704#endif
9705
Kailang Yanga361d842007-06-05 12:30:55 +02009706/* create input playback/capture controls for the given pin */
9707static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9708 const char *ctlname, int idx)
9709{
9710 char name[32];
9711 int err;
9712
9713 sprintf(name, "%s Playback Volume", ctlname);
9714 if (nid == 0x14) {
9715 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9716 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9717 HDA_OUTPUT));
9718 if (err < 0)
9719 return err;
9720 } else if (nid == 0x15) {
9721 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9722 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9723 HDA_OUTPUT));
9724 if (err < 0)
9725 return err;
9726 } else
9727 return -1;
9728 sprintf(name, "%s Playback Switch", ctlname);
9729 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9730 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9731 if (err < 0)
9732 return err;
9733 return 0;
9734}
9735
9736/* add playback controls from the parsed DAC table */
9737static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9738 const struct auto_pin_cfg *cfg)
9739{
9740 hda_nid_t nid;
9741 int err;
9742
9743 spec->multiout.num_dacs = 2; /* only use one dac */
9744 spec->multiout.dac_nids = spec->private_dac_nids;
9745 spec->multiout.dac_nids[0] = 2;
9746 spec->multiout.dac_nids[1] = 3;
9747
9748 nid = cfg->line_out_pins[0];
9749 if (nid)
9750 alc268_new_analog_output(spec, nid, "Front", 0);
9751
9752 nid = cfg->speaker_pins[0];
9753 if (nid == 0x1d) {
9754 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9755 "Speaker Playback Volume",
9756 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9757 if (err < 0)
9758 return err;
9759 }
9760 nid = cfg->hp_pins[0];
9761 if (nid)
9762 alc268_new_analog_output(spec, nid, "Headphone", 0);
9763
9764 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9765 if (nid == 0x16) {
9766 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9767 "Mono Playback Switch",
9768 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9769 if (err < 0)
9770 return err;
9771 }
9772 return 0;
9773}
9774
9775/* create playback/capture controls for input pins */
9776static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9777 const struct auto_pin_cfg *cfg)
9778{
9779 struct hda_input_mux *imux = &spec->private_imux;
9780 int i, idx1;
9781
9782 for (i = 0; i < AUTO_PIN_LAST; i++) {
9783 switch(cfg->input_pins[i]) {
9784 case 0x18:
9785 idx1 = 0; /* Mic 1 */
9786 break;
9787 case 0x19:
9788 idx1 = 1; /* Mic 2 */
9789 break;
9790 case 0x1a:
9791 idx1 = 2; /* Line In */
9792 break;
9793 case 0x1c:
9794 idx1 = 3; /* CD */
9795 break;
9796 default:
9797 continue;
9798 }
9799 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9800 imux->items[imux->num_items].index = idx1;
9801 imux->num_items++;
9802 }
9803 return 0;
9804}
9805
9806static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9807{
9808 struct alc_spec *spec = codec->spec;
9809 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9810 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9811 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9812 unsigned int dac_vol1, dac_vol2;
9813
9814 if (speaker_nid) {
9815 snd_hda_codec_write(codec, speaker_nid, 0,
9816 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9817 snd_hda_codec_write(codec, 0x0f, 0,
9818 AC_VERB_SET_AMP_GAIN_MUTE,
9819 AMP_IN_UNMUTE(1));
9820 snd_hda_codec_write(codec, 0x10, 0,
9821 AC_VERB_SET_AMP_GAIN_MUTE,
9822 AMP_IN_UNMUTE(1));
9823 } else {
9824 snd_hda_codec_write(codec, 0x0f, 0,
9825 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9826 snd_hda_codec_write(codec, 0x10, 0,
9827 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9828 }
9829
9830 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9831 if (line_nid == 0x14)
9832 dac_vol2 = AMP_OUT_ZERO;
9833 else if (line_nid == 0x15)
9834 dac_vol1 = AMP_OUT_ZERO;
9835 if (hp_nid == 0x14)
9836 dac_vol2 = AMP_OUT_ZERO;
9837 else if (hp_nid == 0x15)
9838 dac_vol1 = AMP_OUT_ZERO;
9839 if (line_nid != 0x16 || hp_nid != 0x16 ||
9840 spec->autocfg.line_out_pins[1] != 0x16 ||
9841 spec->autocfg.line_out_pins[2] != 0x16)
9842 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9843
9844 snd_hda_codec_write(codec, 0x02, 0,
9845 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9846 snd_hda_codec_write(codec, 0x03, 0,
9847 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9848}
9849
9850/* pcm configuration: identiacal with ALC880 */
9851#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9852#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009853#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +02009854#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9855
9856/*
9857 * BIOS auto configuration
9858 */
9859static int alc268_parse_auto_config(struct hda_codec *codec)
9860{
9861 struct alc_spec *spec = codec->spec;
9862 int err;
9863 static hda_nid_t alc268_ignore[] = { 0 };
9864
9865 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9866 alc268_ignore);
9867 if (err < 0)
9868 return err;
9869 if (!spec->autocfg.line_outs)
9870 return 0; /* can't find valid BIOS pin config */
9871
9872 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9873 if (err < 0)
9874 return err;
9875 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9876 if (err < 0)
9877 return err;
9878
9879 spec->multiout.max_channels = 2;
9880
9881 /* digital only support output */
9882 if (spec->autocfg.dig_out_pin)
9883 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9884
9885 if (spec->kctl_alloc)
9886 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9887
9888 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9889 spec->num_mux_defs = 1;
9890 spec->input_mux = &spec->private_imux;
9891
Takashi Iwai776e1842007-08-29 15:07:11 +02009892 err = alc_auto_add_mic_boost(codec);
9893 if (err < 0)
9894 return err;
9895
Kailang Yanga361d842007-06-05 12:30:55 +02009896 return 1;
9897}
9898
9899#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9900#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9901#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9902
9903/* init callback for auto-configuration model -- overriding the default init */
9904static void alc268_auto_init(struct hda_codec *codec)
9905{
9906 alc268_auto_init_multi_out(codec);
9907 alc268_auto_init_hp_out(codec);
9908 alc268_auto_init_mono_speaker_out(codec);
9909 alc268_auto_init_analog_input(codec);
9910}
9911
9912/*
9913 * configuration and preset
9914 */
9915static const char *alc268_models[ALC268_MODEL_LAST] = {
9916 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009917 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009918 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009919 [ALC268_DELL] = "dell",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009920#ifdef CONFIG_SND_DEBUG
9921 [ALC268_TEST] = "test",
9922#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009923 [ALC268_AUTO] = "auto",
9924};
9925
9926static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009927 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +01009928 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009929 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +01009930 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009931 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009932 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009933 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009934 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009935 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009936 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009937 {}
9938};
9939
9940static struct alc_config_preset alc268_presets[] = {
9941 [ALC268_3ST] = {
9942 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9943 .init_verbs = { alc268_base_init_verbs },
9944 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9945 .dac_nids = alc268_dac_nids,
9946 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9947 .adc_nids = alc268_adc_nids_alt,
9948 .hp_nid = 0x03,
9949 .dig_out_nid = ALC268_DIGOUT_NID,
9950 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9951 .channel_mode = alc268_modes,
9952 .input_mux = &alc268_capture_source,
9953 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009954 [ALC268_TOSHIBA] = {
9955 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009956 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9957 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009958 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9959 .dac_nids = alc268_dac_nids,
9960 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9961 .adc_nids = alc268_adc_nids_alt,
9962 .hp_nid = 0x03,
9963 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9964 .channel_mode = alc268_modes,
9965 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009966 .unsol_event = alc268_toshiba_unsol_event,
9967 .init_hook = alc268_toshiba_automute,
9968 },
9969 [ALC268_ACER] = {
9970 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9971 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9972 alc268_acer_verbs },
9973 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9974 .dac_nids = alc268_dac_nids,
9975 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9976 .adc_nids = alc268_adc_nids_alt,
9977 .hp_nid = 0x02,
9978 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9979 .channel_mode = alc268_modes,
9980 .input_mux = &alc268_capture_source,
9981 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009982 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009983 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009984 [ALC268_DELL] = {
9985 .mixers = { alc268_dell_mixer },
9986 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9987 alc268_dell_verbs },
9988 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9989 .dac_nids = alc268_dac_nids,
9990 .hp_nid = 0x02,
9991 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9992 .channel_mode = alc268_modes,
9993 .unsol_event = alc268_dell_unsol_event,
9994 .init_hook = alc268_dell_init_hook,
9995 .input_mux = &alc268_capture_source,
9996 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009997#ifdef CONFIG_SND_DEBUG
9998 [ALC268_TEST] = {
9999 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10000 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10001 alc268_volume_init_verbs },
10002 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10003 .dac_nids = alc268_dac_nids,
10004 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10005 .adc_nids = alc268_adc_nids_alt,
10006 .hp_nid = 0x03,
10007 .dig_out_nid = ALC268_DIGOUT_NID,
10008 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10009 .channel_mode = alc268_modes,
10010 .input_mux = &alc268_capture_source,
10011 },
10012#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010013};
10014
10015static int patch_alc268(struct hda_codec *codec)
10016{
10017 struct alc_spec *spec;
10018 int board_config;
10019 int err;
10020
10021 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10022 if (spec == NULL)
10023 return -ENOMEM;
10024
10025 codec->spec = spec;
10026
10027 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10028 alc268_models,
10029 alc268_cfg_tbl);
10030
10031 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10032 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10033 "trying auto-probe from BIOS...\n");
10034 board_config = ALC268_AUTO;
10035 }
10036
10037 if (board_config == ALC268_AUTO) {
10038 /* automatic parse from the BIOS config */
10039 err = alc268_parse_auto_config(codec);
10040 if (err < 0) {
10041 alc_free(codec);
10042 return err;
10043 } else if (!err) {
10044 printk(KERN_INFO
10045 "hda_codec: Cannot set up configuration "
10046 "from BIOS. Using base mode...\n");
10047 board_config = ALC268_3ST;
10048 }
10049 }
10050
10051 if (board_config != ALC268_AUTO)
10052 setup_preset(spec, &alc268_presets[board_config]);
10053
10054 spec->stream_name_analog = "ALC268 Analog";
10055 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10056 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010057 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010058
10059 spec->stream_name_digital = "ALC268 Digital";
10060 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10061
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010062 if (!spec->adc_nids && spec->input_mux) {
10063 /* check whether NID 0x07 is valid */
10064 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020010065
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010066 /* get type */
10067 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10068 if (wcap != AC_WID_AUD_IN) {
10069 spec->adc_nids = alc268_adc_nids_alt;
10070 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10071 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010072 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010073 spec->num_mixers++;
10074 } else {
10075 spec->adc_nids = alc268_adc_nids;
10076 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10077 spec->mixers[spec->num_mixers] =
10078 alc268_capture_mixer;
10079 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010080 }
10081 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010082
10083 spec->vmaster_nid = 0x02;
10084
Kailang Yanga361d842007-06-05 12:30:55 +020010085 codec->patch_ops = alc_patch_ops;
10086 if (board_config == ALC268_AUTO)
10087 spec->init_hook = alc268_auto_init;
10088
10089 return 0;
10090}
10091
10092/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010093 * ALC269 channel source setting (2 channel)
10094 */
10095#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10096
10097#define alc269_dac_nids alc260_dac_nids
10098
10099static hda_nid_t alc269_adc_nids[1] = {
10100 /* ADC1 */
10101 0x07,
10102};
10103
10104#define alc269_modes alc260_modes
10105#define alc269_capture_source alc880_lg_lw_capture_source
10106
10107static struct snd_kcontrol_new alc269_base_mixer[] = {
10108 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10120 { } /* end */
10121};
10122
10123/* capture mixer elements */
10124static struct snd_kcontrol_new alc269_capture_mixer[] = {
10125 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10126 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10127 {
10128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10129 /* The multiple "Capture Source" controls confuse alsamixer
10130 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010131 */
10132 /* .name = "Capture Source", */
10133 .name = "Input Source",
10134 .count = 1,
10135 .info = alc_mux_enum_info,
10136 .get = alc_mux_enum_get,
10137 .put = alc_mux_enum_put,
10138 },
10139 { } /* end */
10140};
10141
10142/*
10143 * generic initialization of ADC, input mixers and output mixers
10144 */
10145static struct hda_verb alc269_init_verbs[] = {
10146 /*
10147 * Unmute ADC0 and set the default input to mic-in
10148 */
10149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10150
10151 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10152 * analog-loopback mixer widget
10153 * Note: PASD motherboards uses the Line In 2 as the input for
10154 * front panel mic (mic 2)
10155 */
10156 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10162
10163 /*
10164 * Set up output mixers (0x0c - 0x0e)
10165 */
10166 /* set vol=0 to output mixers */
10167 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10168 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10169
10170 /* set up input amps for analog loopback */
10171 /* Amp Indices: DAC = 0, mixer = 1 */
10172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10178
10179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10186
10187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10194
10195 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10197
10198 /* FIXME: use matrix-type input source selection */
10199 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10200 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10205
10206 /* set EAPD */
10207 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10208 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10209 { }
10210};
10211
10212/* add playback controls from the parsed DAC table */
10213static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10214 const struct auto_pin_cfg *cfg)
10215{
10216 hda_nid_t nid;
10217 int err;
10218
10219 spec->multiout.num_dacs = 1; /* only use one dac */
10220 spec->multiout.dac_nids = spec->private_dac_nids;
10221 spec->multiout.dac_nids[0] = 2;
10222
10223 nid = cfg->line_out_pins[0];
10224 if (nid) {
10225 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10226 "Front Playback Volume",
10227 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10228 if (err < 0)
10229 return err;
10230 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10231 "Front Playback Switch",
10232 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10233 if (err < 0)
10234 return err;
10235 }
10236
10237 nid = cfg->speaker_pins[0];
10238 if (nid) {
10239 if (!cfg->line_out_pins[0]) {
10240 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10241 "Speaker Playback Volume",
10242 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10243 HDA_OUTPUT));
10244 if (err < 0)
10245 return err;
10246 }
10247 if (nid == 0x16) {
10248 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10249 "Speaker Playback Switch",
10250 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10251 HDA_OUTPUT));
10252 if (err < 0)
10253 return err;
10254 } else {
10255 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10256 "Speaker Playback Switch",
10257 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10258 HDA_OUTPUT));
10259 if (err < 0)
10260 return err;
10261 }
10262 }
10263 nid = cfg->hp_pins[0];
10264 if (nid) {
10265 /* spec->multiout.hp_nid = 2; */
10266 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10267 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10268 "Headphone Playback Volume",
10269 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10270 HDA_OUTPUT));
10271 if (err < 0)
10272 return err;
10273 }
10274 if (nid == 0x16) {
10275 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10276 "Headphone Playback Switch",
10277 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10278 HDA_OUTPUT));
10279 if (err < 0)
10280 return err;
10281 } else {
10282 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10283 "Headphone Playback Switch",
10284 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10285 HDA_OUTPUT));
10286 if (err < 0)
10287 return err;
10288 }
10289 }
10290 return 0;
10291}
10292
10293#define alc269_auto_create_analog_input_ctls \
10294 alc880_auto_create_analog_input_ctls
10295
10296#ifdef CONFIG_SND_HDA_POWER_SAVE
10297#define alc269_loopbacks alc880_loopbacks
10298#endif
10299
10300/* pcm configuration: identiacal with ALC880 */
10301#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10302#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10303#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10304#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10305
10306/*
10307 * BIOS auto configuration
10308 */
10309static int alc269_parse_auto_config(struct hda_codec *codec)
10310{
10311 struct alc_spec *spec = codec->spec;
10312 int err;
10313 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10314
10315 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10316 alc269_ignore);
10317 if (err < 0)
10318 return err;
10319
10320 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10321 if (err < 0)
10322 return err;
10323 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10324 if (err < 0)
10325 return err;
10326
10327 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10328
10329 if (spec->autocfg.dig_out_pin)
10330 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10331
10332 if (spec->kctl_alloc)
10333 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10334
10335 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10336 spec->num_mux_defs = 1;
10337 spec->input_mux = &spec->private_imux;
10338
10339 err = alc_auto_add_mic_boost(codec);
10340 if (err < 0)
10341 return err;
10342
10343 return 1;
10344}
10345
10346#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10347#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10348#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10349
10350
10351/* init callback for auto-configuration model -- overriding the default init */
10352static void alc269_auto_init(struct hda_codec *codec)
10353{
10354 alc269_auto_init_multi_out(codec);
10355 alc269_auto_init_hp_out(codec);
10356 alc269_auto_init_analog_input(codec);
10357}
10358
10359/*
10360 * configuration and preset
10361 */
10362static const char *alc269_models[ALC269_MODEL_LAST] = {
10363 [ALC269_BASIC] = "basic",
10364};
10365
10366static struct snd_pci_quirk alc269_cfg_tbl[] = {
10367 {}
10368};
10369
10370static struct alc_config_preset alc269_presets[] = {
10371 [ALC269_BASIC] = {
10372 .mixers = { alc269_base_mixer },
10373 .init_verbs = { alc269_init_verbs },
10374 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10375 .dac_nids = alc269_dac_nids,
10376 .hp_nid = 0x03,
10377 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10378 .channel_mode = alc269_modes,
10379 .input_mux = &alc269_capture_source,
10380 },
10381};
10382
10383static int patch_alc269(struct hda_codec *codec)
10384{
10385 struct alc_spec *spec;
10386 int board_config;
10387 int err;
10388
10389 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10390 if (spec == NULL)
10391 return -ENOMEM;
10392
10393 codec->spec = spec;
10394
10395 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10396 alc269_models,
10397 alc269_cfg_tbl);
10398
10399 if (board_config < 0) {
10400 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10401 "trying auto-probe from BIOS...\n");
10402 board_config = ALC269_AUTO;
10403 }
10404
10405 if (board_config == ALC269_AUTO) {
10406 /* automatic parse from the BIOS config */
10407 err = alc269_parse_auto_config(codec);
10408 if (err < 0) {
10409 alc_free(codec);
10410 return err;
10411 } else if (!err) {
10412 printk(KERN_INFO
10413 "hda_codec: Cannot set up configuration "
10414 "from BIOS. Using base mode...\n");
10415 board_config = ALC269_BASIC;
10416 }
10417 }
10418
10419 if (board_config != ALC269_AUTO)
10420 setup_preset(spec, &alc269_presets[board_config]);
10421
10422 spec->stream_name_analog = "ALC269 Analog";
10423 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10424 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10425
10426 spec->stream_name_digital = "ALC269 Digital";
10427 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10428 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10429
10430 spec->adc_nids = alc269_adc_nids;
10431 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10432 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10433 spec->num_mixers++;
10434
10435 codec->patch_ops = alc_patch_ops;
10436 if (board_config == ALC269_AUTO)
10437 spec->init_hook = alc269_auto_init;
10438#ifdef CONFIG_SND_HDA_POWER_SAVE
10439 if (!spec->loopback.amplist)
10440 spec->loopback.amplist = alc269_loopbacks;
10441#endif
10442
10443 return 0;
10444}
10445
10446/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010447 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10448 */
10449
10450/*
10451 * set the path ways for 2 channel output
10452 * need to set the codec line out and mic 1 pin widgets to inputs
10453 */
10454static struct hda_verb alc861_threestack_ch2_init[] = {
10455 /* set pin widget 1Ah (line in) for input */
10456 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010457 /* set pin widget 18h (mic1/2) for input, for mic also enable
10458 * the vref
10459 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010460 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10461
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010462 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10463#if 0
10464 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10465 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10466#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010467 { } /* end */
10468};
10469/*
10470 * 6ch mode
10471 * need to set the codec line out and mic 1 pin widgets to outputs
10472 */
10473static struct hda_verb alc861_threestack_ch6_init[] = {
10474 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10475 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10476 /* set pin widget 18h (mic1) for output (CLFE)*/
10477 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10478
10479 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010480 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010481
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010482 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10483#if 0
10484 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10485 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10486#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010487 { } /* end */
10488};
10489
10490static struct hda_channel_mode alc861_threestack_modes[2] = {
10491 { 2, alc861_threestack_ch2_init },
10492 { 6, alc861_threestack_ch6_init },
10493};
Takashi Iwai22309c32006-08-09 16:57:28 +020010494/* Set mic1 as input and unmute the mixer */
10495static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10496 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10498 { } /* end */
10499};
10500/* Set mic1 as output and mute mixer */
10501static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10502 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10503 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10504 { } /* end */
10505};
10506
10507static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10508 { 2, alc861_uniwill_m31_ch2_init },
10509 { 4, alc861_uniwill_m31_ch4_init },
10510};
Kailang Yangdf694da2005-12-05 19:42:22 +010010511
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010512/* Set mic1 and line-in as input and unmute the mixer */
10513static struct hda_verb alc861_asus_ch2_init[] = {
10514 /* set pin widget 1Ah (line in) for input */
10515 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010516 /* set pin widget 18h (mic1/2) for input, for mic also enable
10517 * the vref
10518 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010519 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10520
10521 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10522#if 0
10523 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10524 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10525#endif
10526 { } /* end */
10527};
10528/* Set mic1 nad line-in as output and mute mixer */
10529static struct hda_verb alc861_asus_ch6_init[] = {
10530 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10531 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10532 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10533 /* set pin widget 18h (mic1) for output (CLFE)*/
10534 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10535 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10536 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10537 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10538
10539 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10540#if 0
10541 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10542 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10543#endif
10544 { } /* end */
10545};
10546
10547static struct hda_channel_mode alc861_asus_modes[2] = {
10548 { 2, alc861_asus_ch2_init },
10549 { 6, alc861_asus_ch6_init },
10550};
10551
Kailang Yangdf694da2005-12-05 19:42:22 +010010552/* patch-ALC861 */
10553
10554static struct snd_kcontrol_new alc861_base_mixer[] = {
10555 /* output mixer control */
10556 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10557 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10560 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10561
10562 /*Input mixer control */
10563 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10564 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10565 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10566 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10567 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10568 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10570 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10571 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010573
Kailang Yangdf694da2005-12-05 19:42:22 +010010574 /* Capture mixer control */
10575 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10576 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10577 {
10578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10579 .name = "Capture Source",
10580 .count = 1,
10581 .info = alc_mux_enum_info,
10582 .get = alc_mux_enum_get,
10583 .put = alc_mux_enum_put,
10584 },
10585 { } /* end */
10586};
10587
10588static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10589 /* output mixer control */
10590 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10591 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10592 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10593 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10594 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10595
10596 /* Input mixer control */
10597 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10598 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10599 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10600 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10601 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10602 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10604 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10605 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010607
Kailang Yangdf694da2005-12-05 19:42:22 +010010608 /* Capture mixer control */
10609 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10610 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10611 {
10612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10613 .name = "Capture Source",
10614 .count = 1,
10615 .info = alc_mux_enum_info,
10616 .get = alc_mux_enum_get,
10617 .put = alc_mux_enum_put,
10618 },
10619 {
10620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10621 .name = "Channel Mode",
10622 .info = alc_ch_mode_info,
10623 .get = alc_ch_mode_get,
10624 .put = alc_ch_mode_put,
10625 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10626 },
10627 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010628};
10629
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010630static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010631 /* output mixer control */
10632 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10634 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10635
10636 /*Capture mixer control */
10637 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10638 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10639 {
10640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10641 .name = "Capture Source",
10642 .count = 1,
10643 .info = alc_mux_enum_info,
10644 .get = alc_mux_enum_get,
10645 .put = alc_mux_enum_put,
10646 },
10647
10648 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010649};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010650
Takashi Iwai22309c32006-08-09 16:57:28 +020010651static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10652 /* output mixer control */
10653 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10654 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10655 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10656 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10657 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10658
10659 /* Input mixer control */
10660 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10661 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10662 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10663 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10664 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10665 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10667 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10668 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010670
Takashi Iwai22309c32006-08-09 16:57:28 +020010671 /* Capture mixer control */
10672 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10673 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10674 {
10675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10676 .name = "Capture Source",
10677 .count = 1,
10678 .info = alc_mux_enum_info,
10679 .get = alc_mux_enum_get,
10680 .put = alc_mux_enum_put,
10681 },
10682 {
10683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10684 .name = "Channel Mode",
10685 .info = alc_ch_mode_info,
10686 .get = alc_ch_mode_get,
10687 .put = alc_ch_mode_put,
10688 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10689 },
10690 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010691};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010692
10693static struct snd_kcontrol_new alc861_asus_mixer[] = {
10694 /* output mixer control */
10695 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10696 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10697 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10699 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10700
10701 /* Input mixer control */
10702 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10703 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10704 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("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10707 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10709 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10712
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010713 /* Capture mixer control */
10714 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10715 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10716 {
10717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10718 .name = "Capture Source",
10719 .count = 1,
10720 .info = alc_mux_enum_info,
10721 .get = alc_mux_enum_get,
10722 .put = alc_mux_enum_put,
10723 },
10724 {
10725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10726 .name = "Channel Mode",
10727 .info = alc_ch_mode_info,
10728 .get = alc_ch_mode_get,
10729 .put = alc_ch_mode_put,
10730 .private_value = ARRAY_SIZE(alc861_asus_modes),
10731 },
10732 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010733};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010734
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010735/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010736static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010737 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10738 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10739 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10740 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10741 { }
10742};
10743
Kailang Yangdf694da2005-12-05 19:42:22 +010010744/*
10745 * generic initialization of ADC, input mixers and output mixers
10746 */
10747static struct hda_verb alc861_base_init_verbs[] = {
10748 /*
10749 * Unmute ADC0 and set the default input to mic-in
10750 */
10751 /* port-A for surround (rear panel) */
10752 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10753 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10754 /* port-B for mic-in (rear panel) with vref */
10755 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10756 /* port-C for line-in (rear panel) */
10757 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10758 /* port-D for Front */
10759 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10760 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10761 /* port-E for HP out (front panel) */
10762 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10763 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010765 /* port-F for mic-in (front panel) with vref */
10766 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10767 /* port-G for CLFE (rear panel) */
10768 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10769 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10770 /* port-H for side (rear panel) */
10771 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10772 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10773 /* CD-in */
10774 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10775 /* route front mic to ADC1*/
10776 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10777 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10778
10779 /* Unmute DAC0~3 & spdif out*/
10780 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10782 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10783 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10785
10786 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10787 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10788 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10789 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10790 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10791
10792 /* Unmute Stereo Mixer 15 */
10793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010797
10798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010806 /* hp used DAC 3 (Front) */
10807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10809
10810 { }
10811};
10812
10813static struct hda_verb alc861_threestack_init_verbs[] = {
10814 /*
10815 * Unmute ADC0 and set the default input to mic-in
10816 */
10817 /* port-A for surround (rear panel) */
10818 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10819 /* port-B for mic-in (rear panel) with vref */
10820 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10821 /* port-C for line-in (rear panel) */
10822 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10823 /* port-D for Front */
10824 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10825 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10826 /* port-E for HP out (front panel) */
10827 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10828 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010829 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010830 /* port-F for mic-in (front panel) with vref */
10831 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10832 /* port-G for CLFE (rear panel) */
10833 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10834 /* port-H for side (rear panel) */
10835 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10836 /* CD-in */
10837 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10838 /* route front mic to ADC1*/
10839 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 /* Unmute DAC0~3 & spdif out*/
10842 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10843 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10844 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10845 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10847
10848 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10849 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10850 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10851 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10852 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10853
10854 /* Unmute Stereo Mixer 15 */
10855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010859
10860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10866 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868 /* hp used DAC 3 (Front) */
10869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10871 { }
10872};
Takashi Iwai22309c32006-08-09 16:57:28 +020010873
10874static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10875 /*
10876 * Unmute ADC0 and set the default input to mic-in
10877 */
10878 /* port-A for surround (rear panel) */
10879 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10880 /* port-B for mic-in (rear panel) with vref */
10881 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10882 /* port-C for line-in (rear panel) */
10883 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10884 /* port-D for Front */
10885 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10886 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10887 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010888 /* this has to be set to VREF80 */
10889 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010890 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010891 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010892 /* port-F for mic-in (front panel) with vref */
10893 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10894 /* port-G for CLFE (rear panel) */
10895 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10896 /* port-H for side (rear panel) */
10897 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10898 /* CD-in */
10899 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10900 /* route front mic to ADC1*/
10901 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10903 /* Unmute DAC0~3 & spdif out*/
10904 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10905 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10906 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10907 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10909
10910 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10911 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10912 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10913 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10914 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10915
10916 /* Unmute Stereo Mixer 15 */
10917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010921
10922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10923 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010930 /* hp used DAC 3 (Front) */
10931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10933 { }
10934};
10935
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010936static struct hda_verb alc861_asus_init_verbs[] = {
10937 /*
10938 * Unmute ADC0 and set the default input to mic-in
10939 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010940 /* port-A for surround (rear panel)
10941 * according to codec#0 this is the HP jack
10942 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010943 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10944 /* route front PCM to HP */
10945 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10946 /* port-B for mic-in (rear panel) with vref */
10947 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10948 /* port-C for line-in (rear panel) */
10949 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10950 /* port-D for Front */
10951 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10952 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10953 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010954 /* this has to be set to VREF80 */
10955 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010956 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010957 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010958 /* port-F for mic-in (front panel) with vref */
10959 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10960 /* port-G for CLFE (rear panel) */
10961 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10962 /* port-H for side (rear panel) */
10963 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10964 /* CD-in */
10965 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10966 /* route front mic to ADC1*/
10967 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10969 /* Unmute DAC0~3 & spdif out*/
10970 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10971 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10972 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10973 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10975 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10976 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10977 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10978 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10979 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10980
10981 /* Unmute Stereo Mixer 15 */
10982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010986
10987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10988 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10990 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010995 /* hp used DAC 3 (Front) */
10996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10998 { }
10999};
11000
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011001/* additional init verbs for ASUS laptops */
11002static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11003 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11004 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11005 { }
11006};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011007
Kailang Yangdf694da2005-12-05 19:42:22 +010011008/*
11009 * generic initialization of ADC, input mixers and output mixers
11010 */
11011static struct hda_verb alc861_auto_init_verbs[] = {
11012 /*
11013 * Unmute ADC0 and set the default input to mic-in
11014 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011015 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011016 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11017
11018 /* Unmute DAC0~3 & spdif out*/
11019 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11022 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11024
11025 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11026 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11028 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11030
11031 /* Unmute Stereo Mixer 15 */
11032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11036
11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11045
11046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11051 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011054
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011056
11057 { }
11058};
11059
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011060static struct hda_verb alc861_toshiba_init_verbs[] = {
11061 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011062
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011063 { }
11064};
11065
11066/* toggle speaker-output according to the hp-jack state */
11067static void alc861_toshiba_automute(struct hda_codec *codec)
11068{
11069 unsigned int present;
11070
11071 present = snd_hda_codec_read(codec, 0x0f, 0,
11072 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011073 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11074 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11075 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11076 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011077}
11078
11079static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11080 unsigned int res)
11081{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011082 if ((res >> 26) == ALC880_HP_EVENT)
11083 alc861_toshiba_automute(codec);
11084}
11085
Kailang Yangdf694da2005-12-05 19:42:22 +010011086/* pcm configuration: identiacal with ALC880 */
11087#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11088#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11089#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11090#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11091
11092
11093#define ALC861_DIGOUT_NID 0x07
11094
11095static struct hda_channel_mode alc861_8ch_modes[1] = {
11096 { 8, NULL }
11097};
11098
11099static hda_nid_t alc861_dac_nids[4] = {
11100 /* front, surround, clfe, side */
11101 0x03, 0x06, 0x05, 0x04
11102};
11103
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011104static hda_nid_t alc660_dac_nids[3] = {
11105 /* front, clfe, surround */
11106 0x03, 0x05, 0x06
11107};
11108
Kailang Yangdf694da2005-12-05 19:42:22 +010011109static hda_nid_t alc861_adc_nids[1] = {
11110 /* ADC0-2 */
11111 0x08,
11112};
11113
11114static struct hda_input_mux alc861_capture_source = {
11115 .num_items = 5,
11116 .items = {
11117 { "Mic", 0x0 },
11118 { "Front Mic", 0x3 },
11119 { "Line", 0x1 },
11120 { "CD", 0x4 },
11121 { "Mixer", 0x5 },
11122 },
11123};
11124
11125/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011126static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11127 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011128{
11129 int i;
11130 hda_nid_t nid;
11131
11132 spec->multiout.dac_nids = spec->private_dac_nids;
11133 for (i = 0; i < cfg->line_outs; i++) {
11134 nid = cfg->line_out_pins[i];
11135 if (nid) {
11136 if (i >= ARRAY_SIZE(alc861_dac_nids))
11137 continue;
11138 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11139 }
11140 }
11141 spec->multiout.num_dacs = cfg->line_outs;
11142 return 0;
11143}
11144
11145/* add playback controls from the parsed DAC table */
11146static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11147 const struct auto_pin_cfg *cfg)
11148{
11149 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011150 static const char *chname[4] = {
11151 "Front", "Surround", NULL /*CLFE*/, "Side"
11152 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011153 hda_nid_t nid;
11154 int i, idx, err;
11155
11156 for (i = 0; i < cfg->line_outs; i++) {
11157 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011158 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011159 continue;
11160 if (nid == 0x05) {
11161 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011162 err = add_control(spec, ALC_CTL_BIND_MUTE,
11163 "Center Playback Switch",
11164 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11165 HDA_OUTPUT));
11166 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011167 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011168 err = add_control(spec, ALC_CTL_BIND_MUTE,
11169 "LFE Playback Switch",
11170 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11171 HDA_OUTPUT));
11172 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011173 return err;
11174 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011175 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11176 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011177 if (nid == alc861_dac_nids[idx])
11178 break;
11179 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011180 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11181 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11182 HDA_OUTPUT));
11183 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011184 return err;
11185 }
11186 }
11187 return 0;
11188}
11189
11190static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11191{
11192 int err;
11193 hda_nid_t nid;
11194
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011195 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011196 return 0;
11197
11198 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11199 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11201 "Headphone Playback Switch",
11202 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11203 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011204 return err;
11205 spec->multiout.hp_nid = nid;
11206 }
11207 return 0;
11208}
11209
11210/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011211static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11212 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011213{
Kailang Yangdf694da2005-12-05 19:42:22 +010011214 struct hda_input_mux *imux = &spec->private_imux;
11215 int i, err, idx, idx1;
11216
11217 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011218 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011219 case 0x0c:
11220 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011222 break;
11223 case 0x0f:
11224 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011225 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011226 break;
11227 case 0x0d:
11228 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011229 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011230 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011231 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011232 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011233 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011234 break;
11235 case 0x11:
11236 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011237 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011238 break;
11239 default:
11240 continue;
11241 }
11242
Takashi Iwai4a471b72005-12-07 13:56:29 +010011243 err = new_analog_input(spec, cfg->input_pins[i],
11244 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011245 if (err < 0)
11246 return err;
11247
Takashi Iwai4a471b72005-12-07 13:56:29 +010011248 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011249 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011250 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011251 }
11252 return 0;
11253}
11254
11255static struct snd_kcontrol_new alc861_capture_mixer[] = {
11256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11258
11259 {
11260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11261 /* The multiple "Capture Source" controls confuse alsamixer
11262 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 */
11264 /* .name = "Capture Source", */
11265 .name = "Input Source",
11266 .count = 1,
11267 .info = alc_mux_enum_info,
11268 .get = alc_mux_enum_get,
11269 .put = alc_mux_enum_put,
11270 },
11271 { } /* end */
11272};
11273
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011274static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11275 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 int pin_type, int dac_idx)
11277{
11278 /* set as output */
11279
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011280 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11281 pin_type);
11282 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11283 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011284
11285}
11286
11287static void alc861_auto_init_multi_out(struct hda_codec *codec)
11288{
11289 struct alc_spec *spec = codec->spec;
11290 int i;
11291
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011292 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011293 for (i = 0; i < spec->autocfg.line_outs; i++) {
11294 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011295 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011296 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011297 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011298 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011299 }
11300}
11301
11302static void alc861_auto_init_hp_out(struct hda_codec *codec)
11303{
11304 struct alc_spec *spec = codec->spec;
11305 hda_nid_t pin;
11306
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011307 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011308 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011309 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11310 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011311}
11312
11313static void alc861_auto_init_analog_input(struct hda_codec *codec)
11314{
11315 struct alc_spec *spec = codec->spec;
11316 int i;
11317
11318 for (i = 0; i < AUTO_PIN_LAST; i++) {
11319 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011320 if (nid >= 0x0c && nid <= 0x11) {
11321 snd_hda_codec_write(codec, nid, 0,
11322 AC_VERB_SET_PIN_WIDGET_CONTROL,
11323 i <= AUTO_PIN_FRONT_MIC ?
11324 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011325 }
11326 }
11327}
11328
11329/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011330/* return 1 if successful, 0 if the proper config is not found,
11331 * or a negative error code
11332 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011333static int alc861_parse_auto_config(struct hda_codec *codec)
11334{
11335 struct alc_spec *spec = codec->spec;
11336 int err;
11337 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11338
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011339 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11340 alc861_ignore);
11341 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011342 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011343 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011344 return 0; /* can't find valid BIOS pin config */
11345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011346 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11347 if (err < 0)
11348 return err;
11349 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11350 if (err < 0)
11351 return err;
11352 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11353 if (err < 0)
11354 return err;
11355 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11356 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011357 return err;
11358
11359 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11360
11361 if (spec->autocfg.dig_out_pin)
11362 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11363
11364 if (spec->kctl_alloc)
11365 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11366
11367 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11368
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011369 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011370 spec->input_mux = &spec->private_imux;
11371
11372 spec->adc_nids = alc861_adc_nids;
11373 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11374 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11375 spec->num_mixers++;
11376
11377 return 1;
11378}
11379
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011380/* additional initialization for auto-configuration model */
11381static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011382{
Kailang Yangdf694da2005-12-05 19:42:22 +010011383 alc861_auto_init_multi_out(codec);
11384 alc861_auto_init_hp_out(codec);
11385 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011386}
11387
Takashi Iwaicb53c622007-08-10 17:21:45 +020011388#ifdef CONFIG_SND_HDA_POWER_SAVE
11389static struct hda_amp_list alc861_loopbacks[] = {
11390 { 0x15, HDA_INPUT, 0 },
11391 { 0x15, HDA_INPUT, 1 },
11392 { 0x15, HDA_INPUT, 2 },
11393 { 0x15, HDA_INPUT, 3 },
11394 { } /* end */
11395};
11396#endif
11397
Kailang Yangdf694da2005-12-05 19:42:22 +010011398
11399/*
11400 * configuration and preset
11401 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011402static const char *alc861_models[ALC861_MODEL_LAST] = {
11403 [ALC861_3ST] = "3stack",
11404 [ALC660_3ST] = "3stack-660",
11405 [ALC861_3ST_DIG] = "3stack-dig",
11406 [ALC861_6ST_DIG] = "6stack-dig",
11407 [ALC861_UNIWILL_M31] = "uniwill-m31",
11408 [ALC861_TOSHIBA] = "toshiba",
11409 [ALC861_ASUS] = "asus",
11410 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11411 [ALC861_AUTO] = "auto",
11412};
11413
11414static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011415 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011416 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11417 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11418 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011419 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011420 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011421 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011422 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11423 * Any other models that need this preset?
11424 */
11425 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011426 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11427 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011428 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11429 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11430 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11431 /* FIXME: the below seems conflict */
11432 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11433 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11434 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011435 {}
11436};
11437
11438static struct alc_config_preset alc861_presets[] = {
11439 [ALC861_3ST] = {
11440 .mixers = { alc861_3ST_mixer },
11441 .init_verbs = { alc861_threestack_init_verbs },
11442 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11443 .dac_nids = alc861_dac_nids,
11444 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11445 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011446 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011447 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11448 .adc_nids = alc861_adc_nids,
11449 .input_mux = &alc861_capture_source,
11450 },
11451 [ALC861_3ST_DIG] = {
11452 .mixers = { alc861_base_mixer },
11453 .init_verbs = { alc861_threestack_init_verbs },
11454 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11455 .dac_nids = alc861_dac_nids,
11456 .dig_out_nid = ALC861_DIGOUT_NID,
11457 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11458 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011459 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11461 .adc_nids = alc861_adc_nids,
11462 .input_mux = &alc861_capture_source,
11463 },
11464 [ALC861_6ST_DIG] = {
11465 .mixers = { alc861_base_mixer },
11466 .init_verbs = { alc861_base_init_verbs },
11467 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11468 .dac_nids = alc861_dac_nids,
11469 .dig_out_nid = ALC861_DIGOUT_NID,
11470 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11471 .channel_mode = alc861_8ch_modes,
11472 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11473 .adc_nids = alc861_adc_nids,
11474 .input_mux = &alc861_capture_source,
11475 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011476 [ALC660_3ST] = {
11477 .mixers = { alc861_3ST_mixer },
11478 .init_verbs = { alc861_threestack_init_verbs },
11479 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11480 .dac_nids = alc660_dac_nids,
11481 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11482 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011483 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011484 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11485 .adc_nids = alc861_adc_nids,
11486 .input_mux = &alc861_capture_source,
11487 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011488 [ALC861_UNIWILL_M31] = {
11489 .mixers = { alc861_uniwill_m31_mixer },
11490 .init_verbs = { alc861_uniwill_m31_init_verbs },
11491 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11492 .dac_nids = alc861_dac_nids,
11493 .dig_out_nid = ALC861_DIGOUT_NID,
11494 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11495 .channel_mode = alc861_uniwill_m31_modes,
11496 .need_dac_fix = 1,
11497 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11498 .adc_nids = alc861_adc_nids,
11499 .input_mux = &alc861_capture_source,
11500 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011501 [ALC861_TOSHIBA] = {
11502 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011503 .init_verbs = { alc861_base_init_verbs,
11504 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011505 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11506 .dac_nids = alc861_dac_nids,
11507 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11508 .channel_mode = alc883_3ST_2ch_modes,
11509 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11510 .adc_nids = alc861_adc_nids,
11511 .input_mux = &alc861_capture_source,
11512 .unsol_event = alc861_toshiba_unsol_event,
11513 .init_hook = alc861_toshiba_automute,
11514 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011515 [ALC861_ASUS] = {
11516 .mixers = { alc861_asus_mixer },
11517 .init_verbs = { alc861_asus_init_verbs },
11518 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11519 .dac_nids = alc861_dac_nids,
11520 .dig_out_nid = ALC861_DIGOUT_NID,
11521 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11522 .channel_mode = alc861_asus_modes,
11523 .need_dac_fix = 1,
11524 .hp_nid = 0x06,
11525 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11526 .adc_nids = alc861_adc_nids,
11527 .input_mux = &alc861_capture_source,
11528 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011529 [ALC861_ASUS_LAPTOP] = {
11530 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11531 .init_verbs = { alc861_asus_init_verbs,
11532 alc861_asus_laptop_init_verbs },
11533 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11534 .dac_nids = alc861_dac_nids,
11535 .dig_out_nid = ALC861_DIGOUT_NID,
11536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11537 .channel_mode = alc883_3ST_2ch_modes,
11538 .need_dac_fix = 1,
11539 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11540 .adc_nids = alc861_adc_nids,
11541 .input_mux = &alc861_capture_source,
11542 },
11543};
Kailang Yangdf694da2005-12-05 19:42:22 +010011544
11545
11546static int patch_alc861(struct hda_codec *codec)
11547{
11548 struct alc_spec *spec;
11549 int board_config;
11550 int err;
11551
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011552 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011553 if (spec == NULL)
11554 return -ENOMEM;
11555
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011556 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011557
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011558 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11559 alc861_models,
11560 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011561
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011562 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011563 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11564 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011565 board_config = ALC861_AUTO;
11566 }
11567
11568 if (board_config == ALC861_AUTO) {
11569 /* automatic parse from the BIOS config */
11570 err = alc861_parse_auto_config(codec);
11571 if (err < 0) {
11572 alc_free(codec);
11573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011574 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011575 printk(KERN_INFO
11576 "hda_codec: Cannot set up configuration "
11577 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011578 board_config = ALC861_3ST_DIG;
11579 }
11580 }
11581
11582 if (board_config != ALC861_AUTO)
11583 setup_preset(spec, &alc861_presets[board_config]);
11584
11585 spec->stream_name_analog = "ALC861 Analog";
11586 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11587 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11588
11589 spec->stream_name_digital = "ALC861 Digital";
11590 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11591 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11592
Takashi Iwai2134ea42008-01-10 16:53:55 +010011593 spec->vmaster_nid = 0x03;
11594
Kailang Yangdf694da2005-12-05 19:42:22 +010011595 codec->patch_ops = alc_patch_ops;
11596 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011597 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011598#ifdef CONFIG_SND_HDA_POWER_SAVE
11599 if (!spec->loopback.amplist)
11600 spec->loopback.amplist = alc861_loopbacks;
11601#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011602
11603 return 0;
11604}
11605
11606/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011607 * ALC861-VD support
11608 *
11609 * Based on ALC882
11610 *
11611 * In addition, an independent DAC
11612 */
11613#define ALC861VD_DIGOUT_NID 0x06
11614
11615static hda_nid_t alc861vd_dac_nids[4] = {
11616 /* front, surr, clfe, side surr */
11617 0x02, 0x03, 0x04, 0x05
11618};
11619
11620/* dac_nids for ALC660vd are in a different order - according to
11621 * Realtek's driver.
11622 * This should probably tesult in a different mixer for 6stack models
11623 * of ALC660vd codecs, but for now there is only 3stack mixer
11624 * - and it is the same as in 861vd.
11625 * adc_nids in ALC660vd are (is) the same as in 861vd
11626 */
11627static hda_nid_t alc660vd_dac_nids[3] = {
11628 /* front, rear, clfe, rear_surr */
11629 0x02, 0x04, 0x03
11630};
11631
11632static hda_nid_t alc861vd_adc_nids[1] = {
11633 /* ADC0 */
11634 0x09,
11635};
11636
11637/* input MUX */
11638/* FIXME: should be a matrix-type input source selection */
11639static struct hda_input_mux alc861vd_capture_source = {
11640 .num_items = 4,
11641 .items = {
11642 { "Mic", 0x0 },
11643 { "Front Mic", 0x1 },
11644 { "Line", 0x2 },
11645 { "CD", 0x4 },
11646 },
11647};
11648
Kailang Yang272a5272007-05-14 11:00:38 +020011649static struct hda_input_mux alc861vd_dallas_capture_source = {
11650 .num_items = 3,
11651 .items = {
11652 { "Front Mic", 0x0 },
11653 { "ATAPI Mic", 0x1 },
11654 { "Line In", 0x5 },
11655 },
11656};
11657
Kailang Yangd1a991a2007-08-15 16:21:59 +020011658static struct hda_input_mux alc861vd_hp_capture_source = {
11659 .num_items = 2,
11660 .items = {
11661 { "Front Mic", 0x0 },
11662 { "ATAPI Mic", 0x1 },
11663 },
11664};
11665
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011666#define alc861vd_mux_enum_info alc_mux_enum_info
11667#define alc861vd_mux_enum_get alc_mux_enum_get
11668
11669static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11670 struct snd_ctl_elem_value *ucontrol)
11671{
11672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11673 struct alc_spec *spec = codec->spec;
11674 const struct hda_input_mux *imux = spec->input_mux;
11675 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11676 static hda_nid_t capture_mixers[1] = { 0x22 };
11677 hda_nid_t nid = capture_mixers[adc_idx];
11678 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11679 unsigned int i, idx;
11680
11681 idx = ucontrol->value.enumerated.item[0];
11682 if (idx >= imux->num_items)
11683 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011684 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011685 return 0;
11686 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011687 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11688 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11689 imux->items[i].index,
11690 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011691 }
11692 *cur_val = idx;
11693 return 1;
11694}
11695
11696/*
11697 * 2ch mode
11698 */
11699static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11700 { 2, NULL }
11701};
11702
11703/*
11704 * 6ch mode
11705 */
11706static struct hda_verb alc861vd_6stack_ch6_init[] = {
11707 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11708 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11709 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11710 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11711 { } /* end */
11712};
11713
11714/*
11715 * 8ch mode
11716 */
11717static struct hda_verb alc861vd_6stack_ch8_init[] = {
11718 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11719 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11720 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11721 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11722 { } /* end */
11723};
11724
11725static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11726 { 6, alc861vd_6stack_ch6_init },
11727 { 8, alc861vd_6stack_ch8_init },
11728};
11729
11730static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11731 {
11732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11733 .name = "Channel Mode",
11734 .info = alc_ch_mode_info,
11735 .get = alc_ch_mode_get,
11736 .put = alc_ch_mode_put,
11737 },
11738 { } /* end */
11739};
11740
11741static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11742 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11743 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11744
11745 {
11746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11747 /* The multiple "Capture Source" controls confuse alsamixer
11748 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011749 */
11750 /* .name = "Capture Source", */
11751 .name = "Input Source",
11752 .count = 1,
11753 .info = alc861vd_mux_enum_info,
11754 .get = alc861vd_mux_enum_get,
11755 .put = alc861vd_mux_enum_put,
11756 },
11757 { } /* end */
11758};
11759
11760/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11761 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11762 */
11763static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11764 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11765 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11766
11767 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11768 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11769
11770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11771 HDA_OUTPUT),
11772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11773 HDA_OUTPUT),
11774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11776
11777 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11778 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11779
11780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11781
11782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11785
11786 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11789
11790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11792
11793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11795
11796 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11797 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11798
11799 { } /* end */
11800};
11801
11802static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11803 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11805
11806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11807
11808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11811
11812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11815
11816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11818
11819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11821
11822 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11823 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11824
11825 { } /* end */
11826};
11827
Kailang Yangbdd148a2007-05-08 15:19:08 +020011828static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11829 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11830 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11831 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11832
11833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11834
11835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11838
11839 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11842
11843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11845
11846 { } /* end */
11847};
11848
Kailang Yang272a5272007-05-14 11:00:38 +020011849/* Pin assignment: Front=0x14, HP = 0x15,
11850 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11851 */
11852static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11853 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11856 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11857 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11858 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11859 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11860 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011863 { } /* end */
11864};
11865
Kailang Yangd1a991a2007-08-15 16:21:59 +020011866/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11867 * Front Mic=0x18, ATAPI Mic = 0x19,
11868 */
11869static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11870 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11871 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11872 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11873 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11874 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11875 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11876 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11877 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11878
11879 { } /* end */
11880};
11881
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011882/*
11883 * generic initialization of ADC, input mixers and output mixers
11884 */
11885static struct hda_verb alc861vd_volume_init_verbs[] = {
11886 /*
11887 * Unmute ADC0 and set the default input to mic-in
11888 */
11889 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11891
11892 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11893 * the analog-loopback mixer widget
11894 */
11895 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011901
11902 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011907
11908 /*
11909 * Set up output mixers (0x02 - 0x05)
11910 */
11911 /* set vol=0 to output mixers */
11912 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11913 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11914 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11915 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11916
11917 /* set up input amps for analog loopback */
11918 /* Amp Indices: DAC = 0, mixer = 1 */
11919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11927
11928 { }
11929};
11930
11931/*
11932 * 3-stack pin configuration:
11933 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11934 */
11935static struct hda_verb alc861vd_3stack_init_verbs[] = {
11936 /*
11937 * Set pin mode and muting
11938 */
11939 /* set front pin widgets 0x14 for output */
11940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11942 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11943
11944 /* Mic (rear) pin: input vref at 80% */
11945 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11946 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11947 /* Front Mic pin: input vref at 80% */
11948 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11949 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11950 /* Line In pin: input */
11951 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11952 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11953 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11955 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11956 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11957 /* CD pin widget for input */
11958 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11959
11960 { }
11961};
11962
11963/*
11964 * 6-stack pin configuration:
11965 */
11966static struct hda_verb alc861vd_6stack_init_verbs[] = {
11967 /*
11968 * Set pin mode and muting
11969 */
11970 /* set front pin widgets 0x14 for output */
11971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11973 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11974
11975 /* Rear Pin: output 1 (0x0d) */
11976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11979 /* CLFE Pin: output 2 (0x0e) */
11980 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11981 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11982 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11983 /* Side Pin: output 3 (0x0f) */
11984 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11985 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11986 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11987
11988 /* Mic (rear) pin: input vref at 80% */
11989 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11991 /* Front Mic pin: input vref at 80% */
11992 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11994 /* Line In pin: input */
11995 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11997 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11999 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12000 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12001 /* CD pin widget for input */
12002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12003
12004 { }
12005};
12006
Kailang Yangbdd148a2007-05-08 15:19:08 +020012007static struct hda_verb alc861vd_eapd_verbs[] = {
12008 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12009 { }
12010};
12011
12012static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12016 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12017 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12018 {}
12019};
12020
12021/* toggle speaker-output according to the hp-jack state */
12022static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12023{
12024 unsigned int present;
12025 unsigned char bits;
12026
12027 present = snd_hda_codec_read(codec, 0x1b, 0,
12028 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012029 bits = present ? HDA_AMP_MUTE : 0;
12030 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12031 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012032}
12033
12034static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12035{
12036 unsigned int present;
12037 unsigned char bits;
12038
12039 present = snd_hda_codec_read(codec, 0x18, 0,
12040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012041 bits = present ? HDA_AMP_MUTE : 0;
12042 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12043 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012044}
12045
12046static void alc861vd_lenovo_automute(struct hda_codec *codec)
12047{
12048 alc861vd_lenovo_hp_automute(codec);
12049 alc861vd_lenovo_mic_automute(codec);
12050}
12051
12052static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12053 unsigned int res)
12054{
12055 switch (res >> 26) {
12056 case ALC880_HP_EVENT:
12057 alc861vd_lenovo_hp_automute(codec);
12058 break;
12059 case ALC880_MIC_EVENT:
12060 alc861vd_lenovo_mic_automute(codec);
12061 break;
12062 }
12063}
12064
Kailang Yang272a5272007-05-14 11:00:38 +020012065static struct hda_verb alc861vd_dallas_verbs[] = {
12066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12070
12071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12079
12080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12081 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12085 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12086 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12087 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12088
12089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12091 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12094 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12095 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12096 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12097
12098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12102
12103 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12104 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12105 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12106
12107 { } /* end */
12108};
12109
12110/* toggle speaker-output according to the hp-jack state */
12111static void alc861vd_dallas_automute(struct hda_codec *codec)
12112{
12113 unsigned int present;
12114
12115 present = snd_hda_codec_read(codec, 0x15, 0,
12116 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012117 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12118 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012119}
12120
12121static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12122{
12123 if ((res >> 26) == ALC880_HP_EVENT)
12124 alc861vd_dallas_automute(codec);
12125}
12126
Takashi Iwaicb53c622007-08-10 17:21:45 +020012127#ifdef CONFIG_SND_HDA_POWER_SAVE
12128#define alc861vd_loopbacks alc880_loopbacks
12129#endif
12130
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012131/* pcm configuration: identiacal with ALC880 */
12132#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12133#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12134#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12135#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12136
12137/*
12138 * configuration and preset
12139 */
12140static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12141 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012142 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012143 [ALC861VD_3ST] = "3stack",
12144 [ALC861VD_3ST_DIG] = "3stack-digout",
12145 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012146 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012147 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012148 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012149 [ALC861VD_AUTO] = "auto",
12150};
12151
12152static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012153 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12154 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012155 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012156 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012157 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012158 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012159 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012160 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012161 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012162 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012163 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012164 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12165 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012166 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012167 {}
12168};
12169
12170static struct alc_config_preset alc861vd_presets[] = {
12171 [ALC660VD_3ST] = {
12172 .mixers = { alc861vd_3st_mixer },
12173 .init_verbs = { alc861vd_volume_init_verbs,
12174 alc861vd_3stack_init_verbs },
12175 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12176 .dac_nids = alc660vd_dac_nids,
12177 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12178 .adc_nids = alc861vd_adc_nids,
12179 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12180 .channel_mode = alc861vd_3stack_2ch_modes,
12181 .input_mux = &alc861vd_capture_source,
12182 },
Mike Crash6963f842007-06-25 12:12:51 +020012183 [ALC660VD_3ST_DIG] = {
12184 .mixers = { alc861vd_3st_mixer },
12185 .init_verbs = { alc861vd_volume_init_verbs,
12186 alc861vd_3stack_init_verbs },
12187 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12188 .dac_nids = alc660vd_dac_nids,
12189 .dig_out_nid = ALC861VD_DIGOUT_NID,
12190 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12191 .adc_nids = alc861vd_adc_nids,
12192 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12193 .channel_mode = alc861vd_3stack_2ch_modes,
12194 .input_mux = &alc861vd_capture_source,
12195 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012196 [ALC861VD_3ST] = {
12197 .mixers = { alc861vd_3st_mixer },
12198 .init_verbs = { alc861vd_volume_init_verbs,
12199 alc861vd_3stack_init_verbs },
12200 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12201 .dac_nids = alc861vd_dac_nids,
12202 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12203 .channel_mode = alc861vd_3stack_2ch_modes,
12204 .input_mux = &alc861vd_capture_source,
12205 },
12206 [ALC861VD_3ST_DIG] = {
12207 .mixers = { alc861vd_3st_mixer },
12208 .init_verbs = { alc861vd_volume_init_verbs,
12209 alc861vd_3stack_init_verbs },
12210 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12211 .dac_nids = alc861vd_dac_nids,
12212 .dig_out_nid = ALC861VD_DIGOUT_NID,
12213 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12214 .channel_mode = alc861vd_3stack_2ch_modes,
12215 .input_mux = &alc861vd_capture_source,
12216 },
12217 [ALC861VD_6ST_DIG] = {
12218 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12219 .init_verbs = { alc861vd_volume_init_verbs,
12220 alc861vd_6stack_init_verbs },
12221 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12222 .dac_nids = alc861vd_dac_nids,
12223 .dig_out_nid = ALC861VD_DIGOUT_NID,
12224 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12225 .channel_mode = alc861vd_6stack_modes,
12226 .input_mux = &alc861vd_capture_source,
12227 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012228 [ALC861VD_LENOVO] = {
12229 .mixers = { alc861vd_lenovo_mixer },
12230 .init_verbs = { alc861vd_volume_init_verbs,
12231 alc861vd_3stack_init_verbs,
12232 alc861vd_eapd_verbs,
12233 alc861vd_lenovo_unsol_verbs },
12234 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12235 .dac_nids = alc660vd_dac_nids,
12236 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12237 .adc_nids = alc861vd_adc_nids,
12238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12239 .channel_mode = alc861vd_3stack_2ch_modes,
12240 .input_mux = &alc861vd_capture_source,
12241 .unsol_event = alc861vd_lenovo_unsol_event,
12242 .init_hook = alc861vd_lenovo_automute,
12243 },
Kailang Yang272a5272007-05-14 11:00:38 +020012244 [ALC861VD_DALLAS] = {
12245 .mixers = { alc861vd_dallas_mixer },
12246 .init_verbs = { alc861vd_dallas_verbs },
12247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12248 .dac_nids = alc861vd_dac_nids,
12249 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12250 .adc_nids = alc861vd_adc_nids,
12251 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12252 .channel_mode = alc861vd_3stack_2ch_modes,
12253 .input_mux = &alc861vd_dallas_capture_source,
12254 .unsol_event = alc861vd_dallas_unsol_event,
12255 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012256 },
12257 [ALC861VD_HP] = {
12258 .mixers = { alc861vd_hp_mixer },
12259 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12260 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12261 .dac_nids = alc861vd_dac_nids,
12262 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12263 .dig_out_nid = ALC861VD_DIGOUT_NID,
12264 .adc_nids = alc861vd_adc_nids,
12265 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12266 .channel_mode = alc861vd_3stack_2ch_modes,
12267 .input_mux = &alc861vd_hp_capture_source,
12268 .unsol_event = alc861vd_dallas_unsol_event,
12269 .init_hook = alc861vd_dallas_automute,
12270 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012271};
12272
12273/*
12274 * BIOS auto configuration
12275 */
12276static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12277 hda_nid_t nid, int pin_type, int dac_idx)
12278{
12279 /* set as output */
12280 snd_hda_codec_write(codec, nid, 0,
12281 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12282 snd_hda_codec_write(codec, nid, 0,
12283 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12284}
12285
12286static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12287{
12288 struct alc_spec *spec = codec->spec;
12289 int i;
12290
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012291 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012292 for (i = 0; i <= HDA_SIDE; i++) {
12293 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012295 if (nid)
12296 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012297 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012298 }
12299}
12300
12301
12302static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12303{
12304 struct alc_spec *spec = codec->spec;
12305 hda_nid_t pin;
12306
12307 pin = spec->autocfg.hp_pins[0];
12308 if (pin) /* connect to front and use dac 0 */
12309 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12310}
12311
12312#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12313#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12314
12315static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12316{
12317 struct alc_spec *spec = codec->spec;
12318 int i;
12319
12320 for (i = 0; i < AUTO_PIN_LAST; i++) {
12321 hda_nid_t nid = spec->autocfg.input_pins[i];
12322 if (alc861vd_is_input_pin(nid)) {
12323 snd_hda_codec_write(codec, nid, 0,
12324 AC_VERB_SET_PIN_WIDGET_CONTROL,
12325 i <= AUTO_PIN_FRONT_MIC ?
12326 PIN_VREF80 : PIN_IN);
12327 if (nid != ALC861VD_PIN_CD_NID)
12328 snd_hda_codec_write(codec, nid, 0,
12329 AC_VERB_SET_AMP_GAIN_MUTE,
12330 AMP_OUT_MUTE);
12331 }
12332 }
12333}
12334
12335#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12336#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12337
12338/* add playback controls from the parsed DAC table */
12339/* Based on ALC880 version. But ALC861VD has separate,
12340 * different NIDs for mute/unmute switch and volume control */
12341static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12342 const struct auto_pin_cfg *cfg)
12343{
12344 char name[32];
12345 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12346 hda_nid_t nid_v, nid_s;
12347 int i, err;
12348
12349 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012350 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012351 continue;
12352 nid_v = alc861vd_idx_to_mixer_vol(
12353 alc880_dac_to_idx(
12354 spec->multiout.dac_nids[i]));
12355 nid_s = alc861vd_idx_to_mixer_switch(
12356 alc880_dac_to_idx(
12357 spec->multiout.dac_nids[i]));
12358
12359 if (i == 2) {
12360 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012361 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12362 "Center Playback Volume",
12363 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12364 HDA_OUTPUT));
12365 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012366 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12368 "LFE Playback Volume",
12369 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12370 HDA_OUTPUT));
12371 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012372 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012373 err = add_control(spec, ALC_CTL_BIND_MUTE,
12374 "Center Playback Switch",
12375 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12376 HDA_INPUT));
12377 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012378 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012379 err = add_control(spec, ALC_CTL_BIND_MUTE,
12380 "LFE Playback Switch",
12381 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12382 HDA_INPUT));
12383 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012384 return err;
12385 } else {
12386 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012387 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12388 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12389 HDA_OUTPUT));
12390 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012391 return err;
12392 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012394 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012395 HDA_INPUT));
12396 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012397 return err;
12398 }
12399 }
12400 return 0;
12401}
12402
12403/* add playback controls for speaker and HP outputs */
12404/* Based on ALC880 version. But ALC861VD has separate,
12405 * different NIDs for mute/unmute switch and volume control */
12406static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12407 hda_nid_t pin, const char *pfx)
12408{
12409 hda_nid_t nid_v, nid_s;
12410 int err;
12411 char name[32];
12412
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012413 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012414 return 0;
12415
12416 if (alc880_is_fixed_pin(pin)) {
12417 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12418 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012419 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012420 spec->multiout.hp_nid = nid_v;
12421 else
12422 spec->multiout.extra_out_nid[0] = nid_v;
12423 /* control HP volume/switch on the output mixer amp */
12424 nid_v = alc861vd_idx_to_mixer_vol(
12425 alc880_fixed_pin_idx(pin));
12426 nid_s = alc861vd_idx_to_mixer_switch(
12427 alc880_fixed_pin_idx(pin));
12428
12429 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012430 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12431 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12432 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012433 return err;
12434 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012435 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12436 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12437 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012438 return err;
12439 } else if (alc880_is_multi_pin(pin)) {
12440 /* set manual connection */
12441 /* we have only a switch on HP-out PIN */
12442 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012443 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12444 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12445 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012446 return err;
12447 }
12448 return 0;
12449}
12450
12451/* parse the BIOS configuration and set up the alc_spec
12452 * return 1 if successful, 0 if the proper config is not found,
12453 * or a negative error code
12454 * Based on ALC880 version - had to change it to override
12455 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12456static int alc861vd_parse_auto_config(struct hda_codec *codec)
12457{
12458 struct alc_spec *spec = codec->spec;
12459 int err;
12460 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12461
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012462 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12463 alc861vd_ignore);
12464 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012465 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012466 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012467 return 0; /* can't find valid BIOS pin config */
12468
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012469 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12470 if (err < 0)
12471 return err;
12472 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12473 if (err < 0)
12474 return err;
12475 err = alc861vd_auto_create_extra_out(spec,
12476 spec->autocfg.speaker_pins[0],
12477 "Speaker");
12478 if (err < 0)
12479 return err;
12480 err = alc861vd_auto_create_extra_out(spec,
12481 spec->autocfg.hp_pins[0],
12482 "Headphone");
12483 if (err < 0)
12484 return err;
12485 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12486 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012487 return err;
12488
12489 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12490
12491 if (spec->autocfg.dig_out_pin)
12492 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12493
12494 if (spec->kctl_alloc)
12495 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12496
12497 spec->init_verbs[spec->num_init_verbs++]
12498 = alc861vd_volume_init_verbs;
12499
12500 spec->num_mux_defs = 1;
12501 spec->input_mux = &spec->private_imux;
12502
Takashi Iwai776e1842007-08-29 15:07:11 +020012503 err = alc_auto_add_mic_boost(codec);
12504 if (err < 0)
12505 return err;
12506
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012507 return 1;
12508}
12509
12510/* additional initialization for auto-configuration model */
12511static void alc861vd_auto_init(struct hda_codec *codec)
12512{
12513 alc861vd_auto_init_multi_out(codec);
12514 alc861vd_auto_init_hp_out(codec);
12515 alc861vd_auto_init_analog_input(codec);
12516}
12517
12518static int patch_alc861vd(struct hda_codec *codec)
12519{
12520 struct alc_spec *spec;
12521 int err, board_config;
12522
12523 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12524 if (spec == NULL)
12525 return -ENOMEM;
12526
12527 codec->spec = spec;
12528
12529 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12530 alc861vd_models,
12531 alc861vd_cfg_tbl);
12532
12533 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12534 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12535 "ALC861VD, trying auto-probe from BIOS...\n");
12536 board_config = ALC861VD_AUTO;
12537 }
12538
12539 if (board_config == ALC861VD_AUTO) {
12540 /* automatic parse from the BIOS config */
12541 err = alc861vd_parse_auto_config(codec);
12542 if (err < 0) {
12543 alc_free(codec);
12544 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012545 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012546 printk(KERN_INFO
12547 "hda_codec: Cannot set up configuration "
12548 "from BIOS. Using base mode...\n");
12549 board_config = ALC861VD_3ST;
12550 }
12551 }
12552
12553 if (board_config != ALC861VD_AUTO)
12554 setup_preset(spec, &alc861vd_presets[board_config]);
12555
12556 spec->stream_name_analog = "ALC861VD Analog";
12557 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12558 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12559
12560 spec->stream_name_digital = "ALC861VD Digital";
12561 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12562 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12563
12564 spec->adc_nids = alc861vd_adc_nids;
12565 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12566
12567 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12568 spec->num_mixers++;
12569
Takashi Iwai2134ea42008-01-10 16:53:55 +010012570 spec->vmaster_nid = 0x02;
12571
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012572 codec->patch_ops = alc_patch_ops;
12573
12574 if (board_config == ALC861VD_AUTO)
12575 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012576#ifdef CONFIG_SND_HDA_POWER_SAVE
12577 if (!spec->loopback.amplist)
12578 spec->loopback.amplist = alc861vd_loopbacks;
12579#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012580
12581 return 0;
12582}
12583
12584/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012585 * ALC662 support
12586 *
12587 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12588 * configuration. Each pin widget can choose any input DACs and a mixer.
12589 * Each ADC is connected from a mixer of all inputs. This makes possible
12590 * 6-channel independent captures.
12591 *
12592 * In addition, an independent DAC for the multi-playback (not used in this
12593 * driver yet).
12594 */
12595#define ALC662_DIGOUT_NID 0x06
12596#define ALC662_DIGIN_NID 0x0a
12597
12598static hda_nid_t alc662_dac_nids[4] = {
12599 /* front, rear, clfe, rear_surr */
12600 0x02, 0x03, 0x04
12601};
12602
12603static hda_nid_t alc662_adc_nids[1] = {
12604 /* ADC1-2 */
12605 0x09,
12606};
12607/* input MUX */
12608/* FIXME: should be a matrix-type input source selection */
12609
12610static struct hda_input_mux alc662_capture_source = {
12611 .num_items = 4,
12612 .items = {
12613 { "Mic", 0x0 },
12614 { "Front Mic", 0x1 },
12615 { "Line", 0x2 },
12616 { "CD", 0x4 },
12617 },
12618};
12619
12620static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12621 .num_items = 2,
12622 .items = {
12623 { "Mic", 0x1 },
12624 { "Line", 0x2 },
12625 },
12626};
Kailang Yang291702f2007-10-16 14:28:03 +020012627
12628static struct hda_input_mux alc662_eeepc_capture_source = {
12629 .num_items = 2,
12630 .items = {
12631 { "i-Mic", 0x1 },
12632 { "e-Mic", 0x0 },
12633 },
12634};
12635
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012636#define alc662_mux_enum_info alc_mux_enum_info
12637#define alc662_mux_enum_get alc_mux_enum_get
12638
12639static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12640 struct snd_ctl_elem_value *ucontrol)
12641{
12642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12643 struct alc_spec *spec = codec->spec;
12644 const struct hda_input_mux *imux = spec->input_mux;
12645 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012646 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012647 hda_nid_t nid = capture_mixers[adc_idx];
12648 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12649 unsigned int i, idx;
12650
12651 idx = ucontrol->value.enumerated.item[0];
12652 if (idx >= imux->num_items)
12653 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012654 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012655 return 0;
12656 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012657 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12658 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12659 imux->items[i].index,
12660 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012661 }
12662 *cur_val = idx;
12663 return 1;
12664}
12665/*
12666 * 2ch mode
12667 */
12668static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12669 { 2, NULL }
12670};
12671
12672/*
12673 * 2ch mode
12674 */
12675static struct hda_verb alc662_3ST_ch2_init[] = {
12676 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12677 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12678 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12679 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12680 { } /* end */
12681};
12682
12683/*
12684 * 6ch mode
12685 */
12686static struct hda_verb alc662_3ST_ch6_init[] = {
12687 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12688 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12689 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12690 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12691 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12692 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12693 { } /* end */
12694};
12695
12696static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12697 { 2, alc662_3ST_ch2_init },
12698 { 6, alc662_3ST_ch6_init },
12699};
12700
12701/*
12702 * 2ch mode
12703 */
12704static struct hda_verb alc662_sixstack_ch6_init[] = {
12705 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12707 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12708 { } /* end */
12709};
12710
12711/*
12712 * 6ch mode
12713 */
12714static struct hda_verb alc662_sixstack_ch8_init[] = {
12715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12718 { } /* end */
12719};
12720
12721static struct hda_channel_mode alc662_5stack_modes[2] = {
12722 { 2, alc662_sixstack_ch6_init },
12723 { 6, alc662_sixstack_ch8_init },
12724};
12725
12726/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12727 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12728 */
12729
12730static struct snd_kcontrol_new alc662_base_mixer[] = {
12731 /* output mixer control */
12732 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12733 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12735 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12736 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12737 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12738 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12739 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12741
12742 /*Input mixer control */
12743 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12744 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12745 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12746 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12747 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12748 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12749 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12750 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012751 { } /* end */
12752};
12753
12754static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12755 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12756 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12764 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12765 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12766 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12767 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012768 { } /* end */
12769};
12770
12771static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12772 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12773 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12774 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12775 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12776 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12778 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12779 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12781 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12782 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12789 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12790 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012791 { } /* end */
12792};
12793
12794static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12795 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12796 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12797 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12798 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012804 { } /* end */
12805};
12806
Kailang Yang291702f2007-10-16 14:28:03 +020012807static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12808 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12809
12810 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12811 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12812
12813 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12814 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12815 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12816
12817 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12818 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12819 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12820 { } /* end */
12821};
12822
Kailang Yang8c427222008-01-10 13:03:59 +010012823static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12824 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12825 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12827 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12832 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12833 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12838 { } /* end */
12839};
12840
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012841static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12842 {
12843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12844 .name = "Channel Mode",
12845 .info = alc_ch_mode_info,
12846 .get = alc_ch_mode_get,
12847 .put = alc_ch_mode_put,
12848 },
12849 { } /* end */
12850};
12851
12852static struct hda_verb alc662_init_verbs[] = {
12853 /* ADC: mute amp left and right */
12854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12855 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12856 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12857
Takashi Iwaicb53c622007-08-10 17:21:45 +020012858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012863
Kailang Yangb60dd392007-09-20 12:50:29 +020012864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012870
12871 /* Front Pin: output 0 (0x0c) */
12872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12874
12875 /* Rear Pin: output 1 (0x0d) */
12876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12878
12879 /* CLFE Pin: output 2 (0x0e) */
12880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12882
12883 /* Mic (rear) pin: input vref at 80% */
12884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12886 /* Front Mic pin: input vref at 80% */
12887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12889 /* Line In pin: input */
12890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12892 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12896 /* CD pin widget for input */
12897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12898
12899 /* FIXME: use matrix-type input source selection */
12900 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12901 /* Input mixer */
12902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012906
12907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012911 { }
12912};
12913
12914static struct hda_verb alc662_sue_init_verbs[] = {
12915 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12916 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012917 {}
12918};
12919
12920static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12921 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12922 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12923 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012924};
12925
Kailang Yang8c427222008-01-10 13:03:59 +010012926/* Set Unsolicited Event*/
12927static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12929 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12930 {}
12931};
12932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012933/*
12934 * generic initialization of ADC, input mixers and output mixers
12935 */
12936static struct hda_verb alc662_auto_init_verbs[] = {
12937 /*
12938 * Unmute ADC and set the default input to mic-in
12939 */
12940 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12941 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12942
12943 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12944 * mixer widget
12945 * Note: PASD motherboards uses the Line In 2 as the input for front
12946 * panel mic (mic 2)
12947 */
12948 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012954
12955 /*
12956 * Set up output mixers (0x0c - 0x0f)
12957 */
12958 /* set vol=0 to output mixers */
12959 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12960 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12961 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12962
12963 /* set up input amps for analog loopback */
12964 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012971
12972
12973 /* FIXME: use matrix-type input source selection */
12974 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12975 /* Input mixer */
12976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012978 { }
12979};
12980
12981/* capture mixer elements */
12982static struct snd_kcontrol_new alc662_capture_mixer[] = {
12983 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12984 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12985 {
12986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12987 /* The multiple "Capture Source" controls confuse alsamixer
12988 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012989 */
12990 /* .name = "Capture Source", */
12991 .name = "Input Source",
12992 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012993 .info = alc662_mux_enum_info,
12994 .get = alc662_mux_enum_get,
12995 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012996 },
12997 { } /* end */
12998};
12999
13000static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13001{
13002 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013003 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013004
13005 present = snd_hda_codec_read(codec, 0x14, 0,
13006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013007 bits = present ? HDA_AMP_MUTE : 0;
13008 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13009 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013010}
13011
13012static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13013{
13014 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013015 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013016
13017 present = snd_hda_codec_read(codec, 0x1b, 0,
13018 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013019 bits = present ? HDA_AMP_MUTE : 0;
13020 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13021 HDA_AMP_MUTE, bits);
13022 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13023 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013024}
13025
13026static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13027 unsigned int res)
13028{
13029 if ((res >> 26) == ALC880_HP_EVENT)
13030 alc662_lenovo_101e_all_automute(codec);
13031 if ((res >> 26) == ALC880_FRONT_EVENT)
13032 alc662_lenovo_101e_ispeaker_automute(codec);
13033}
13034
Kailang Yang291702f2007-10-16 14:28:03 +020013035static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13036{
13037 unsigned int present;
13038
13039 present = snd_hda_codec_read(codec, 0x18, 0,
13040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13041 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13042 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13043 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13044 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13045 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13046 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13047 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13048 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13049}
13050
13051/* unsolicited event for HP jack sensing */
13052static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13053 unsigned int res)
13054{
13055 if ((res >> 26) == ALC880_HP_EVENT)
13056 alc262_hippo1_automute( codec );
13057
13058 if ((res >> 26) == ALC880_MIC_EVENT)
13059 alc662_eeepc_mic_automute(codec);
13060}
13061
13062static void alc662_eeepc_inithook(struct hda_codec *codec)
13063{
13064 alc262_hippo1_automute( codec );
13065 alc662_eeepc_mic_automute(codec);
13066}
13067
Kailang Yang8c427222008-01-10 13:03:59 +010013068static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13069{
13070 unsigned int mute;
13071 unsigned int present;
13072
13073 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13074 present = snd_hda_codec_read(codec, 0x14, 0,
13075 AC_VERB_GET_PIN_SENSE, 0);
13076 present = (present & 0x80000000) != 0;
13077 if (present) {
13078 /* mute internal speaker */
13079 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13080 HDA_AMP_MUTE, HDA_AMP_MUTE);
13081 } else {
13082 /* unmute internal speaker if necessary */
13083 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13084 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13085 HDA_AMP_MUTE, mute);
13086 }
13087}
13088
13089/* unsolicited event for HP jack sensing */
13090static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13091 unsigned int res)
13092{
13093 if ((res >> 26) == ALC880_HP_EVENT)
13094 alc662_eeepc_ep20_automute(codec);
13095}
13096
13097static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13098{
13099 alc662_eeepc_ep20_automute(codec);
13100}
13101
Takashi Iwaicb53c622007-08-10 17:21:45 +020013102#ifdef CONFIG_SND_HDA_POWER_SAVE
13103#define alc662_loopbacks alc880_loopbacks
13104#endif
13105
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013106
13107/* pcm configuration: identiacal with ALC880 */
13108#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13109#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13110#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13111#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13112
13113/*
13114 * configuration and preset
13115 */
13116static const char *alc662_models[ALC662_MODEL_LAST] = {
13117 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13118 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13119 [ALC662_3ST_6ch] = "3stack-6ch",
13120 [ALC662_5ST_DIG] = "6stack-dig",
13121 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013122 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013123 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013124 [ALC662_AUTO] = "auto",
13125};
13126
13127static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013128 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013129 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013130 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013131 {}
13132};
13133
13134static struct alc_config_preset alc662_presets[] = {
13135 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013136 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013137 .init_verbs = { alc662_init_verbs },
13138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13139 .dac_nids = alc662_dac_nids,
13140 .dig_out_nid = ALC662_DIGOUT_NID,
13141 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13142 .adc_nids = alc662_adc_nids,
13143 .dig_in_nid = ALC662_DIGIN_NID,
13144 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13145 .channel_mode = alc662_3ST_2ch_modes,
13146 .input_mux = &alc662_capture_source,
13147 },
13148 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013149 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13150 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013151 .init_verbs = { alc662_init_verbs },
13152 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13153 .dac_nids = alc662_dac_nids,
13154 .dig_out_nid = ALC662_DIGOUT_NID,
13155 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13156 .adc_nids = alc662_adc_nids,
13157 .dig_in_nid = ALC662_DIGIN_NID,
13158 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13159 .channel_mode = alc662_3ST_6ch_modes,
13160 .need_dac_fix = 1,
13161 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013162 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013163 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013164 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13165 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013166 .init_verbs = { alc662_init_verbs },
13167 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13168 .dac_nids = alc662_dac_nids,
13169 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13170 .adc_nids = alc662_adc_nids,
13171 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13172 .channel_mode = alc662_3ST_6ch_modes,
13173 .need_dac_fix = 1,
13174 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013175 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013176 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013177 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13178 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013179 .init_verbs = { alc662_init_verbs },
13180 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13181 .dac_nids = alc662_dac_nids,
13182 .dig_out_nid = ALC662_DIGOUT_NID,
13183 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13184 .adc_nids = alc662_adc_nids,
13185 .dig_in_nid = ALC662_DIGIN_NID,
13186 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13187 .channel_mode = alc662_5stack_modes,
13188 .input_mux = &alc662_capture_source,
13189 },
13190 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013191 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013192 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13194 .dac_nids = alc662_dac_nids,
13195 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13196 .adc_nids = alc662_adc_nids,
13197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13198 .channel_mode = alc662_3ST_2ch_modes,
13199 .input_mux = &alc662_lenovo_101e_capture_source,
13200 .unsol_event = alc662_lenovo_101e_unsol_event,
13201 .init_hook = alc662_lenovo_101e_all_automute,
13202 },
Kailang Yang291702f2007-10-16 14:28:03 +020013203 [ALC662_ASUS_EEEPC_P701] = {
13204 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13205 .init_verbs = { alc662_init_verbs,
13206 alc662_eeepc_sue_init_verbs },
13207 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13208 .dac_nids = alc662_dac_nids,
13209 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13210 .adc_nids = alc662_adc_nids,
13211 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13212 .channel_mode = alc662_3ST_2ch_modes,
13213 .input_mux = &alc662_eeepc_capture_source,
13214 .unsol_event = alc662_eeepc_unsol_event,
13215 .init_hook = alc662_eeepc_inithook,
13216 },
Kailang Yang8c427222008-01-10 13:03:59 +010013217 [ALC662_ASUS_EEEPC_EP20] = {
13218 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13219 alc662_chmode_mixer },
13220 .init_verbs = { alc662_init_verbs,
13221 alc662_eeepc_ep20_sue_init_verbs },
13222 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13223 .dac_nids = alc662_dac_nids,
13224 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13225 .adc_nids = alc662_adc_nids,
13226 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13227 .channel_mode = alc662_3ST_6ch_modes,
13228 .input_mux = &alc662_lenovo_101e_capture_source,
13229 .unsol_event = alc662_eeepc_ep20_unsol_event,
13230 .init_hook = alc662_eeepc_ep20_inithook,
13231 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013232
13233};
13234
13235
13236/*
13237 * BIOS auto configuration
13238 */
13239
13240/* add playback controls from the parsed DAC table */
13241static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13242 const struct auto_pin_cfg *cfg)
13243{
13244 char name[32];
13245 static const char *chname[4] = {
13246 "Front", "Surround", NULL /*CLFE*/, "Side"
13247 };
13248 hda_nid_t nid;
13249 int i, err;
13250
13251 for (i = 0; i < cfg->line_outs; i++) {
13252 if (!spec->multiout.dac_nids[i])
13253 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013254 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013255 if (i == 2) {
13256 /* Center/LFE */
13257 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13258 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013259 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13260 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013261 if (err < 0)
13262 return err;
13263 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13264 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013265 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13266 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013267 if (err < 0)
13268 return err;
13269 err = add_control(spec, ALC_CTL_BIND_MUTE,
13270 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013271 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13272 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013273 if (err < 0)
13274 return err;
13275 err = add_control(spec, ALC_CTL_BIND_MUTE,
13276 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013277 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13278 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013279 if (err < 0)
13280 return err;
13281 } else {
13282 sprintf(name, "%s Playback Volume", chname[i]);
13283 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013284 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13285 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013286 if (err < 0)
13287 return err;
13288 sprintf(name, "%s Playback Switch", chname[i]);
13289 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013290 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13291 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013292 if (err < 0)
13293 return err;
13294 }
13295 }
13296 return 0;
13297}
13298
13299/* add playback controls for speaker and HP outputs */
13300static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13301 const char *pfx)
13302{
13303 hda_nid_t nid;
13304 int err;
13305 char name[32];
13306
13307 if (!pin)
13308 return 0;
13309
13310 if (alc880_is_fixed_pin(pin)) {
13311 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13312 /* printk("DAC nid=%x\n",nid); */
13313 /* specify the DAC as the extra output */
13314 if (!spec->multiout.hp_nid)
13315 spec->multiout.hp_nid = nid;
13316 else
13317 spec->multiout.extra_out_nid[0] = nid;
13318 /* control HP volume/switch on the output mixer amp */
13319 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13320 sprintf(name, "%s Playback Volume", pfx);
13321 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13322 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13323 if (err < 0)
13324 return err;
13325 sprintf(name, "%s Playback Switch", pfx);
13326 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13327 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13328 if (err < 0)
13329 return err;
13330 } else if (alc880_is_multi_pin(pin)) {
13331 /* set manual connection */
13332 /* we have only a switch on HP-out PIN */
13333 sprintf(name, "%s Playback Switch", pfx);
13334 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13335 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13336 if (err < 0)
13337 return err;
13338 }
13339 return 0;
13340}
13341
13342/* create playback/capture controls for input pins */
13343static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13344 const struct auto_pin_cfg *cfg)
13345{
13346 struct hda_input_mux *imux = &spec->private_imux;
13347 int i, err, idx;
13348
13349 for (i = 0; i < AUTO_PIN_LAST; i++) {
13350 if (alc880_is_input_pin(cfg->input_pins[i])) {
13351 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13352 err = new_analog_input(spec, cfg->input_pins[i],
13353 auto_pin_cfg_labels[i],
13354 idx, 0x0b);
13355 if (err < 0)
13356 return err;
13357 imux->items[imux->num_items].label =
13358 auto_pin_cfg_labels[i];
13359 imux->items[imux->num_items].index =
13360 alc880_input_pin_idx(cfg->input_pins[i]);
13361 imux->num_items++;
13362 }
13363 }
13364 return 0;
13365}
13366
13367static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13368 hda_nid_t nid, int pin_type,
13369 int dac_idx)
13370{
13371 /* set as output */
13372 snd_hda_codec_write(codec, nid, 0,
13373 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13374 snd_hda_codec_write(codec, nid, 0,
13375 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13376 /* need the manual connection? */
13377 if (alc880_is_multi_pin(nid)) {
13378 struct alc_spec *spec = codec->spec;
13379 int idx = alc880_multi_pin_idx(nid);
13380 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13381 AC_VERB_SET_CONNECT_SEL,
13382 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13383 }
13384}
13385
13386static void alc662_auto_init_multi_out(struct hda_codec *codec)
13387{
13388 struct alc_spec *spec = codec->spec;
13389 int i;
13390
Kailang Yang8c427222008-01-10 13:03:59 +010013391 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013392 for (i = 0; i <= HDA_SIDE; i++) {
13393 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013394 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013395 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013396 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013397 i);
13398 }
13399}
13400
13401static void alc662_auto_init_hp_out(struct hda_codec *codec)
13402{
13403 struct alc_spec *spec = codec->spec;
13404 hda_nid_t pin;
13405
13406 pin = spec->autocfg.hp_pins[0];
13407 if (pin) /* connect to front */
13408 /* use dac 0 */
13409 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13410}
13411
13412#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13413#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13414
13415static void alc662_auto_init_analog_input(struct hda_codec *codec)
13416{
13417 struct alc_spec *spec = codec->spec;
13418 int i;
13419
13420 for (i = 0; i < AUTO_PIN_LAST; i++) {
13421 hda_nid_t nid = spec->autocfg.input_pins[i];
13422 if (alc662_is_input_pin(nid)) {
13423 snd_hda_codec_write(codec, nid, 0,
13424 AC_VERB_SET_PIN_WIDGET_CONTROL,
13425 (i <= AUTO_PIN_FRONT_MIC ?
13426 PIN_VREF80 : PIN_IN));
13427 if (nid != ALC662_PIN_CD_NID)
13428 snd_hda_codec_write(codec, nid, 0,
13429 AC_VERB_SET_AMP_GAIN_MUTE,
13430 AMP_OUT_MUTE);
13431 }
13432 }
13433}
13434
13435static int alc662_parse_auto_config(struct hda_codec *codec)
13436{
13437 struct alc_spec *spec = codec->spec;
13438 int err;
13439 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13440
13441 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13442 alc662_ignore);
13443 if (err < 0)
13444 return err;
13445 if (!spec->autocfg.line_outs)
13446 return 0; /* can't find valid BIOS pin config */
13447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013448 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13449 if (err < 0)
13450 return err;
13451 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13452 if (err < 0)
13453 return err;
13454 err = alc662_auto_create_extra_out(spec,
13455 spec->autocfg.speaker_pins[0],
13456 "Speaker");
13457 if (err < 0)
13458 return err;
13459 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13460 "Headphone");
13461 if (err < 0)
13462 return err;
13463 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13464 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013465 return err;
13466
13467 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13468
13469 if (spec->autocfg.dig_out_pin)
13470 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13471
13472 if (spec->kctl_alloc)
13473 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13474
13475 spec->num_mux_defs = 1;
13476 spec->input_mux = &spec->private_imux;
13477
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013478 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013479 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13480 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013481 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013482}
13483
13484/* additional initialization for auto-configuration model */
13485static void alc662_auto_init(struct hda_codec *codec)
13486{
13487 alc662_auto_init_multi_out(codec);
13488 alc662_auto_init_hp_out(codec);
13489 alc662_auto_init_analog_input(codec);
13490}
13491
13492static int patch_alc662(struct hda_codec *codec)
13493{
13494 struct alc_spec *spec;
13495 int err, board_config;
13496
13497 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13498 if (!spec)
13499 return -ENOMEM;
13500
13501 codec->spec = spec;
13502
13503 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13504 alc662_models,
13505 alc662_cfg_tbl);
13506 if (board_config < 0) {
13507 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13508 "trying auto-probe from BIOS...\n");
13509 board_config = ALC662_AUTO;
13510 }
13511
13512 if (board_config == ALC662_AUTO) {
13513 /* automatic parse from the BIOS config */
13514 err = alc662_parse_auto_config(codec);
13515 if (err < 0) {
13516 alc_free(codec);
13517 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013518 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013519 printk(KERN_INFO
13520 "hda_codec: Cannot set up configuration "
13521 "from BIOS. Using base mode...\n");
13522 board_config = ALC662_3ST_2ch_DIG;
13523 }
13524 }
13525
13526 if (board_config != ALC662_AUTO)
13527 setup_preset(spec, &alc662_presets[board_config]);
13528
13529 spec->stream_name_analog = "ALC662 Analog";
13530 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13531 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13532
13533 spec->stream_name_digital = "ALC662 Digital";
13534 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13535 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13536
13537 if (!spec->adc_nids && spec->input_mux) {
13538 spec->adc_nids = alc662_adc_nids;
13539 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13540 }
13541
Takashi Iwai2134ea42008-01-10 16:53:55 +010013542 spec->vmaster_nid = 0x02;
13543
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013544 codec->patch_ops = alc_patch_ops;
13545 if (board_config == ALC662_AUTO)
13546 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013547#ifdef CONFIG_SND_HDA_POWER_SAVE
13548 if (!spec->loopback.amplist)
13549 spec->loopback.amplist = alc662_loopbacks;
13550#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013551
13552 return 0;
13553}
13554
13555/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013556 * patch entries
13557 */
13558struct hda_codec_preset snd_hda_preset_realtek[] = {
13559 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013560 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013561 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013562 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013563 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013564 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013565 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013566 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13567 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13568 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013569 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13570 .patch = patch_alc883 },
13571 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13572 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013573 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013574 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013575 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013577 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013578 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013579 {} /* terminator */
13580};