blob: 1b2ad52bc908314363218c9ddeafe8f5b527030b [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
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010095 ALC262_HP_TC_T5735,
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,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100109#ifdef CONFIG_SND_DEBUG
110 ALC268_TEST,
111#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200112 ALC268_AUTO,
113 ALC268_MODEL_LAST /* last tag */
114};
115
Kailang Yangf6a92242007-12-13 16:52:54 +0100116/* ALC269 models */
117enum {
118 ALC269_BASIC,
119 ALC269_AUTO,
120 ALC269_MODEL_LAST /* last tag */
121};
122
Kailang Yangdf694da2005-12-05 19:42:22 +0100123/* ALC861 models */
124enum {
125 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200126 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100127 ALC861_3ST_DIG,
128 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200129 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200130 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200131 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100132 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100133 ALC861_AUTO,
134 ALC861_MODEL_LAST,
135};
136
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100137/* ALC861-VD models */
138enum {
139 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200140 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100141 ALC861VD_3ST,
142 ALC861VD_3ST_DIG,
143 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200144 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200145 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200146 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147 ALC861VD_AUTO,
148 ALC861VD_MODEL_LAST,
149};
150
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200151/* ALC662 models */
152enum {
153 ALC662_3ST_2ch_DIG,
154 ALC662_3ST_6ch_DIG,
155 ALC662_3ST_6ch,
156 ALC662_5ST_DIG,
157 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200158 ALC662_ASUS_EEEPC_P701,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200159 ALC662_AUTO,
160 ALC662_MODEL_LAST,
161};
162
Kailang Yangdf694da2005-12-05 19:42:22 +0100163/* ALC882 models */
164enum {
165 ALC882_3ST_DIG,
166 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200167 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC882_TARGA,
170 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200171 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100172 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200173 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200174 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200175 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100176 ALC882_MODEL_LAST,
177};
178
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200179/* ALC883 models */
180enum {
181 ALC883_3ST_2ch_DIG,
182 ALC883_3ST_6ch_DIG,
183 ALC883_3ST_6ch,
184 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200185 ALC883_TARGA_DIG,
186 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200187 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200188 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200189 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200190 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100191 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200192 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200193 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200194 ALC888_LENOVO_MS7195_DIG,
195 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200196 ALC888_6ST_HP,
197 ALC888_3ST_HP,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100198 ALC883_MITAC,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200199 ALC883_AUTO,
200 ALC883_MODEL_LAST,
201};
202
Kailang Yangdf694da2005-12-05 19:42:22 +0100203/* for GPIO Poll */
204#define GPIO_MASK 0x03
205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206struct alc_spec {
207 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100208 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 unsigned int num_mixers;
210
Kailang Yangdf694da2005-12-05 19:42:22 +0100211 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200212 * don't forget NULL
213 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200214 */
215 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Takashi Iwai16ded522005-06-10 19:58:24 +0200217 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 struct hda_pcm_stream *stream_analog_playback;
219 struct hda_pcm_stream *stream_analog_capture;
220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200221 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 struct hda_pcm_stream *stream_digital_playback;
223 struct hda_pcm_stream *stream_digital_capture;
224
225 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200226 struct hda_multi_out multiout; /* playback set-up
227 * max_channels, dacs must be set
228 * dig_out_nid and hp_nid are optional
229 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231 /* capture */
232 unsigned int num_adc_nids;
233 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200234 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
236 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200237 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 const struct hda_input_mux *input_mux;
239 unsigned int cur_mux[3];
240
241 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100242 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200244 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
246 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100247 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200248
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200249 /* dynamic controls, init_verbs and input_mux */
250 struct auto_pin_cfg autocfg;
251 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100252 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200253 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200254 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100255
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100256 /* hooks */
257 void (*init_hook)(struct hda_codec *codec);
258 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
259
Takashi Iwai834be882006-03-01 14:16:17 +0100260 /* for pin sensing */
261 unsigned int sense_updated: 1;
262 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200263
264#ifdef CONFIG_SND_HDA_POWER_SAVE
265 struct hda_loopback_check loopback;
266#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100267};
268
269/*
270 * configuration template - to be copied to the spec instance
271 */
272struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273 struct snd_kcontrol_new *mixers[5]; /* should be identical size
274 * with spec
275 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 const struct hda_verb *init_verbs[5];
277 unsigned int num_dacs;
278 hda_nid_t *dac_nids;
279 hda_nid_t dig_out_nid; /* optional */
280 hda_nid_t hp_nid; /* optional */
281 unsigned int num_adc_nids;
282 hda_nid_t *adc_nids;
283 hda_nid_t dig_in_nid;
284 unsigned int num_channel_mode;
285 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200286 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200287 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100288 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100289 void (*unsol_event)(struct hda_codec *, unsigned int);
290 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200291#ifdef CONFIG_SND_HDA_POWER_SAVE
292 struct hda_amp_list *loopbacks;
293#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294};
295
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297/*
298 * input MUX handling
299 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200300static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302{
303 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
304 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200305 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
306 if (mux_idx >= spec->num_mux_defs)
307 mux_idx = 0;
308 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200311static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct alc_spec *spec = codec->spec;
316 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
317
318 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
319 return 0;
320}
321
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200322static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
323 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324{
325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
326 struct alc_spec *spec = codec->spec;
327 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200328 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
329 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330 spec->adc_nids[adc_idx],
331 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332}
333
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200334
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335/*
336 * channel mode setting
337 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200338static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
339 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340{
341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
342 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100343 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
344 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345}
346
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200347static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_value *ucontrol)
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_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200353 spec->num_channel_mode,
354 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355}
356
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359{
360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200362 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
363 spec->num_channel_mode,
364 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200365 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200366 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
367 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100371 * Control the mode of pin widget settings via the mixer. "pc" is used
372 * instead of "%" to avoid consequences of accidently treating the % as
373 * being part of a format specifier. Maximum allowed length of a value is
374 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100375 *
376 * Note: some retasking pin complexes seem to ignore requests for input
377 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
378 * are requested. Therefore order this list so that this behaviour will not
379 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
381 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200382 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100383static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100384 "Mic 50pc bias", "Mic 80pc bias",
385 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100386};
387static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100388 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389};
390/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391 * in the pin being assumed to be exclusively an input or an output pin. In
392 * addition, "input" pins may or may not process the mic bias option
393 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
394 * accept requests for bias as of chip versions up to March 2006) and/or
395 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100396 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200397#define ALC_PIN_DIR_IN 0x00
398#define ALC_PIN_DIR_OUT 0x01
399#define ALC_PIN_DIR_INOUT 0x02
400#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
401#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100402
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200403/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404 * For each direction the minimum and maximum values are given.
405 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200406static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 { 0, 2 }, /* ALC_PIN_DIR_IN */
408 { 3, 4 }, /* ALC_PIN_DIR_OUT */
409 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200410 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
411 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412};
413#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
414#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
415#define alc_pin_mode_n_items(_dir) \
416 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
417
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200420{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421 unsigned int item_num = uinfo->value.enumerated.item;
422 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
423
424 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200425 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
427
428 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
429 item_num = alc_pin_mode_min(dir);
430 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200431 return 0;
432}
433
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200436{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200441 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
443 AC_VERB_GET_PIN_WIDGET_CONTROL,
444 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200445
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446 /* Find enumerated value for current pinctl setting */
447 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100449 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200450 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 return 0;
452}
453
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456{
457 signed int change;
458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
459 hda_nid_t nid = kcontrol->private_value & 0xffff;
460 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
461 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
463 AC_VERB_GET_PIN_WIDGET_CONTROL,
464 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200466 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 val = alc_pin_mode_min(dir);
468
469 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100470 if (change) {
471 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200472 snd_hda_codec_write_cache(codec, nid, 0,
473 AC_VERB_SET_PIN_WIDGET_CONTROL,
474 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100475
476 /* Also enable the retasking pin's input/output as required
477 * for the requested pin mode. Enum values of 2 or less are
478 * input modes.
479 *
480 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200481 * reduces noise slightly (particularly on input) so we'll
482 * do it. However, having both input and output buffers
483 * enabled simultaneously doesn't seem to be problematic if
484 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100485 */
486 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200487 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
488 HDA_AMP_MUTE, HDA_AMP_MUTE);
489 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
490 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100491 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200492 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
493 HDA_AMP_MUTE, HDA_AMP_MUTE);
494 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
495 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100496 }
497 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200498 return change;
499}
500
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200502 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 .info = alc_pin_mode_info, \
504 .get = alc_pin_mode_get, \
505 .put = alc_pin_mode_put, \
506 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100507
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100508/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
509 * together using a mask with more than one bit set. This control is
510 * currently used only by the ALC260 test model. At this stage they are not
511 * needed for any "production" models.
512 */
513#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200514#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200515
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 hda_nid_t nid = kcontrol->private_value & 0xffff;
521 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
522 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523 unsigned int val = snd_hda_codec_read(codec, nid, 0,
524 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100525
526 *valp = (val & mask) != 0;
527 return 0;
528}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100531{
532 signed int change;
533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
534 hda_nid_t nid = kcontrol->private_value & 0xffff;
535 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
536 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200537 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
538 AC_VERB_GET_GPIO_DATA,
539 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100540
541 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
543 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100544 gpio_data &= ~mask;
545 else
546 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200547 snd_hda_codec_write_cache(codec, nid, 0,
548 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100549
550 return change;
551}
552#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
553 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
554 .info = alc_gpio_data_info, \
555 .get = alc_gpio_data_get, \
556 .put = alc_gpio_data_put, \
557 .private_value = nid | (mask<<16) }
558#endif /* CONFIG_SND_DEBUG */
559
Jonathan Woithe92621f12006-02-28 11:47:47 +0100560/* A switch control to allow the enabling of the digital IO pins on the
561 * ALC260. This is incredibly simplistic; the intention of this control is
562 * to provide something in the test model allowing digital outputs to be
563 * identified if present. If models are found which can utilise these
564 * outputs a more complete mixer control can be devised for those models if
565 * necessary.
566 */
567#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200568#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200569
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
571 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100572{
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 hda_nid_t nid = kcontrol->private_value & 0xffff;
575 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
576 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100578 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100579
580 *valp = (val & mask) != 0;
581 return 0;
582}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100585{
586 signed int change;
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 hda_nid_t nid = kcontrol->private_value & 0xffff;
589 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
590 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100592 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200593 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100594
595 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100597 if (val==0)
598 ctrl_data &= ~mask;
599 else
600 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200601 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
602 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100603
604 return change;
605}
606#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
607 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
608 .info = alc_spdif_ctrl_info, \
609 .get = alc_spdif_ctrl_get, \
610 .put = alc_spdif_ctrl_put, \
611 .private_value = nid | (mask<<16) }
612#endif /* CONFIG_SND_DEBUG */
613
Jonathan Woithef8225f62008-01-08 12:16:54 +0100614/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
615 * Again, this is only used in the ALC26x test models to help identify when
616 * the EAPD line must be asserted for features to work.
617 */
618#ifdef CONFIG_SND_DEBUG
619#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
620
621static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 hda_nid_t nid = kcontrol->private_value & 0xffff;
626 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
627 long *valp = ucontrol->value.integer.value;
628 unsigned int val = snd_hda_codec_read(codec, nid, 0,
629 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
630
631 *valp = (val & mask) != 0;
632 return 0;
633}
634
635static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
637{
638 int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
643 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_EAPD_BTLENABLE,
645 0x00);
646
647 /* Set/unset the masked control bit(s) as needed */
648 change = (!val ? 0 : mask) != (ctrl_data & mask);
649 if (!val)
650 ctrl_data &= ~mask;
651 else
652 ctrl_data |= mask;
653 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
654 ctrl_data);
655
656 return change;
657}
658
659#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
660 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
661 .info = alc_eapd_ctrl_info, \
662 .get = alc_eapd_ctrl_get, \
663 .put = alc_eapd_ctrl_put, \
664 .private_value = nid | (mask<<16) }
665#endif /* CONFIG_SND_DEBUG */
666
Kailang Yangdf694da2005-12-05 19:42:22 +0100667/*
668 * set up from the preset table
669 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200670static void setup_preset(struct alc_spec *spec,
671 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100672{
673 int i;
674
675 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
676 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200677 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
678 i++)
679 spec->init_verbs[spec->num_init_verbs++] =
680 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100681
682 spec->channel_mode = preset->channel_mode;
683 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200684 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100685
686 spec->multiout.max_channels = spec->channel_mode[0].channels;
687
688 spec->multiout.num_dacs = preset->num_dacs;
689 spec->multiout.dac_nids = preset->dac_nids;
690 spec->multiout.dig_out_nid = preset->dig_out_nid;
691 spec->multiout.hp_nid = preset->hp_nid;
692
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200693 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200694 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200695 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100696 spec->input_mux = preset->input_mux;
697
698 spec->num_adc_nids = preset->num_adc_nids;
699 spec->adc_nids = preset->adc_nids;
700 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100701
702 spec->unsol_event = preset->unsol_event;
703 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200704#ifdef CONFIG_SND_HDA_POWER_SAVE
705 spec->loopback.amplist = preset->loopbacks;
706#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100707}
708
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200709/* Enable GPIO mask and set output */
710static struct hda_verb alc_gpio1_init_verbs[] = {
711 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
712 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
713 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
714 { }
715};
716
717static struct hda_verb alc_gpio2_init_verbs[] = {
718 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
719 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
720 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
721 { }
722};
723
Kailang Yangbdd148a2007-05-08 15:19:08 +0200724static struct hda_verb alc_gpio3_init_verbs[] = {
725 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
726 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
727 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
728 { }
729};
730
Kailang Yangc9b58002007-10-16 14:30:01 +0200731static void alc_sku_automute(struct hda_codec *codec)
732{
733 struct alc_spec *spec = codec->spec;
734 unsigned int mute;
735 unsigned int present;
736 unsigned int hp_nid = spec->autocfg.hp_pins[0];
737 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
738
739 /* need to execute and sync at first */
740 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
741 present = snd_hda_codec_read(codec, hp_nid, 0,
742 AC_VERB_GET_PIN_SENSE, 0);
743 spec->jack_present = (present & 0x80000000) != 0;
744 if (spec->jack_present) {
745 /* mute internal speaker */
746 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
747 HDA_AMP_MUTE, HDA_AMP_MUTE);
748 } else {
749 /* unmute internal speaker if necessary */
750 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
751 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
752 HDA_AMP_MUTE, mute);
753 }
754}
755
756/* unsolicited event for HP jack sensing */
757static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
758{
759 if (codec->vendor_id == 0x10ec0880)
760 res >>= 28;
761 else
762 res >>= 26;
763 if (res != ALC880_HP_EVENT)
764 return;
765
766 alc_sku_automute(codec);
767}
768
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200769/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
770 * 31 ~ 16 : Manufacture ID
771 * 15 ~ 8 : SKU ID
772 * 7 ~ 0 : Assembly ID
773 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
774 */
775static void alc_subsystem_id(struct hda_codec *codec,
776 unsigned int porta, unsigned int porte,
777 unsigned int portd)
778{
Kailang Yangc9b58002007-10-16 14:30:01 +0200779 unsigned int ass, tmp, i;
780 unsigned nid;
781 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200782
Kailang Yangc9b58002007-10-16 14:30:01 +0200783 ass = codec->subsystem_id & 0xffff;
784 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
785 goto do_sku;
786
787 /*
788 * 31~30 : port conetcivity
789 * 29~21 : reserve
790 * 20 : PCBEEP input
791 * 19~16 : Check sum (15:1)
792 * 15~1 : Custom
793 * 0 : override
794 */
795 nid = 0x1d;
796 if (codec->vendor_id == 0x10ec0260)
797 nid = 0x17;
798 ass = snd_hda_codec_read(codec, nid, 0,
799 AC_VERB_GET_CONFIG_DEFAULT, 0);
800 if (!(ass & 1) && !(ass & 0x100000))
801 return;
802 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200803 return;
804
Kailang Yangc9b58002007-10-16 14:30:01 +0200805 /* check sum */
806 tmp = 0;
807 for (i = 1; i < 16; i++) {
808 if ((ass >> i) && 1)
809 tmp++;
810 }
811 if (((ass >> 16) & 0xf) != tmp)
812 return;
813do_sku:
814 /*
815 * 0 : override
816 * 1 : Swap Jack
817 * 2 : 0 --> Desktop, 1 --> Laptop
818 * 3~5 : External Amplifier control
819 * 7~6 : Reserved
820 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200821 tmp = (ass & 0x38) >> 3; /* external Amp control */
822 switch (tmp) {
823 case 1:
824 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
825 break;
826 case 3:
827 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
828 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200829 case 7:
830 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
831 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200832 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200833 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200834 case 0x10ec0260:
835 snd_hda_codec_write(codec, 0x0f, 0,
836 AC_VERB_SET_EAPD_BTLENABLE, 2);
837 snd_hda_codec_write(codec, 0x10, 0,
838 AC_VERB_SET_EAPD_BTLENABLE, 2);
839 break;
840 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200841 case 0x10ec0267:
842 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200843 case 0x10ec0269:
844 case 0x10ec0862:
845 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200846 snd_hda_codec_write(codec, 0x14, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 snd_hda_codec_write(codec, 0x15, 0,
849 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200850 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200851 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200852 switch (codec->vendor_id) {
853 case 0x10ec0260:
854 snd_hda_codec_write(codec, 0x1a, 0,
855 AC_VERB_SET_COEF_INDEX, 7);
856 tmp = snd_hda_codec_read(codec, 0x1a, 0,
857 AC_VERB_GET_PROC_COEF, 0);
858 snd_hda_codec_write(codec, 0x1a, 0,
859 AC_VERB_SET_COEF_INDEX, 7);
860 snd_hda_codec_write(codec, 0x1a, 0,
861 AC_VERB_SET_PROC_COEF,
862 tmp | 0x2010);
863 break;
864 case 0x10ec0262:
865 case 0x10ec0880:
866 case 0x10ec0882:
867 case 0x10ec0883:
868 case 0x10ec0885:
869 case 0x10ec0888:
870 snd_hda_codec_write(codec, 0x20, 0,
871 AC_VERB_SET_COEF_INDEX, 7);
872 tmp = snd_hda_codec_read(codec, 0x20, 0,
873 AC_VERB_GET_PROC_COEF, 0);
874 snd_hda_codec_write(codec, 0x20, 0,
875 AC_VERB_SET_COEF_INDEX, 7);
876 snd_hda_codec_write(codec, 0x20, 0,
877 AC_VERB_SET_PROC_COEF,
878 tmp | 0x2010);
879 break;
880 case 0x10ec0267:
881 case 0x10ec0268:
882 snd_hda_codec_write(codec, 0x20, 0,
883 AC_VERB_SET_COEF_INDEX, 7);
884 tmp = snd_hda_codec_read(codec, 0x20, 0,
885 AC_VERB_GET_PROC_COEF, 0);
886 snd_hda_codec_write(codec, 0x20, 0,
887 AC_VERB_SET_COEF_INDEX, 7);
888 snd_hda_codec_write(codec, 0x20, 0,
889 AC_VERB_SET_PROC_COEF,
890 tmp | 0x3000);
891 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200892 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200893 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200894 break;
895 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200896
897 /* is laptop and enable the function "Mute internal speaker
898 * when the external headphone out jack is plugged"
899 */
900 if (!(ass & 0x4) || !(ass & 0x8000))
901 return;
902 /*
903 * 10~8 : Jack location
904 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
905 * 14~13: Resvered
906 * 15 : 1 --> enable the function "Mute internal speaker
907 * when the external headphone out jack is plugged"
908 */
909 if (!spec->autocfg.speaker_pins[0]) {
910 if (spec->multiout.dac_nids[0])
911 spec->autocfg.speaker_pins[0] =
912 spec->multiout.dac_nids[0];
913 else
914 return;
915 }
916
917 if (!spec->autocfg.hp_pins[0]) {
918 tmp = (ass >> 11) & 0x3; /* HP to chassis */
919 if (tmp == 0)
920 spec->autocfg.hp_pins[0] = porta;
921 else if (tmp == 1)
922 spec->autocfg.hp_pins[0] = porte;
923 else if (tmp == 2)
924 spec->autocfg.hp_pins[0] = portd;
925 else
926 return;
927 }
928
929 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
930 AC_VERB_SET_UNSOLICITED_ENABLE,
931 AC_USRSP_EN | ALC880_HP_EVENT);
932 spec->unsol_event = alc_sku_unsol_event;
933 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200934}
935
Takashi Iwai41e41f12005-06-08 14:48:49 +0200936/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200937 * Fix-up pin default configurations
938 */
939
940struct alc_pincfg {
941 hda_nid_t nid;
942 u32 val;
943};
944
945static void alc_fix_pincfg(struct hda_codec *codec,
946 const struct snd_pci_quirk *quirk,
947 const struct alc_pincfg **pinfix)
948{
949 const struct alc_pincfg *cfg;
950
951 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
952 if (!quirk)
953 return;
954
955 cfg = pinfix[quirk->value];
956 for (; cfg->nid; cfg++) {
957 int i;
958 u32 val = cfg->val;
959 for (i = 0; i < 4; i++) {
960 snd_hda_codec_write(codec, cfg->nid, 0,
961 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
962 val & 0xff);
963 val >>= 8;
964 }
965 }
966}
967
968/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200969 * ALC880 3-stack model
970 *
971 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200972 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
973 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 */
975
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200976static hda_nid_t alc880_dac_nids[4] = {
977 /* front, rear, clfe, rear_surr */
978 0x02, 0x05, 0x04, 0x03
979};
980
981static hda_nid_t alc880_adc_nids[3] = {
982 /* ADC0-2 */
983 0x07, 0x08, 0x09,
984};
985
986/* The datasheet says the node 0x07 is connected from inputs,
987 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100988 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200990static hda_nid_t alc880_adc_nids_alt[2] = {
991 /* ADC1-2 */
992 0x08, 0x09,
993};
994
995#define ALC880_DIGOUT_NID 0x06
996#define ALC880_DIGIN_NID 0x0a
997
998static struct hda_input_mux alc880_capture_source = {
999 .num_items = 4,
1000 .items = {
1001 { "Mic", 0x0 },
1002 { "Front Mic", 0x3 },
1003 { "Line", 0x2 },
1004 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001006};
1007
1008/* channel source setting (2/6 channel selection for 3-stack) */
1009/* 2ch mode */
1010static struct hda_verb alc880_threestack_ch2_init[] = {
1011 /* set line-in to input, mute it */
1012 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1013 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1014 /* set mic-in to input vref 80%, mute it */
1015 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1016 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 { } /* end */
1018};
1019
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001020/* 6ch mode */
1021static struct hda_verb alc880_threestack_ch6_init[] = {
1022 /* set line-in to output, unmute it */
1023 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1024 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1025 /* set mic-in to output, unmute it */
1026 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1027 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1028 { } /* end */
1029};
1030
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001031static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001032 { 2, alc880_threestack_ch2_init },
1033 { 6, alc880_threestack_ch6_init },
1034};
1035
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001036static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001040 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1044 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1046 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1051 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1053 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1054 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001056 {
1057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1058 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001059 .info = alc_ch_mode_info,
1060 .get = alc_ch_mode_get,
1061 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 },
1063 { } /* end */
1064};
1065
1066/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001067static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1069 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1072 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1073 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1074 {
1075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1076 /* The multiple "Capture Source" controls confuse alsamixer
1077 * So call somewhat different..
1078 * FIXME: the controls appear in the "playback" view!
1079 */
1080 /* .name = "Capture Source", */
1081 .name = "Input Source",
1082 .count = 3,
1083 .info = alc_mux_enum_info,
1084 .get = alc_mux_enum_get,
1085 .put = alc_mux_enum_put,
1086 },
1087 { } /* end */
1088};
1089
1090/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001091static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001092 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1093 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 {
1097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1098 /* The multiple "Capture Source" controls confuse alsamixer
1099 * So call somewhat different..
1100 * FIXME: the controls appear in the "playback" view!
1101 */
1102 /* .name = "Capture Source", */
1103 .name = "Input Source",
1104 .count = 2,
1105 .info = alc_mux_enum_info,
1106 .get = alc_mux_enum_get,
1107 .put = alc_mux_enum_put,
1108 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 { } /* end */
1110};
1111
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001112
1113
1114/*
1115 * ALC880 5-stack model
1116 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001117 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1118 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001119 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1120 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1121 */
1122
1123/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001124static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001126 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 { } /* end */
1128};
1129
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001130/* channel source setting (6/8 channel selection for 5-stack) */
1131/* 6ch mode */
1132static struct hda_verb alc880_fivestack_ch6_init[] = {
1133 /* set line-in to input, mute it */
1134 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1135 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001136 { } /* end */
1137};
1138
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001139/* 8ch mode */
1140static struct hda_verb alc880_fivestack_ch8_init[] = {
1141 /* set line-in to output, unmute it */
1142 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1143 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1144 { } /* end */
1145};
1146
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001147static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 { 6, alc880_fivestack_ch6_init },
1149 { 8, alc880_fivestack_ch8_init },
1150};
1151
1152
1153/*
1154 * ALC880 6-stack model
1155 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001156 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1157 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001158 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1159 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1160 */
1161
1162static hda_nid_t alc880_6st_dac_nids[4] = {
1163 /* front, rear, clfe, rear_surr */
1164 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001165};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001166
1167static struct hda_input_mux alc880_6stack_capture_source = {
1168 .num_items = 4,
1169 .items = {
1170 { "Mic", 0x0 },
1171 { "Front Mic", 0x1 },
1172 { "Line", 0x2 },
1173 { "CD", 0x4 },
1174 },
1175};
1176
1177/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001178static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001179 { 8, NULL },
1180};
1181
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001182static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001185 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001186 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001187 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1188 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001189 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1190 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001191 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001192 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1201 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1202 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001203 {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001206 .info = alc_ch_mode_info,
1207 .get = alc_ch_mode_get,
1208 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001209 },
1210 { } /* end */
1211};
1212
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001213
1214/*
1215 * ALC880 W810 model
1216 *
1217 * W810 has rear IO for:
1218 * Front (DAC 02)
1219 * Surround (DAC 03)
1220 * Center/LFE (DAC 04)
1221 * Digital out (06)
1222 *
1223 * The system also has a pair of internal speakers, and a headphone jack.
1224 * These are both connected to Line2 on the codec, hence to DAC 02.
1225 *
1226 * There is a variable resistor to control the speaker or headphone
1227 * volume. This is a hardware-only device without a software API.
1228 *
1229 * Plugging headphones in will disable the internal speakers. This is
1230 * implemented in hardware, not via the driver using jack sense. In
1231 * a similar fashion, plugging into the rear socket marked "front" will
1232 * disable both the speakers and headphones.
1233 *
1234 * For input, there's a microphone jack, and an "audio in" jack.
1235 * These may not do anything useful with this driver yet, because I
1236 * haven't setup any initialization verbs for these yet...
1237 */
1238
1239static hda_nid_t alc880_w810_dac_nids[3] = {
1240 /* front, rear/surround, clfe */
1241 0x02, 0x03, 0x04
1242};
1243
1244/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001245static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001246 { 6, NULL }
1247};
1248
1249/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001250static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001254 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1260 { } /* end */
1261};
1262
1263
1264/*
1265 * Z710V model
1266 *
1267 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001268 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1269 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270 */
1271
1272static hda_nid_t alc880_z71v_dac_nids[1] = {
1273 0x02
1274};
1275#define ALC880_Z71V_HP_DAC 0x03
1276
1277/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001278static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 { 2, NULL }
1280};
1281
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001282static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001284 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001286 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1288 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1291 { } /* end */
1292};
1293
1294
1295/* FIXME! */
1296/*
1297 * ALC880 F1734 model
1298 *
1299 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1300 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1301 */
1302
1303static hda_nid_t alc880_f1734_dac_nids[1] = {
1304 0x03
1305};
1306#define ALC880_F1734_HP_DAC 0x02
1307
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001308static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001309 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001310 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001311 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001312 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001317 { } /* end */
1318};
1319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001320
1321/* FIXME! */
1322/*
1323 * ALC880 ASUS model
1324 *
1325 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1326 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1327 * Mic = 0x18, Line = 0x1a
1328 */
1329
1330#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1331#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1332
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001333static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001334 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001335 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001336 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001337 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001338 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1339 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001340 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1341 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001342 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1343 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1345 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001348 {
1349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1350 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001351 .info = alc_ch_mode_info,
1352 .get = alc_ch_mode_get,
1353 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001354 },
1355 { } /* end */
1356};
1357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001358/* FIXME! */
1359/*
1360 * ALC880 ASUS W1V model
1361 *
1362 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1363 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1364 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1365 */
1366
1367/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001368static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001369 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1370 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001371 { } /* end */
1372};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001373
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001374/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001375static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001376 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1377 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1378 { } /* end */
1379};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001380
Kailang Yangdf694da2005-12-05 19:42:22 +01001381/* TCL S700 */
1382static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1384 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1387 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1391 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1392 {
1393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1394 /* The multiple "Capture Source" controls confuse alsamixer
1395 * So call somewhat different..
1396 * FIXME: the controls appear in the "playback" view!
1397 */
1398 /* .name = "Capture Source", */
1399 .name = "Input Source",
1400 .count = 1,
1401 .info = alc_mux_enum_info,
1402 .get = alc_mux_enum_get,
1403 .put = alc_mux_enum_put,
1404 },
1405 { } /* end */
1406};
1407
Kailang Yangccc656c2006-10-17 12:32:26 +02001408/* Uniwill */
1409static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1410 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1411 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1412 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1413 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1414 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1415 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1417 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1426 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1427 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1428 {
1429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1430 .name = "Channel Mode",
1431 .info = alc_ch_mode_info,
1432 .get = alc_ch_mode_get,
1433 .put = alc_ch_mode_put,
1434 },
1435 { } /* end */
1436};
1437
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001438static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1440 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1441 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1442 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1443 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1444 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1446 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1447 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1448 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1449 { } /* end */
1450};
1451
Kailang Yangccc656c2006-10-17 12:32:26 +02001452static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1453 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1454 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1455 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1456 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1459 { } /* end */
1460};
1461
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001463 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 */
1465static int alc_build_controls(struct hda_codec *codec)
1466{
1467 struct alc_spec *spec = codec->spec;
1468 int err;
1469 int i;
1470
1471 for (i = 0; i < spec->num_mixers; i++) {
1472 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1473 if (err < 0)
1474 return err;
1475 }
1476
1477 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001478 err = snd_hda_create_spdif_out_ctls(codec,
1479 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 if (err < 0)
1481 return err;
1482 }
1483 if (spec->dig_in_nid) {
1484 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1485 if (err < 0)
1486 return err;
1487 }
1488 return 0;
1489}
1490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001491
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492/*
1493 * initialize the codec volumes, etc
1494 */
1495
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001496/*
1497 * generic initialization of ADC, input mixers and output mixers
1498 */
1499static struct hda_verb alc880_volume_init_verbs[] = {
1500 /*
1501 * Unmute ADC0-2 and set the default input to mic-in
1502 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001503 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001505 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001507 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001510 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1511 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001512 * Note: PASD motherboards uses the Line In 2 as the input for front
1513 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001515 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001524 /*
1525 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001527 /* set vol=0 to output mixers */
1528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1532 /* set up input amps for analog loopback */
1533 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542
1543 { }
1544};
1545
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001546/*
1547 * 3-stack pin configuration:
1548 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1549 */
1550static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1551 /*
1552 * preset connection lists of input pins
1553 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1554 */
1555 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1556 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1557 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1558
1559 /*
1560 * Set pin mode and muting
1561 */
1562 /* set front pin widgets 0x14 for output */
1563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1565 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1568 /* Mic2 (as headphone out) for HP output */
1569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1571 /* Line In pin widget for input */
1572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1574 /* Line2 (as front mic) pin widget for input and vref at 80% */
1575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1576 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1577 /* CD pin widget for input */
1578 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1579
1580 { }
1581};
1582
1583/*
1584 * 5-stack pin configuration:
1585 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1586 * line-in/side = 0x1a, f-mic = 0x1b
1587 */
1588static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1589 /*
1590 * preset connection lists of input pins
1591 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1592 */
1593 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1594 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1595
1596 /*
1597 * Set pin mode and muting
1598 */
1599 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001604 /* unmute pins for output (no gain on this amp) */
1605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1609
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1613 /* Mic2 (as headphone out) for HP output */
1614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001616 /* Line In pin widget for input */
1617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1619 /* Line2 (as front mic) pin widget for input and vref at 80% */
1620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* CD pin widget for input */
1623 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624
1625 { }
1626};
1627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001628/*
1629 * W810 pin configuration:
1630 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1631 */
1632static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 /* hphone/speaker input selector: front DAC */
1634 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1642
1643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001644 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646 { }
1647};
1648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001649/*
1650 * Z71V pin configuration:
1651 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1652 */
1653static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001658
Takashi Iwai16ded522005-06-10 19:58:24 +02001659 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001661 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001663
1664 { }
1665};
1666
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001667/*
1668 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001669 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1670 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001671 */
1672static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1673 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1674
Takashi Iwai16ded522005-06-10 19:58:24 +02001675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001677 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001681 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001682 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1683
Takashi Iwai16ded522005-06-10 19:58:24 +02001684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001691 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001694 { }
1695};
Takashi Iwai16ded522005-06-10 19:58:24 +02001696
Kailang Yangccc656c2006-10-17 12:32:26 +02001697/*
1698 * Uniwill pin configuration:
1699 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1700 * line = 0x1a
1701 */
1702static struct hda_verb alc880_uniwill_init_verbs[] = {
1703 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1704
1705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1719
1720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1726 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1727 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1729
1730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1731 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1732
1733 { }
1734};
1735
1736/*
1737* Uniwill P53
1738* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1739 */
1740static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1741 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1742
1743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1755
1756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1762
1763 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1764 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1765
1766 { }
1767};
1768
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001769static struct hda_verb alc880_beep_init_verbs[] = {
1770 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1771 { }
1772};
1773
Kailang Yangccc656c2006-10-17 12:32:26 +02001774/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001775static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001776{
1777 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001778 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001779
1780 present = snd_hda_codec_read(codec, 0x14, 0,
1781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001782 bits = present ? HDA_AMP_MUTE : 0;
1783 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1784 HDA_AMP_MUTE, bits);
1785 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1786 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001787}
1788
1789/* auto-toggle front mic */
1790static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1791{
1792 unsigned int present;
1793 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001794
1795 present = snd_hda_codec_read(codec, 0x18, 0,
1796 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001797 bits = present ? HDA_AMP_MUTE : 0;
1798 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001799}
1800
1801static void alc880_uniwill_automute(struct hda_codec *codec)
1802{
1803 alc880_uniwill_hp_automute(codec);
1804 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001805}
1806
1807static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1808 unsigned int res)
1809{
1810 /* Looks like the unsol event is incompatible with the standard
1811 * definition. 4bit tag is placed at 28 bit!
1812 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001813 switch (res >> 28) {
1814 case ALC880_HP_EVENT:
1815 alc880_uniwill_hp_automute(codec);
1816 break;
1817 case ALC880_MIC_EVENT:
1818 alc880_uniwill_mic_automute(codec);
1819 break;
1820 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001821}
1822
1823static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1824{
1825 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001826 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001827
1828 present = snd_hda_codec_read(codec, 0x14, 0,
1829 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001830 bits = present ? HDA_AMP_MUTE : 0;
1831 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001832}
1833
1834static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1835{
1836 unsigned int present;
1837
1838 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001839 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1840 present &= HDA_AMP_VOLMASK;
1841 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1842 HDA_AMP_VOLMASK, present);
1843 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1844 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001845}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001846
Kailang Yangccc656c2006-10-17 12:32:26 +02001847static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1848 unsigned int res)
1849{
1850 /* Looks like the unsol event is incompatible with the standard
1851 * definition. 4bit tag is placed at 28 bit!
1852 */
1853 if ((res >> 28) == ALC880_HP_EVENT)
1854 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001855 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001856 alc880_uniwill_p53_dcvol_automute(codec);
1857}
1858
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001859/* FIXME! */
1860/*
1861 * F1734 pin configuration:
1862 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1863 */
1864static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1865 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1868 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1869
1870 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1871 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1874
1875 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1877 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1878 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1882 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1883 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001884
1885 { }
1886};
1887
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001888/* FIXME! */
1889/*
1890 * ASUS pin configuration:
1891 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1892 */
1893static struct hda_verb alc880_pin_asus_init_verbs[] = {
1894 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1895 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1896 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1897 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1898
1899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1905 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1907
1908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1917
1918 { }
1919};
1920
1921/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001922#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1923#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001924
Kailang Yangdf694da2005-12-05 19:42:22 +01001925/* Clevo m520g init */
1926static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1927 /* headphone output */
1928 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1929 /* line-out */
1930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 /* Line-in */
1933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1935 /* CD */
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 /* Mic1 (rear panel) */
1939 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1940 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1941 /* Mic2 (front panel) */
1942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1944 /* headphone */
1945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 /* change to EAPD mode */
1948 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1949 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1950
1951 { }
1952};
1953
1954static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001955 /* change to EAPD mode */
1956 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1957 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1958
Kailang Yangdf694da2005-12-05 19:42:22 +01001959 /* Headphone output */
1960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1961 /* Front output*/
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1964
1965 /* Line In pin widget for input */
1966 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1967 /* CD pin widget for input */
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1969 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1971
1972 /* change to EAPD mode */
1973 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1974 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1975
1976 { }
1977};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001978
1979/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001980 * LG m1 express dual
1981 *
1982 * Pin assignment:
1983 * Rear Line-In/Out (blue): 0x14
1984 * Build-in Mic-In: 0x15
1985 * Speaker-out: 0x17
1986 * HP-Out (green): 0x1b
1987 * Mic-In/Out (red): 0x19
1988 * SPDIF-Out: 0x1e
1989 */
1990
1991/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1992static hda_nid_t alc880_lg_dac_nids[3] = {
1993 0x05, 0x02, 0x03
1994};
1995
1996/* seems analog CD is not working */
1997static struct hda_input_mux alc880_lg_capture_source = {
1998 .num_items = 3,
1999 .items = {
2000 { "Mic", 0x1 },
2001 { "Line", 0x5 },
2002 { "Internal Mic", 0x6 },
2003 },
2004};
2005
2006/* 2,4,6 channel modes */
2007static struct hda_verb alc880_lg_ch2_init[] = {
2008 /* set line-in and mic-in to input */
2009 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2010 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2011 { }
2012};
2013
2014static struct hda_verb alc880_lg_ch4_init[] = {
2015 /* set line-in to out and mic-in to input */
2016 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2017 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2018 { }
2019};
2020
2021static struct hda_verb alc880_lg_ch6_init[] = {
2022 /* set line-in and mic-in to output */
2023 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2024 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2025 { }
2026};
2027
2028static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2029 { 2, alc880_lg_ch2_init },
2030 { 4, alc880_lg_ch4_init },
2031 { 6, alc880_lg_ch6_init },
2032};
2033
2034static struct snd_kcontrol_new alc880_lg_mixer[] = {
2035 /* FIXME: it's not really "master" but front channels */
2036 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2037 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
2038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2039 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2048 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2049 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2050 {
2051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2052 .name = "Channel Mode",
2053 .info = alc_ch_mode_info,
2054 .get = alc_ch_mode_get,
2055 .put = alc_ch_mode_put,
2056 },
2057 { } /* end */
2058};
2059
2060static struct hda_verb alc880_lg_init_verbs[] = {
2061 /* set capture source to mic-in */
2062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2065 /* mute all amp mixer inputs */
2066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002069 /* line-in to input */
2070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 /* built-in mic */
2073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2075 /* speaker-out */
2076 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 /* mic-in to input */
2079 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2082 /* HP-out */
2083 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2084 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2085 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2086 /* jack sense */
2087 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2088 { }
2089};
2090
2091/* toggle speaker-output according to the hp-jack state */
2092static void alc880_lg_automute(struct hda_codec *codec)
2093{
2094 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002095 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002096
2097 present = snd_hda_codec_read(codec, 0x1b, 0,
2098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002099 bits = present ? HDA_AMP_MUTE : 0;
2100 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2101 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002102}
2103
2104static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2105{
2106 /* Looks like the unsol event is incompatible with the standard
2107 * definition. 4bit tag is placed at 28 bit!
2108 */
2109 if ((res >> 28) == 0x01)
2110 alc880_lg_automute(codec);
2111}
2112
2113/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002114 * LG LW20
2115 *
2116 * Pin assignment:
2117 * Speaker-out: 0x14
2118 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002119 * Built-in Mic-In: 0x19
2120 * Line-In: 0x1b
2121 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002122 * SPDIF-Out: 0x1e
2123 */
2124
Takashi Iwaid6815182006-03-23 16:06:23 +01002125static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002126 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002127 .items = {
2128 { "Mic", 0x0 },
2129 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002130 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002131 },
2132};
2133
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002134#define alc880_lg_lw_modes alc880_threestack_modes
2135
Takashi Iwaid6815182006-03-23 16:06:23 +01002136static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2138 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2139 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2140 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2141 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2142 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2143 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2144 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2149 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2150 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002151 {
2152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2153 .name = "Channel Mode",
2154 .info = alc_ch_mode_info,
2155 .get = alc_ch_mode_get,
2156 .put = alc_ch_mode_put,
2157 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002158 { } /* end */
2159};
2160
2161static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002162 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2163 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2164 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2165
Takashi Iwaid6815182006-03-23 16:06:23 +01002166 /* set capture source to mic-in */
2167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002171 /* speaker-out */
2172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2174 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002175 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2176 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2177 /* mic-in to input */
2178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2180 /* built-in mic */
2181 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2183 /* jack sense */
2184 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2185 { }
2186};
2187
2188/* toggle speaker-output according to the hp-jack state */
2189static void alc880_lg_lw_automute(struct hda_codec *codec)
2190{
2191 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002192 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002193
2194 present = snd_hda_codec_read(codec, 0x1b, 0,
2195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002196 bits = present ? HDA_AMP_MUTE : 0;
2197 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2198 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002199}
2200
2201static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2202{
2203 /* Looks like the unsol event is incompatible with the standard
2204 * definition. 4bit tag is placed at 28 bit!
2205 */
2206 if ((res >> 28) == 0x01)
2207 alc880_lg_lw_automute(codec);
2208}
2209
Takashi Iwaicb53c622007-08-10 17:21:45 +02002210#ifdef CONFIG_SND_HDA_POWER_SAVE
2211static struct hda_amp_list alc880_loopbacks[] = {
2212 { 0x0b, HDA_INPUT, 0 },
2213 { 0x0b, HDA_INPUT, 1 },
2214 { 0x0b, HDA_INPUT, 2 },
2215 { 0x0b, HDA_INPUT, 3 },
2216 { 0x0b, HDA_INPUT, 4 },
2217 { } /* end */
2218};
2219
2220static struct hda_amp_list alc880_lg_loopbacks[] = {
2221 { 0x0b, HDA_INPUT, 1 },
2222 { 0x0b, HDA_INPUT, 6 },
2223 { 0x0b, HDA_INPUT, 7 },
2224 { } /* end */
2225};
2226#endif
2227
Takashi Iwaid6815182006-03-23 16:06:23 +01002228/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002229 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002230 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002231
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232static int alc_init(struct hda_codec *codec)
2233{
2234 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 unsigned int i;
2236
2237 for (i = 0; i < spec->num_init_verbs; i++)
2238 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002239
2240 if (spec->init_hook)
2241 spec->init_hook(codec);
2242
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 return 0;
2244}
2245
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002246static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2247{
2248 struct alc_spec *spec = codec->spec;
2249
2250 if (spec->unsol_event)
2251 spec->unsol_event(codec, res);
2252}
2253
Takashi Iwaicb53c622007-08-10 17:21:45 +02002254#ifdef CONFIG_SND_HDA_POWER_SAVE
2255static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2256{
2257 struct alc_spec *spec = codec->spec;
2258 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2259}
2260#endif
2261
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262/*
2263 * Analog playback callbacks
2264 */
2265static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2266 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268{
2269 struct alc_spec *spec = codec->spec;
2270 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2271}
2272
2273static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
2275 unsigned int stream_tag,
2276 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002277 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278{
2279 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002280 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2281 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282}
2283
2284static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2285 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002286 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287{
2288 struct alc_spec *spec = codec->spec;
2289 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2290}
2291
2292/*
2293 * Digital out
2294 */
2295static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2296 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002297 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298{
2299 struct alc_spec *spec = codec->spec;
2300 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2301}
2302
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002303static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 unsigned int stream_tag,
2306 unsigned int format,
2307 struct snd_pcm_substream *substream)
2308{
2309 struct alc_spec *spec = codec->spec;
2310 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2311 stream_tag, format, substream);
2312}
2313
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2315 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002316 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317{
2318 struct alc_spec *spec = codec->spec;
2319 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2320}
2321
2322/*
2323 * Analog capture
2324 */
2325static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2326 struct hda_codec *codec,
2327 unsigned int stream_tag,
2328 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002329 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330{
2331 struct alc_spec *spec = codec->spec;
2332
2333 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2334 stream_tag, 0, format);
2335 return 0;
2336}
2337
2338static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2339 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002340 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341{
2342 struct alc_spec *spec = codec->spec;
2343
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002344 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2345 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 return 0;
2347}
2348
2349
2350/*
2351 */
2352static struct hda_pcm_stream alc880_pcm_analog_playback = {
2353 .substreams = 1,
2354 .channels_min = 2,
2355 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002356 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 .ops = {
2358 .open = alc880_playback_pcm_open,
2359 .prepare = alc880_playback_pcm_prepare,
2360 .cleanup = alc880_playback_pcm_cleanup
2361 },
2362};
2363
2364static struct hda_pcm_stream alc880_pcm_analog_capture = {
2365 .substreams = 2,
2366 .channels_min = 2,
2367 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002368 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 .ops = {
2370 .prepare = alc880_capture_pcm_prepare,
2371 .cleanup = alc880_capture_pcm_cleanup
2372 },
2373};
2374
2375static struct hda_pcm_stream alc880_pcm_digital_playback = {
2376 .substreams = 1,
2377 .channels_min = 2,
2378 .channels_max = 2,
2379 /* NID is set in alc_build_pcms */
2380 .ops = {
2381 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002382 .close = alc880_dig_playback_pcm_close,
2383 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 },
2385};
2386
2387static struct hda_pcm_stream alc880_pcm_digital_capture = {
2388 .substreams = 1,
2389 .channels_min = 2,
2390 .channels_max = 2,
2391 /* NID is set in alc_build_pcms */
2392};
2393
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002394/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2395static struct hda_pcm_stream alc_pcm_null_playback = {
2396 .substreams = 0,
2397 .channels_min = 0,
2398 .channels_max = 0,
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401static int alc_build_pcms(struct hda_codec *codec)
2402{
2403 struct alc_spec *spec = codec->spec;
2404 struct hda_pcm *info = spec->pcm_rec;
2405 int i;
2406
2407 codec->num_pcms = 1;
2408 codec->pcm_info = info;
2409
2410 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002411 if (spec->stream_analog_playback) {
2412 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2413 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2414 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2415 }
2416 if (spec->stream_analog_capture) {
2417 snd_assert(spec->adc_nids, return -EINVAL);
2418 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2419 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2420 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421
Takashi Iwai4a471b72005-12-07 13:56:29 +01002422 if (spec->channel_mode) {
2423 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2424 for (i = 0; i < spec->num_channel_mode; i++) {
2425 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2426 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2427 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 }
2429 }
2430
Takashi Iwaie08a0072006-09-07 17:52:14 +02002431 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002433 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002434 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002436 if (spec->multiout.dig_out_nid &&
2437 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2440 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002441 if (spec->dig_in_nid &&
2442 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2444 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2445 }
2446 }
2447
Takashi Iwaie08a0072006-09-07 17:52:14 +02002448 /* If the use of more than one ADC is requested for the current
2449 * model, configure a second analog capture-only PCM.
2450 */
2451 /* Additional Analaog capture for index #2 */
2452 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2453 spec->adc_nids) {
2454 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002455 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002456 info->name = spec->stream_name_analog;
2457 /* No playback stream for second PCM */
2458 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2459 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2460 if (spec->stream_analog_capture) {
2461 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2462 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2463 }
2464 }
2465
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466 return 0;
2467}
2468
2469static void alc_free(struct hda_codec *codec)
2470{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002471 struct alc_spec *spec = codec->spec;
2472 unsigned int i;
2473
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002474 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475 return;
2476
2477 if (spec->kctl_alloc) {
2478 for (i = 0; i < spec->num_kctl_used; i++)
2479 kfree(spec->kctl_alloc[i].name);
2480 kfree(spec->kctl_alloc);
2481 }
2482 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483}
2484
2485/*
2486 */
2487static struct hda_codec_ops alc_patch_ops = {
2488 .build_controls = alc_build_controls,
2489 .build_pcms = alc_build_pcms,
2490 .init = alc_init,
2491 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002492 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002493#ifdef CONFIG_SND_HDA_POWER_SAVE
2494 .check_power_status = alc_check_power_status,
2495#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496};
2497
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002498
2499/*
2500 * Test configuration for debugging
2501 *
2502 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2503 * enum controls.
2504 */
2505#ifdef CONFIG_SND_DEBUG
2506static hda_nid_t alc880_test_dac_nids[4] = {
2507 0x02, 0x03, 0x04, 0x05
2508};
2509
2510static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002511 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002512 .items = {
2513 { "In-1", 0x0 },
2514 { "In-2", 0x1 },
2515 { "In-3", 0x2 },
2516 { "In-4", 0x3 },
2517 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002518 { "Front", 0x5 },
2519 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002520 },
2521};
2522
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002523static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002524 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002525 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002526 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002527 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002528};
2529
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002530static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2531 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002532{
2533 static char *texts[] = {
2534 "N/A", "Line Out", "HP Out",
2535 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2536 };
2537 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2538 uinfo->count = 1;
2539 uinfo->value.enumerated.items = 8;
2540 if (uinfo->value.enumerated.item >= 8)
2541 uinfo->value.enumerated.item = 7;
2542 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2543 return 0;
2544}
2545
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002546static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2547 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002548{
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2551 unsigned int pin_ctl, item = 0;
2552
2553 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2554 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2555 if (pin_ctl & AC_PINCTL_OUT_EN) {
2556 if (pin_ctl & AC_PINCTL_HP_EN)
2557 item = 2;
2558 else
2559 item = 1;
2560 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2561 switch (pin_ctl & AC_PINCTL_VREFEN) {
2562 case AC_PINCTL_VREF_HIZ: item = 3; break;
2563 case AC_PINCTL_VREF_50: item = 4; break;
2564 case AC_PINCTL_VREF_GRD: item = 5; break;
2565 case AC_PINCTL_VREF_80: item = 6; break;
2566 case AC_PINCTL_VREF_100: item = 7; break;
2567 }
2568 }
2569 ucontrol->value.enumerated.item[0] = item;
2570 return 0;
2571}
2572
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002573static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2574 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002575{
2576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2577 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2578 static unsigned int ctls[] = {
2579 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2580 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2581 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2582 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2583 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2584 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2585 };
2586 unsigned int old_ctl, new_ctl;
2587
2588 old_ctl = snd_hda_codec_read(codec, nid, 0,
2589 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2590 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2591 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002592 int val;
2593 snd_hda_codec_write_cache(codec, nid, 0,
2594 AC_VERB_SET_PIN_WIDGET_CONTROL,
2595 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002596 val = ucontrol->value.enumerated.item[0] >= 3 ?
2597 HDA_AMP_MUTE : 0;
2598 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2599 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002600 return 1;
2601 }
2602 return 0;
2603}
2604
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002605static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2606 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002607{
2608 static char *texts[] = {
2609 "Front", "Surround", "CLFE", "Side"
2610 };
2611 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2612 uinfo->count = 1;
2613 uinfo->value.enumerated.items = 4;
2614 if (uinfo->value.enumerated.item >= 4)
2615 uinfo->value.enumerated.item = 3;
2616 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2617 return 0;
2618}
2619
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002620static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2621 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002622{
2623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2624 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2625 unsigned int sel;
2626
2627 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2628 ucontrol->value.enumerated.item[0] = sel & 3;
2629 return 0;
2630}
2631
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002632static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2633 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002634{
2635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2636 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2637 unsigned int sel;
2638
2639 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2640 if (ucontrol->value.enumerated.item[0] != sel) {
2641 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002642 snd_hda_codec_write_cache(codec, nid, 0,
2643 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002644 return 1;
2645 }
2646 return 0;
2647}
2648
2649#define PIN_CTL_TEST(xname,nid) { \
2650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2651 .name = xname, \
2652 .info = alc_test_pin_ctl_info, \
2653 .get = alc_test_pin_ctl_get, \
2654 .put = alc_test_pin_ctl_put, \
2655 .private_value = nid \
2656 }
2657
2658#define PIN_SRC_TEST(xname,nid) { \
2659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2660 .name = xname, \
2661 .info = alc_test_pin_src_info, \
2662 .get = alc_test_pin_src_get, \
2663 .put = alc_test_pin_src_put, \
2664 .private_value = nid \
2665 }
2666
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002667static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2669 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2670 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2671 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002672 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2673 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2674 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2675 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002676 PIN_CTL_TEST("Front Pin Mode", 0x14),
2677 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2678 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2679 PIN_CTL_TEST("Side Pin Mode", 0x17),
2680 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2681 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2682 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2683 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2684 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2685 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2686 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2687 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2688 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2689 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2690 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2691 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2692 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2693 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2694 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2695 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2696 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2697 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002698 {
2699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2700 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002701 .info = alc_ch_mode_info,
2702 .get = alc_ch_mode_get,
2703 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002704 },
2705 { } /* end */
2706};
2707
2708static struct hda_verb alc880_test_init_verbs[] = {
2709 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002718 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2721 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2722 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002723 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2726 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2727 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002728 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002733 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002734 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2735 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2738 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002739 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002744 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002746 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002748 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002750 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002751 /* Analog input/passthru */
2752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002757 { }
2758};
2759#endif
2760
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761/*
2762 */
2763
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002764static const char *alc880_models[ALC880_MODEL_LAST] = {
2765 [ALC880_3ST] = "3stack",
2766 [ALC880_TCL_S700] = "tcl",
2767 [ALC880_3ST_DIG] = "3stack-digout",
2768 [ALC880_CLEVO] = "clevo",
2769 [ALC880_5ST] = "5stack",
2770 [ALC880_5ST_DIG] = "5stack-digout",
2771 [ALC880_W810] = "w810",
2772 [ALC880_Z71V] = "z71v",
2773 [ALC880_6ST] = "6stack",
2774 [ALC880_6ST_DIG] = "6stack-digout",
2775 [ALC880_ASUS] = "asus",
2776 [ALC880_ASUS_W1V] = "asus-w1v",
2777 [ALC880_ASUS_DIG] = "asus-dig",
2778 [ALC880_ASUS_DIG2] = "asus-dig2",
2779 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002780 [ALC880_UNIWILL_P53] = "uniwill-p53",
2781 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002782 [ALC880_F1734] = "F1734",
2783 [ALC880_LG] = "lg",
2784 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002785#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002786 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002787#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002788 [ALC880_AUTO] = "auto",
2789};
2790
2791static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002792 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002793 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2794 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2795 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2796 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2797 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2798 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2799 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2800 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002801 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2802 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002803 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2804 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2805 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2806 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2807 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2808 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2809 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2810 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2811 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2812 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002813 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002814 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2815 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2816 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002817 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002818 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002819 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2820 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002821 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2822 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002823 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2824 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2825 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2826 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002827 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2828 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002829 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002830 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002831 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002832 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002833 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2834 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002835 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2836 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002837 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002838 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002839 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002840 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002841 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002842 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2843 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002844 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002845 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2846 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2847 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2848 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002849 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2850 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002851 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002852 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002853 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2854 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002855 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2856 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2857 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002858 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2859 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2860 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861 {}
2862};
2863
Takashi Iwai16ded522005-06-10 19:58:24 +02002864/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002865 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002866 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002867static struct alc_config_preset alc880_presets[] = {
2868 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002869 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002870 .init_verbs = { alc880_volume_init_verbs,
2871 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002872 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002873 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002874 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2875 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002876 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002877 .input_mux = &alc880_capture_source,
2878 },
2879 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002880 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002881 .init_verbs = { alc880_volume_init_verbs,
2882 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002884 .dac_nids = alc880_dac_nids,
2885 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002886 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2887 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002888 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002889 .input_mux = &alc880_capture_source,
2890 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002891 [ALC880_TCL_S700] = {
2892 .mixers = { alc880_tcl_s700_mixer },
2893 .init_verbs = { alc880_volume_init_verbs,
2894 alc880_pin_tcl_S700_init_verbs,
2895 alc880_gpio2_init_verbs },
2896 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2897 .dac_nids = alc880_dac_nids,
2898 .hp_nid = 0x03,
2899 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2900 .channel_mode = alc880_2_jack_modes,
2901 .input_mux = &alc880_capture_source,
2902 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002903 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002904 .mixers = { alc880_three_stack_mixer,
2905 alc880_five_stack_mixer},
2906 .init_verbs = { alc880_volume_init_verbs,
2907 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002908 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2909 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002910 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2911 .channel_mode = alc880_fivestack_modes,
2912 .input_mux = &alc880_capture_source,
2913 },
2914 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002915 .mixers = { alc880_three_stack_mixer,
2916 alc880_five_stack_mixer },
2917 .init_verbs = { alc880_volume_init_verbs,
2918 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2920 .dac_nids = alc880_dac_nids,
2921 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002922 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2923 .channel_mode = alc880_fivestack_modes,
2924 .input_mux = &alc880_capture_source,
2925 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002926 [ALC880_6ST] = {
2927 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002928 .init_verbs = { alc880_volume_init_verbs,
2929 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002930 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2931 .dac_nids = alc880_6st_dac_nids,
2932 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2933 .channel_mode = alc880_sixstack_modes,
2934 .input_mux = &alc880_6stack_capture_source,
2935 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002936 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002937 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002938 .init_verbs = { alc880_volume_init_verbs,
2939 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002940 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2941 .dac_nids = alc880_6st_dac_nids,
2942 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002943 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2944 .channel_mode = alc880_sixstack_modes,
2945 .input_mux = &alc880_6stack_capture_source,
2946 },
2947 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002948 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002949 .init_verbs = { alc880_volume_init_verbs,
2950 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002951 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002952 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2953 .dac_nids = alc880_w810_dac_nids,
2954 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002955 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2956 .channel_mode = alc880_w810_modes,
2957 .input_mux = &alc880_capture_source,
2958 },
2959 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002960 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002963 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2964 .dac_nids = alc880_z71v_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
2966 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2968 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .input_mux = &alc880_capture_source,
2970 },
2971 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2976 .dac_nids = alc880_f1734_dac_nids,
2977 .hp_nid = 0x02,
2978 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2979 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002980 .input_mux = &alc880_capture_source,
2981 },
2982 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002983 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002984 .init_verbs = { alc880_volume_init_verbs,
2985 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002986 alc880_gpio1_init_verbs },
2987 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2988 .dac_nids = alc880_asus_dac_nids,
2989 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2990 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002991 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002992 .input_mux = &alc880_capture_source,
2993 },
2994 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002995 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002996 .init_verbs = { alc880_volume_init_verbs,
2997 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 alc880_gpio1_init_verbs },
2999 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3000 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3003 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003004 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003005 .input_mux = &alc880_capture_source,
3006 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003007 [ALC880_ASUS_DIG2] = {
3008 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003009 .init_verbs = { alc880_volume_init_verbs,
3010 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003011 alc880_gpio2_init_verbs }, /* use GPIO2 */
3012 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3013 .dac_nids = alc880_asus_dac_nids,
3014 .dig_out_nid = ALC880_DIGOUT_NID,
3015 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3016 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003017 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003018 .input_mux = &alc880_capture_source,
3019 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003020 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003022 .init_verbs = { alc880_volume_init_verbs,
3023 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 alc880_gpio1_init_verbs },
3025 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3026 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003027 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3029 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003030 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003031 .input_mux = &alc880_capture_source,
3032 },
3033 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003034 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003035 .init_verbs = { alc880_volume_init_verbs,
3036 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003037 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3038 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3041 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003042 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003043 .input_mux = &alc880_capture_source,
3044 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003045 [ALC880_UNIWILL] = {
3046 .mixers = { alc880_uniwill_mixer },
3047 .init_verbs = { alc880_volume_init_verbs,
3048 alc880_uniwill_init_verbs },
3049 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3050 .dac_nids = alc880_asus_dac_nids,
3051 .dig_out_nid = ALC880_DIGOUT_NID,
3052 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3053 .channel_mode = alc880_threestack_modes,
3054 .need_dac_fix = 1,
3055 .input_mux = &alc880_capture_source,
3056 .unsol_event = alc880_uniwill_unsol_event,
3057 .init_hook = alc880_uniwill_automute,
3058 },
3059 [ALC880_UNIWILL_P53] = {
3060 .mixers = { alc880_uniwill_p53_mixer },
3061 .init_verbs = { alc880_volume_init_verbs,
3062 alc880_uniwill_p53_init_verbs },
3063 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3064 .dac_nids = alc880_asus_dac_nids,
3065 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003066 .channel_mode = alc880_threestack_modes,
3067 .input_mux = &alc880_capture_source,
3068 .unsol_event = alc880_uniwill_p53_unsol_event,
3069 .init_hook = alc880_uniwill_p53_hp_automute,
3070 },
3071 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003072 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003073 alc880_pcbeep_mixer, },
3074 .init_verbs = { alc880_volume_init_verbs,
3075 alc880_uniwill_p53_init_verbs,
3076 alc880_beep_init_verbs },
3077 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3078 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003079 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003080 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3081 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003082 .input_mux = &alc880_capture_source,
3083 .unsol_event = alc880_uniwill_p53_unsol_event,
3084 .init_hook = alc880_uniwill_p53_hp_automute,
3085 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003086 [ALC880_CLEVO] = {
3087 .mixers = { alc880_three_stack_mixer },
3088 .init_verbs = { alc880_volume_init_verbs,
3089 alc880_pin_clevo_init_verbs },
3090 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3091 .dac_nids = alc880_dac_nids,
3092 .hp_nid = 0x03,
3093 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3094 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003095 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003096 .input_mux = &alc880_capture_source,
3097 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003098 [ALC880_LG] = {
3099 .mixers = { alc880_lg_mixer },
3100 .init_verbs = { alc880_volume_init_verbs,
3101 alc880_lg_init_verbs },
3102 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3103 .dac_nids = alc880_lg_dac_nids,
3104 .dig_out_nid = ALC880_DIGOUT_NID,
3105 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3106 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003107 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003108 .input_mux = &alc880_lg_capture_source,
3109 .unsol_event = alc880_lg_unsol_event,
3110 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003111#ifdef CONFIG_SND_HDA_POWER_SAVE
3112 .loopbacks = alc880_lg_loopbacks,
3113#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003114 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003115 [ALC880_LG_LW] = {
3116 .mixers = { alc880_lg_lw_mixer },
3117 .init_verbs = { alc880_volume_init_verbs,
3118 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003119 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003120 .dac_nids = alc880_dac_nids,
3121 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003122 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3123 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003124 .input_mux = &alc880_lg_lw_capture_source,
3125 .unsol_event = alc880_lg_lw_unsol_event,
3126 .init_hook = alc880_lg_lw_automute,
3127 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003128#ifdef CONFIG_SND_DEBUG
3129 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 .mixers = { alc880_test_mixer },
3131 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003132 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3133 .dac_nids = alc880_test_dac_nids,
3134 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3136 .channel_mode = alc880_test_modes,
3137 .input_mux = &alc880_test_capture_source,
3138 },
3139#endif
3140};
3141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142/*
3143 * Automatic parse of I/O pins from the BIOS configuration
3144 */
3145
3146#define NUM_CONTROL_ALLOC 32
3147#define NUM_VERB_ALLOC 32
3148
3149enum {
3150 ALC_CTL_WIDGET_VOL,
3151 ALC_CTL_WIDGET_MUTE,
3152 ALC_CTL_BIND_MUTE,
3153};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003154static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3156 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003157 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158};
3159
3160/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003161static int add_control(struct alc_spec *spec, int type, const char *name,
3162 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003164 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165
3166 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3167 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3168
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003169 /* array + terminator */
3170 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3171 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172 return -ENOMEM;
3173 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003174 memcpy(knew, spec->kctl_alloc,
3175 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 kfree(spec->kctl_alloc);
3177 }
3178 spec->kctl_alloc = knew;
3179 spec->num_kctl_alloc = num;
3180 }
3181
3182 knew = &spec->kctl_alloc[spec->num_kctl_used];
3183 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003184 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003185 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 return -ENOMEM;
3187 knew->private_value = val;
3188 spec->num_kctl_used++;
3189 return 0;
3190}
3191
3192#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3193#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3194#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3195#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3196#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3197#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3198#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3199#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3200#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3201#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3202#define ALC880_PIN_CD_NID 0x1c
3203
3204/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003205static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3206 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207{
3208 hda_nid_t nid;
3209 int assigned[4];
3210 int i, j;
3211
3212 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003213 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003214
3215 /* check the pins hardwired to audio widget */
3216 for (i = 0; i < cfg->line_outs; i++) {
3217 nid = cfg->line_out_pins[i];
3218 if (alc880_is_fixed_pin(nid)) {
3219 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003220 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003221 assigned[idx] = 1;
3222 }
3223 }
3224 /* left pins can be connect to any audio widget */
3225 for (i = 0; i < cfg->line_outs; i++) {
3226 nid = cfg->line_out_pins[i];
3227 if (alc880_is_fixed_pin(nid))
3228 continue;
3229 /* search for an empty channel */
3230 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003231 if (!assigned[j]) {
3232 spec->multiout.dac_nids[i] =
3233 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003234 assigned[j] = 1;
3235 break;
3236 }
3237 }
3238 }
3239 spec->multiout.num_dacs = cfg->line_outs;
3240 return 0;
3241}
3242
3243/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003244static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3245 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246{
3247 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 static const char *chname[4] = {
3249 "Front", "Surround", NULL /*CLFE*/, "Side"
3250 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 hda_nid_t nid;
3252 int i, err;
3253
3254 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003255 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 continue;
3257 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3258 if (i == 2) {
3259 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003260 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3261 "Center Playback Volume",
3262 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3263 HDA_OUTPUT));
3264 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003266 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3267 "LFE Playback Volume",
3268 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3269 HDA_OUTPUT));
3270 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003272 err = add_control(spec, ALC_CTL_BIND_MUTE,
3273 "Center Playback Switch",
3274 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3275 HDA_INPUT));
3276 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003278 err = add_control(spec, ALC_CTL_BIND_MUTE,
3279 "LFE Playback Switch",
3280 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3281 HDA_INPUT));
3282 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 return err;
3284 } else {
3285 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003286 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3287 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3288 HDA_OUTPUT));
3289 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 return err;
3291 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003292 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3293 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3294 HDA_INPUT));
3295 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003296 return err;
3297 }
3298 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299 return 0;
3300}
3301
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003302/* add playback controls for speaker and HP outputs */
3303static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3304 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003305{
3306 hda_nid_t nid;
3307 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003308 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003310 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 return 0;
3312
3313 if (alc880_is_fixed_pin(pin)) {
3314 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003315 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003316 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003318 else
3319 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 /* control HP volume/switch on the output mixer amp */
3321 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003322 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003323 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3324 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3325 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003326 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003327 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003328 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3329 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3330 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 return err;
3332 } else if (alc880_is_multi_pin(pin)) {
3333 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003334 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003335 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003336 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3337 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3338 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003339 return err;
3340 }
3341 return 0;
3342}
3343
3344/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003345static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3346 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003347 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348{
3349 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003350 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351
3352 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003353 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3354 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3355 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356 return err;
3357 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003358 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3359 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3360 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003361 return err;
3362 return 0;
3363}
3364
3365/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003366static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3367 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003369 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003370 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003371
3372 for (i = 0; i < AUTO_PIN_LAST; i++) {
3373 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003374 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003375 err = new_analog_input(spec, cfg->input_pins[i],
3376 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003377 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003378 if (err < 0)
3379 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003380 imux->items[imux->num_items].label =
3381 auto_pin_cfg_labels[i];
3382 imux->items[imux->num_items].index =
3383 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 imux->num_items++;
3385 }
3386 }
3387 return 0;
3388}
3389
Kailang Yangdf694da2005-12-05 19:42:22 +01003390static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3391 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003392 int dac_idx)
3393{
3394 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003395 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3396 pin_type);
3397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3398 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003399 /* need the manual connection? */
3400 if (alc880_is_multi_pin(nid)) {
3401 struct alc_spec *spec = codec->spec;
3402 int idx = alc880_multi_pin_idx(nid);
3403 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3404 AC_VERB_SET_CONNECT_SEL,
3405 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3406 }
3407}
3408
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003409static int get_pin_type(int line_out_type)
3410{
3411 if (line_out_type == AUTO_PIN_HP_OUT)
3412 return PIN_HP;
3413 else
3414 return PIN_OUT;
3415}
3416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417static void alc880_auto_init_multi_out(struct hda_codec *codec)
3418{
3419 struct alc_spec *spec = codec->spec;
3420 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003421
3422 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003423 for (i = 0; i < spec->autocfg.line_outs; i++) {
3424 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003425 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3426 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427 }
3428}
3429
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003430static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431{
3432 struct alc_spec *spec = codec->spec;
3433 hda_nid_t pin;
3434
Takashi Iwai82bc9552006-03-21 11:24:42 +01003435 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003436 if (pin) /* connect to front */
3437 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003438 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 if (pin) /* connect to front */
3440 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3441}
3442
3443static void alc880_auto_init_analog_input(struct hda_codec *codec)
3444{
3445 struct alc_spec *spec = codec->spec;
3446 int i;
3447
3448 for (i = 0; i < AUTO_PIN_LAST; i++) {
3449 hda_nid_t nid = spec->autocfg.input_pins[i];
3450 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003451 snd_hda_codec_write(codec, nid, 0,
3452 AC_VERB_SET_PIN_WIDGET_CONTROL,
3453 i <= AUTO_PIN_FRONT_MIC ?
3454 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003456 snd_hda_codec_write(codec, nid, 0,
3457 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 AMP_OUT_MUTE);
3459 }
3460 }
3461}
3462
3463/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003464/* return 1 if successful, 0 if the proper config is not found,
3465 * or a negative error code
3466 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003467static int alc880_parse_auto_config(struct hda_codec *codec)
3468{
3469 struct alc_spec *spec = codec->spec;
3470 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003471 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003472
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003473 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3474 alc880_ignore);
3475 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003477 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003478 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003479
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003480 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3481 if (err < 0)
3482 return err;
3483 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3484 if (err < 0)
3485 return err;
3486 err = alc880_auto_create_extra_out(spec,
3487 spec->autocfg.speaker_pins[0],
3488 "Speaker");
3489 if (err < 0)
3490 return err;
3491 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3492 "Headphone");
3493 if (err < 0)
3494 return err;
3495 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3496 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497 return err;
3498
3499 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3500
3501 if (spec->autocfg.dig_out_pin)
3502 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3503 if (spec->autocfg.dig_in_pin)
3504 spec->dig_in_nid = ALC880_DIGIN_NID;
3505
3506 if (spec->kctl_alloc)
3507 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3508
3509 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3510
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003511 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003512 spec->input_mux = &spec->private_imux;
3513
3514 return 1;
3515}
3516
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003517/* additional initialization for auto-configuration model */
3518static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003521 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523}
3524
3525/*
3526 * OK, here we have finally the patch for ALC880
3527 */
3528
Linus Torvalds1da177e2005-04-16 15:20:36 -07003529static int patch_alc880(struct hda_codec *codec)
3530{
3531 struct alc_spec *spec;
3532 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003533 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003534
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003535 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003536 if (spec == NULL)
3537 return -ENOMEM;
3538
3539 codec->spec = spec;
3540
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003541 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3542 alc880_models,
3543 alc880_cfg_tbl);
3544 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003545 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3546 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003547 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003548 }
3549
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 if (board_config == ALC880_AUTO) {
3551 /* automatic parse from the BIOS config */
3552 err = alc880_parse_auto_config(codec);
3553 if (err < 0) {
3554 alc_free(codec);
3555 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003556 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003557 printk(KERN_INFO
3558 "hda_codec: Cannot set up configuration "
3559 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003560 board_config = ALC880_3ST;
3561 }
3562 }
3563
Kailang Yangdf694da2005-12-05 19:42:22 +01003564 if (board_config != ALC880_AUTO)
3565 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566
3567 spec->stream_name_analog = "ALC880 Analog";
3568 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3569 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3570
3571 spec->stream_name_digital = "ALC880 Digital";
3572 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3573 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003575 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003576 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003577 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003578 /* get type */
3579 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 if (wcap != AC_WID_AUD_IN) {
3581 spec->adc_nids = alc880_adc_nids_alt;
3582 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003583 spec->mixers[spec->num_mixers] =
3584 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 spec->num_mixers++;
3586 } else {
3587 spec->adc_nids = alc880_adc_nids;
3588 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3589 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3590 spec->num_mixers++;
3591 }
3592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003593
3594 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003596 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003597#ifdef CONFIG_SND_HDA_POWER_SAVE
3598 if (!spec->loopback.amplist)
3599 spec->loopback.amplist = alc880_loopbacks;
3600#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003601
3602 return 0;
3603}
3604
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605
Linus Torvalds1da177e2005-04-16 15:20:36 -07003606/*
3607 * ALC260 support
3608 */
3609
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003610static hda_nid_t alc260_dac_nids[1] = {
3611 /* front */
3612 0x02,
3613};
3614
3615static hda_nid_t alc260_adc_nids[1] = {
3616 /* ADC0 */
3617 0x04,
3618};
3619
Kailang Yangdf694da2005-12-05 19:42:22 +01003620static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003621 /* ADC1 */
3622 0x05,
3623};
3624
Kailang Yangdf694da2005-12-05 19:42:22 +01003625static hda_nid_t alc260_hp_adc_nids[2] = {
3626 /* ADC1, 0 */
3627 0x05, 0x04
3628};
3629
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003630/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3631 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3632 */
3633static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003634 /* ADC0, ADC1 */
3635 0x04, 0x05
3636};
3637
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638#define ALC260_DIGOUT_NID 0x03
3639#define ALC260_DIGIN_NID 0x06
3640
3641static struct hda_input_mux alc260_capture_source = {
3642 .num_items = 4,
3643 .items = {
3644 { "Mic", 0x0 },
3645 { "Front Mic", 0x1 },
3646 { "Line", 0x2 },
3647 { "CD", 0x4 },
3648 },
3649};
3650
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003651/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003652 * headphone jack and the internal CD lines since these are the only pins at
3653 * which audio can appear. For flexibility, also allow the option of
3654 * recording the mixer output on the second ADC (ADC0 doesn't have a
3655 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003656 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003657static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3658 {
3659 .num_items = 3,
3660 .items = {
3661 { "Mic/Line", 0x0 },
3662 { "CD", 0x4 },
3663 { "Headphone", 0x2 },
3664 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003665 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003666 {
3667 .num_items = 4,
3668 .items = {
3669 { "Mic/Line", 0x0 },
3670 { "CD", 0x4 },
3671 { "Headphone", 0x2 },
3672 { "Mixer", 0x5 },
3673 },
3674 },
3675
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003676};
3677
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003678/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3679 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003680 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003681static struct hda_input_mux alc260_acer_capture_sources[2] = {
3682 {
3683 .num_items = 4,
3684 .items = {
3685 { "Mic", 0x0 },
3686 { "Line", 0x2 },
3687 { "CD", 0x4 },
3688 { "Headphone", 0x5 },
3689 },
3690 },
3691 {
3692 .num_items = 5,
3693 .items = {
3694 { "Mic", 0x0 },
3695 { "Line", 0x2 },
3696 { "CD", 0x4 },
3697 { "Headphone", 0x6 },
3698 { "Mixer", 0x5 },
3699 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003700 },
3701};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702/*
3703 * This is just place-holder, so there's something for alc_build_pcms to look
3704 * at when it calculates the maximum number of channels. ALC260 has no mixer
3705 * element which allows changing the channel mode, so the verb list is
3706 * never used.
3707 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003708static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709 { 2, NULL },
3710};
3711
Kailang Yangdf694da2005-12-05 19:42:22 +01003712
3713/* Mixer combinations
3714 *
3715 * basic: base_output + input + pc_beep + capture
3716 * HP: base_output + input + capture_alt
3717 * HP_3013: hp_3013 + input + capture
3718 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003719 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003720 */
3721
3722static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003723 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003724 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3726 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3727 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3728 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3729 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003730};
Kailang Yangdf694da2005-12-05 19:42:22 +01003731
3732static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003733 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3734 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3735 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3736 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3738 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3739 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003741 { } /* end */
3742};
3743
Kailang Yangdf694da2005-12-05 19:42:22 +01003744static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3745 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3746 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3747 { } /* end */
3748};
3749
3750static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3751 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3752 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3753 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3754 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3755 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3757 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3758 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003759 { } /* end */
3760};
3761
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003762/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3763 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3764 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003765static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003766 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003767 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003768 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003769 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3770 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3771 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3772 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003773 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003774 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3775 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3776 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003777 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003778 { } /* end */
3779};
3780
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003781/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3782 * versions of the ALC260 don't act on requests to enable mic bias from NID
3783 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3784 * datasheet doesn't mention this restriction. At this stage it's not clear
3785 * whether this behaviour is intentional or is a hardware bug in chip
3786 * revisions available in early 2006. Therefore for now allow the
3787 * "Headphone Jack Mode" control to span all choices, but if it turns out
3788 * that the lack of mic bias for this NID is intentional we could change the
3789 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3790 *
3791 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3792 * don't appear to make the mic bias available from the "line" jack, even
3793 * though the NID used for this jack (0x14) can supply it. The theory is
3794 * that perhaps Acer have included blocking capacitors between the ALC260
3795 * and the output jack. If this turns out to be the case for all such
3796 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3797 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003798 *
3799 * The C20x Tablet series have a mono internal speaker which is controlled
3800 * via the chip's Mono sum widget and pin complex, so include the necessary
3801 * controls for such models. On models without a "mono speaker" the control
3802 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003803 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003804static struct snd_kcontrol_new alc260_acer_mixer[] = {
3805 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3806 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003807 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003808 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3809 HDA_OUTPUT),
3810 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3811 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003812 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3813 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3815 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3816 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3817 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3818 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3819 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3820 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3821 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3822 { } /* end */
3823};
3824
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003825/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3826 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3827 */
3828static struct snd_kcontrol_new alc260_will_mixer[] = {
3829 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3830 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3832 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3833 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3834 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3835 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3836 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3837 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3838 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3839 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3840 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3841 { } /* end */
3842};
3843
3844/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3845 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3846 */
3847static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3848 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3849 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3851 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3852 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3853 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3854 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3855 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3856 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3857 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3858 { } /* end */
3859};
3860
Kailang Yangdf694da2005-12-05 19:42:22 +01003861/* capture mixer elements */
3862static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003863 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3864 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003865 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3866 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003867 {
3868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003869 /* The multiple "Capture Source" controls confuse alsamixer
3870 * So call somewhat different..
3871 * FIXME: the controls appear in the "playback" view!
3872 */
3873 /* .name = "Capture Source", */
3874 .name = "Input Source",
3875 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003876 .info = alc_mux_enum_info,
3877 .get = alc_mux_enum_get,
3878 .put = alc_mux_enum_put,
3879 },
3880 { } /* end */
3881};
3882
Kailang Yangdf694da2005-12-05 19:42:22 +01003883static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3884 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3885 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3886 {
3887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3888 /* The multiple "Capture Source" controls confuse alsamixer
3889 * So call somewhat different..
3890 * FIXME: the controls appear in the "playback" view!
3891 */
3892 /* .name = "Capture Source", */
3893 .name = "Input Source",
3894 .count = 1,
3895 .info = alc_mux_enum_info,
3896 .get = alc_mux_enum_get,
3897 .put = alc_mux_enum_put,
3898 },
3899 { } /* end */
3900};
3901
3902/*
3903 * initialization verbs
3904 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003905static struct hda_verb alc260_init_verbs[] = {
3906 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003908 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003909 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003910 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003911 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003913 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003914 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003916 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003917 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003918 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003919 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003920 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003921 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003922 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003923 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3924 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003925 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003926 /* set connection select to line in (default select for this ADC) */
3927 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003928 /* mute capture amp left and right */
3929 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3930 /* set connection select to line in (default select for this ADC) */
3931 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003932 /* set vol=0 Line-Out mixer amp left and right */
3933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3934 /* unmute pin widget amp left and right (no gain on this amp) */
3935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3936 /* set vol=0 HP mixer amp left and right */
3937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3938 /* unmute pin widget amp left and right (no gain on this amp) */
3939 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3940 /* set vol=0 Mono mixer amp left and right */
3941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3942 /* unmute pin widget amp left and right (no gain on this amp) */
3943 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3944 /* unmute LINE-2 out pin */
3945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003946 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3947 * Line In 2 = 0x03
3948 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003949 /* mute analog inputs */
3950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003955 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003956 /* mute Front out path */
3957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3959 /* mute Headphone out path */
3960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3961 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3962 /* mute Mono out path */
3963 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3964 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 { }
3966};
3967
Takashi Iwai474167d2006-05-17 17:17:43 +02003968#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003969static struct hda_verb alc260_hp_init_verbs[] = {
3970 /* Headphone and output */
3971 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3972 /* mono output */
3973 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3974 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3975 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3976 /* Mic2 (front panel) pin widget for input and vref at 80% */
3977 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3978 /* Line In pin widget for input */
3979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3980 /* Line-2 pin widget for output */
3981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3982 /* CD pin widget for input */
3983 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3984 /* unmute amp left and right */
3985 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3986 /* set connection select to line in (default select for this ADC) */
3987 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3988 /* unmute Line-Out mixer amp left and right (volume = 0) */
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3990 /* mute pin widget amp left and right (no gain on this amp) */
3991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3992 /* unmute HP mixer amp left and right (volume = 0) */
3993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3994 /* mute pin widget amp left and right (no gain on this amp) */
3995 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3997 * Line In 2 = 0x03
3998 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003999 /* mute analog inputs */
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004005 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4006 /* Unmute Front out path */
4007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4009 /* Unmute Headphone out path */
4010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4012 /* Unmute Mono out path */
4013 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4015 { }
4016};
Takashi Iwai474167d2006-05-17 17:17:43 +02004017#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004018
4019static struct hda_verb alc260_hp_3013_init_verbs[] = {
4020 /* Line out and output */
4021 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4022 /* mono output */
4023 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4024 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4025 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4026 /* Mic2 (front panel) pin widget for input and vref at 80% */
4027 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4028 /* Line In pin widget for input */
4029 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4030 /* Headphone pin widget for output */
4031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4032 /* CD pin widget for input */
4033 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4034 /* unmute amp left and right */
4035 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4036 /* set connection select to line in (default select for this ADC) */
4037 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4038 /* unmute Line-Out mixer amp left and right (volume = 0) */
4039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4040 /* mute pin widget amp left and right (no gain on this amp) */
4041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4042 /* unmute HP mixer amp left and right (volume = 0) */
4043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4044 /* mute pin widget amp left and right (no gain on this amp) */
4045 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004046 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4047 * Line In 2 = 0x03
4048 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004049 /* mute analog inputs */
4050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004055 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4056 /* Unmute Front out path */
4057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4059 /* Unmute Headphone out path */
4060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4062 /* Unmute Mono out path */
4063 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4065 { }
4066};
4067
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004068/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004069 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4070 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004071 */
4072static struct hda_verb alc260_fujitsu_init_verbs[] = {
4073 /* Disable all GPIOs */
4074 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4075 /* Internal speaker is connected to headphone pin */
4076 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4077 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004079 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4080 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4081 /* Ensure all other unused pins are disabled and muted. */
4082 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004084 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004085 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004086 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004087 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004090
Jonathan Woithef7ace402006-02-28 11:46:14 +01004091 /* Disable digital (SPDIF) pins */
4092 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4093 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004094
Jonathan Woithef7ace402006-02-28 11:46:14 +01004095 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4096 * when acting as an output.
4097 */
4098 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4099
4100 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4107 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4108 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4109 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004110
Jonathan Woithef7ace402006-02-28 11:46:14 +01004111 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4112 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4113 /* Unmute Line1 pin widget output buffer since it starts as an output.
4114 * If the pin mode is changed by the user the pin mode control will
4115 * take care of enabling the pin's input/output buffers as needed.
4116 * Therefore there's no need to enable the input buffer at this
4117 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004118 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004120 /* Unmute input buffer of pin widget used for Line-in (no equiv
4121 * mixer ctrl)
4122 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004123 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004124
Jonathan Woithef7ace402006-02-28 11:46:14 +01004125 /* Mute capture amp left and right */
4126 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4127 /* Set ADC connection select to match default mixer setting - line
4128 * in (on mic1 pin)
4129 */
4130 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004131
Jonathan Woithef7ace402006-02-28 11:46:14 +01004132 /* Do the same for the second ADC: mute capture input amp and
4133 * set ADC connection to line in (on mic1 pin)
4134 */
4135 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4136 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004137
Jonathan Woithef7ace402006-02-28 11:46:14 +01004138 /* Mute all inputs to mixer widget (even unconnected ones) */
4139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004147
4148 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004149};
4150
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004151/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4152 * similar laptops (adapted from Fujitsu init verbs).
4153 */
4154static struct hda_verb alc260_acer_init_verbs[] = {
4155 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4156 * the headphone jack. Turn this on and rely on the standard mute
4157 * methods whenever the user wants to turn these outputs off.
4158 */
4159 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4160 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4161 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4162 /* Internal speaker/Headphone jack is connected to Line-out pin */
4163 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4164 /* Internal microphone/Mic jack is connected to Mic1 pin */
4165 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4166 /* Line In jack is connected to Line1 pin */
4167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004168 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4169 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004170 /* Ensure all other unused pins are disabled and muted. */
4171 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4172 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004173 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4174 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4177 /* Disable digital (SPDIF) pins */
4178 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4179 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4180
4181 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4182 * bus when acting as outputs.
4183 */
4184 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4185 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4186
4187 /* Start with output sum widgets muted and their output gains at min */
4188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4194 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004198 /* Unmute Line-out pin widget amp left and right
4199 * (no equiv mixer ctrl)
4200 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004202 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4203 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004204 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4205 * inputs. If the pin mode is changed by the user the pin mode control
4206 * will take care of enabling the pin's input/output buffers as needed.
4207 * Therefore there's no need to enable the input buffer at this
4208 * stage.
4209 */
4210 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4212
4213 /* Mute capture amp left and right */
4214 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4215 /* Set ADC connection select to match default mixer setting - mic
4216 * (on mic1 pin)
4217 */
4218 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4219
4220 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004221 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004222 */
4223 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004224 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004225
4226 /* Mute all inputs to mixer widget (even unconnected ones) */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4235
4236 { }
4237};
4238
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004239static struct hda_verb alc260_will_verbs[] = {
4240 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4241 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4242 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4243 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4244 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4245 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4246 {}
4247};
4248
4249static struct hda_verb alc260_replacer_672v_verbs[] = {
4250 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4251 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4252 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4253
4254 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4255 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4256 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4257
4258 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4259 {}
4260};
4261
4262/* toggle speaker-output according to the hp-jack state */
4263static void alc260_replacer_672v_automute(struct hda_codec *codec)
4264{
4265 unsigned int present;
4266
4267 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4268 present = snd_hda_codec_read(codec, 0x0f, 0,
4269 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4270 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004271 snd_hda_codec_write_cache(codec, 0x01, 0,
4272 AC_VERB_SET_GPIO_DATA, 1);
4273 snd_hda_codec_write_cache(codec, 0x0f, 0,
4274 AC_VERB_SET_PIN_WIDGET_CONTROL,
4275 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004276 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004277 snd_hda_codec_write_cache(codec, 0x01, 0,
4278 AC_VERB_SET_GPIO_DATA, 0);
4279 snd_hda_codec_write_cache(codec, 0x0f, 0,
4280 AC_VERB_SET_PIN_WIDGET_CONTROL,
4281 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004282 }
4283}
4284
4285static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4286 unsigned int res)
4287{
4288 if ((res >> 26) == ALC880_HP_EVENT)
4289 alc260_replacer_672v_automute(codec);
4290}
4291
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004292/* Test configuration for debugging, modelled after the ALC880 test
4293 * configuration.
4294 */
4295#ifdef CONFIG_SND_DEBUG
4296static hda_nid_t alc260_test_dac_nids[1] = {
4297 0x02,
4298};
4299static hda_nid_t alc260_test_adc_nids[2] = {
4300 0x04, 0x05,
4301};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004302/* For testing the ALC260, each input MUX needs its own definition since
4303 * the signal assignments are different. This assumes that the first ADC
4304 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004305 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004306static struct hda_input_mux alc260_test_capture_sources[2] = {
4307 {
4308 .num_items = 7,
4309 .items = {
4310 { "MIC1 pin", 0x0 },
4311 { "MIC2 pin", 0x1 },
4312 { "LINE1 pin", 0x2 },
4313 { "LINE2 pin", 0x3 },
4314 { "CD pin", 0x4 },
4315 { "LINE-OUT pin", 0x5 },
4316 { "HP-OUT pin", 0x6 },
4317 },
4318 },
4319 {
4320 .num_items = 8,
4321 .items = {
4322 { "MIC1 pin", 0x0 },
4323 { "MIC2 pin", 0x1 },
4324 { "LINE1 pin", 0x2 },
4325 { "LINE2 pin", 0x3 },
4326 { "CD pin", 0x4 },
4327 { "Mixer", 0x5 },
4328 { "LINE-OUT pin", 0x6 },
4329 { "HP-OUT pin", 0x7 },
4330 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004331 },
4332};
4333static struct snd_kcontrol_new alc260_test_mixer[] = {
4334 /* Output driver widgets */
4335 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4336 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4337 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4338 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4339 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4340 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4341
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004342 /* Modes for retasking pin widgets
4343 * Note: the ALC260 doesn't seem to act on requests to enable mic
4344 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4345 * mention this restriction. At this stage it's not clear whether
4346 * this behaviour is intentional or is a hardware bug in chip
4347 * revisions available at least up until early 2006. Therefore for
4348 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4349 * choices, but if it turns out that the lack of mic bias for these
4350 * NIDs is intentional we could change their modes from
4351 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4352 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004353 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4354 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4355 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4356 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4357 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4358 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4359
4360 /* Loopback mixer controls */
4361 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4362 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4363 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4364 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4365 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4366 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4367 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4368 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4369 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4370 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4371 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4372 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4373 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4374 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4375 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4376 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004377
4378 /* Controls for GPIO pins, assuming they are configured as outputs */
4379 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4380 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4381 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4382 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4383
Jonathan Woithe92621f12006-02-28 11:47:47 +01004384 /* Switches to allow the digital IO pins to be enabled. The datasheet
4385 * is ambigious as to which NID is which; testing on laptops which
4386 * make this output available should provide clarification.
4387 */
4388 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4389 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4390
Jonathan Woithef8225f62008-01-08 12:16:54 +01004391 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4392 * this output to turn on an external amplifier.
4393 */
4394 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4395 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4396
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004397 { } /* end */
4398};
4399static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004400 /* Enable all GPIOs as outputs with an initial value of 0 */
4401 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4402 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4403 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4404
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004405 /* Enable retasking pins as output, initially without power amp */
4406 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4407 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4410 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4411 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4412
Jonathan Woithe92621f12006-02-28 11:47:47 +01004413 /* Disable digital (SPDIF) pins initially, but users can enable
4414 * them via a mixer switch. In the case of SPDIF-out, this initverb
4415 * payload also sets the generation to 0, output to be in "consumer"
4416 * PCM format, copyright asserted, no pre-emphasis and no validity
4417 * control.
4418 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004419 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4420 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4421
Jonathan Woithef7ace402006-02-28 11:46:14 +01004422 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004423 * OUT1 sum bus when acting as an output.
4424 */
4425 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4426 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4427 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4428 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4429
4430 /* Start with output sum widgets muted and their output gains at min */
4431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4436 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4437 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4438 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4439 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4440
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004441 /* Unmute retasking pin widget output buffers since the default
4442 * state appears to be output. As the pin mode is changed by the
4443 * user the pin mode control will take care of enabling the pin's
4444 * input/output buffers as needed.
4445 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004446 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4450 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4451 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4452 /* Also unmute the mono-out pin widget */
4453 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4454
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004455 /* Mute capture amp left and right */
4456 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004457 /* Set ADC connection select to match default mixer setting (mic1
4458 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004459 */
4460 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4461
4462 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004463 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004464 */
4465 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4466 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4467
4468 /* Mute all inputs to mixer widget (even unconnected ones) */
4469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4477
4478 { }
4479};
4480#endif
4481
Linus Torvalds1da177e2005-04-16 15:20:36 -07004482static struct hda_pcm_stream alc260_pcm_analog_playback = {
4483 .substreams = 1,
4484 .channels_min = 2,
4485 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004486};
4487
4488static struct hda_pcm_stream alc260_pcm_analog_capture = {
4489 .substreams = 1,
4490 .channels_min = 2,
4491 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004492};
4493
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004494#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4495#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4496
Kailang Yangdf694da2005-12-05 19:42:22 +01004497/*
4498 * for BIOS auto-configuration
4499 */
4500
4501static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4502 const char *pfx)
4503{
4504 hda_nid_t nid_vol;
4505 unsigned long vol_val, sw_val;
4506 char name[32];
4507 int err;
4508
4509 if (nid >= 0x0f && nid < 0x11) {
4510 nid_vol = nid - 0x7;
4511 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4512 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4513 } else if (nid == 0x11) {
4514 nid_vol = nid - 0x7;
4515 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4516 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4517 } else if (nid >= 0x12 && nid <= 0x15) {
4518 nid_vol = 0x08;
4519 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4520 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4521 } else
4522 return 0; /* N/A */
4523
4524 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004525 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4526 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004527 return err;
4528 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004529 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4530 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004531 return err;
4532 return 1;
4533}
4534
4535/* add playback controls from the parsed DAC table */
4536static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4537 const struct auto_pin_cfg *cfg)
4538{
4539 hda_nid_t nid;
4540 int err;
4541
4542 spec->multiout.num_dacs = 1;
4543 spec->multiout.dac_nids = spec->private_dac_nids;
4544 spec->multiout.dac_nids[0] = 0x02;
4545
4546 nid = cfg->line_out_pins[0];
4547 if (nid) {
4548 err = alc260_add_playback_controls(spec, nid, "Front");
4549 if (err < 0)
4550 return err;
4551 }
4552
Takashi Iwai82bc9552006-03-21 11:24:42 +01004553 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004554 if (nid) {
4555 err = alc260_add_playback_controls(spec, nid, "Speaker");
4556 if (err < 0)
4557 return err;
4558 }
4559
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004560 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004561 if (nid) {
4562 err = alc260_add_playback_controls(spec, nid, "Headphone");
4563 if (err < 0)
4564 return err;
4565 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004567}
4568
4569/* create playback/capture controls for input pins */
4570static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4571 const struct auto_pin_cfg *cfg)
4572{
Kailang Yangdf694da2005-12-05 19:42:22 +01004573 struct hda_input_mux *imux = &spec->private_imux;
4574 int i, err, idx;
4575
4576 for (i = 0; i < AUTO_PIN_LAST; i++) {
4577 if (cfg->input_pins[i] >= 0x12) {
4578 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004579 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004580 auto_pin_cfg_labels[i], idx,
4581 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004582 if (err < 0)
4583 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004584 imux->items[imux->num_items].label =
4585 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004586 imux->items[imux->num_items].index = idx;
4587 imux->num_items++;
4588 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004589 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004590 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004591 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004592 auto_pin_cfg_labels[i], idx,
4593 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004594 if (err < 0)
4595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 imux->items[imux->num_items].label =
4597 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004598 imux->items[imux->num_items].index = idx;
4599 imux->num_items++;
4600 }
4601 }
4602 return 0;
4603}
4604
4605static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4606 hda_nid_t nid, int pin_type,
4607 int sel_idx)
4608{
4609 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004610 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4611 pin_type);
4612 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4613 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004614 /* need the manual connection? */
4615 if (nid >= 0x12) {
4616 int idx = nid - 0x12;
4617 snd_hda_codec_write(codec, idx + 0x0b, 0,
4618 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004619 }
4620}
4621
4622static void alc260_auto_init_multi_out(struct hda_codec *codec)
4623{
4624 struct alc_spec *spec = codec->spec;
4625 hda_nid_t nid;
4626
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004627 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004629 if (nid) {
4630 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4631 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4632 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004633
Takashi Iwai82bc9552006-03-21 11:24:42 +01004634 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004635 if (nid)
4636 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4637
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004638 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004639 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004640 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641}
Kailang Yangdf694da2005-12-05 19:42:22 +01004642
4643#define ALC260_PIN_CD_NID 0x16
4644static void alc260_auto_init_analog_input(struct hda_codec *codec)
4645{
4646 struct alc_spec *spec = codec->spec;
4647 int i;
4648
4649 for (i = 0; i < AUTO_PIN_LAST; i++) {
4650 hda_nid_t nid = spec->autocfg.input_pins[i];
4651 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 snd_hda_codec_write(codec, nid, 0,
4653 AC_VERB_SET_PIN_WIDGET_CONTROL,
4654 i <= AUTO_PIN_FRONT_MIC ?
4655 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004656 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004657 snd_hda_codec_write(codec, nid, 0,
4658 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004659 AMP_OUT_MUTE);
4660 }
4661 }
4662}
4663
4664/*
4665 * generic initialization of ADC, input mixers and output mixers
4666 */
4667static struct hda_verb alc260_volume_init_verbs[] = {
4668 /*
4669 * Unmute ADC0-1 and set the default input to mic-in
4670 */
4671 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4672 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4673 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4674 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4675
4676 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4677 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004678 * Note: PASD motherboards uses the Line In 2 as the input for
4679 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004680 */
4681 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004682 /* mute analog inputs */
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004688
4689 /*
4690 * Set up output mixers (0x08 - 0x0a)
4691 */
4692 /* set vol=0 to output mixers */
4693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4695 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4696 /* set up input amps for analog loopback */
4697 /* Amp Indices: DAC = 0, mixer = 1 */
4698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4702 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4704
4705 { }
4706};
4707
4708static int alc260_parse_auto_config(struct hda_codec *codec)
4709{
4710 struct alc_spec *spec = codec->spec;
4711 unsigned int wcap;
4712 int err;
4713 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4714
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004715 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4716 alc260_ignore);
4717 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004718 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004719 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4720 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004721 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004722 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004724 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4725 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004726 return err;
4727
4728 spec->multiout.max_channels = 2;
4729
4730 if (spec->autocfg.dig_out_pin)
4731 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4732 if (spec->kctl_alloc)
4733 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4734
4735 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4736
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004737 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004738 spec->input_mux = &spec->private_imux;
4739
4740 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004741 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004742 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4743 if (wcap != AC_WID_AUD_IN) {
4744 spec->adc_nids = alc260_adc_nids_alt;
4745 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4746 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004747 } else {
4748 spec->adc_nids = alc260_adc_nids;
4749 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4750 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004751 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004752 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004753
4754 return 1;
4755}
4756
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004757/* additional initialization for auto-configuration model */
4758static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004759{
Kailang Yangdf694da2005-12-05 19:42:22 +01004760 alc260_auto_init_multi_out(codec);
4761 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004762}
4763
Takashi Iwaicb53c622007-08-10 17:21:45 +02004764#ifdef CONFIG_SND_HDA_POWER_SAVE
4765static struct hda_amp_list alc260_loopbacks[] = {
4766 { 0x07, HDA_INPUT, 0 },
4767 { 0x07, HDA_INPUT, 1 },
4768 { 0x07, HDA_INPUT, 2 },
4769 { 0x07, HDA_INPUT, 3 },
4770 { 0x07, HDA_INPUT, 4 },
4771 { } /* end */
4772};
4773#endif
4774
Kailang Yangdf694da2005-12-05 19:42:22 +01004775/*
4776 * ALC260 configurations
4777 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004778static const char *alc260_models[ALC260_MODEL_LAST] = {
4779 [ALC260_BASIC] = "basic",
4780 [ALC260_HP] = "hp",
4781 [ALC260_HP_3013] = "hp-3013",
4782 [ALC260_FUJITSU_S702X] = "fujitsu",
4783 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004784 [ALC260_WILL] = "will",
4785 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004786#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004787 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004788#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004789 [ALC260_AUTO] = "auto",
4790};
4791
4792static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004793 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004794 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004795 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004796 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004797 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4798 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4799 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4800 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4801 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4802 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4803 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4804 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4805 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4806 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4807 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4808 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004809 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004810 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02004811 {}
4812};
4813
Kailang Yangdf694da2005-12-05 19:42:22 +01004814static struct alc_config_preset alc260_presets[] = {
4815 [ALC260_BASIC] = {
4816 .mixers = { alc260_base_output_mixer,
4817 alc260_input_mixer,
4818 alc260_pc_beep_mixer,
4819 alc260_capture_mixer },
4820 .init_verbs = { alc260_init_verbs },
4821 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4822 .dac_nids = alc260_dac_nids,
4823 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4824 .adc_nids = alc260_adc_nids,
4825 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4826 .channel_mode = alc260_modes,
4827 .input_mux = &alc260_capture_source,
4828 },
4829 [ALC260_HP] = {
4830 .mixers = { alc260_base_output_mixer,
4831 alc260_input_mixer,
4832 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004833 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004834 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4835 .dac_nids = alc260_dac_nids,
4836 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4837 .adc_nids = alc260_hp_adc_nids,
4838 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4839 .channel_mode = alc260_modes,
4840 .input_mux = &alc260_capture_source,
4841 },
4842 [ALC260_HP_3013] = {
4843 .mixers = { alc260_hp_3013_mixer,
4844 alc260_input_mixer,
4845 alc260_capture_alt_mixer },
4846 .init_verbs = { alc260_hp_3013_init_verbs },
4847 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4848 .dac_nids = alc260_dac_nids,
4849 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4850 .adc_nids = alc260_hp_adc_nids,
4851 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4852 .channel_mode = alc260_modes,
4853 .input_mux = &alc260_capture_source,
4854 },
4855 [ALC260_FUJITSU_S702X] = {
4856 .mixers = { alc260_fujitsu_mixer,
4857 alc260_capture_mixer },
4858 .init_verbs = { alc260_fujitsu_init_verbs },
4859 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4860 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004861 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4862 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004863 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4864 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004865 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4866 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004867 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004868 [ALC260_ACER] = {
4869 .mixers = { alc260_acer_mixer,
4870 alc260_capture_mixer },
4871 .init_verbs = { alc260_acer_init_verbs },
4872 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4873 .dac_nids = alc260_dac_nids,
4874 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4875 .adc_nids = alc260_dual_adc_nids,
4876 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4877 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004878 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4879 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004880 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004881 [ALC260_WILL] = {
4882 .mixers = { alc260_will_mixer,
4883 alc260_capture_mixer },
4884 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4885 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4886 .dac_nids = alc260_dac_nids,
4887 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4888 .adc_nids = alc260_adc_nids,
4889 .dig_out_nid = ALC260_DIGOUT_NID,
4890 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4891 .channel_mode = alc260_modes,
4892 .input_mux = &alc260_capture_source,
4893 },
4894 [ALC260_REPLACER_672V] = {
4895 .mixers = { alc260_replacer_672v_mixer,
4896 alc260_capture_mixer },
4897 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4898 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4899 .dac_nids = alc260_dac_nids,
4900 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4901 .adc_nids = alc260_adc_nids,
4902 .dig_out_nid = ALC260_DIGOUT_NID,
4903 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4904 .channel_mode = alc260_modes,
4905 .input_mux = &alc260_capture_source,
4906 .unsol_event = alc260_replacer_672v_unsol_event,
4907 .init_hook = alc260_replacer_672v_automute,
4908 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004909#ifdef CONFIG_SND_DEBUG
4910 [ALC260_TEST] = {
4911 .mixers = { alc260_test_mixer,
4912 alc260_capture_mixer },
4913 .init_verbs = { alc260_test_init_verbs },
4914 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4915 .dac_nids = alc260_test_dac_nids,
4916 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4917 .adc_nids = alc260_test_adc_nids,
4918 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4919 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004920 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4921 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004922 },
4923#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004924};
4925
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926static int patch_alc260(struct hda_codec *codec)
4927{
4928 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004929 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004930
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004931 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 if (spec == NULL)
4933 return -ENOMEM;
4934
4935 codec->spec = spec;
4936
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004937 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4938 alc260_models,
4939 alc260_cfg_tbl);
4940 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004941 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4942 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004943 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004944 }
4945
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 if (board_config == ALC260_AUTO) {
4947 /* automatic parse from the BIOS config */
4948 err = alc260_parse_auto_config(codec);
4949 if (err < 0) {
4950 alc_free(codec);
4951 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004952 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004953 printk(KERN_INFO
4954 "hda_codec: Cannot set up configuration "
4955 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004956 board_config = ALC260_BASIC;
4957 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004958 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004959
Kailang Yangdf694da2005-12-05 19:42:22 +01004960 if (board_config != ALC260_AUTO)
4961 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962
4963 spec->stream_name_analog = "ALC260 Analog";
4964 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4965 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4966
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004967 spec->stream_name_digital = "ALC260 Digital";
4968 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4969 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4970
Linus Torvalds1da177e2005-04-16 15:20:36 -07004971 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004972 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004973 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004974#ifdef CONFIG_SND_HDA_POWER_SAVE
4975 if (!spec->loopback.amplist)
4976 spec->loopback.amplist = alc260_loopbacks;
4977#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004978
4979 return 0;
4980}
4981
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983/*
4984 * ALC882 support
4985 *
4986 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4987 * configuration. Each pin widget can choose any input DACs and a mixer.
4988 * Each ADC is connected from a mixer of all inputs. This makes possible
4989 * 6-channel independent captures.
4990 *
4991 * In addition, an independent DAC for the multi-playback (not used in this
4992 * driver yet).
4993 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004994#define ALC882_DIGOUT_NID 0x06
4995#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004997static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998 { 8, NULL }
4999};
5000
5001static hda_nid_t alc882_dac_nids[4] = {
5002 /* front, rear, clfe, rear_surr */
5003 0x02, 0x03, 0x04, 0x05
5004};
5005
Kailang Yangdf694da2005-12-05 19:42:22 +01005006/* identical with ALC880 */
5007#define alc882_adc_nids alc880_adc_nids
5008#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005009
5010/* input MUX */
5011/* FIXME: should be a matrix-type input source selection */
5012
5013static struct hda_input_mux alc882_capture_source = {
5014 .num_items = 4,
5015 .items = {
5016 { "Mic", 0x0 },
5017 { "Front Mic", 0x1 },
5018 { "Line", 0x2 },
5019 { "CD", 0x4 },
5020 },
5021};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005022#define alc882_mux_enum_info alc_mux_enum_info
5023#define alc882_mux_enum_get alc_mux_enum_get
5024
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005025static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5026 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005027{
5028 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5029 struct alc_spec *spec = codec->spec;
5030 const struct hda_input_mux *imux = spec->input_mux;
5031 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5032 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5033 hda_nid_t nid = capture_mixers[adc_idx];
5034 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5035 unsigned int i, idx;
5036
5037 idx = ucontrol->value.enumerated.item[0];
5038 if (idx >= imux->num_items)
5039 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005040 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041 return 0;
5042 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005043 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5044 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005045 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005046 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005047 }
5048 *cur_val = idx;
5049 return 1;
5050}
5051
Kailang Yangdf694da2005-12-05 19:42:22 +01005052/*
Kailang Yang272a5272007-05-14 11:00:38 +02005053 * 2ch mode
5054 */
5055static struct hda_verb alc882_3ST_ch2_init[] = {
5056 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5057 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5058 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5059 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5060 { } /* end */
5061};
5062
5063/*
5064 * 6ch mode
5065 */
5066static struct hda_verb alc882_3ST_ch6_init[] = {
5067 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5068 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5069 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5070 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5071 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5072 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5073 { } /* end */
5074};
5075
5076static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5077 { 2, alc882_3ST_ch2_init },
5078 { 6, alc882_3ST_ch6_init },
5079};
5080
5081/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005082 * 6ch mode
5083 */
5084static struct hda_verb alc882_sixstack_ch6_init[] = {
5085 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5086 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5087 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5088 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5089 { } /* end */
5090};
5091
5092/*
5093 * 8ch mode
5094 */
5095static struct hda_verb alc882_sixstack_ch8_init[] = {
5096 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5097 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5098 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5099 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5100 { } /* end */
5101};
5102
5103static struct hda_channel_mode alc882_sixstack_modes[2] = {
5104 { 6, alc882_sixstack_ch6_init },
5105 { 8, alc882_sixstack_ch8_init },
5106};
5107
Takashi Iwai87350ad2007-08-16 18:19:38 +02005108/*
5109 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5110 */
5111
5112/*
5113 * 2ch mode
5114 */
5115static struct hda_verb alc885_mbp_ch2_init[] = {
5116 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5117 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5118 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5119 { } /* end */
5120};
5121
5122/*
5123 * 6ch mode
5124 */
5125static struct hda_verb alc885_mbp_ch6_init[] = {
5126 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5127 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5129 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5130 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5131 { } /* end */
5132};
5133
5134static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5135 { 2, alc885_mbp_ch2_init },
5136 { 6, alc885_mbp_ch6_init },
5137};
5138
5139
Linus Torvalds1da177e2005-04-16 15:20:36 -07005140/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5141 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5142 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005143static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005144 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005145 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005146 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005147 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005148 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5149 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5151 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005152 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005153 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5155 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5156 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5157 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5158 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5159 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005160 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5162 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005163 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5165 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5166 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005167 { } /* end */
5168};
5169
Takashi Iwai87350ad2007-08-16 18:19:38 +02005170static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5171 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
5172 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
5173 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
5174 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
5175 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
5176 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
5177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5178 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5179 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
5180 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5181 { } /* end */
5182};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005183static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5184 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5185 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5193 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5194 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5195 { } /* end */
5196};
5197
Kailang Yang272a5272007-05-14 11:00:38 +02005198static struct snd_kcontrol_new alc882_targa_mixer[] = {
5199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5200 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005208 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5210 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005211 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005212 { } /* end */
5213};
5214
5215/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5216 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5217 */
5218static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5220 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5222 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5227 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5228 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005232 { } /* end */
5233};
5234
Takashi Iwai914759b2007-09-06 14:52:04 +02005235static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5244 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5246 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5247 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5248 { } /* end */
5249};
5250
Kailang Yangdf694da2005-12-05 19:42:22 +01005251static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5252 {
5253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5254 .name = "Channel Mode",
5255 .info = alc_ch_mode_info,
5256 .get = alc_ch_mode_get,
5257 .put = alc_ch_mode_put,
5258 },
5259 { } /* end */
5260};
5261
Linus Torvalds1da177e2005-04-16 15:20:36 -07005262static struct hda_verb alc882_init_verbs[] = {
5263 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005267 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005271 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005275 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005276 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005288 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005291 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005292 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005295 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005296 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5299 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005301 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5302 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5305 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5308 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005309 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005310 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005311
5312 /* FIXME: use matrix-type input source selection */
5313 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5314 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005319 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005324 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5329 /* ADC1: mute amp left and right */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005331 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005332 /* ADC2: mute amp left and right */
5333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005334 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005335 /* ADC3: mute amp left and right */
5336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005337 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005338
5339 { }
5340};
5341
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005342static struct hda_verb alc882_eapd_verbs[] = {
5343 /* change to EAPD mode */
5344 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005345 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005346 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005347};
5348
Tobin Davis9102cd12006-12-15 10:02:12 +01005349/* Mac Pro test */
5350static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5351 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5352 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5355 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5356 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5357 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5358 { } /* end */
5359};
5360
5361static struct hda_verb alc882_macpro_init_verbs[] = {
5362 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5366 /* Front Pin: output 0 (0x0c) */
5367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5370 /* Front Mic pin: input vref at 80% */
5371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5373 /* Speaker: output */
5374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5376 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5377 /* Headphone output (output 0 - 0x0c) */
5378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5380 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5381
5382 /* FIXME: use matrix-type input source selection */
5383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5384 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5389 /* Input mixer2 */
5390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5394 /* Input mixer3 */
5395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5399 /* ADC1: mute amp left and right */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5401 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5402 /* ADC2: mute amp left and right */
5403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5405 /* ADC3: mute amp left and right */
5406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5408
5409 { }
5410};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005411
Takashi Iwai87350ad2007-08-16 18:19:38 +02005412/* Macbook Pro rev3 */
5413static struct hda_verb alc885_mbp3_init_verbs[] = {
5414 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5418 /* Rear mixer */
5419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5422 /* Front Pin: output 0 (0x0c) */
5423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5425 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5426 /* HP Pin: output 0 (0x0d) */
5427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5429 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5431 /* Mic (rear) pin: input vref at 80% */
5432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5434 /* Front Mic pin: input vref at 80% */
5435 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5437 /* Line In pin: use output 1 when in LineOut mode */
5438 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5439 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5440 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5441
5442 /* FIXME: use matrix-type input source selection */
5443 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5444 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5449 /* Input mixer2 */
5450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5454 /* Input mixer3 */
5455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5459 /* ADC1: mute amp left and right */
5460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5461 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5462 /* ADC2: mute amp left and right */
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5464 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5465 /* ADC3: mute amp left and right */
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5467 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5468
5469 { }
5470};
5471
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005472/* iMac 24 mixer. */
5473static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5474 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5475 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5476 { } /* end */
5477};
5478
5479/* iMac 24 init verbs. */
5480static struct hda_verb alc885_imac24_init_verbs[] = {
5481 /* Internal speakers: output 0 (0x0c) */
5482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5484 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5485 /* Internal speakers: output 0 (0x0c) */
5486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5488 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5489 /* Headphone: output 0 (0x0c) */
5490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5492 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5493 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5494 /* Front Mic: input vref at 80% */
5495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5497 { }
5498};
5499
5500/* Toggle speaker-output according to the hp-jack state */
5501static void alc885_imac24_automute(struct hda_codec *codec)
5502{
5503 unsigned int present;
5504
5505 present = snd_hda_codec_read(codec, 0x14, 0,
5506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005507 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5508 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5509 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5510 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005511}
5512
5513/* Processes unsolicited events. */
5514static void alc885_imac24_unsol_event(struct hda_codec *codec,
5515 unsigned int res)
5516{
5517 /* Headphone insertion or removal. */
5518 if ((res >> 26) == ALC880_HP_EVENT)
5519 alc885_imac24_automute(codec);
5520}
5521
Takashi Iwai87350ad2007-08-16 18:19:38 +02005522static void alc885_mbp3_automute(struct hda_codec *codec)
5523{
5524 unsigned int present;
5525
5526 present = snd_hda_codec_read(codec, 0x15, 0,
5527 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5528 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5529 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5530 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5531 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5532
5533}
5534static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5535 unsigned int res)
5536{
5537 /* Headphone insertion or removal. */
5538 if ((res >> 26) == ALC880_HP_EVENT)
5539 alc885_mbp3_automute(codec);
5540}
5541
5542
Kailang Yang272a5272007-05-14 11:00:38 +02005543static struct hda_verb alc882_targa_verbs[] = {
5544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5546
5547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5549
5550 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5551 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5552 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5553
5554 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5555 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5556 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5557 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5558 { } /* end */
5559};
5560
5561/* toggle speaker-output according to the hp-jack state */
5562static void alc882_targa_automute(struct hda_codec *codec)
5563{
5564 unsigned int present;
5565
5566 present = snd_hda_codec_read(codec, 0x14, 0,
5567 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005568 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5569 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005570 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5571 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005572}
5573
5574static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5575{
5576 /* Looks like the unsol event is incompatible with the standard
5577 * definition. 4bit tag is placed at 26 bit!
5578 */
5579 if (((res >> 26) == ALC880_HP_EVENT)) {
5580 alc882_targa_automute(codec);
5581 }
5582}
5583
5584static struct hda_verb alc882_asus_a7j_verbs[] = {
5585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5587
5588 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5590 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5591
5592 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5594 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5595
5596 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5597 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5598 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5599 { } /* end */
5600};
5601
Takashi Iwai914759b2007-09-06 14:52:04 +02005602static struct hda_verb alc882_asus_a7m_verbs[] = {
5603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5605
5606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5608 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5609
5610 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5612 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5613
5614 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5615 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5616 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5617 { } /* end */
5618};
5619
Tobin Davis9102cd12006-12-15 10:02:12 +01005620static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5621{
5622 unsigned int gpiostate, gpiomask, gpiodir;
5623
5624 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5625 AC_VERB_GET_GPIO_DATA, 0);
5626
5627 if (!muted)
5628 gpiostate |= (1 << pin);
5629 else
5630 gpiostate &= ~(1 << pin);
5631
5632 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5633 AC_VERB_GET_GPIO_MASK, 0);
5634 gpiomask |= (1 << pin);
5635
5636 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5637 AC_VERB_GET_GPIO_DIRECTION, 0);
5638 gpiodir |= (1 << pin);
5639
5640
5641 snd_hda_codec_write(codec, codec->afg, 0,
5642 AC_VERB_SET_GPIO_MASK, gpiomask);
5643 snd_hda_codec_write(codec, codec->afg, 0,
5644 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5645
5646 msleep(1);
5647
5648 snd_hda_codec_write(codec, codec->afg, 0,
5649 AC_VERB_SET_GPIO_DATA, gpiostate);
5650}
5651
Takashi Iwai7debbe52007-08-16 15:01:03 +02005652/* set up GPIO at initialization */
5653static void alc885_macpro_init_hook(struct hda_codec *codec)
5654{
5655 alc882_gpio_mute(codec, 0, 0);
5656 alc882_gpio_mute(codec, 1, 0);
5657}
5658
5659/* set up GPIO and update auto-muting at initialization */
5660static void alc885_imac24_init_hook(struct hda_codec *codec)
5661{
5662 alc885_macpro_init_hook(codec);
5663 alc885_imac24_automute(codec);
5664}
5665
Kailang Yangdf694da2005-12-05 19:42:22 +01005666/*
5667 * generic initialization of ADC, input mixers and output mixers
5668 */
5669static struct hda_verb alc882_auto_init_verbs[] = {
5670 /*
5671 * Unmute ADC0-2 and set the default input to mic-in
5672 */
5673 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5675 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5677 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5679
Takashi Iwaicb53c622007-08-10 17:21:45 +02005680 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005681 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005682 * Note: PASD motherboards uses the Line In 2 as the input for
5683 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005684 */
5685 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005691
5692 /*
5693 * Set up output mixers (0x0c - 0x0f)
5694 */
5695 /* set vol=0 to output mixers */
5696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5700 /* set up input amps for analog loopback */
5701 /* Amp Indices: DAC = 0, mixer = 1 */
5702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5710 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5711 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5712
5713 /* FIXME: use matrix-type input source selection */
5714 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5715 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5720 /* Input mixer2 */
5721 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5725 /* Input mixer3 */
5726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5730
5731 { }
5732};
5733
5734/* capture mixer elements */
5735static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5736 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5737 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5738 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5739 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5740 {
5741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5742 /* The multiple "Capture Source" controls confuse alsamixer
5743 * So call somewhat different..
5744 * FIXME: the controls appear in the "playback" view!
5745 */
5746 /* .name = "Capture Source", */
5747 .name = "Input Source",
5748 .count = 2,
5749 .info = alc882_mux_enum_info,
5750 .get = alc882_mux_enum_get,
5751 .put = alc882_mux_enum_put,
5752 },
5753 { } /* end */
5754};
5755
5756static struct snd_kcontrol_new alc882_capture_mixer[] = {
5757 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5758 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5759 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5760 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5761 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5762 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5763 {
5764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5765 /* The multiple "Capture Source" controls confuse alsamixer
5766 * So call somewhat different..
5767 * FIXME: the controls appear in the "playback" view!
5768 */
5769 /* .name = "Capture Source", */
5770 .name = "Input Source",
5771 .count = 3,
5772 .info = alc882_mux_enum_info,
5773 .get = alc882_mux_enum_get,
5774 .put = alc882_mux_enum_put,
5775 },
5776 { } /* end */
5777};
5778
Takashi Iwaicb53c622007-08-10 17:21:45 +02005779#ifdef CONFIG_SND_HDA_POWER_SAVE
5780#define alc882_loopbacks alc880_loopbacks
5781#endif
5782
Kailang Yangdf694da2005-12-05 19:42:22 +01005783/* pcm configuration: identiacal with ALC880 */
5784#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5785#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5786#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5787#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5788
5789/*
5790 * configuration and preset
5791 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005792static const char *alc882_models[ALC882_MODEL_LAST] = {
5793 [ALC882_3ST_DIG] = "3stack-dig",
5794 [ALC882_6ST_DIG] = "6stack-dig",
5795 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005796 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005797 [ALC882_TARGA] = "targa",
5798 [ALC882_ASUS_A7J] = "asus-a7j",
5799 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005800 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005801 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005802 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005803 [ALC882_AUTO] = "auto",
5804};
5805
5806static struct snd_pci_quirk alc882_cfg_tbl[] = {
5807 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005808 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005809 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005810 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005811 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005812 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005813 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005814 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5815 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5816 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5817 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 {}
5819};
5820
5821static struct alc_config_preset alc882_presets[] = {
5822 [ALC882_3ST_DIG] = {
5823 .mixers = { alc882_base_mixer },
5824 .init_verbs = { alc882_init_verbs },
5825 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5826 .dac_nids = alc882_dac_nids,
5827 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005828 .dig_in_nid = ALC882_DIGIN_NID,
5829 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5830 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005831 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005832 .input_mux = &alc882_capture_source,
5833 },
5834 [ALC882_6ST_DIG] = {
5835 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5836 .init_verbs = { alc882_init_verbs },
5837 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5838 .dac_nids = alc882_dac_nids,
5839 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 .dig_in_nid = ALC882_DIGIN_NID,
5841 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5842 .channel_mode = alc882_sixstack_modes,
5843 .input_mux = &alc882_capture_source,
5844 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005845 [ALC882_ARIMA] = {
5846 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5847 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5848 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5849 .dac_nids = alc882_dac_nids,
5850 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5851 .channel_mode = alc882_sixstack_modes,
5852 .input_mux = &alc882_capture_source,
5853 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005854 [ALC882_W2JC] = {
5855 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5856 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5857 alc880_gpio1_init_verbs },
5858 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5859 .dac_nids = alc882_dac_nids,
5860 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5861 .channel_mode = alc880_threestack_modes,
5862 .need_dac_fix = 1,
5863 .input_mux = &alc882_capture_source,
5864 .dig_out_nid = ALC882_DIGOUT_NID,
5865 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005866 [ALC885_MBP3] = {
5867 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5868 .init_verbs = { alc885_mbp3_init_verbs,
5869 alc880_gpio1_init_verbs },
5870 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5871 .dac_nids = alc882_dac_nids,
5872 .channel_mode = alc885_mbp_6ch_modes,
5873 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5874 .input_mux = &alc882_capture_source,
5875 .dig_out_nid = ALC882_DIGOUT_NID,
5876 .dig_in_nid = ALC882_DIGIN_NID,
5877 .unsol_event = alc885_mbp3_unsol_event,
5878 .init_hook = alc885_mbp3_automute,
5879 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005880 [ALC885_MACPRO] = {
5881 .mixers = { alc882_macpro_mixer },
5882 .init_verbs = { alc882_macpro_init_verbs },
5883 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5884 .dac_nids = alc882_dac_nids,
5885 .dig_out_nid = ALC882_DIGOUT_NID,
5886 .dig_in_nid = ALC882_DIGIN_NID,
5887 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5888 .channel_mode = alc882_ch_modes,
5889 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005890 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005891 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005892 [ALC885_IMAC24] = {
5893 .mixers = { alc885_imac24_mixer },
5894 .init_verbs = { alc885_imac24_init_verbs },
5895 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5896 .dac_nids = alc882_dac_nids,
5897 .dig_out_nid = ALC882_DIGOUT_NID,
5898 .dig_in_nid = ALC882_DIGIN_NID,
5899 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5900 .channel_mode = alc882_ch_modes,
5901 .input_mux = &alc882_capture_source,
5902 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005903 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005904 },
Kailang Yang272a5272007-05-14 11:00:38 +02005905 [ALC882_TARGA] = {
5906 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5907 alc882_capture_mixer },
5908 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5910 .dac_nids = alc882_dac_nids,
5911 .dig_out_nid = ALC882_DIGOUT_NID,
5912 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5913 .adc_nids = alc882_adc_nids,
5914 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5915 .channel_mode = alc882_3ST_6ch_modes,
5916 .need_dac_fix = 1,
5917 .input_mux = &alc882_capture_source,
5918 .unsol_event = alc882_targa_unsol_event,
5919 .init_hook = alc882_targa_automute,
5920 },
5921 [ALC882_ASUS_A7J] = {
5922 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5923 alc882_capture_mixer },
5924 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5926 .dac_nids = alc882_dac_nids,
5927 .dig_out_nid = ALC882_DIGOUT_NID,
5928 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5929 .adc_nids = alc882_adc_nids,
5930 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5931 .channel_mode = alc882_3ST_6ch_modes,
5932 .need_dac_fix = 1,
5933 .input_mux = &alc882_capture_source,
5934 },
Takashi Iwai914759b2007-09-06 14:52:04 +02005935 [ALC882_ASUS_A7M] = {
5936 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5937 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5938 alc880_gpio1_init_verbs,
5939 alc882_asus_a7m_verbs },
5940 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5941 .dac_nids = alc882_dac_nids,
5942 .dig_out_nid = ALC882_DIGOUT_NID,
5943 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5944 .channel_mode = alc880_threestack_modes,
5945 .need_dac_fix = 1,
5946 .input_mux = &alc882_capture_source,
5947 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005948};
5949
5950
5951/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005952 * Pin config fixes
5953 */
5954enum {
5955 PINFIX_ABIT_AW9D_MAX
5956};
5957
5958static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5959 { 0x15, 0x01080104 }, /* side */
5960 { 0x16, 0x01011012 }, /* rear */
5961 { 0x17, 0x01016011 }, /* clfe */
5962 { }
5963};
5964
5965static const struct alc_pincfg *alc882_pin_fixes[] = {
5966 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5967};
5968
5969static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5970 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5971 {}
5972};
5973
5974/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005975 * BIOS auto configuration
5976 */
5977static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5978 hda_nid_t nid, int pin_type,
5979 int dac_idx)
5980{
5981 /* set as output */
5982 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005983 int idx;
5984
Kailang Yangdf694da2005-12-05 19:42:22 +01005985 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5986 idx = 4;
5987 else
5988 idx = spec->multiout.dac_nids[dac_idx] - 2;
5989
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005990 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5991 pin_type);
5992 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5993 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5995
5996}
5997
5998static void alc882_auto_init_multi_out(struct hda_codec *codec)
5999{
6000 struct alc_spec *spec = codec->spec;
6001 int i;
6002
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006003 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006004 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006005 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006006 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006007 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006008 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006009 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006010 }
6011}
6012
6013static void alc882_auto_init_hp_out(struct hda_codec *codec)
6014{
6015 struct alc_spec *spec = codec->spec;
6016 hda_nid_t pin;
6017
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006018 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006019 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006020 /* use dac 0 */
6021 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006022}
6023
6024#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6025#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6026
6027static void alc882_auto_init_analog_input(struct hda_codec *codec)
6028{
6029 struct alc_spec *spec = codec->spec;
6030 int i;
6031
6032 for (i = 0; i < AUTO_PIN_LAST; i++) {
6033 hda_nid_t nid = spec->autocfg.input_pins[i];
6034 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006035 snd_hda_codec_write(codec, nid, 0,
6036 AC_VERB_SET_PIN_WIDGET_CONTROL,
6037 i <= AUTO_PIN_FRONT_MIC ?
6038 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01006039 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006040 snd_hda_codec_write(codec, nid, 0,
6041 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006042 AMP_OUT_MUTE);
6043 }
6044 }
6045}
6046
Takashi Iwai776e1842007-08-29 15:07:11 +02006047/* add mic boosts if needed */
6048static int alc_auto_add_mic_boost(struct hda_codec *codec)
6049{
6050 struct alc_spec *spec = codec->spec;
6051 int err;
6052 hda_nid_t nid;
6053
6054 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6055 if (nid) {
6056 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6057 "Mic Boost",
6058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6059 if (err < 0)
6060 return err;
6061 }
6062 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6063 if (nid) {
6064 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6065 "Front Mic Boost",
6066 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6067 if (err < 0)
6068 return err;
6069 }
6070 return 0;
6071}
6072
Kailang Yangdf694da2005-12-05 19:42:22 +01006073/* almost identical with ALC880 parser... */
6074static int alc882_parse_auto_config(struct hda_codec *codec)
6075{
6076 struct alc_spec *spec = codec->spec;
6077 int err = alc880_parse_auto_config(codec);
6078
6079 if (err < 0)
6080 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006081 else if (!err)
6082 return 0; /* no config found */
6083
6084 err = alc_auto_add_mic_boost(codec);
6085 if (err < 0)
6086 return err;
6087
6088 /* hack - override the init verbs */
6089 spec->init_verbs[0] = alc882_auto_init_verbs;
6090
6091 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006092}
6093
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006094/* additional initialization for auto-configuration model */
6095static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006096{
Kailang Yangdf694da2005-12-05 19:42:22 +01006097 alc882_auto_init_multi_out(codec);
6098 alc882_auto_init_hp_out(codec);
6099 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006100}
6101
Linus Torvalds1da177e2005-04-16 15:20:36 -07006102static int patch_alc882(struct hda_codec *codec)
6103{
6104 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006106
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006107 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006108 if (spec == NULL)
6109 return -ENOMEM;
6110
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 codec->spec = spec;
6112
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006113 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6114 alc882_models,
6115 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006116
Kailang Yangdf694da2005-12-05 19:42:22 +01006117 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006118 /* Pick up systems that don't supply PCI SSID */
6119 switch (codec->subsystem_id) {
6120 case 0x106b0c00: /* Mac Pro */
6121 board_config = ALC885_MACPRO;
6122 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006123 case 0x106b1000: /* iMac 24 */
6124 board_config = ALC885_IMAC24;
6125 break;
Takashi Iwai87350ad2007-08-16 18:19:38 +02006126 case 0x106b2c00: /* Macbook Pro rev3 */
6127 board_config = ALC885_MBP3;
6128 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006129 default:
6130 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6131 "trying auto-probe from BIOS...\n");
6132 board_config = ALC882_AUTO;
6133 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006134 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006135
Takashi Iwaif95474e2007-07-10 00:47:43 +02006136 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6137
Kailang Yangdf694da2005-12-05 19:42:22 +01006138 if (board_config == ALC882_AUTO) {
6139 /* automatic parse from the BIOS config */
6140 err = alc882_parse_auto_config(codec);
6141 if (err < 0) {
6142 alc_free(codec);
6143 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006144 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006145 printk(KERN_INFO
6146 "hda_codec: Cannot set up configuration "
6147 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006148 board_config = ALC882_3ST_DIG;
6149 }
6150 }
6151
6152 if (board_config != ALC882_AUTO)
6153 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006154
6155 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006156 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6157 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006158
6159 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006160 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6161 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006162
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006163 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006164 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006165 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006166 /* get type */
6167 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 if (wcap != AC_WID_AUD_IN) {
6169 spec->adc_nids = alc882_adc_nids_alt;
6170 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006171 spec->mixers[spec->num_mixers] =
6172 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006173 spec->num_mixers++;
6174 } else {
6175 spec->adc_nids = alc882_adc_nids;
6176 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6177 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6178 spec->num_mixers++;
6179 }
6180 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006181
6182 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006183 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006184 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006185#ifdef CONFIG_SND_HDA_POWER_SAVE
6186 if (!spec->loopback.amplist)
6187 spec->loopback.amplist = alc882_loopbacks;
6188#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006189
6190 return 0;
6191}
6192
6193/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006194 * ALC883 support
6195 *
6196 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6197 * configuration. Each pin widget can choose any input DACs and a mixer.
6198 * Each ADC is connected from a mixer of all inputs. This makes possible
6199 * 6-channel independent captures.
6200 *
6201 * In addition, an independent DAC for the multi-playback (not used in this
6202 * driver yet).
6203 */
6204#define ALC883_DIGOUT_NID 0x06
6205#define ALC883_DIGIN_NID 0x0a
6206
6207static hda_nid_t alc883_dac_nids[4] = {
6208 /* front, rear, clfe, rear_surr */
6209 0x02, 0x04, 0x03, 0x05
6210};
6211
6212static hda_nid_t alc883_adc_nids[2] = {
6213 /* ADC1-2 */
6214 0x08, 0x09,
6215};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006216
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006217/* input MUX */
6218/* FIXME: should be a matrix-type input source selection */
6219
6220static struct hda_input_mux alc883_capture_source = {
6221 .num_items = 4,
6222 .items = {
6223 { "Mic", 0x0 },
6224 { "Front Mic", 0x1 },
6225 { "Line", 0x2 },
6226 { "CD", 0x4 },
6227 },
6228};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006229
6230static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6231 .num_items = 2,
6232 .items = {
6233 { "Mic", 0x1 },
6234 { "Line", 0x2 },
6235 },
6236};
6237
Kailang Yang272a5272007-05-14 11:00:38 +02006238static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6239 .num_items = 4,
6240 .items = {
6241 { "Mic", 0x0 },
6242 { "iMic", 0x1 },
6243 { "Line", 0x2 },
6244 { "CD", 0x4 },
6245 },
6246};
6247
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006248#define alc883_mux_enum_info alc_mux_enum_info
6249#define alc883_mux_enum_get alc_mux_enum_get
6250
6251static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6252 struct snd_ctl_elem_value *ucontrol)
6253{
6254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6255 struct alc_spec *spec = codec->spec;
6256 const struct hda_input_mux *imux = spec->input_mux;
6257 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6258 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6259 hda_nid_t nid = capture_mixers[adc_idx];
6260 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6261 unsigned int i, idx;
6262
6263 idx = ucontrol->value.enumerated.item[0];
6264 if (idx >= imux->num_items)
6265 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006266 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006267 return 0;
6268 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006269 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6270 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006271 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006272 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006273 }
6274 *cur_val = idx;
6275 return 1;
6276}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006277
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006278/*
6279 * 2ch mode
6280 */
6281static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6282 { 2, NULL }
6283};
6284
6285/*
6286 * 2ch mode
6287 */
6288static struct hda_verb alc883_3ST_ch2_init[] = {
6289 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6290 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6291 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6292 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6293 { } /* end */
6294};
6295
6296/*
Tobin Davisb2011312007-09-17 12:45:11 +02006297 * 4ch mode
6298 */
6299static struct hda_verb alc883_3ST_ch4_init[] = {
6300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6302 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6303 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6304 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6305 { } /* end */
6306};
6307
6308/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006309 * 6ch mode
6310 */
6311static struct hda_verb alc883_3ST_ch6_init[] = {
6312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6314 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6315 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6316 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6317 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6318 { } /* end */
6319};
6320
Tobin Davisb2011312007-09-17 12:45:11 +02006321static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006322 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006323 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006324 { 6, alc883_3ST_ch6_init },
6325};
6326
6327/*
6328 * 6ch mode
6329 */
6330static struct hda_verb alc883_sixstack_ch6_init[] = {
6331 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6332 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6333 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6334 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6335 { } /* end */
6336};
6337
6338/*
6339 * 8ch mode
6340 */
6341static struct hda_verb alc883_sixstack_ch8_init[] = {
6342 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6343 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6344 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6345 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6346 { } /* end */
6347};
6348
6349static struct hda_channel_mode alc883_sixstack_modes[2] = {
6350 { 6, alc883_sixstack_ch6_init },
6351 { 8, alc883_sixstack_ch8_init },
6352};
6353
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006354static struct hda_verb alc883_medion_eapd_verbs[] = {
6355 /* eanable EAPD on medion laptop */
6356 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6357 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6358 { }
6359};
6360
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006361/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6362 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6363 */
6364
6365static struct snd_kcontrol_new alc883_base_mixer[] = {
6366 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6367 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6368 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6369 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6370 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6371 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6372 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6373 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6374 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6375 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006385 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006386 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6387 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6388 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6389 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6390 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6391 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6392 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6393 {
6394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6395 /* .name = "Capture Source", */
6396 .name = "Input Source",
6397 .count = 2,
6398 .info = alc883_mux_enum_info,
6399 .get = alc883_mux_enum_get,
6400 .put = alc883_mux_enum_put,
6401 },
6402 { } /* end */
6403};
6404
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006405static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6407 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6408 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6409 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6410 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6411 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6416 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6418 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6419 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6420 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6421 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6422 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6423 {
6424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6425 /* .name = "Capture Source", */
6426 .name = "Input Source",
6427 .count = 2,
6428 .info = alc883_mux_enum_info,
6429 .get = alc883_mux_enum_get,
6430 .put = alc883_mux_enum_put,
6431 },
6432 { } /* end */
6433};
6434
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006435static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6437 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6439 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6440 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6441 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6442 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6446 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006447 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6449 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6450 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6451 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6452 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6453 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6454 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6455 {
6456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6457 /* .name = "Capture Source", */
6458 .name = "Input Source",
6459 .count = 2,
6460 .info = alc883_mux_enum_info,
6461 .get = alc883_mux_enum_get,
6462 .put = alc883_mux_enum_put,
6463 },
6464 { } /* end */
6465};
6466
6467static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6468 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6469 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6471 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6472 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6473 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6474 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6475 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006482 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6484 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006485 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6487 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6488 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6489 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6490 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6491 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6492 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6493 {
6494 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6495 /* .name = "Capture Source", */
6496 .name = "Input Source",
6497 .count = 2,
6498 .info = alc883_mux_enum_info,
6499 .get = alc883_mux_enum_get,
6500 .put = alc883_mux_enum_put,
6501 },
6502 { } /* end */
6503};
6504
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006505static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006506 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6507 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6508 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6509 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6510 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6511 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6512 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6513 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6515 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6516 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6517 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6518 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006520 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006521 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6522 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006523 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006524 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6525 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6526 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6527 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6528 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6529
6530 {
6531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6532 /* .name = "Capture Source", */
6533 .name = "Input Source",
6534 .count = 1,
6535 .info = alc883_mux_enum_info,
6536 .get = alc883_mux_enum_get,
6537 .put = alc883_mux_enum_put,
6538 },
6539 { } /* end */
6540};
6541
Kailang Yangccc656c2006-10-17 12:32:26 +02006542static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6545 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6546 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6547 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6548 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6549 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6550 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6551 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6552 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6553 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006557 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6559 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6560 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6561 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6562 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6563 {
6564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6565 /* .name = "Capture Source", */
6566 .name = "Input Source",
6567 .count = 2,
6568 .info = alc883_mux_enum_info,
6569 .get = alc883_mux_enum_get,
6570 .put = alc883_mux_enum_put,
6571 },
6572 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006573};
Kailang Yangccc656c2006-10-17 12:32:26 +02006574
6575static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6578 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6579 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6580 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6584 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6585 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6586 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6587 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6588 {
6589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6590 /* .name = "Capture Source", */
6591 .name = "Input Source",
6592 .count = 2,
6593 .info = alc883_mux_enum_info,
6594 .get = alc883_mux_enum_get,
6595 .put = alc883_mux_enum_put,
6596 },
6597 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006598};
Kailang Yangccc656c2006-10-17 12:32:26 +02006599
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006600static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6602 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6603 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6604 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6606 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6610 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6611 {
6612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6613 /* .name = "Capture Source", */
6614 .name = "Input Source",
6615 .count = 1,
6616 .info = alc883_mux_enum_info,
6617 .get = alc883_mux_enum_get,
6618 .put = alc883_mux_enum_put,
6619 },
6620 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006621};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006622
Kailang Yang272a5272007-05-14 11:00:38 +02006623static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6625 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6631 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6632 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6633 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6634 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6635 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6636 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6637 {
6638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6639 /* .name = "Capture Source", */
6640 .name = "Input Source",
6641 .count = 2,
6642 .info = alc883_mux_enum_info,
6643 .get = alc883_mux_enum_get,
6644 .put = alc883_mux_enum_put,
6645 },
6646 { } /* end */
6647};
6648
6649static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6652 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6659 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6660 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6661 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6662 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6663 {
6664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6665 /* .name = "Capture Source", */
6666 .name = "Input Source",
6667 .count = 2,
6668 .info = alc883_mux_enum_info,
6669 .get = alc883_mux_enum_get,
6670 .put = alc883_mux_enum_put,
6671 },
6672 { } /* end */
6673};
6674
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006675static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006676 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6678 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6679 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6680 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6681 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6682 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6683 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6684 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6685 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6686 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6694 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6696 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6697 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6698 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6699 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6700 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6701 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6702 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6703 {
6704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6705 /* .name = "Capture Source", */
6706 .name = "Input Source",
6707 .count = 2,
6708 .info = alc883_mux_enum_info,
6709 .get = alc883_mux_enum_get,
6710 .put = alc883_mux_enum_put,
6711 },
6712 { } /* end */
6713};
6714
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006715static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6718 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6719 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6720 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6722 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6723 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6725 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6726 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6727 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6728 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6732 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6735 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6736 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, 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
Tobin Davis2880a862007-08-07 11:50:26 +02006753static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006762 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6763 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6764 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6765 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6766 {
6767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6768 /* .name = "Capture Source", */
6769 .name = "Input Source",
6770 .count = 2,
6771 .info = alc883_mux_enum_info,
6772 .get = alc883_mux_enum_get,
6773 .put = alc883_mux_enum_put,
6774 },
6775 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006776};
Tobin Davis2880a862007-08-07 11:50:26 +02006777
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006778static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6779 {
6780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6781 .name = "Channel Mode",
6782 .info = alc_ch_mode_info,
6783 .get = alc_ch_mode_get,
6784 .put = alc_ch_mode_put,
6785 },
6786 { } /* end */
6787};
6788
6789static struct hda_verb alc883_init_verbs[] = {
6790 /* ADC1: mute amp left and right */
6791 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6792 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6793 /* ADC2: mute amp left and right */
6794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6795 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6796 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6800 /* Rear mixer */
6801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6804 /* CLFE mixer */
6805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6808 /* Side mixer */
6809 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6812
Takashi Iwaicb53c622007-08-10 17:21:45 +02006813 /* mute analog input loopbacks */
6814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006819
6820 /* Front Pin: output 0 (0x0c) */
6821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6824 /* Rear Pin: output 1 (0x0d) */
6825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6828 /* CLFE Pin: output 2 (0x0e) */
6829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6830 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6831 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6832 /* Side Pin: output 3 (0x0f) */
6833 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6834 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6835 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6836 /* Mic (rear) pin: input vref at 80% */
6837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6839 /* Front Mic pin: input vref at 80% */
6840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6842 /* Line In pin: input */
6843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6845 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6847 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6848 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6849 /* CD pin widget for input */
6850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6851
6852 /* FIXME: use matrix-type input source selection */
6853 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6854 /* Input mixer2 */
6855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6859 /* Input mixer3 */
6860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6864 { }
6865};
6866
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006867/* toggle speaker-output according to the hp-jack state */
6868static void alc883_mitac_hp_automute(struct hda_codec *codec)
6869{
6870 unsigned int present;
6871
6872 present = snd_hda_codec_read(codec, 0x15, 0,
6873 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6874 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6875 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6876 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6877 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6878}
6879
6880/* auto-toggle front mic */
6881/*
6882static void alc883_mitac_mic_automute(struct hda_codec *codec)
6883{
6884 unsigned int present;
6885 unsigned char bits;
6886
6887 present = snd_hda_codec_read(codec, 0x18, 0,
6888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6889 bits = present ? HDA_AMP_MUTE : 0;
6890 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
6891}
6892*/
6893
6894static void alc883_mitac_automute(struct hda_codec *codec)
6895{
6896 alc883_mitac_hp_automute(codec);
6897 /* alc883_mitac_mic_automute(codec); */
6898}
6899
6900static void alc883_mitac_unsol_event(struct hda_codec *codec,
6901 unsigned int res)
6902{
6903 switch (res >> 26) {
6904 case ALC880_HP_EVENT:
6905 alc883_mitac_hp_automute(codec);
6906 break;
6907 case ALC880_MIC_EVENT:
6908 /* alc883_mitac_mic_automute(codec); */
6909 break;
6910 }
6911}
6912
6913static struct hda_verb alc883_mitac_verbs[] = {
6914 /* HP */
6915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6917 /* Subwoofer */
6918 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
6919 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6920
6921 /* enable unsolicited event */
6922 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6923 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
6924
6925 { } /* end */
6926};
6927
Kailang Yangccc656c2006-10-17 12:32:26 +02006928static struct hda_verb alc883_tagra_verbs[] = {
6929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6931
6932 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6933 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6934
6935 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6936 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6938
6939 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006940 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6941 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6942 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006943
6944 { } /* end */
6945};
6946
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006947static struct hda_verb alc883_lenovo_101e_verbs[] = {
6948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6949 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6950 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6951 { } /* end */
6952};
6953
Kailang Yang272a5272007-05-14 11:00:38 +02006954static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6957 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6959 { } /* end */
6960};
6961
6962static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6966 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6967 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6968 { } /* end */
6969};
6970
Kailang Yang189609a2007-08-20 11:31:23 +02006971static struct hda_verb alc883_haier_w66_verbs[] = {
6972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6974
6975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6976
6977 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6979 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6981 { } /* end */
6982};
6983
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006984static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006985 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6987 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6988 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6989 { }
6990};
6991
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006992static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6994 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6995 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6996 { }
6997};
6998
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006999static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007000 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7001 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7002 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7003 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7004 { }
7005};
7006
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007007static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007008 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7009 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7010 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7011 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7012 { }
7013};
7014
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007015static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7016 { 2, alc888_3st_hp_2ch_init },
7017 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007018};
7019
Kailang Yang272a5272007-05-14 11:00:38 +02007020/* toggle front-jack and RCA according to the hp-jack state */
7021static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7022{
7023 unsigned int present;
7024
7025 present = snd_hda_codec_read(codec, 0x1b, 0,
7026 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007027 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7028 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7029 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7030 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007031}
7032
7033/* toggle RCA according to the front-jack state */
7034static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7035{
7036 unsigned int present;
7037
7038 present = snd_hda_codec_read(codec, 0x14, 0,
7039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007040 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7041 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007042}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007043
Kailang Yang272a5272007-05-14 11:00:38 +02007044static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7045 unsigned int res)
7046{
7047 if ((res >> 26) == ALC880_HP_EVENT)
7048 alc888_lenovo_ms7195_front_automute(codec);
7049 if ((res >> 26) == ALC880_FRONT_EVENT)
7050 alc888_lenovo_ms7195_rca_automute(codec);
7051}
7052
7053static struct hda_verb alc883_medion_md2_verbs[] = {
7054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7056
7057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7058
7059 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7060 { } /* end */
7061};
7062
7063/* toggle speaker-output according to the hp-jack state */
7064static void alc883_medion_md2_automute(struct hda_codec *codec)
7065{
7066 unsigned int present;
7067
7068 present = snd_hda_codec_read(codec, 0x14, 0,
7069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007070 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7071 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007072}
7073
7074static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7075 unsigned int res)
7076{
7077 if ((res >> 26) == ALC880_HP_EVENT)
7078 alc883_medion_md2_automute(codec);
7079}
7080
Kailang Yangccc656c2006-10-17 12:32:26 +02007081/* toggle speaker-output according to the hp-jack state */
7082static void alc883_tagra_automute(struct hda_codec *codec)
7083{
7084 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007085 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007086
7087 present = snd_hda_codec_read(codec, 0x14, 0,
7088 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007089 bits = present ? HDA_AMP_MUTE : 0;
7090 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7091 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007092 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7093 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007094}
7095
7096static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7097{
7098 if ((res >> 26) == ALC880_HP_EVENT)
7099 alc883_tagra_automute(codec);
7100}
7101
Kailang Yang189609a2007-08-20 11:31:23 +02007102static void alc883_haier_w66_automute(struct hda_codec *codec)
7103{
7104 unsigned int present;
7105 unsigned char bits;
7106
7107 present = snd_hda_codec_read(codec, 0x1b, 0,
7108 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7109 bits = present ? 0x80 : 0;
7110 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7111 0x80, bits);
7112}
7113
7114static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7115 unsigned int res)
7116{
7117 if ((res >> 26) == ALC880_HP_EVENT)
7118 alc883_haier_w66_automute(codec);
7119}
7120
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007121static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7122{
7123 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007124 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007125
7126 present = snd_hda_codec_read(codec, 0x14, 0,
7127 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007128 bits = present ? HDA_AMP_MUTE : 0;
7129 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7130 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007131}
7132
7133static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7134{
7135 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007136 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007137
7138 present = snd_hda_codec_read(codec, 0x1b, 0,
7139 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007140 bits = present ? HDA_AMP_MUTE : 0;
7141 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7142 HDA_AMP_MUTE, bits);
7143 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7144 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007145}
7146
7147static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7148 unsigned int res)
7149{
7150 if ((res >> 26) == ALC880_HP_EVENT)
7151 alc883_lenovo_101e_all_automute(codec);
7152 if ((res >> 26) == ALC880_FRONT_EVENT)
7153 alc883_lenovo_101e_ispeaker_automute(codec);
7154}
7155
Takashi Iwai676a9b52007-08-16 15:23:35 +02007156/* toggle speaker-output according to the hp-jack state */
7157static void alc883_acer_aspire_automute(struct hda_codec *codec)
7158{
7159 unsigned int present;
7160
7161 present = snd_hda_codec_read(codec, 0x14, 0,
7162 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7163 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7164 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7165 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7166 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7167}
7168
7169static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7170 unsigned int res)
7171{
7172 if ((res >> 26) == ALC880_HP_EVENT)
7173 alc883_acer_aspire_automute(codec);
7174}
7175
Kailang Yangd1a991a2007-08-15 16:21:59 +02007176static struct hda_verb alc883_acer_eapd_verbs[] = {
7177 /* HP Pin: output 0 (0x0c) */
7178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7180 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7181 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007185 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7186 /* eanable EAPD on medion laptop */
7187 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7188 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007189 /* enable unsolicited event */
7190 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007191 { }
7192};
7193
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007194/*
7195 * generic initialization of ADC, input mixers and output mixers
7196 */
7197static struct hda_verb alc883_auto_init_verbs[] = {
7198 /*
7199 * Unmute ADC0-2 and set the default input to mic-in
7200 */
7201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7205
Takashi Iwaicb53c622007-08-10 17:21:45 +02007206 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007207 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007208 * Note: PASD motherboards uses the Line In 2 as the input for
7209 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007210 */
7211 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007217
7218 /*
7219 * Set up output mixers (0x0c - 0x0f)
7220 */
7221 /* set vol=0 to output mixers */
7222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7226 /* set up input amps for analog loopback */
7227 /* Amp Indices: DAC = 0, mixer = 1 */
7228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7236 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7237 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7238
7239 /* FIXME: use matrix-type input source selection */
7240 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7241 /* Input mixer1 */
7242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007245 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7247 /* Input mixer2 */
7248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007251 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007253
7254 { }
7255};
7256
7257/* capture mixer elements */
7258static struct snd_kcontrol_new alc883_capture_mixer[] = {
7259 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7260 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7261 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7262 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7263 {
7264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7265 /* The multiple "Capture Source" controls confuse alsamixer
7266 * So call somewhat different..
7267 * FIXME: the controls appear in the "playback" view!
7268 */
7269 /* .name = "Capture Source", */
7270 .name = "Input Source",
7271 .count = 2,
7272 .info = alc882_mux_enum_info,
7273 .get = alc882_mux_enum_get,
7274 .put = alc882_mux_enum_put,
7275 },
7276 { } /* end */
7277};
7278
Takashi Iwaicb53c622007-08-10 17:21:45 +02007279#ifdef CONFIG_SND_HDA_POWER_SAVE
7280#define alc883_loopbacks alc880_loopbacks
7281#endif
7282
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007283/* pcm configuration: identiacal with ALC880 */
7284#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7285#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7286#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7287#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7288
7289/*
7290 * configuration and preset
7291 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007292static const char *alc883_models[ALC883_MODEL_LAST] = {
7293 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7294 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7295 [ALC883_3ST_6ch] = "3stack-6ch",
7296 [ALC883_6ST_DIG] = "6stack-dig",
7297 [ALC883_TARGA_DIG] = "targa-dig",
7298 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007299 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007300 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007301 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007302 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007303 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007304 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007305 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7306 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007307 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007308 [ALC888_6ST_HP] = "6stack-hp",
7309 [ALC888_3ST_HP] = "3stack-hp",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007310 [ALC883_MITAC] = "mitac",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007311 [ALC883_AUTO] = "auto",
7312};
7313
7314static struct snd_pci_quirk alc883_cfg_tbl[] = {
7315 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007316 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7317 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7318 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7319 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Tobin Davisfebe3372007-06-12 11:27:46 +02007320 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007321 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7322 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7323 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7324 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007325 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007326 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7327 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7328 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007329 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007330 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7331 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7332 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7333 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7334 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7335 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7336 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7337 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7338 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7339 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7340 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7341 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7342 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007343 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7344 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007345 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007346 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007347 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007348 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007349 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7350 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007351 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007352 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Kailang Yang272a5272007-05-14 11:00:38 +02007353 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007354 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007355 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7356 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007357 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007358 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007359 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007360 {}
7361};
7362
7363static struct alc_config_preset alc883_presets[] = {
7364 [ALC883_3ST_2ch_DIG] = {
7365 .mixers = { alc883_3ST_2ch_mixer },
7366 .init_verbs = { alc883_init_verbs },
7367 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7368 .dac_nids = alc883_dac_nids,
7369 .dig_out_nid = ALC883_DIGOUT_NID,
7370 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7371 .adc_nids = alc883_adc_nids,
7372 .dig_in_nid = ALC883_DIGIN_NID,
7373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7374 .channel_mode = alc883_3ST_2ch_modes,
7375 .input_mux = &alc883_capture_source,
7376 },
7377 [ALC883_3ST_6ch_DIG] = {
7378 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7379 .init_verbs = { alc883_init_verbs },
7380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7381 .dac_nids = alc883_dac_nids,
7382 .dig_out_nid = ALC883_DIGOUT_NID,
7383 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7384 .adc_nids = alc883_adc_nids,
7385 .dig_in_nid = ALC883_DIGIN_NID,
7386 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7387 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007388 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007389 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007390 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007391 [ALC883_3ST_6ch] = {
7392 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7393 .init_verbs = { alc883_init_verbs },
7394 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7395 .dac_nids = alc883_dac_nids,
7396 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7397 .adc_nids = alc883_adc_nids,
7398 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7399 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007400 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007401 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007402 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007403 [ALC883_6ST_DIG] = {
7404 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7405 .init_verbs = { alc883_init_verbs },
7406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7407 .dac_nids = alc883_dac_nids,
7408 .dig_out_nid = ALC883_DIGOUT_NID,
7409 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7410 .adc_nids = alc883_adc_nids,
7411 .dig_in_nid = ALC883_DIGIN_NID,
7412 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7413 .channel_mode = alc883_sixstack_modes,
7414 .input_mux = &alc883_capture_source,
7415 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007416 [ALC883_TARGA_DIG] = {
7417 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7418 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7420 .dac_nids = alc883_dac_nids,
7421 .dig_out_nid = ALC883_DIGOUT_NID,
7422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7423 .adc_nids = alc883_adc_nids,
7424 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7425 .channel_mode = alc883_3ST_6ch_modes,
7426 .need_dac_fix = 1,
7427 .input_mux = &alc883_capture_source,
7428 .unsol_event = alc883_tagra_unsol_event,
7429 .init_hook = alc883_tagra_automute,
7430 },
7431 [ALC883_TARGA_2ch_DIG] = {
7432 .mixers = { alc883_tagra_2ch_mixer},
7433 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7435 .dac_nids = alc883_dac_nids,
7436 .dig_out_nid = ALC883_DIGOUT_NID,
7437 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7438 .adc_nids = alc883_adc_nids,
7439 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7440 .channel_mode = alc883_3ST_2ch_modes,
7441 .input_mux = &alc883_capture_source,
7442 .unsol_event = alc883_tagra_unsol_event,
7443 .init_hook = alc883_tagra_automute,
7444 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007445 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007446 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007447 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7448 * and the headphone jack. Turn this on and rely on the
7449 * standard mute methods whenever the user wants to turn
7450 * these outputs off.
7451 */
7452 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7454 .dac_nids = alc883_dac_nids,
7455 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7456 .adc_nids = alc883_adc_nids,
7457 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7458 .channel_mode = alc883_3ST_2ch_modes,
7459 .input_mux = &alc883_capture_source,
7460 },
Tobin Davis2880a862007-08-07 11:50:26 +02007461 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007462 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007463 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7465 .dac_nids = alc883_dac_nids,
7466 .dig_out_nid = ALC883_DIGOUT_NID,
7467 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7468 .adc_nids = alc883_adc_nids,
7469 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7470 .channel_mode = alc883_3ST_2ch_modes,
7471 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007472 .unsol_event = alc883_acer_aspire_unsol_event,
7473 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007474 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007475 [ALC883_MEDION] = {
7476 .mixers = { alc883_fivestack_mixer,
7477 alc883_chmode_mixer },
7478 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007479 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7481 .dac_nids = alc883_dac_nids,
7482 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7483 .adc_nids = alc883_adc_nids,
7484 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7485 .channel_mode = alc883_sixstack_modes,
7486 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007487 },
Kailang Yang272a5272007-05-14 11:00:38 +02007488 [ALC883_MEDION_MD2] = {
7489 .mixers = { alc883_medion_md2_mixer},
7490 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7491 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7492 .dac_nids = alc883_dac_nids,
7493 .dig_out_nid = ALC883_DIGOUT_NID,
7494 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7495 .adc_nids = alc883_adc_nids,
7496 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7497 .channel_mode = alc883_3ST_2ch_modes,
7498 .input_mux = &alc883_capture_source,
7499 .unsol_event = alc883_medion_md2_unsol_event,
7500 .init_hook = alc883_medion_md2_automute,
7501 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007502 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007503 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007504 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7505 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7506 .dac_nids = alc883_dac_nids,
7507 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7508 .adc_nids = alc883_adc_nids,
7509 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7510 .channel_mode = alc883_3ST_2ch_modes,
7511 .input_mux = &alc883_capture_source,
7512 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007513 [ALC883_LENOVO_101E_2ch] = {
7514 .mixers = { alc883_lenovo_101e_2ch_mixer},
7515 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7516 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7517 .dac_nids = alc883_dac_nids,
7518 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7519 .adc_nids = alc883_adc_nids,
7520 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7521 .channel_mode = alc883_3ST_2ch_modes,
7522 .input_mux = &alc883_lenovo_101e_capture_source,
7523 .unsol_event = alc883_lenovo_101e_unsol_event,
7524 .init_hook = alc883_lenovo_101e_all_automute,
7525 },
Kailang Yang272a5272007-05-14 11:00:38 +02007526 [ALC883_LENOVO_NB0763] = {
7527 .mixers = { alc883_lenovo_nb0763_mixer },
7528 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7530 .dac_nids = alc883_dac_nids,
7531 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7532 .adc_nids = alc883_adc_nids,
7533 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7534 .channel_mode = alc883_3ST_2ch_modes,
7535 .need_dac_fix = 1,
7536 .input_mux = &alc883_lenovo_nb0763_capture_source,
7537 .unsol_event = alc883_medion_md2_unsol_event,
7538 .init_hook = alc883_medion_md2_automute,
7539 },
7540 [ALC888_LENOVO_MS7195_DIG] = {
7541 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7542 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7543 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7544 .dac_nids = alc883_dac_nids,
7545 .dig_out_nid = ALC883_DIGOUT_NID,
7546 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7547 .adc_nids = alc883_adc_nids,
7548 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7549 .channel_mode = alc883_3ST_6ch_modes,
7550 .need_dac_fix = 1,
7551 .input_mux = &alc883_capture_source,
7552 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7553 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007554 },
7555 [ALC883_HAIER_W66] = {
7556 .mixers = { alc883_tagra_2ch_mixer},
7557 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7559 .dac_nids = alc883_dac_nids,
7560 .dig_out_nid = ALC883_DIGOUT_NID,
7561 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7562 .adc_nids = alc883_adc_nids,
7563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7564 .channel_mode = alc883_3ST_2ch_modes,
7565 .input_mux = &alc883_capture_source,
7566 .unsol_event = alc883_haier_w66_unsol_event,
7567 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007568 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007569 [ALC888_6ST_HP] = {
7570 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7571 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7573 .dac_nids = alc883_dac_nids,
7574 .dig_out_nid = ALC883_DIGOUT_NID,
7575 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7576 .adc_nids = alc883_adc_nids,
7577 .dig_in_nid = ALC883_DIGIN_NID,
7578 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7579 .channel_mode = alc883_sixstack_modes,
7580 .input_mux = &alc883_capture_source,
7581 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007582 [ALC888_3ST_HP] = {
7583 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7584 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7586 .dac_nids = alc883_dac_nids,
7587 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7588 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007589 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7590 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007591 .need_dac_fix = 1,
7592 .input_mux = &alc883_capture_source,
7593 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007594 [ALC883_MITAC] = {
7595 .mixers = { alc883_mitac_mixer },
7596 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7597 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7598 .dac_nids = alc883_dac_nids,
7599 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7600 .adc_nids = alc883_adc_nids,
7601 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7602 .channel_mode = alc883_3ST_2ch_modes,
7603 .input_mux = &alc883_capture_source,
7604 .unsol_event = alc883_mitac_unsol_event,
7605 .init_hook = alc883_mitac_automute,
7606 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007607};
7608
7609
7610/*
7611 * BIOS auto configuration
7612 */
7613static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7614 hda_nid_t nid, int pin_type,
7615 int dac_idx)
7616{
7617 /* set as output */
7618 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007619 int idx;
7620
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007621 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7622 idx = 4;
7623 else
7624 idx = spec->multiout.dac_nids[dac_idx] - 2;
7625
7626 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7627 pin_type);
7628 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7629 AMP_OUT_UNMUTE);
7630 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7631
7632}
7633
7634static void alc883_auto_init_multi_out(struct hda_codec *codec)
7635{
7636 struct alc_spec *spec = codec->spec;
7637 int i;
7638
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007639 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007640 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007641 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007642 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007643 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007644 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007645 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007646 }
7647}
7648
7649static void alc883_auto_init_hp_out(struct hda_codec *codec)
7650{
7651 struct alc_spec *spec = codec->spec;
7652 hda_nid_t pin;
7653
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007654 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007655 if (pin) /* connect to front */
7656 /* use dac 0 */
7657 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7658}
7659
7660#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7661#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7662
7663static void alc883_auto_init_analog_input(struct hda_codec *codec)
7664{
7665 struct alc_spec *spec = codec->spec;
7666 int i;
7667
7668 for (i = 0; i < AUTO_PIN_LAST; i++) {
7669 hda_nid_t nid = spec->autocfg.input_pins[i];
7670 if (alc883_is_input_pin(nid)) {
7671 snd_hda_codec_write(codec, nid, 0,
7672 AC_VERB_SET_PIN_WIDGET_CONTROL,
7673 (i <= AUTO_PIN_FRONT_MIC ?
7674 PIN_VREF80 : PIN_IN));
7675 if (nid != ALC883_PIN_CD_NID)
7676 snd_hda_codec_write(codec, nid, 0,
7677 AC_VERB_SET_AMP_GAIN_MUTE,
7678 AMP_OUT_MUTE);
7679 }
7680 }
7681}
7682
7683/* almost identical with ALC880 parser... */
7684static int alc883_parse_auto_config(struct hda_codec *codec)
7685{
7686 struct alc_spec *spec = codec->spec;
7687 int err = alc880_parse_auto_config(codec);
7688
7689 if (err < 0)
7690 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007691 else if (!err)
7692 return 0; /* no config found */
7693
7694 err = alc_auto_add_mic_boost(codec);
7695 if (err < 0)
7696 return err;
7697
7698 /* hack - override the init verbs */
7699 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007700 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7701 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007702
7703 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007704}
7705
7706/* additional initialization for auto-configuration model */
7707static void alc883_auto_init(struct hda_codec *codec)
7708{
7709 alc883_auto_init_multi_out(codec);
7710 alc883_auto_init_hp_out(codec);
7711 alc883_auto_init_analog_input(codec);
7712}
7713
7714static int patch_alc883(struct hda_codec *codec)
7715{
7716 struct alc_spec *spec;
7717 int err, board_config;
7718
7719 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7720 if (spec == NULL)
7721 return -ENOMEM;
7722
7723 codec->spec = spec;
7724
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007725 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7726 alc883_models,
7727 alc883_cfg_tbl);
7728 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007729 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7730 "trying auto-probe from BIOS...\n");
7731 board_config = ALC883_AUTO;
7732 }
7733
7734 if (board_config == ALC883_AUTO) {
7735 /* automatic parse from the BIOS config */
7736 err = alc883_parse_auto_config(codec);
7737 if (err < 0) {
7738 alc_free(codec);
7739 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007740 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007741 printk(KERN_INFO
7742 "hda_codec: Cannot set up configuration "
7743 "from BIOS. Using base mode...\n");
7744 board_config = ALC883_3ST_2ch_DIG;
7745 }
7746 }
7747
7748 if (board_config != ALC883_AUTO)
7749 setup_preset(spec, &alc883_presets[board_config]);
7750
7751 spec->stream_name_analog = "ALC883 Analog";
7752 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7753 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7754
7755 spec->stream_name_digital = "ALC883 Digital";
7756 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7757 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007759 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007760 spec->adc_nids = alc883_adc_nids;
7761 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7762 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007763
7764 codec->patch_ops = alc_patch_ops;
7765 if (board_config == ALC883_AUTO)
7766 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007767#ifdef CONFIG_SND_HDA_POWER_SAVE
7768 if (!spec->loopback.amplist)
7769 spec->loopback.amplist = alc883_loopbacks;
7770#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007771
7772 return 0;
7773}
7774
7775/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007776 * ALC262 support
7777 */
7778
7779#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7780#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7781
7782#define alc262_dac_nids alc260_dac_nids
7783#define alc262_adc_nids alc882_adc_nids
7784#define alc262_adc_nids_alt alc882_adc_nids_alt
7785
7786#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007787#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007788
7789static struct snd_kcontrol_new alc262_base_mixer[] = {
7790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007802 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7803 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7806 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007808 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007809};
7810
Kailang Yangccc656c2006-10-17 12:32:26 +02007811static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007821 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007824 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7825 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7826 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7828 { } /* end */
7829};
7830
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7833 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7835 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7836 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7837
7838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7849 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7850 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7851 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7852 { } /* end */
7853};
7854
Kailang Yangcd7509a2007-01-26 18:33:17 +01007855static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007864 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7869 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7870 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7871 { } /* end */
7872};
7873
7874static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7875 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7876 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007877 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007878 { } /* end */
7879};
7880
Kailang Yang66d2a9d2007-11-14 12:06:21 +01007881static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
7882 .ops = &snd_hda_bind_vol,
7883 .values = {
7884 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7885 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7886 0
7887 },
7888};
7889
7890static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
7891 .ops = &snd_hda_bind_sw,
7892 .values = {
7893 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7894 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7895 0
7896 },
7897};
7898
7899/* mute/unmute internal speaker according to the hp jack and mute state */
7900static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
7901{
7902 struct alc_spec *spec = codec->spec;
7903 unsigned int mute;
7904
7905 if (force || !spec->sense_updated) {
7906 unsigned int present;
7907 present = snd_hda_codec_read(codec, 0x15, 0,
7908 AC_VERB_GET_PIN_SENSE, 0);
7909 spec->jack_present = (present & 0x80000000) != 0;
7910 spec->sense_updated = 1;
7911 }
7912 if (spec->jack_present)
7913 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
7914 else /* unmute internal speaker if necessary */
7915 mute = (0x7000 | ((0)<<8));
7916 snd_hda_codec_write(codec, 0x0c, 0,
7917 AC_VERB_SET_AMP_GAIN_MUTE, mute );
7918}
7919
7920static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
7921 unsigned int res)
7922{
7923 if ((res >> 26) != ALC880_HP_EVENT)
7924 return;
7925 alc262_hp_t5735_automute(codec, 1);
7926}
7927
7928static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
7929{
7930 alc262_hp_t5735_automute(codec, 1);
7931}
7932
7933static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
7934 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
7935 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
7936 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7937 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7939 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7940 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7945 { } /* end */
7946};
7947
7948static struct hda_verb alc262_hp_t5735_verbs[] = {
7949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7951
7952 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7953 { }
7954};
7955
Takashi Iwai0724ea22007-08-23 00:31:43 +02007956/* bind hp and internal speaker mute (with plug check) */
7957static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7958 struct snd_ctl_elem_value *ucontrol)
7959{
7960 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7961 long *valp = ucontrol->value.integer.value;
7962 int change;
7963
7964 /* change hp mute */
7965 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7966 HDA_AMP_MUTE,
7967 valp[0] ? 0 : HDA_AMP_MUTE);
7968 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE,
7970 valp[1] ? 0 : HDA_AMP_MUTE);
7971 if (change) {
7972 /* change speaker according to HP jack state */
7973 struct alc_spec *spec = codec->spec;
7974 unsigned int mute;
7975 if (spec->jack_present)
7976 mute = HDA_AMP_MUTE;
7977 else
7978 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
7979 HDA_OUTPUT, 0);
7980 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7981 HDA_AMP_MUTE, mute);
7982 }
7983 return change;
7984}
Takashi Iwai5b319542007-07-26 11:49:22 +02007985
Kailang Yang272a5272007-05-14 11:00:38 +02007986static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02007987 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7988 {
7989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7990 .name = "Master Playback Switch",
7991 .info = snd_hda_mixer_amp_switch_info,
7992 .get = snd_hda_mixer_amp_switch_get,
7993 .put = alc262_sony_master_sw_put,
7994 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7995 },
Kailang Yang272a5272007-05-14 11:00:38 +02007996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7998 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7999 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8000 { } /* end */
8001};
8002
Kailang Yang83c34212007-07-05 11:43:05 +02008003static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8010 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8011 { } /* end */
8012};
Kailang Yang272a5272007-05-14 11:00:38 +02008013
Kailang Yangdf694da2005-12-05 19:42:22 +01008014#define alc262_capture_mixer alc882_capture_mixer
8015#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8016
8017/*
8018 * generic initialization of ADC, input mixers and output mixers
8019 */
8020static struct hda_verb alc262_init_verbs[] = {
8021 /*
8022 * Unmute ADC0-2 and set the default input to mic-in
8023 */
8024 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8026 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8027 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8028 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8030
Takashi Iwaicb53c622007-08-10 17:21:45 +02008031 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008032 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008033 * Note: PASD motherboards uses the Line In 2 as the input for
8034 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008035 */
8036 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008042
8043 /*
8044 * Set up output mixers (0x0c - 0x0e)
8045 */
8046 /* set vol=0 to output mixers */
8047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8050 /* set up input amps for analog loopback */
8051 /* Amp Indices: DAC = 0, mixer = 1 */
8052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8058
8059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8062 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8063 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8064 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8065
8066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8071
8072 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8074
8075 /* FIXME: use matrix-type input source selection */
8076 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8077 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8082 /* Input mixer2 */
8083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8087 /* Input mixer3 */
8088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008092
8093 { }
8094};
8095
Kailang Yangccc656c2006-10-17 12:32:26 +02008096static struct hda_verb alc262_hippo_unsol_verbs[] = {
8097 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8099 {}
8100};
8101
8102static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8103 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8106
8107 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8109 {}
8110};
8111
Kailang Yang272a5272007-05-14 11:00:38 +02008112static struct hda_verb alc262_sony_unsol_verbs[] = {
8113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8115 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8116
8117 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8119};
8120
Kailang Yangccc656c2006-10-17 12:32:26 +02008121/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008122static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008123{
8124 struct alc_spec *spec = codec->spec;
8125 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008126 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008127
Takashi Iwai5b319542007-07-26 11:49:22 +02008128 /* need to execute and sync at first */
8129 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8130 present = snd_hda_codec_read(codec, 0x15, 0,
8131 AC_VERB_GET_PIN_SENSE, 0);
8132 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008133 if (spec->jack_present) {
8134 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008135 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8136 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008137 } else {
8138 /* unmute internal speaker if necessary */
8139 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008140 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8141 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008142 }
8143}
8144
8145/* unsolicited event for HP jack sensing */
8146static void alc262_hippo_unsol_event(struct hda_codec *codec,
8147 unsigned int res)
8148{
8149 if ((res >> 26) != ALC880_HP_EVENT)
8150 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008151 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008152}
8153
Takashi Iwai5b319542007-07-26 11:49:22 +02008154static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008155{
Kailang Yangccc656c2006-10-17 12:32:26 +02008156 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008157 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008158
Takashi Iwai5b319542007-07-26 11:49:22 +02008159 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8160 present = snd_hda_codec_read(codec, 0x1b, 0,
8161 AC_VERB_GET_PIN_SENSE, 0);
8162 present = (present & 0x80000000) != 0;
8163 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008164 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008165 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8166 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008167 } else {
8168 /* unmute internal speaker if necessary */
8169 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008170 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8171 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008172 }
8173}
8174
8175/* unsolicited event for HP jack sensing */
8176static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8177 unsigned int res)
8178{
8179 if ((res >> 26) != ALC880_HP_EVENT)
8180 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008181 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008182}
8183
Takashi Iwai834be882006-03-01 14:16:17 +01008184/*
8185 * fujitsu model
8186 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8187 */
8188
8189#define ALC_HP_EVENT 0x37
8190
8191static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8192 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8194 {}
8195};
8196
8197static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008198 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008199 .items = {
8200 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008201 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008202 { "CD", 0x4 },
8203 },
8204};
8205
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008206static struct hda_input_mux alc262_HP_capture_source = {
8207 .num_items = 5,
8208 .items = {
8209 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008210 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008211 { "Line", 0x2 },
8212 { "CD", 0x4 },
8213 { "AUX IN", 0x6 },
8214 },
8215};
8216
zhejiangaccbe492007-08-31 12:36:05 +02008217static struct hda_input_mux alc262_HP_D7000_capture_source = {
8218 .num_items = 4,
8219 .items = {
8220 { "Mic", 0x0 },
8221 { "Front Mic", 0x2 },
8222 { "Line", 0x1 },
8223 { "CD", 0x4 },
8224 },
8225};
8226
Takashi Iwai834be882006-03-01 14:16:17 +01008227/* mute/unmute internal speaker according to the hp jack and mute state */
8228static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8229{
8230 struct alc_spec *spec = codec->spec;
8231 unsigned int mute;
8232
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008233 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008234 unsigned int present;
8235 /* need to execute and sync at first */
8236 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8237 present = snd_hda_codec_read(codec, 0x14, 0,
8238 AC_VERB_GET_PIN_SENSE, 0);
8239 spec->jack_present = (present & 0x80000000) != 0;
8240 spec->sense_updated = 1;
8241 }
8242 if (spec->jack_present) {
8243 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008244 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8245 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008246 } else {
8247 /* unmute internal speaker if necessary */
8248 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008249 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8250 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008251 }
8252}
8253
8254/* unsolicited event for HP jack sensing */
8255static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8256 unsigned int res)
8257{
8258 if ((res >> 26) != ALC_HP_EVENT)
8259 return;
8260 alc262_fujitsu_automute(codec, 1);
8261}
8262
8263/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008264static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8265 .ops = &snd_hda_bind_vol,
8266 .values = {
8267 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8268 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8269 0
8270 },
8271};
Takashi Iwai834be882006-03-01 14:16:17 +01008272
8273/* bind hp and internal speaker mute (with plug check) */
8274static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8275 struct snd_ctl_elem_value *ucontrol)
8276{
8277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8278 long *valp = ucontrol->value.integer.value;
8279 int change;
8280
8281 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008282 HDA_AMP_MUTE,
8283 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008284 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008285 HDA_AMP_MUTE,
8286 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008287 if (change)
8288 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008289 return change;
8290}
8291
8292static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008293 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008294 {
8295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8296 .name = "Master Playback Switch",
8297 .info = snd_hda_mixer_amp_switch_info,
8298 .get = snd_hda_mixer_amp_switch_get,
8299 .put = alc262_fujitsu_master_sw_put,
8300 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8301 },
8302 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8303 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008307 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8308 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8309 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008310 { } /* end */
8311};
8312
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008313/* additional init verbs for Benq laptops */
8314static struct hda_verb alc262_EAPD_verbs[] = {
8315 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8316 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8317 {}
8318};
8319
Kailang Yang83c34212007-07-05 11:43:05 +02008320static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8321 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8323
8324 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8325 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8326 {}
8327};
8328
Tobin Davisf651b502007-10-26 12:40:47 +02008329/* Samsung Q1 Ultra Vista model setup */
8330static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8332 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8336 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8337 { } /* end */
8338};
8339
8340static struct hda_verb alc262_ultra_verbs[] = {
8341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8344 /* Mic is on Node 0x19 */
8345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8346 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8348 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8350 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8352 {}
8353};
8354
8355static struct hda_input_mux alc262_ultra_capture_source = {
8356 .num_items = 1,
8357 .items = {
8358 { "Mic", 0x1 },
8359 },
8360};
8361
8362/* mute/unmute internal speaker according to the hp jack and mute state */
8363static void alc262_ultra_automute(struct hda_codec *codec)
8364{
8365 struct alc_spec *spec = codec->spec;
8366 unsigned int mute;
8367 unsigned int present;
8368
8369 /* need to execute and sync at first */
8370 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8371 present = snd_hda_codec_read(codec, 0x15, 0,
8372 AC_VERB_GET_PIN_SENSE, 0);
8373 spec->jack_present = (present & 0x80000000) != 0;
8374 if (spec->jack_present) {
8375 /* mute internal speaker */
8376 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8377 HDA_AMP_MUTE, HDA_AMP_MUTE);
8378 } else {
8379 /* unmute internal speaker if necessary */
8380 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8381 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8382 HDA_AMP_MUTE, mute);
8383 }
8384}
8385
8386/* unsolicited event for HP jack sensing */
8387static void alc262_ultra_unsol_event(struct hda_codec *codec,
8388 unsigned int res)
8389{
8390 if ((res >> 26) != ALC880_HP_EVENT)
8391 return;
8392 alc262_ultra_automute(codec);
8393}
8394
Kailang Yangdf694da2005-12-05 19:42:22 +01008395/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008396static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8397 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008398{
8399 hda_nid_t nid;
8400 int err;
8401
8402 spec->multiout.num_dacs = 1; /* only use one dac */
8403 spec->multiout.dac_nids = spec->private_dac_nids;
8404 spec->multiout.dac_nids[0] = 2;
8405
8406 nid = cfg->line_out_pins[0];
8407 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008408 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8409 "Front Playback Volume",
8410 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8411 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008412 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8414 "Front Playback Switch",
8415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8416 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008417 return err;
8418 }
8419
Takashi Iwai82bc9552006-03-21 11:24:42 +01008420 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008421 if (nid) {
8422 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008423 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8424 "Speaker Playback Volume",
8425 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8426 HDA_OUTPUT));
8427 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008428 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008429 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8430 "Speaker Playback Switch",
8431 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8432 HDA_OUTPUT));
8433 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008434 return err;
8435 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008436 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8437 "Speaker Playback Switch",
8438 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8439 HDA_OUTPUT));
8440 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008441 return err;
8442 }
8443 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008444 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008445 if (nid) {
8446 /* spec->multiout.hp_nid = 2; */
8447 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008448 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8449 "Headphone Playback Volume",
8450 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8451 HDA_OUTPUT));
8452 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008453 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008454 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8455 "Headphone Playback Switch",
8456 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8457 HDA_OUTPUT));
8458 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008459 return err;
8460 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008461 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8462 "Headphone Playback Switch",
8463 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8464 HDA_OUTPUT));
8465 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008466 return err;
8467 }
8468 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008469 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008470}
8471
8472/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008473#define alc262_auto_create_analog_input_ctls \
8474 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008475
8476/*
8477 * generic initialization of ADC, input mixers and output mixers
8478 */
8479static struct hda_verb alc262_volume_init_verbs[] = {
8480 /*
8481 * Unmute ADC0-2 and set the default input to mic-in
8482 */
8483 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8485 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8487 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8489
Takashi Iwaicb53c622007-08-10 17:21:45 +02008490 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008491 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008492 * Note: PASD motherboards uses the Line In 2 as the input for
8493 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008494 */
8495 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008501
8502 /*
8503 * Set up output mixers (0x0c - 0x0f)
8504 */
8505 /* set vol=0 to output mixers */
8506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8509
8510 /* set up input amps for analog loopback */
8511 /* Amp Indices: DAC = 0, mixer = 1 */
8512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8515 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8518
8519 /* FIXME: use matrix-type input source selection */
8520 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8521 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8526 /* Input mixer2 */
8527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8531 /* Input mixer3 */
8532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8536
8537 { }
8538};
8539
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008540static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8541 /*
8542 * Unmute ADC0-2 and set the default input to mic-in
8543 */
8544 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8548 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8550
Takashi Iwaicb53c622007-08-10 17:21:45 +02008551 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008552 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008553 * Note: PASD motherboards uses the Line In 2 as the input for
8554 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008555 */
8556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008564
8565 /*
8566 * Set up output mixers (0x0c - 0x0e)
8567 */
8568 /* set vol=0 to output mixers */
8569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8570 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8572
8573 /* set up input amps for analog loopback */
8574 /* Amp Indices: DAC = 0, mixer = 1 */
8575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8577 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8579 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8581
8582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8585
8586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8588
8589 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8591
8592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8594 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8596 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8597
8598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8602 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8603 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8604
8605
8606 /* FIXME: use matrix-type input source selection */
8607 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8613 /* Input mixer2 */
8614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8618 /* Input mixer3 */
8619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8623
8624 { }
8625};
8626
Kailang Yangcd7509a2007-01-26 18:33:17 +01008627static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8628 /*
8629 * Unmute ADC0-2 and set the default input to mic-in
8630 */
8631 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8633 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8635 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8637
Takashi Iwaicb53c622007-08-10 17:21:45 +02008638 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008639 * mixer widget
8640 * Note: PASD motherboards uses the Line In 2 as the input for front
8641 * panel mic (mic 2)
8642 */
8643 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008652 /*
8653 * Set up output mixers (0x0c - 0x0e)
8654 */
8655 /* set vol=0 to output mixers */
8656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8659
8660 /* set up input amps for analog loopback */
8661 /* Amp Indices: DAC = 0, mixer = 1 */
8662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8668
8669
8670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8671 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8672 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8673 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8674 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8677
8678 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8680
8681 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8683
8684 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8686 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8688 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8689 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8690
8691 /* FIXME: use matrix-type input source selection */
8692 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8693 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8699 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8701 /* Input mixer2 */
8702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8707 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8709 /* Input mixer3 */
8710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8715 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8717
8718 { }
8719};
8720
Takashi Iwaicb53c622007-08-10 17:21:45 +02008721#ifdef CONFIG_SND_HDA_POWER_SAVE
8722#define alc262_loopbacks alc880_loopbacks
8723#endif
8724
Kailang Yangdf694da2005-12-05 19:42:22 +01008725/* pcm configuration: identiacal with ALC880 */
8726#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8727#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8728#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8729#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8730
8731/*
8732 * BIOS auto configuration
8733 */
8734static int alc262_parse_auto_config(struct hda_codec *codec)
8735{
8736 struct alc_spec *spec = codec->spec;
8737 int err;
8738 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8739
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008740 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8741 alc262_ignore);
8742 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008743 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008744 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008745 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008746 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8747 if (err < 0)
8748 return err;
8749 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8750 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008751 return err;
8752
8753 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8754
8755 if (spec->autocfg.dig_out_pin)
8756 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8757 if (spec->autocfg.dig_in_pin)
8758 spec->dig_in_nid = ALC262_DIGIN_NID;
8759
8760 if (spec->kctl_alloc)
8761 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8762
8763 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008764 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008765 spec->input_mux = &spec->private_imux;
8766
Takashi Iwai776e1842007-08-29 15:07:11 +02008767 err = alc_auto_add_mic_boost(codec);
8768 if (err < 0)
8769 return err;
8770
Kailang Yangdf694da2005-12-05 19:42:22 +01008771 return 1;
8772}
8773
8774#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8775#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8776#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8777
8778
8779/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008780static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008781{
Kailang Yangdf694da2005-12-05 19:42:22 +01008782 alc262_auto_init_multi_out(codec);
8783 alc262_auto_init_hp_out(codec);
8784 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008785}
8786
8787/*
8788 * configuration and preset
8789 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008790static const char *alc262_models[ALC262_MODEL_LAST] = {
8791 [ALC262_BASIC] = "basic",
8792 [ALC262_HIPPO] = "hippo",
8793 [ALC262_HIPPO_1] = "hippo_1",
8794 [ALC262_FUJITSU] = "fujitsu",
8795 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008796 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01008797 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008798 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008799 [ALC262_BENQ_T31] = "benq-t31",
8800 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02008801 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008802 [ALC262_AUTO] = "auto",
8803};
8804
8805static struct snd_pci_quirk alc262_cfg_tbl[] = {
8806 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8807 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008808 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008809 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8810 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008811 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008812 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008813 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01008814 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008815 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008816 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008817 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008818 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008819 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008820 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008821 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008822 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008823 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8824 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8825 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008826 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
8827 ALC262_HP_TC_T5735),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008828 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008829 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008830 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8831 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8832 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008833 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008834 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008835 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02008836 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008837 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01008838 {}
8839};
8840
8841static struct alc_config_preset alc262_presets[] = {
8842 [ALC262_BASIC] = {
8843 .mixers = { alc262_base_mixer },
8844 .init_verbs = { alc262_init_verbs },
8845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8846 .dac_nids = alc262_dac_nids,
8847 .hp_nid = 0x03,
8848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8849 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01008850 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008851 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008852 [ALC262_HIPPO] = {
8853 .mixers = { alc262_base_mixer },
8854 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8855 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8856 .dac_nids = alc262_dac_nids,
8857 .hp_nid = 0x03,
8858 .dig_out_nid = ALC262_DIGOUT_NID,
8859 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8860 .channel_mode = alc262_modes,
8861 .input_mux = &alc262_capture_source,
8862 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008863 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008864 },
8865 [ALC262_HIPPO_1] = {
8866 .mixers = { alc262_hippo1_mixer },
8867 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8869 .dac_nids = alc262_dac_nids,
8870 .hp_nid = 0x02,
8871 .dig_out_nid = ALC262_DIGOUT_NID,
8872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8873 .channel_mode = alc262_modes,
8874 .input_mux = &alc262_capture_source,
8875 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008876 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008877 },
Takashi Iwai834be882006-03-01 14:16:17 +01008878 [ALC262_FUJITSU] = {
8879 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008880 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
8881 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01008882 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8883 .dac_nids = alc262_dac_nids,
8884 .hp_nid = 0x03,
8885 .dig_out_nid = ALC262_DIGOUT_NID,
8886 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8887 .channel_mode = alc262_modes,
8888 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008889 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008890 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008891 [ALC262_HP_BPC] = {
8892 .mixers = { alc262_HP_BPC_mixer },
8893 .init_verbs = { alc262_HP_BPC_init_verbs },
8894 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8895 .dac_nids = alc262_dac_nids,
8896 .hp_nid = 0x03,
8897 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8898 .channel_mode = alc262_modes,
8899 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008900 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008901 [ALC262_HP_BPC_D7000_WF] = {
8902 .mixers = { alc262_HP_BPC_WildWest_mixer },
8903 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8904 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8905 .dac_nids = alc262_dac_nids,
8906 .hp_nid = 0x03,
8907 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8908 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008909 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008910 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008911 [ALC262_HP_BPC_D7000_WL] = {
8912 .mixers = { alc262_HP_BPC_WildWest_mixer,
8913 alc262_HP_BPC_WildWest_option_mixer },
8914 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8915 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8916 .dac_nids = alc262_dac_nids,
8917 .hp_nid = 0x03,
8918 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8919 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008920 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008921 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008922 [ALC262_HP_TC_T5735] = {
8923 .mixers = { alc262_hp_t5735_mixer },
8924 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
8925 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8926 .dac_nids = alc262_dac_nids,
8927 .hp_nid = 0x03,
8928 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8929 .channel_mode = alc262_modes,
8930 .input_mux = &alc262_capture_source,
8931 .unsol_event = alc262_hp_t5735_unsol_event,
8932 .init_hook = alc262_hp_t5735_init_hook,
8933 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008934 [ALC262_BENQ_ED8] = {
8935 .mixers = { alc262_base_mixer },
8936 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8937 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8938 .dac_nids = alc262_dac_nids,
8939 .hp_nid = 0x03,
8940 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8941 .channel_mode = alc262_modes,
8942 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008943 },
Kailang Yang272a5272007-05-14 11:00:38 +02008944 [ALC262_SONY_ASSAMD] = {
8945 .mixers = { alc262_sony_mixer },
8946 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8947 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8948 .dac_nids = alc262_dac_nids,
8949 .hp_nid = 0x02,
8950 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8951 .channel_mode = alc262_modes,
8952 .input_mux = &alc262_capture_source,
8953 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008954 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008955 },
8956 [ALC262_BENQ_T31] = {
8957 .mixers = { alc262_benq_t31_mixer },
8958 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8959 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8960 .dac_nids = alc262_dac_nids,
8961 .hp_nid = 0x03,
8962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8963 .channel_mode = alc262_modes,
8964 .input_mux = &alc262_capture_source,
8965 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008966 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008967 },
Tobin Davisf651b502007-10-26 12:40:47 +02008968 [ALC262_ULTRA] = {
8969 .mixers = { alc262_ultra_mixer },
8970 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
8971 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8972 .dac_nids = alc262_dac_nids,
8973 .hp_nid = 0x03,
8974 .dig_out_nid = ALC262_DIGOUT_NID,
8975 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8976 .channel_mode = alc262_modes,
8977 .input_mux = &alc262_ultra_capture_source,
8978 .unsol_event = alc262_ultra_unsol_event,
8979 .init_hook = alc262_ultra_automute,
8980 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008981};
8982
8983static int patch_alc262(struct hda_codec *codec)
8984{
8985 struct alc_spec *spec;
8986 int board_config;
8987 int err;
8988
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008989 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008990 if (spec == NULL)
8991 return -ENOMEM;
8992
8993 codec->spec = spec;
8994#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008995 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8996 * under-run
8997 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008998 {
8999 int tmp;
9000 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9001 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9002 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9003 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9004 }
9005#endif
9006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009007 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9008 alc262_models,
9009 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009010
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009011 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009012 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9013 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009014 board_config = ALC262_AUTO;
9015 }
9016
9017 if (board_config == ALC262_AUTO) {
9018 /* automatic parse from the BIOS config */
9019 err = alc262_parse_auto_config(codec);
9020 if (err < 0) {
9021 alc_free(codec);
9022 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009023 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009024 printk(KERN_INFO
9025 "hda_codec: Cannot set up configuration "
9026 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009027 board_config = ALC262_BASIC;
9028 }
9029 }
9030
9031 if (board_config != ALC262_AUTO)
9032 setup_preset(spec, &alc262_presets[board_config]);
9033
9034 spec->stream_name_analog = "ALC262 Analog";
9035 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9036 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9037
9038 spec->stream_name_digital = "ALC262 Digital";
9039 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9040 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009042 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009043 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009044 unsigned int wcap = get_wcaps(codec, 0x07);
9045
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009046 /* get type */
9047 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009048 if (wcap != AC_WID_AUD_IN) {
9049 spec->adc_nids = alc262_adc_nids_alt;
9050 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009051 spec->mixers[spec->num_mixers] =
9052 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009053 spec->num_mixers++;
9054 } else {
9055 spec->adc_nids = alc262_adc_nids;
9056 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9057 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9058 spec->num_mixers++;
9059 }
9060 }
9061
9062 codec->patch_ops = alc_patch_ops;
9063 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009064 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009065#ifdef CONFIG_SND_HDA_POWER_SAVE
9066 if (!spec->loopback.amplist)
9067 spec->loopback.amplist = alc262_loopbacks;
9068#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009069
Kailang Yangdf694da2005-12-05 19:42:22 +01009070 return 0;
9071}
9072
Kailang Yangdf694da2005-12-05 19:42:22 +01009073/*
Kailang Yanga361d842007-06-05 12:30:55 +02009074 * ALC268 channel source setting (2 channel)
9075 */
9076#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9077#define alc268_modes alc260_modes
9078
9079static hda_nid_t alc268_dac_nids[2] = {
9080 /* front, hp */
9081 0x02, 0x03
9082};
9083
9084static hda_nid_t alc268_adc_nids[2] = {
9085 /* ADC0-1 */
9086 0x08, 0x07
9087};
9088
9089static hda_nid_t alc268_adc_nids_alt[1] = {
9090 /* ADC0 */
9091 0x08
9092};
9093
9094static struct snd_kcontrol_new alc268_base_mixer[] = {
9095 /* output mixer control */
9096 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9097 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9102 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009103 { }
9104};
9105
Kailang Yangd1a991a2007-08-15 16:21:59 +02009106static struct hda_verb alc268_eapd_verbs[] = {
9107 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9108 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9109 { }
9110};
9111
Takashi Iwaid2738092007-08-16 14:59:45 +02009112/* Toshiba specific */
9113#define alc268_toshiba_automute alc262_hippo_automute
9114
9115static struct hda_verb alc268_toshiba_verbs[] = {
9116 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9117 { } /* end */
9118};
9119
9120/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009121/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009122static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9123 .ops = &snd_hda_bind_vol,
9124 .values = {
9125 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9126 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9127 0
9128 },
9129};
9130
Takashi Iwai889c4392007-08-23 18:56:52 +02009131/* mute/unmute internal speaker according to the hp jack and mute state */
9132static void alc268_acer_automute(struct hda_codec *codec, int force)
9133{
9134 struct alc_spec *spec = codec->spec;
9135 unsigned int mute;
9136
9137 if (force || !spec->sense_updated) {
9138 unsigned int present;
9139 present = snd_hda_codec_read(codec, 0x14, 0,
9140 AC_VERB_GET_PIN_SENSE, 0);
9141 spec->jack_present = (present & 0x80000000) != 0;
9142 spec->sense_updated = 1;
9143 }
9144 if (spec->jack_present)
9145 mute = HDA_AMP_MUTE; /* mute internal speaker */
9146 else /* unmute internal speaker if necessary */
9147 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9148 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9149 HDA_AMP_MUTE, mute);
9150}
9151
9152
9153/* bind hp and internal speaker mute (with plug check) */
9154static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9155 struct snd_ctl_elem_value *ucontrol)
9156{
9157 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9158 long *valp = ucontrol->value.integer.value;
9159 int change;
9160
9161 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9162 HDA_AMP_MUTE,
9163 valp[0] ? 0 : HDA_AMP_MUTE);
9164 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9165 HDA_AMP_MUTE,
9166 valp[1] ? 0 : HDA_AMP_MUTE);
9167 if (change)
9168 alc268_acer_automute(codec, 0);
9169 return change;
9170}
Takashi Iwaid2738092007-08-16 14:59:45 +02009171
9172static struct snd_kcontrol_new alc268_acer_mixer[] = {
9173 /* output mixer control */
9174 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9175 {
9176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9177 .name = "Master Playback Switch",
9178 .info = snd_hda_mixer_amp_switch_info,
9179 .get = snd_hda_mixer_amp_switch_get,
9180 .put = alc268_acer_master_sw_put,
9181 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9182 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009183 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9184 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9185 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009186 { }
9187};
9188
9189static struct hda_verb alc268_acer_verbs[] = {
9190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9192
9193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9194 { }
9195};
9196
9197/* unsolicited event for HP jack sensing */
9198static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9199 unsigned int res)
9200{
Takashi Iwai889c4392007-08-23 18:56:52 +02009201 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009202 return;
9203 alc268_toshiba_automute(codec);
9204}
9205
9206static void alc268_acer_unsol_event(struct hda_codec *codec,
9207 unsigned int res)
9208{
Takashi Iwai889c4392007-08-23 18:56:52 +02009209 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009210 return;
9211 alc268_acer_automute(codec, 1);
9212}
9213
Takashi Iwai889c4392007-08-23 18:56:52 +02009214static void alc268_acer_init_hook(struct hda_codec *codec)
9215{
9216 alc268_acer_automute(codec, 1);
9217}
9218
Kailang Yanga361d842007-06-05 12:30:55 +02009219/*
9220 * generic initialization of ADC, input mixers and output mixers
9221 */
9222static struct hda_verb alc268_base_init_verbs[] = {
9223 /* Unmute DAC0-1 and set vol = 0 */
9224 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9225 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9226 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9227 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9229 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9230
9231 /*
9232 * Set up output mixers (0x0c - 0x0e)
9233 */
9234 /* set vol=0 to output mixers */
9235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9238 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9239
9240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9241 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242
9243 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9245 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9246 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9247 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9249 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9250 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9251
9252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9256 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9258 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9259 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9260
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009261 /* Unmute Selector 23h,24h and set the default input to mic-in */
9262
9263 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9264 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9265 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009267
Kailang Yanga361d842007-06-05 12:30:55 +02009268 { }
9269};
9270
9271/*
9272 * generic initialization of ADC, input mixers and output mixers
9273 */
9274static struct hda_verb alc268_volume_init_verbs[] = {
9275 /* set output DAC */
9276 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9277 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9278 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9279 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9280
9281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9284 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9285 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9286
9287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9291 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9292
9293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9296 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9297
9298 /* set PCBEEP vol = 0 */
9299 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9300
9301 { }
9302};
9303
9304#define alc268_mux_enum_info alc_mux_enum_info
9305#define alc268_mux_enum_get alc_mux_enum_get
9306
9307static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9308 struct snd_ctl_elem_value *ucontrol)
9309{
9310 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9311 struct alc_spec *spec = codec->spec;
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009312
Kailang Yanga361d842007-06-05 12:30:55 +02009313 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9314 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9315 hda_nid_t nid = capture_mixers[adc_idx];
Kailang Yanga361d842007-06-05 12:30:55 +02009316
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009317 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9318 nid,
9319 &spec->cur_mux[adc_idx]);
Kailang Yanga361d842007-06-05 12:30:55 +02009320}
9321
9322static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9323 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9324 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9325 {
9326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9327 /* The multiple "Capture Source" controls confuse alsamixer
9328 * So call somewhat different..
9329 * FIXME: the controls appear in the "playback" view!
9330 */
9331 /* .name = "Capture Source", */
9332 .name = "Input Source",
9333 .count = 1,
9334 .info = alc268_mux_enum_info,
9335 .get = alc268_mux_enum_get,
9336 .put = alc268_mux_enum_put,
9337 },
9338 { } /* end */
9339};
9340
9341static struct snd_kcontrol_new alc268_capture_mixer[] = {
9342 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9343 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9344 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9345 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9346 {
9347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9348 /* The multiple "Capture Source" controls confuse alsamixer
9349 * So call somewhat different..
9350 * FIXME: the controls appear in the "playback" view!
9351 */
9352 /* .name = "Capture Source", */
9353 .name = "Input Source",
9354 .count = 2,
9355 .info = alc268_mux_enum_info,
9356 .get = alc268_mux_enum_get,
9357 .put = alc268_mux_enum_put,
9358 },
9359 { } /* end */
9360};
9361
9362static struct hda_input_mux alc268_capture_source = {
9363 .num_items = 4,
9364 .items = {
9365 { "Mic", 0x0 },
9366 { "Front Mic", 0x1 },
9367 { "Line", 0x2 },
9368 { "CD", 0x3 },
9369 },
9370};
9371
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009372#ifdef CONFIG_SND_DEBUG
9373static struct snd_kcontrol_new alc268_test_mixer[] = {
9374 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9375 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9376 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9378
9379 /* Volume widgets */
9380 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9381 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9382 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9383 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9384 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9385 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9386 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9387 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9388 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9389 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9390 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9391 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9392 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9393 HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),
9394 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9395 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9396 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9397 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9398
9399 /* Modes for retasking pin widgets */
9400 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9401 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9402 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9403 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9404
9405 /* Controls for GPIO pins, assuming they are configured as outputs */
9406 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9407 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9408 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9409 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9410
9411 /* Switches to allow the digital SPDIF output pin to be enabled.
9412 * The ALC268 does not have an SPDIF input.
9413 */
9414 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9415
9416 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9417 * this output to turn on an external amplifier.
9418 */
9419 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9420 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9421
9422 { } /* end */
9423};
9424#endif
9425
Kailang Yanga361d842007-06-05 12:30:55 +02009426/* create input playback/capture controls for the given pin */
9427static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9428 const char *ctlname, int idx)
9429{
9430 char name[32];
9431 int err;
9432
9433 sprintf(name, "%s Playback Volume", ctlname);
9434 if (nid == 0x14) {
9435 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9436 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9437 HDA_OUTPUT));
9438 if (err < 0)
9439 return err;
9440 } else if (nid == 0x15) {
9441 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9442 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9443 HDA_OUTPUT));
9444 if (err < 0)
9445 return err;
9446 } else
9447 return -1;
9448 sprintf(name, "%s Playback Switch", ctlname);
9449 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9450 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9451 if (err < 0)
9452 return err;
9453 return 0;
9454}
9455
9456/* add playback controls from the parsed DAC table */
9457static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9458 const struct auto_pin_cfg *cfg)
9459{
9460 hda_nid_t nid;
9461 int err;
9462
9463 spec->multiout.num_dacs = 2; /* only use one dac */
9464 spec->multiout.dac_nids = spec->private_dac_nids;
9465 spec->multiout.dac_nids[0] = 2;
9466 spec->multiout.dac_nids[1] = 3;
9467
9468 nid = cfg->line_out_pins[0];
9469 if (nid)
9470 alc268_new_analog_output(spec, nid, "Front", 0);
9471
9472 nid = cfg->speaker_pins[0];
9473 if (nid == 0x1d) {
9474 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9475 "Speaker Playback Volume",
9476 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9477 if (err < 0)
9478 return err;
9479 }
9480 nid = cfg->hp_pins[0];
9481 if (nid)
9482 alc268_new_analog_output(spec, nid, "Headphone", 0);
9483
9484 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9485 if (nid == 0x16) {
9486 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9487 "Mono Playback Switch",
9488 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9489 if (err < 0)
9490 return err;
9491 }
9492 return 0;
9493}
9494
9495/* create playback/capture controls for input pins */
9496static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9497 const struct auto_pin_cfg *cfg)
9498{
9499 struct hda_input_mux *imux = &spec->private_imux;
9500 int i, idx1;
9501
9502 for (i = 0; i < AUTO_PIN_LAST; i++) {
9503 switch(cfg->input_pins[i]) {
9504 case 0x18:
9505 idx1 = 0; /* Mic 1 */
9506 break;
9507 case 0x19:
9508 idx1 = 1; /* Mic 2 */
9509 break;
9510 case 0x1a:
9511 idx1 = 2; /* Line In */
9512 break;
9513 case 0x1c:
9514 idx1 = 3; /* CD */
9515 break;
9516 default:
9517 continue;
9518 }
9519 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9520 imux->items[imux->num_items].index = idx1;
9521 imux->num_items++;
9522 }
9523 return 0;
9524}
9525
9526static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9527{
9528 struct alc_spec *spec = codec->spec;
9529 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9530 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9531 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9532 unsigned int dac_vol1, dac_vol2;
9533
9534 if (speaker_nid) {
9535 snd_hda_codec_write(codec, speaker_nid, 0,
9536 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9537 snd_hda_codec_write(codec, 0x0f, 0,
9538 AC_VERB_SET_AMP_GAIN_MUTE,
9539 AMP_IN_UNMUTE(1));
9540 snd_hda_codec_write(codec, 0x10, 0,
9541 AC_VERB_SET_AMP_GAIN_MUTE,
9542 AMP_IN_UNMUTE(1));
9543 } else {
9544 snd_hda_codec_write(codec, 0x0f, 0,
9545 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9546 snd_hda_codec_write(codec, 0x10, 0,
9547 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9548 }
9549
9550 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9551 if (line_nid == 0x14)
9552 dac_vol2 = AMP_OUT_ZERO;
9553 else if (line_nid == 0x15)
9554 dac_vol1 = AMP_OUT_ZERO;
9555 if (hp_nid == 0x14)
9556 dac_vol2 = AMP_OUT_ZERO;
9557 else if (hp_nid == 0x15)
9558 dac_vol1 = AMP_OUT_ZERO;
9559 if (line_nid != 0x16 || hp_nid != 0x16 ||
9560 spec->autocfg.line_out_pins[1] != 0x16 ||
9561 spec->autocfg.line_out_pins[2] != 0x16)
9562 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9563
9564 snd_hda_codec_write(codec, 0x02, 0,
9565 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9566 snd_hda_codec_write(codec, 0x03, 0,
9567 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9568}
9569
9570/* pcm configuration: identiacal with ALC880 */
9571#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9572#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9573#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9574
9575/*
9576 * BIOS auto configuration
9577 */
9578static int alc268_parse_auto_config(struct hda_codec *codec)
9579{
9580 struct alc_spec *spec = codec->spec;
9581 int err;
9582 static hda_nid_t alc268_ignore[] = { 0 };
9583
9584 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9585 alc268_ignore);
9586 if (err < 0)
9587 return err;
9588 if (!spec->autocfg.line_outs)
9589 return 0; /* can't find valid BIOS pin config */
9590
9591 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9592 if (err < 0)
9593 return err;
9594 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9595 if (err < 0)
9596 return err;
9597
9598 spec->multiout.max_channels = 2;
9599
9600 /* digital only support output */
9601 if (spec->autocfg.dig_out_pin)
9602 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9603
9604 if (spec->kctl_alloc)
9605 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9606
9607 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9608 spec->num_mux_defs = 1;
9609 spec->input_mux = &spec->private_imux;
9610
Takashi Iwai776e1842007-08-29 15:07:11 +02009611 err = alc_auto_add_mic_boost(codec);
9612 if (err < 0)
9613 return err;
9614
Kailang Yanga361d842007-06-05 12:30:55 +02009615 return 1;
9616}
9617
9618#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9619#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9620#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9621
9622/* init callback for auto-configuration model -- overriding the default init */
9623static void alc268_auto_init(struct hda_codec *codec)
9624{
9625 alc268_auto_init_multi_out(codec);
9626 alc268_auto_init_hp_out(codec);
9627 alc268_auto_init_mono_speaker_out(codec);
9628 alc268_auto_init_analog_input(codec);
9629}
9630
9631/*
9632 * configuration and preset
9633 */
9634static const char *alc268_models[ALC268_MODEL_LAST] = {
9635 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009636 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009637 [ALC268_ACER] = "acer",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009638#ifdef CONFIG_SND_DEBUG
9639 [ALC268_TEST] = "test",
9640#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009641 [ALC268_AUTO] = "auto",
9642};
9643
9644static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009645 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9646 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9647 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +02009648 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009649 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009650 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009651 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009652 {}
9653};
9654
9655static struct alc_config_preset alc268_presets[] = {
9656 [ALC268_3ST] = {
9657 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9658 .init_verbs = { alc268_base_init_verbs },
9659 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9660 .dac_nids = alc268_dac_nids,
9661 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9662 .adc_nids = alc268_adc_nids_alt,
9663 .hp_nid = 0x03,
9664 .dig_out_nid = ALC268_DIGOUT_NID,
9665 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9666 .channel_mode = alc268_modes,
9667 .input_mux = &alc268_capture_source,
9668 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009669 [ALC268_TOSHIBA] = {
9670 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009671 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9672 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009673 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9674 .dac_nids = alc268_dac_nids,
9675 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9676 .adc_nids = alc268_adc_nids_alt,
9677 .hp_nid = 0x03,
9678 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9679 .channel_mode = alc268_modes,
9680 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009681 .unsol_event = alc268_toshiba_unsol_event,
9682 .init_hook = alc268_toshiba_automute,
9683 },
9684 [ALC268_ACER] = {
9685 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9686 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9687 alc268_acer_verbs },
9688 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9689 .dac_nids = alc268_dac_nids,
9690 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9691 .adc_nids = alc268_adc_nids_alt,
9692 .hp_nid = 0x02,
9693 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9694 .channel_mode = alc268_modes,
9695 .input_mux = &alc268_capture_source,
9696 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009697 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009698 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009699#ifdef CONFIG_SND_DEBUG
9700 [ALC268_TEST] = {
9701 .mixers = { alc268_test_mixer, alc268_capture_mixer },
9702 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9703 alc268_volume_init_verbs },
9704 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9705 .dac_nids = alc268_dac_nids,
9706 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9707 .adc_nids = alc268_adc_nids_alt,
9708 .hp_nid = 0x03,
9709 .dig_out_nid = ALC268_DIGOUT_NID,
9710 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9711 .channel_mode = alc268_modes,
9712 .input_mux = &alc268_capture_source,
9713 },
9714#endif
Kailang Yanga361d842007-06-05 12:30:55 +02009715};
9716
9717static int patch_alc268(struct hda_codec *codec)
9718{
9719 struct alc_spec *spec;
9720 int board_config;
9721 int err;
9722
9723 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9724 if (spec == NULL)
9725 return -ENOMEM;
9726
9727 codec->spec = spec;
9728
9729 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9730 alc268_models,
9731 alc268_cfg_tbl);
9732
9733 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9734 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9735 "trying auto-probe from BIOS...\n");
9736 board_config = ALC268_AUTO;
9737 }
9738
9739 if (board_config == ALC268_AUTO) {
9740 /* automatic parse from the BIOS config */
9741 err = alc268_parse_auto_config(codec);
9742 if (err < 0) {
9743 alc_free(codec);
9744 return err;
9745 } else if (!err) {
9746 printk(KERN_INFO
9747 "hda_codec: Cannot set up configuration "
9748 "from BIOS. Using base mode...\n");
9749 board_config = ALC268_3ST;
9750 }
9751 }
9752
9753 if (board_config != ALC268_AUTO)
9754 setup_preset(spec, &alc268_presets[board_config]);
9755
9756 spec->stream_name_analog = "ALC268 Analog";
9757 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9758 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9759
9760 spec->stream_name_digital = "ALC268 Digital";
9761 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9762
9763 if (board_config == ALC268_AUTO) {
9764 if (!spec->adc_nids && spec->input_mux) {
9765 /* check whether NID 0x07 is valid */
9766 unsigned int wcap = get_wcaps(codec, 0x07);
9767
9768 /* get type */
9769 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9770 if (wcap != AC_WID_AUD_IN) {
9771 spec->adc_nids = alc268_adc_nids_alt;
9772 spec->num_adc_nids =
9773 ARRAY_SIZE(alc268_adc_nids_alt);
9774 spec->mixers[spec->num_mixers] =
9775 alc268_capture_alt_mixer;
9776 spec->num_mixers++;
9777 } else {
9778 spec->adc_nids = alc268_adc_nids;
9779 spec->num_adc_nids =
9780 ARRAY_SIZE(alc268_adc_nids);
9781 spec->mixers[spec->num_mixers] =
9782 alc268_capture_mixer;
9783 spec->num_mixers++;
9784 }
9785 }
9786 }
9787 codec->patch_ops = alc_patch_ops;
9788 if (board_config == ALC268_AUTO)
9789 spec->init_hook = alc268_auto_init;
9790
9791 return 0;
9792}
9793
9794/*
Kailang Yangf6a92242007-12-13 16:52:54 +01009795 * ALC269 channel source setting (2 channel)
9796 */
9797#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
9798
9799#define alc269_dac_nids alc260_dac_nids
9800
9801static hda_nid_t alc269_adc_nids[1] = {
9802 /* ADC1 */
9803 0x07,
9804};
9805
9806#define alc269_modes alc260_modes
9807#define alc269_capture_source alc880_lg_lw_capture_source
9808
9809static struct snd_kcontrol_new alc269_base_mixer[] = {
9810 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9812 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9813 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9817 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9818 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9819 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9821 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9822 { } /* end */
9823};
9824
9825/* capture mixer elements */
9826static struct snd_kcontrol_new alc269_capture_mixer[] = {
9827 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9828 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9829 {
9830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9831 /* The multiple "Capture Source" controls confuse alsamixer
9832 * So call somewhat different..
9833 * FIXME: the controls appear in the "playback" view!
9834 */
9835 /* .name = "Capture Source", */
9836 .name = "Input Source",
9837 .count = 1,
9838 .info = alc_mux_enum_info,
9839 .get = alc_mux_enum_get,
9840 .put = alc_mux_enum_put,
9841 },
9842 { } /* end */
9843};
9844
9845/*
9846 * generic initialization of ADC, input mixers and output mixers
9847 */
9848static struct hda_verb alc269_init_verbs[] = {
9849 /*
9850 * Unmute ADC0 and set the default input to mic-in
9851 */
9852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9853
9854 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
9855 * analog-loopback mixer widget
9856 * Note: PASD motherboards uses the Line In 2 as the input for
9857 * front panel mic (mic 2)
9858 */
9859 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9865
9866 /*
9867 * Set up output mixers (0x0c - 0x0e)
9868 */
9869 /* set vol=0 to output mixers */
9870 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9871 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9872
9873 /* set up input amps for analog loopback */
9874 /* Amp Indices: DAC = 0, mixer = 1 */
9875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9881
9882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9884 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9887 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9888 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9889
9890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9892 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9896 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9897
9898 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9900
9901 /* FIXME: use matrix-type input source selection */
9902 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
9903 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9908
9909 /* set EAPD */
9910 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9911 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9912 { }
9913};
9914
9915/* add playback controls from the parsed DAC table */
9916static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
9917 const struct auto_pin_cfg *cfg)
9918{
9919 hda_nid_t nid;
9920 int err;
9921
9922 spec->multiout.num_dacs = 1; /* only use one dac */
9923 spec->multiout.dac_nids = spec->private_dac_nids;
9924 spec->multiout.dac_nids[0] = 2;
9925
9926 nid = cfg->line_out_pins[0];
9927 if (nid) {
9928 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9929 "Front Playback Volume",
9930 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
9931 if (err < 0)
9932 return err;
9933 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9934 "Front Playback Switch",
9935 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9936 if (err < 0)
9937 return err;
9938 }
9939
9940 nid = cfg->speaker_pins[0];
9941 if (nid) {
9942 if (!cfg->line_out_pins[0]) {
9943 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9944 "Speaker Playback Volume",
9945 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
9946 HDA_OUTPUT));
9947 if (err < 0)
9948 return err;
9949 }
9950 if (nid == 0x16) {
9951 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9952 "Speaker Playback Switch",
9953 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9954 HDA_OUTPUT));
9955 if (err < 0)
9956 return err;
9957 } else {
9958 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9959 "Speaker Playback Switch",
9960 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9961 HDA_OUTPUT));
9962 if (err < 0)
9963 return err;
9964 }
9965 }
9966 nid = cfg->hp_pins[0];
9967 if (nid) {
9968 /* spec->multiout.hp_nid = 2; */
9969 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
9970 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9971 "Headphone Playback Volume",
9972 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
9973 HDA_OUTPUT));
9974 if (err < 0)
9975 return err;
9976 }
9977 if (nid == 0x16) {
9978 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9979 "Headphone Playback Switch",
9980 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9981 HDA_OUTPUT));
9982 if (err < 0)
9983 return err;
9984 } else {
9985 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9986 "Headphone Playback Switch",
9987 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9988 HDA_OUTPUT));
9989 if (err < 0)
9990 return err;
9991 }
9992 }
9993 return 0;
9994}
9995
9996#define alc269_auto_create_analog_input_ctls \
9997 alc880_auto_create_analog_input_ctls
9998
9999#ifdef CONFIG_SND_HDA_POWER_SAVE
10000#define alc269_loopbacks alc880_loopbacks
10001#endif
10002
10003/* pcm configuration: identiacal with ALC880 */
10004#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10005#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10006#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10007#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10008
10009/*
10010 * BIOS auto configuration
10011 */
10012static int alc269_parse_auto_config(struct hda_codec *codec)
10013{
10014 struct alc_spec *spec = codec->spec;
10015 int err;
10016 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10017
10018 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10019 alc269_ignore);
10020 if (err < 0)
10021 return err;
10022
10023 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10024 if (err < 0)
10025 return err;
10026 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10027 if (err < 0)
10028 return err;
10029
10030 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10031
10032 if (spec->autocfg.dig_out_pin)
10033 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10034
10035 if (spec->kctl_alloc)
10036 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10037
10038 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10039 spec->num_mux_defs = 1;
10040 spec->input_mux = &spec->private_imux;
10041
10042 err = alc_auto_add_mic_boost(codec);
10043 if (err < 0)
10044 return err;
10045
10046 return 1;
10047}
10048
10049#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10050#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10051#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10052
10053
10054/* init callback for auto-configuration model -- overriding the default init */
10055static void alc269_auto_init(struct hda_codec *codec)
10056{
10057 alc269_auto_init_multi_out(codec);
10058 alc269_auto_init_hp_out(codec);
10059 alc269_auto_init_analog_input(codec);
10060}
10061
10062/*
10063 * configuration and preset
10064 */
10065static const char *alc269_models[ALC269_MODEL_LAST] = {
10066 [ALC269_BASIC] = "basic",
10067};
10068
10069static struct snd_pci_quirk alc269_cfg_tbl[] = {
10070 {}
10071};
10072
10073static struct alc_config_preset alc269_presets[] = {
10074 [ALC269_BASIC] = {
10075 .mixers = { alc269_base_mixer },
10076 .init_verbs = { alc269_init_verbs },
10077 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10078 .dac_nids = alc269_dac_nids,
10079 .hp_nid = 0x03,
10080 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10081 .channel_mode = alc269_modes,
10082 .input_mux = &alc269_capture_source,
10083 },
10084};
10085
10086static int patch_alc269(struct hda_codec *codec)
10087{
10088 struct alc_spec *spec;
10089 int board_config;
10090 int err;
10091
10092 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10093 if (spec == NULL)
10094 return -ENOMEM;
10095
10096 codec->spec = spec;
10097
10098 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10099 alc269_models,
10100 alc269_cfg_tbl);
10101
10102 if (board_config < 0) {
10103 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10104 "trying auto-probe from BIOS...\n");
10105 board_config = ALC269_AUTO;
10106 }
10107
10108 if (board_config == ALC269_AUTO) {
10109 /* automatic parse from the BIOS config */
10110 err = alc269_parse_auto_config(codec);
10111 if (err < 0) {
10112 alc_free(codec);
10113 return err;
10114 } else if (!err) {
10115 printk(KERN_INFO
10116 "hda_codec: Cannot set up configuration "
10117 "from BIOS. Using base mode...\n");
10118 board_config = ALC269_BASIC;
10119 }
10120 }
10121
10122 if (board_config != ALC269_AUTO)
10123 setup_preset(spec, &alc269_presets[board_config]);
10124
10125 spec->stream_name_analog = "ALC269 Analog";
10126 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10127 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10128
10129 spec->stream_name_digital = "ALC269 Digital";
10130 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10131 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10132
10133 spec->adc_nids = alc269_adc_nids;
10134 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10135 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10136 spec->num_mixers++;
10137
10138 codec->patch_ops = alc_patch_ops;
10139 if (board_config == ALC269_AUTO)
10140 spec->init_hook = alc269_auto_init;
10141#ifdef CONFIG_SND_HDA_POWER_SAVE
10142 if (!spec->loopback.amplist)
10143 spec->loopback.amplist = alc269_loopbacks;
10144#endif
10145
10146 return 0;
10147}
10148
10149/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010150 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10151 */
10152
10153/*
10154 * set the path ways for 2 channel output
10155 * need to set the codec line out and mic 1 pin widgets to inputs
10156 */
10157static struct hda_verb alc861_threestack_ch2_init[] = {
10158 /* set pin widget 1Ah (line in) for input */
10159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010160 /* set pin widget 18h (mic1/2) for input, for mic also enable
10161 * the vref
10162 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010163 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10164
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010165 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10166#if 0
10167 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10169#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010170 { } /* end */
10171};
10172/*
10173 * 6ch mode
10174 * need to set the codec line out and mic 1 pin widgets to outputs
10175 */
10176static struct hda_verb alc861_threestack_ch6_init[] = {
10177 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10178 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10179 /* set pin widget 18h (mic1) for output (CLFE)*/
10180 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10181
10182 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010183 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010184
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010185 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10186#if 0
10187 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10189#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010190 { } /* end */
10191};
10192
10193static struct hda_channel_mode alc861_threestack_modes[2] = {
10194 { 2, alc861_threestack_ch2_init },
10195 { 6, alc861_threestack_ch6_init },
10196};
Takashi Iwai22309c32006-08-09 16:57:28 +020010197/* Set mic1 as input and unmute the mixer */
10198static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10199 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10201 { } /* end */
10202};
10203/* Set mic1 as output and mute mixer */
10204static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10205 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10206 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10207 { } /* end */
10208};
10209
10210static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10211 { 2, alc861_uniwill_m31_ch2_init },
10212 { 4, alc861_uniwill_m31_ch4_init },
10213};
Kailang Yangdf694da2005-12-05 19:42:22 +010010214
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010215/* Set mic1 and line-in as input and unmute the mixer */
10216static struct hda_verb alc861_asus_ch2_init[] = {
10217 /* set pin widget 1Ah (line in) for input */
10218 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010219 /* set pin widget 18h (mic1/2) for input, for mic also enable
10220 * the vref
10221 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010222 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10223
10224 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10225#if 0
10226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10227 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10228#endif
10229 { } /* end */
10230};
10231/* Set mic1 nad line-in as output and mute mixer */
10232static struct hda_verb alc861_asus_ch6_init[] = {
10233 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10234 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10235 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10236 /* set pin widget 18h (mic1) for output (CLFE)*/
10237 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10238 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10239 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10240 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10241
10242 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10243#if 0
10244 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10245 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10246#endif
10247 { } /* end */
10248};
10249
10250static struct hda_channel_mode alc861_asus_modes[2] = {
10251 { 2, alc861_asus_ch2_init },
10252 { 6, alc861_asus_ch6_init },
10253};
10254
Kailang Yangdf694da2005-12-05 19:42:22 +010010255/* patch-ALC861 */
10256
10257static struct snd_kcontrol_new alc861_base_mixer[] = {
10258 /* output mixer control */
10259 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10260 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10261 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10262 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10263 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10264
10265 /*Input mixer control */
10266 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10267 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10268 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10269 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10270 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10271 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10273 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010276
Kailang Yangdf694da2005-12-05 19:42:22 +010010277 /* Capture mixer control */
10278 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10279 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10280 {
10281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10282 .name = "Capture Source",
10283 .count = 1,
10284 .info = alc_mux_enum_info,
10285 .get = alc_mux_enum_get,
10286 .put = alc_mux_enum_put,
10287 },
10288 { } /* end */
10289};
10290
10291static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10292 /* output mixer control */
10293 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10294 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10295 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10296 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10297 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10298
10299 /* Input mixer control */
10300 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10301 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10302 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10303 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10304 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10305 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10307 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10308 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010310
Kailang Yangdf694da2005-12-05 19:42:22 +010010311 /* Capture mixer control */
10312 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10313 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10314 {
10315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10316 .name = "Capture Source",
10317 .count = 1,
10318 .info = alc_mux_enum_info,
10319 .get = alc_mux_enum_get,
10320 .put = alc_mux_enum_put,
10321 },
10322 {
10323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10324 .name = "Channel Mode",
10325 .info = alc_ch_mode_info,
10326 .get = alc_ch_mode_get,
10327 .put = alc_ch_mode_put,
10328 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10329 },
10330 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010331};
10332
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010333static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010334 /* output mixer control */
10335 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10337 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10338
10339 /*Capture mixer control */
10340 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10341 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10342 {
10343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10344 .name = "Capture Source",
10345 .count = 1,
10346 .info = alc_mux_enum_info,
10347 .get = alc_mux_enum_get,
10348 .put = alc_mux_enum_put,
10349 },
10350
10351 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010352};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010353
Takashi Iwai22309c32006-08-09 16:57:28 +020010354static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10355 /* output mixer control */
10356 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10357 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10358 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10359 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10360 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10361
10362 /* Input mixer control */
10363 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10364 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10365 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10366 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10367 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10368 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10370 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010373
Takashi Iwai22309c32006-08-09 16:57:28 +020010374 /* Capture mixer control */
10375 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10376 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10377 {
10378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10379 .name = "Capture Source",
10380 .count = 1,
10381 .info = alc_mux_enum_info,
10382 .get = alc_mux_enum_get,
10383 .put = alc_mux_enum_put,
10384 },
10385 {
10386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10387 .name = "Channel Mode",
10388 .info = alc_ch_mode_info,
10389 .get = alc_ch_mode_get,
10390 .put = alc_ch_mode_put,
10391 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10392 },
10393 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010394};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010395
10396static struct snd_kcontrol_new alc861_asus_mixer[] = {
10397 /* output mixer control */
10398 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10399 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10400 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10401 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10402 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10403
10404 /* Input mixer control */
10405 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10406 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10407 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10408 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10409 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10410 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10412 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10415
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010416 /* Capture mixer control */
10417 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10418 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10419 {
10420 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10421 .name = "Capture Source",
10422 .count = 1,
10423 .info = alc_mux_enum_info,
10424 .get = alc_mux_enum_get,
10425 .put = alc_mux_enum_put,
10426 },
10427 {
10428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10429 .name = "Channel Mode",
10430 .info = alc_ch_mode_info,
10431 .get = alc_ch_mode_get,
10432 .put = alc_ch_mode_put,
10433 .private_value = ARRAY_SIZE(alc861_asus_modes),
10434 },
10435 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010436};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010437
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010438/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010010439static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010440 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10441 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10442 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10443 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10444 { }
10445};
10446
Kailang Yangdf694da2005-12-05 19:42:22 +010010447/*
10448 * generic initialization of ADC, input mixers and output mixers
10449 */
10450static struct hda_verb alc861_base_init_verbs[] = {
10451 /*
10452 * Unmute ADC0 and set the default input to mic-in
10453 */
10454 /* port-A for surround (rear panel) */
10455 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10456 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10457 /* port-B for mic-in (rear panel) with vref */
10458 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10459 /* port-C for line-in (rear panel) */
10460 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10461 /* port-D for Front */
10462 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10463 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10464 /* port-E for HP out (front panel) */
10465 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10466 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010467 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010468 /* port-F for mic-in (front panel) with vref */
10469 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10470 /* port-G for CLFE (rear panel) */
10471 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10472 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10473 /* port-H for side (rear panel) */
10474 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10475 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10476 /* CD-in */
10477 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10478 /* route front mic to ADC1*/
10479 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10481
10482 /* Unmute DAC0~3 & spdif out*/
10483 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10484 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10485 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10486 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10488
10489 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10490 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10491 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10492 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10493 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10494
10495 /* Unmute Stereo Mixer 15 */
10496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010500
10501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10504 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10507 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 /* hp used DAC 3 (Front) */
10510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10512
10513 { }
10514};
10515
10516static struct hda_verb alc861_threestack_init_verbs[] = {
10517 /*
10518 * Unmute ADC0 and set the default input to mic-in
10519 */
10520 /* port-A for surround (rear panel) */
10521 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10522 /* port-B for mic-in (rear panel) with vref */
10523 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10524 /* port-C for line-in (rear panel) */
10525 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10526 /* port-D for Front */
10527 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10528 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10529 /* port-E for HP out (front panel) */
10530 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10531 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010532 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010533 /* port-F for mic-in (front panel) with vref */
10534 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10535 /* port-G for CLFE (rear panel) */
10536 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10537 /* port-H for side (rear panel) */
10538 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10539 /* CD-in */
10540 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10541 /* route front mic to ADC1*/
10542 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10544 /* Unmute DAC0~3 & spdif out*/
10545 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10546 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10547 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10548 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10550
10551 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10552 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10553 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10554 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10555 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556
10557 /* Unmute Stereo Mixer 15 */
10558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010010562
10563 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10564 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10565 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10566 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10569 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010571 /* hp used DAC 3 (Front) */
10572 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10574 { }
10575};
Takashi Iwai22309c32006-08-09 16:57:28 +020010576
10577static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10578 /*
10579 * Unmute ADC0 and set the default input to mic-in
10580 */
10581 /* port-A for surround (rear panel) */
10582 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10583 /* port-B for mic-in (rear panel) with vref */
10584 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10585 /* port-C for line-in (rear panel) */
10586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10587 /* port-D for Front */
10588 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10589 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10590 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010591 /* this has to be set to VREF80 */
10592 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010593 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010594 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010595 /* port-F for mic-in (front panel) with vref */
10596 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10597 /* port-G for CLFE (rear panel) */
10598 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10599 /* port-H for side (rear panel) */
10600 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10601 /* CD-in */
10602 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10603 /* route front mic to ADC1*/
10604 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 /* Unmute DAC0~3 & spdif out*/
10607 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10608 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10609 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10610 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10612
10613 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10614 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10615 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10616 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10617 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10618
10619 /* Unmute Stereo Mixer 15 */
10620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020010624
10625 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10627 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10628 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10629 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10631 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10632 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010633 /* hp used DAC 3 (Front) */
10634 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020010635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10636 { }
10637};
10638
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010639static struct hda_verb alc861_asus_init_verbs[] = {
10640 /*
10641 * Unmute ADC0 and set the default input to mic-in
10642 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010643 /* port-A for surround (rear panel)
10644 * according to codec#0 this is the HP jack
10645 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010646 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10647 /* route front PCM to HP */
10648 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10649 /* port-B for mic-in (rear panel) with vref */
10650 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10651 /* port-C for line-in (rear panel) */
10652 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10653 /* port-D for Front */
10654 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10655 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10656 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010657 /* this has to be set to VREF80 */
10658 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010659 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010010660 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010661 /* port-F for mic-in (front panel) with vref */
10662 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10663 /* port-G for CLFE (rear panel) */
10664 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10665 /* port-H for side (rear panel) */
10666 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10667 /* CD-in */
10668 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10669 /* route front mic to ADC1*/
10670 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10672 /* Unmute DAC0~3 & spdif out*/
10673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10676 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10678 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10679 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10681 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10683
10684 /* Unmute Stereo Mixer 15 */
10685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010689
10690 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10692 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010698 /* hp used DAC 3 (Front) */
10699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10701 { }
10702};
10703
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010704/* additional init verbs for ASUS laptops */
10705static struct hda_verb alc861_asus_laptop_init_verbs[] = {
10706 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
10707 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
10708 { }
10709};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010710
Kailang Yangdf694da2005-12-05 19:42:22 +010010711/*
10712 * generic initialization of ADC, input mixers and output mixers
10713 */
10714static struct hda_verb alc861_auto_init_verbs[] = {
10715 /*
10716 * Unmute ADC0 and set the default input to mic-in
10717 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010718 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010010719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10720
10721 /* Unmute DAC0~3 & spdif out*/
10722 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10723 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10725 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10727
10728 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10729 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10730 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10731 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10732 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10733
10734 /* Unmute Stereo Mixer 15 */
10735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
10739
10740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10748
10749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010757
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010758 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010759
10760 { }
10761};
10762
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010763static struct hda_verb alc861_toshiba_init_verbs[] = {
10764 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010765
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010766 { }
10767};
10768
10769/* toggle speaker-output according to the hp-jack state */
10770static void alc861_toshiba_automute(struct hda_codec *codec)
10771{
10772 unsigned int present;
10773
10774 present = snd_hda_codec_read(codec, 0x0f, 0,
10775 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010776 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
10777 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10778 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
10779 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010780}
10781
10782static void alc861_toshiba_unsol_event(struct hda_codec *codec,
10783 unsigned int res)
10784{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010785 if ((res >> 26) == ALC880_HP_EVENT)
10786 alc861_toshiba_automute(codec);
10787}
10788
Kailang Yangdf694da2005-12-05 19:42:22 +010010789/* pcm configuration: identiacal with ALC880 */
10790#define alc861_pcm_analog_playback alc880_pcm_analog_playback
10791#define alc861_pcm_analog_capture alc880_pcm_analog_capture
10792#define alc861_pcm_digital_playback alc880_pcm_digital_playback
10793#define alc861_pcm_digital_capture alc880_pcm_digital_capture
10794
10795
10796#define ALC861_DIGOUT_NID 0x07
10797
10798static struct hda_channel_mode alc861_8ch_modes[1] = {
10799 { 8, NULL }
10800};
10801
10802static hda_nid_t alc861_dac_nids[4] = {
10803 /* front, surround, clfe, side */
10804 0x03, 0x06, 0x05, 0x04
10805};
10806
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010807static hda_nid_t alc660_dac_nids[3] = {
10808 /* front, clfe, surround */
10809 0x03, 0x05, 0x06
10810};
10811
Kailang Yangdf694da2005-12-05 19:42:22 +010010812static hda_nid_t alc861_adc_nids[1] = {
10813 /* ADC0-2 */
10814 0x08,
10815};
10816
10817static struct hda_input_mux alc861_capture_source = {
10818 .num_items = 5,
10819 .items = {
10820 { "Mic", 0x0 },
10821 { "Front Mic", 0x3 },
10822 { "Line", 0x1 },
10823 { "CD", 0x4 },
10824 { "Mixer", 0x5 },
10825 },
10826};
10827
10828/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010829static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
10830 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010831{
10832 int i;
10833 hda_nid_t nid;
10834
10835 spec->multiout.dac_nids = spec->private_dac_nids;
10836 for (i = 0; i < cfg->line_outs; i++) {
10837 nid = cfg->line_out_pins[i];
10838 if (nid) {
10839 if (i >= ARRAY_SIZE(alc861_dac_nids))
10840 continue;
10841 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
10842 }
10843 }
10844 spec->multiout.num_dacs = cfg->line_outs;
10845 return 0;
10846}
10847
10848/* add playback controls from the parsed DAC table */
10849static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
10850 const struct auto_pin_cfg *cfg)
10851{
10852 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010853 static const char *chname[4] = {
10854 "Front", "Surround", NULL /*CLFE*/, "Side"
10855 };
Kailang Yangdf694da2005-12-05 19:42:22 +010010856 hda_nid_t nid;
10857 int i, idx, err;
10858
10859 for (i = 0; i < cfg->line_outs; i++) {
10860 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010861 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010010862 continue;
10863 if (nid == 0x05) {
10864 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010865 err = add_control(spec, ALC_CTL_BIND_MUTE,
10866 "Center Playback Switch",
10867 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10868 HDA_OUTPUT));
10869 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010870 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010871 err = add_control(spec, ALC_CTL_BIND_MUTE,
10872 "LFE Playback Switch",
10873 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10874 HDA_OUTPUT));
10875 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010876 return err;
10877 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010878 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
10879 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 if (nid == alc861_dac_nids[idx])
10881 break;
10882 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010883 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10884 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10885 HDA_OUTPUT));
10886 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010887 return err;
10888 }
10889 }
10890 return 0;
10891}
10892
10893static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
10894{
10895 int err;
10896 hda_nid_t nid;
10897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010898 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010010899 return 0;
10900
10901 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
10902 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010903 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10904 "Headphone Playback Switch",
10905 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10906 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010907 return err;
10908 spec->multiout.hp_nid = nid;
10909 }
10910 return 0;
10911}
10912
10913/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010914static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
10915 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010916{
Kailang Yangdf694da2005-12-05 19:42:22 +010010917 struct hda_input_mux *imux = &spec->private_imux;
10918 int i, err, idx, idx1;
10919
10920 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010921 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010922 case 0x0c:
10923 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010924 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010925 break;
10926 case 0x0f:
10927 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010928 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010929 break;
10930 case 0x0d:
10931 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010932 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010933 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010934 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010936 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010937 break;
10938 case 0x11:
10939 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010940 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010010941 break;
10942 default:
10943 continue;
10944 }
10945
Takashi Iwai4a471b72005-12-07 13:56:29 +010010946 err = new_analog_input(spec, cfg->input_pins[i],
10947 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010010948 if (err < 0)
10949 return err;
10950
Takashi Iwai4a471b72005-12-07 13:56:29 +010010951 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010010952 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010953 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010010954 }
10955 return 0;
10956}
10957
10958static struct snd_kcontrol_new alc861_capture_mixer[] = {
10959 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10960 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10961
10962 {
10963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10964 /* The multiple "Capture Source" controls confuse alsamixer
10965 * So call somewhat different..
10966 *FIXME: the controls appear in the "playback" view!
10967 */
10968 /* .name = "Capture Source", */
10969 .name = "Input Source",
10970 .count = 1,
10971 .info = alc_mux_enum_info,
10972 .get = alc_mux_enum_get,
10973 .put = alc_mux_enum_put,
10974 },
10975 { } /* end */
10976};
10977
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010978static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
10979 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 int pin_type, int dac_idx)
10981{
10982 /* set as output */
10983
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10985 pin_type);
10986 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10987 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010010988
10989}
10990
10991static void alc861_auto_init_multi_out(struct hda_codec *codec)
10992{
10993 struct alc_spec *spec = codec->spec;
10994 int i;
10995
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010996 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010010997 for (i = 0; i < spec->autocfg.line_outs; i++) {
10998 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010999 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011000 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011001 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011002 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011003 }
11004}
11005
11006static void alc861_auto_init_hp_out(struct hda_codec *codec)
11007{
11008 struct alc_spec *spec = codec->spec;
11009 hda_nid_t pin;
11010
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011011 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011012 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011013 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11014 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011015}
11016
11017static void alc861_auto_init_analog_input(struct hda_codec *codec)
11018{
11019 struct alc_spec *spec = codec->spec;
11020 int i;
11021
11022 for (i = 0; i < AUTO_PIN_LAST; i++) {
11023 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011024 if (nid >= 0x0c && nid <= 0x11) {
11025 snd_hda_codec_write(codec, nid, 0,
11026 AC_VERB_SET_PIN_WIDGET_CONTROL,
11027 i <= AUTO_PIN_FRONT_MIC ?
11028 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011029 }
11030 }
11031}
11032
11033/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011034/* return 1 if successful, 0 if the proper config is not found,
11035 * or a negative error code
11036 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011037static int alc861_parse_auto_config(struct hda_codec *codec)
11038{
11039 struct alc_spec *spec = codec->spec;
11040 int err;
11041 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11042
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011043 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11044 alc861_ignore);
11045 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011046 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011047 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011048 return 0; /* can't find valid BIOS pin config */
11049
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011050 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11051 if (err < 0)
11052 return err;
11053 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11054 if (err < 0)
11055 return err;
11056 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11057 if (err < 0)
11058 return err;
11059 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11060 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011061 return err;
11062
11063 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11064
11065 if (spec->autocfg.dig_out_pin)
11066 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11067
11068 if (spec->kctl_alloc)
11069 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11070
11071 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11072
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011073 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011074 spec->input_mux = &spec->private_imux;
11075
11076 spec->adc_nids = alc861_adc_nids;
11077 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11078 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11079 spec->num_mixers++;
11080
11081 return 1;
11082}
11083
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011084/* additional initialization for auto-configuration model */
11085static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011086{
Kailang Yangdf694da2005-12-05 19:42:22 +010011087 alc861_auto_init_multi_out(codec);
11088 alc861_auto_init_hp_out(codec);
11089 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011090}
11091
Takashi Iwaicb53c622007-08-10 17:21:45 +020011092#ifdef CONFIG_SND_HDA_POWER_SAVE
11093static struct hda_amp_list alc861_loopbacks[] = {
11094 { 0x15, HDA_INPUT, 0 },
11095 { 0x15, HDA_INPUT, 1 },
11096 { 0x15, HDA_INPUT, 2 },
11097 { 0x15, HDA_INPUT, 3 },
11098 { } /* end */
11099};
11100#endif
11101
Kailang Yangdf694da2005-12-05 19:42:22 +010011102
11103/*
11104 * configuration and preset
11105 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011106static const char *alc861_models[ALC861_MODEL_LAST] = {
11107 [ALC861_3ST] = "3stack",
11108 [ALC660_3ST] = "3stack-660",
11109 [ALC861_3ST_DIG] = "3stack-dig",
11110 [ALC861_6ST_DIG] = "6stack-dig",
11111 [ALC861_UNIWILL_M31] = "uniwill-m31",
11112 [ALC861_TOSHIBA] = "toshiba",
11113 [ALC861_ASUS] = "asus",
11114 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11115 [ALC861_AUTO] = "auto",
11116};
11117
11118static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011119 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011120 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11121 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11122 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011123 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011124 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011125 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011126 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11127 * Any other models that need this preset?
11128 */
11129 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011130 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11131 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011132 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11133 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11134 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11135 /* FIXME: the below seems conflict */
11136 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11137 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11138 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011139 {}
11140};
11141
11142static struct alc_config_preset alc861_presets[] = {
11143 [ALC861_3ST] = {
11144 .mixers = { alc861_3ST_mixer },
11145 .init_verbs = { alc861_threestack_init_verbs },
11146 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11147 .dac_nids = alc861_dac_nids,
11148 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11149 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011150 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011151 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11152 .adc_nids = alc861_adc_nids,
11153 .input_mux = &alc861_capture_source,
11154 },
11155 [ALC861_3ST_DIG] = {
11156 .mixers = { alc861_base_mixer },
11157 .init_verbs = { alc861_threestack_init_verbs },
11158 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11159 .dac_nids = alc861_dac_nids,
11160 .dig_out_nid = ALC861_DIGOUT_NID,
11161 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11162 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011163 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011164 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11165 .adc_nids = alc861_adc_nids,
11166 .input_mux = &alc861_capture_source,
11167 },
11168 [ALC861_6ST_DIG] = {
11169 .mixers = { alc861_base_mixer },
11170 .init_verbs = { alc861_base_init_verbs },
11171 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11172 .dac_nids = alc861_dac_nids,
11173 .dig_out_nid = ALC861_DIGOUT_NID,
11174 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11175 .channel_mode = alc861_8ch_modes,
11176 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11177 .adc_nids = alc861_adc_nids,
11178 .input_mux = &alc861_capture_source,
11179 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011180 [ALC660_3ST] = {
11181 .mixers = { alc861_3ST_mixer },
11182 .init_verbs = { alc861_threestack_init_verbs },
11183 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11184 .dac_nids = alc660_dac_nids,
11185 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11186 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011187 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011188 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11189 .adc_nids = alc861_adc_nids,
11190 .input_mux = &alc861_capture_source,
11191 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011192 [ALC861_UNIWILL_M31] = {
11193 .mixers = { alc861_uniwill_m31_mixer },
11194 .init_verbs = { alc861_uniwill_m31_init_verbs },
11195 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11196 .dac_nids = alc861_dac_nids,
11197 .dig_out_nid = ALC861_DIGOUT_NID,
11198 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11199 .channel_mode = alc861_uniwill_m31_modes,
11200 .need_dac_fix = 1,
11201 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11202 .adc_nids = alc861_adc_nids,
11203 .input_mux = &alc861_capture_source,
11204 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011205 [ALC861_TOSHIBA] = {
11206 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011207 .init_verbs = { alc861_base_init_verbs,
11208 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011209 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11210 .dac_nids = alc861_dac_nids,
11211 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11212 .channel_mode = alc883_3ST_2ch_modes,
11213 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11214 .adc_nids = alc861_adc_nids,
11215 .input_mux = &alc861_capture_source,
11216 .unsol_event = alc861_toshiba_unsol_event,
11217 .init_hook = alc861_toshiba_automute,
11218 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011219 [ALC861_ASUS] = {
11220 .mixers = { alc861_asus_mixer },
11221 .init_verbs = { alc861_asus_init_verbs },
11222 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11223 .dac_nids = alc861_dac_nids,
11224 .dig_out_nid = ALC861_DIGOUT_NID,
11225 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11226 .channel_mode = alc861_asus_modes,
11227 .need_dac_fix = 1,
11228 .hp_nid = 0x06,
11229 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11230 .adc_nids = alc861_adc_nids,
11231 .input_mux = &alc861_capture_source,
11232 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011233 [ALC861_ASUS_LAPTOP] = {
11234 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11235 .init_verbs = { alc861_asus_init_verbs,
11236 alc861_asus_laptop_init_verbs },
11237 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11238 .dac_nids = alc861_dac_nids,
11239 .dig_out_nid = ALC861_DIGOUT_NID,
11240 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11241 .channel_mode = alc883_3ST_2ch_modes,
11242 .need_dac_fix = 1,
11243 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11244 .adc_nids = alc861_adc_nids,
11245 .input_mux = &alc861_capture_source,
11246 },
11247};
Kailang Yangdf694da2005-12-05 19:42:22 +010011248
11249
11250static int patch_alc861(struct hda_codec *codec)
11251{
11252 struct alc_spec *spec;
11253 int board_config;
11254 int err;
11255
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011256 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011257 if (spec == NULL)
11258 return -ENOMEM;
11259
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011260 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011261
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011262 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11263 alc861_models,
11264 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011265
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011266 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011267 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11268 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011269 board_config = ALC861_AUTO;
11270 }
11271
11272 if (board_config == ALC861_AUTO) {
11273 /* automatic parse from the BIOS config */
11274 err = alc861_parse_auto_config(codec);
11275 if (err < 0) {
11276 alc_free(codec);
11277 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011278 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011279 printk(KERN_INFO
11280 "hda_codec: Cannot set up configuration "
11281 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011282 board_config = ALC861_3ST_DIG;
11283 }
11284 }
11285
11286 if (board_config != ALC861_AUTO)
11287 setup_preset(spec, &alc861_presets[board_config]);
11288
11289 spec->stream_name_analog = "ALC861 Analog";
11290 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11291 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11292
11293 spec->stream_name_digital = "ALC861 Digital";
11294 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11295 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11296
11297 codec->patch_ops = alc_patch_ops;
11298 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011299 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011300#ifdef CONFIG_SND_HDA_POWER_SAVE
11301 if (!spec->loopback.amplist)
11302 spec->loopback.amplist = alc861_loopbacks;
11303#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011304
11305 return 0;
11306}
11307
11308/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011309 * ALC861-VD support
11310 *
11311 * Based on ALC882
11312 *
11313 * In addition, an independent DAC
11314 */
11315#define ALC861VD_DIGOUT_NID 0x06
11316
11317static hda_nid_t alc861vd_dac_nids[4] = {
11318 /* front, surr, clfe, side surr */
11319 0x02, 0x03, 0x04, 0x05
11320};
11321
11322/* dac_nids for ALC660vd are in a different order - according to
11323 * Realtek's driver.
11324 * This should probably tesult in a different mixer for 6stack models
11325 * of ALC660vd codecs, but for now there is only 3stack mixer
11326 * - and it is the same as in 861vd.
11327 * adc_nids in ALC660vd are (is) the same as in 861vd
11328 */
11329static hda_nid_t alc660vd_dac_nids[3] = {
11330 /* front, rear, clfe, rear_surr */
11331 0x02, 0x04, 0x03
11332};
11333
11334static hda_nid_t alc861vd_adc_nids[1] = {
11335 /* ADC0 */
11336 0x09,
11337};
11338
11339/* input MUX */
11340/* FIXME: should be a matrix-type input source selection */
11341static struct hda_input_mux alc861vd_capture_source = {
11342 .num_items = 4,
11343 .items = {
11344 { "Mic", 0x0 },
11345 { "Front Mic", 0x1 },
11346 { "Line", 0x2 },
11347 { "CD", 0x4 },
11348 },
11349};
11350
Kailang Yang272a5272007-05-14 11:00:38 +020011351static struct hda_input_mux alc861vd_dallas_capture_source = {
11352 .num_items = 3,
11353 .items = {
11354 { "Front Mic", 0x0 },
11355 { "ATAPI Mic", 0x1 },
11356 { "Line In", 0x5 },
11357 },
11358};
11359
Kailang Yangd1a991a2007-08-15 16:21:59 +020011360static struct hda_input_mux alc861vd_hp_capture_source = {
11361 .num_items = 2,
11362 .items = {
11363 { "Front Mic", 0x0 },
11364 { "ATAPI Mic", 0x1 },
11365 },
11366};
11367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011368#define alc861vd_mux_enum_info alc_mux_enum_info
11369#define alc861vd_mux_enum_get alc_mux_enum_get
11370
11371static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11372 struct snd_ctl_elem_value *ucontrol)
11373{
11374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11375 struct alc_spec *spec = codec->spec;
11376 const struct hda_input_mux *imux = spec->input_mux;
11377 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11378 static hda_nid_t capture_mixers[1] = { 0x22 };
11379 hda_nid_t nid = capture_mixers[adc_idx];
11380 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11381 unsigned int i, idx;
11382
11383 idx = ucontrol->value.enumerated.item[0];
11384 if (idx >= imux->num_items)
11385 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011386 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011387 return 0;
11388 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011389 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11390 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11391 imux->items[i].index,
11392 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011393 }
11394 *cur_val = idx;
11395 return 1;
11396}
11397
11398/*
11399 * 2ch mode
11400 */
11401static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11402 { 2, NULL }
11403};
11404
11405/*
11406 * 6ch mode
11407 */
11408static struct hda_verb alc861vd_6stack_ch6_init[] = {
11409 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11410 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11411 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11412 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11413 { } /* end */
11414};
11415
11416/*
11417 * 8ch mode
11418 */
11419static struct hda_verb alc861vd_6stack_ch8_init[] = {
11420 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11421 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11422 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11423 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11424 { } /* end */
11425};
11426
11427static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11428 { 6, alc861vd_6stack_ch6_init },
11429 { 8, alc861vd_6stack_ch8_init },
11430};
11431
11432static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11433 {
11434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11435 .name = "Channel Mode",
11436 .info = alc_ch_mode_info,
11437 .get = alc_ch_mode_get,
11438 .put = alc_ch_mode_put,
11439 },
11440 { } /* end */
11441};
11442
11443static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11444 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11445 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11446
11447 {
11448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11449 /* The multiple "Capture Source" controls confuse alsamixer
11450 * So call somewhat different..
11451 *FIXME: the controls appear in the "playback" view!
11452 */
11453 /* .name = "Capture Source", */
11454 .name = "Input Source",
11455 .count = 1,
11456 .info = alc861vd_mux_enum_info,
11457 .get = alc861vd_mux_enum_get,
11458 .put = alc861vd_mux_enum_put,
11459 },
11460 { } /* end */
11461};
11462
11463/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11464 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11465 */
11466static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11467 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11468 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11469
11470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11471 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11472
11473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11474 HDA_OUTPUT),
11475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11476 HDA_OUTPUT),
11477 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11478 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11479
11480 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11481 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11482
11483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11484
11485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11488
11489 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11490 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11492
11493 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11494 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11495
11496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11498
11499 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11500 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11501
11502 { } /* end */
11503};
11504
11505static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11506 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11507 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11508
11509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11510
11511 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11514
11515 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11516 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11518
11519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11521
11522 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11523 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11524
11525 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11526 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11527
11528 { } /* end */
11529};
11530
Kailang Yangbdd148a2007-05-08 15:19:08 +020011531static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11532 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11533 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11534 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11535
11536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11537
11538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11541
11542 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11543 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11544 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11545
11546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11548
11549 { } /* end */
11550};
11551
Kailang Yang272a5272007-05-14 11:00:38 +020011552/* Pin assignment: Front=0x14, HP = 0x15,
11553 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11554 */
11555static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11556 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11557 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11558 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11559 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11562 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11563 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11564 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11565 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020011566 { } /* end */
11567};
11568
Kailang Yangd1a991a2007-08-15 16:21:59 +020011569/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11570 * Front Mic=0x18, ATAPI Mic = 0x19,
11571 */
11572static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11576 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11579 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11580 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11581
11582 { } /* end */
11583};
11584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011585/*
11586 * generic initialization of ADC, input mixers and output mixers
11587 */
11588static struct hda_verb alc861vd_volume_init_verbs[] = {
11589 /*
11590 * Unmute ADC0 and set the default input to mic-in
11591 */
11592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11594
11595 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11596 * the analog-loopback mixer widget
11597 */
11598 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011604
11605 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020011606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011610
11611 /*
11612 * Set up output mixers (0x02 - 0x05)
11613 */
11614 /* set vol=0 to output mixers */
11615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11616 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11617 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11618 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11619
11620 /* set up input amps for analog loopback */
11621 /* Amp Indices: DAC = 0, mixer = 1 */
11622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11630
11631 { }
11632};
11633
11634/*
11635 * 3-stack pin configuration:
11636 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11637 */
11638static struct hda_verb alc861vd_3stack_init_verbs[] = {
11639 /*
11640 * Set pin mode and muting
11641 */
11642 /* set front pin widgets 0x14 for output */
11643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11646
11647 /* Mic (rear) pin: input vref at 80% */
11648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11650 /* Front Mic pin: input vref at 80% */
11651 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11653 /* Line In pin: input */
11654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11656 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11659 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11660 /* CD pin widget for input */
11661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11662
11663 { }
11664};
11665
11666/*
11667 * 6-stack pin configuration:
11668 */
11669static struct hda_verb alc861vd_6stack_init_verbs[] = {
11670 /*
11671 * Set pin mode and muting
11672 */
11673 /* set front pin widgets 0x14 for output */
11674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11676 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11677
11678 /* Rear Pin: output 1 (0x0d) */
11679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11681 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11682 /* CLFE Pin: output 2 (0x0e) */
11683 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11685 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11686 /* Side Pin: output 3 (0x0f) */
11687 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11689 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11690
11691 /* Mic (rear) pin: input vref at 80% */
11692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11694 /* Front Mic pin: input vref at 80% */
11695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11697 /* Line In pin: input */
11698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11700 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11703 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11704 /* CD pin widget for input */
11705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11706
11707 { }
11708};
11709
Kailang Yangbdd148a2007-05-08 15:19:08 +020011710static struct hda_verb alc861vd_eapd_verbs[] = {
11711 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11712 { }
11713};
11714
11715static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
11716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11720 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11721 {}
11722};
11723
11724/* toggle speaker-output according to the hp-jack state */
11725static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
11726{
11727 unsigned int present;
11728 unsigned char bits;
11729
11730 present = snd_hda_codec_read(codec, 0x1b, 0,
11731 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011732 bits = present ? HDA_AMP_MUTE : 0;
11733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11734 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011735}
11736
11737static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
11738{
11739 unsigned int present;
11740 unsigned char bits;
11741
11742 present = snd_hda_codec_read(codec, 0x18, 0,
11743 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011744 bits = present ? HDA_AMP_MUTE : 0;
11745 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
11746 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020011747}
11748
11749static void alc861vd_lenovo_automute(struct hda_codec *codec)
11750{
11751 alc861vd_lenovo_hp_automute(codec);
11752 alc861vd_lenovo_mic_automute(codec);
11753}
11754
11755static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
11756 unsigned int res)
11757{
11758 switch (res >> 26) {
11759 case ALC880_HP_EVENT:
11760 alc861vd_lenovo_hp_automute(codec);
11761 break;
11762 case ALC880_MIC_EVENT:
11763 alc861vd_lenovo_mic_automute(codec);
11764 break;
11765 }
11766}
11767
Kailang Yang272a5272007-05-14 11:00:38 +020011768static struct hda_verb alc861vd_dallas_verbs[] = {
11769 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11770 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11771 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11772 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11773
11774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11782
11783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11787 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11790 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11791
11792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11793 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11799 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11800
11801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11805
11806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11807 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11808 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11809
11810 { } /* end */
11811};
11812
11813/* toggle speaker-output according to the hp-jack state */
11814static void alc861vd_dallas_automute(struct hda_codec *codec)
11815{
11816 unsigned int present;
11817
11818 present = snd_hda_codec_read(codec, 0x15, 0,
11819 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011820 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11821 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020011822}
11823
11824static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
11825{
11826 if ((res >> 26) == ALC880_HP_EVENT)
11827 alc861vd_dallas_automute(codec);
11828}
11829
Takashi Iwaicb53c622007-08-10 17:21:45 +020011830#ifdef CONFIG_SND_HDA_POWER_SAVE
11831#define alc861vd_loopbacks alc880_loopbacks
11832#endif
11833
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011834/* pcm configuration: identiacal with ALC880 */
11835#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
11836#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
11837#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
11838#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
11839
11840/*
11841 * configuration and preset
11842 */
11843static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
11844 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011845 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011846 [ALC861VD_3ST] = "3stack",
11847 [ALC861VD_3ST_DIG] = "3stack-digout",
11848 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020011849 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020011850 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011851 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011852 [ALC861VD_AUTO] = "auto",
11853};
11854
11855static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011856 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
11857 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010011858 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011859 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020011860 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011861 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011862 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020011863 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020011864 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020011865 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020011866 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011867 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
11868 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020011869 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011870 {}
11871};
11872
11873static struct alc_config_preset alc861vd_presets[] = {
11874 [ALC660VD_3ST] = {
11875 .mixers = { alc861vd_3st_mixer },
11876 .init_verbs = { alc861vd_volume_init_verbs,
11877 alc861vd_3stack_init_verbs },
11878 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11879 .dac_nids = alc660vd_dac_nids,
11880 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11881 .adc_nids = alc861vd_adc_nids,
11882 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11883 .channel_mode = alc861vd_3stack_2ch_modes,
11884 .input_mux = &alc861vd_capture_source,
11885 },
Mike Crash6963f842007-06-25 12:12:51 +020011886 [ALC660VD_3ST_DIG] = {
11887 .mixers = { alc861vd_3st_mixer },
11888 .init_verbs = { alc861vd_volume_init_verbs,
11889 alc861vd_3stack_init_verbs },
11890 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11891 .dac_nids = alc660vd_dac_nids,
11892 .dig_out_nid = ALC861VD_DIGOUT_NID,
11893 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11894 .adc_nids = alc861vd_adc_nids,
11895 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11896 .channel_mode = alc861vd_3stack_2ch_modes,
11897 .input_mux = &alc861vd_capture_source,
11898 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011899 [ALC861VD_3ST] = {
11900 .mixers = { alc861vd_3st_mixer },
11901 .init_verbs = { alc861vd_volume_init_verbs,
11902 alc861vd_3stack_init_verbs },
11903 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11904 .dac_nids = alc861vd_dac_nids,
11905 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11906 .channel_mode = alc861vd_3stack_2ch_modes,
11907 .input_mux = &alc861vd_capture_source,
11908 },
11909 [ALC861VD_3ST_DIG] = {
11910 .mixers = { alc861vd_3st_mixer },
11911 .init_verbs = { alc861vd_volume_init_verbs,
11912 alc861vd_3stack_init_verbs },
11913 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11914 .dac_nids = alc861vd_dac_nids,
11915 .dig_out_nid = ALC861VD_DIGOUT_NID,
11916 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11917 .channel_mode = alc861vd_3stack_2ch_modes,
11918 .input_mux = &alc861vd_capture_source,
11919 },
11920 [ALC861VD_6ST_DIG] = {
11921 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
11922 .init_verbs = { alc861vd_volume_init_verbs,
11923 alc861vd_6stack_init_verbs },
11924 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11925 .dac_nids = alc861vd_dac_nids,
11926 .dig_out_nid = ALC861VD_DIGOUT_NID,
11927 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
11928 .channel_mode = alc861vd_6stack_modes,
11929 .input_mux = &alc861vd_capture_source,
11930 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020011931 [ALC861VD_LENOVO] = {
11932 .mixers = { alc861vd_lenovo_mixer },
11933 .init_verbs = { alc861vd_volume_init_verbs,
11934 alc861vd_3stack_init_verbs,
11935 alc861vd_eapd_verbs,
11936 alc861vd_lenovo_unsol_verbs },
11937 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11938 .dac_nids = alc660vd_dac_nids,
11939 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11940 .adc_nids = alc861vd_adc_nids,
11941 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11942 .channel_mode = alc861vd_3stack_2ch_modes,
11943 .input_mux = &alc861vd_capture_source,
11944 .unsol_event = alc861vd_lenovo_unsol_event,
11945 .init_hook = alc861vd_lenovo_automute,
11946 },
Kailang Yang272a5272007-05-14 11:00:38 +020011947 [ALC861VD_DALLAS] = {
11948 .mixers = { alc861vd_dallas_mixer },
11949 .init_verbs = { alc861vd_dallas_verbs },
11950 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11951 .dac_nids = alc861vd_dac_nids,
11952 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11953 .adc_nids = alc861vd_adc_nids,
11954 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11955 .channel_mode = alc861vd_3stack_2ch_modes,
11956 .input_mux = &alc861vd_dallas_capture_source,
11957 .unsol_event = alc861vd_dallas_unsol_event,
11958 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011959 },
11960 [ALC861VD_HP] = {
11961 .mixers = { alc861vd_hp_mixer },
11962 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
11963 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11964 .dac_nids = alc861vd_dac_nids,
11965 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11966 .dig_out_nid = ALC861VD_DIGOUT_NID,
11967 .adc_nids = alc861vd_adc_nids,
11968 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11969 .channel_mode = alc861vd_3stack_2ch_modes,
11970 .input_mux = &alc861vd_hp_capture_source,
11971 .unsol_event = alc861vd_dallas_unsol_event,
11972 .init_hook = alc861vd_dallas_automute,
11973 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011974};
11975
11976/*
11977 * BIOS auto configuration
11978 */
11979static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
11980 hda_nid_t nid, int pin_type, int dac_idx)
11981{
11982 /* set as output */
11983 snd_hda_codec_write(codec, nid, 0,
11984 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11985 snd_hda_codec_write(codec, nid, 0,
11986 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11987}
11988
11989static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
11990{
11991 struct alc_spec *spec = codec->spec;
11992 int i;
11993
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011994 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011995 for (i = 0; i <= HDA_SIDE; i++) {
11996 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011997 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011998 if (nid)
11999 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012000 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012001 }
12002}
12003
12004
12005static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12006{
12007 struct alc_spec *spec = codec->spec;
12008 hda_nid_t pin;
12009
12010 pin = spec->autocfg.hp_pins[0];
12011 if (pin) /* connect to front and use dac 0 */
12012 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12013}
12014
12015#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12016#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12017
12018static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12019{
12020 struct alc_spec *spec = codec->spec;
12021 int i;
12022
12023 for (i = 0; i < AUTO_PIN_LAST; i++) {
12024 hda_nid_t nid = spec->autocfg.input_pins[i];
12025 if (alc861vd_is_input_pin(nid)) {
12026 snd_hda_codec_write(codec, nid, 0,
12027 AC_VERB_SET_PIN_WIDGET_CONTROL,
12028 i <= AUTO_PIN_FRONT_MIC ?
12029 PIN_VREF80 : PIN_IN);
12030 if (nid != ALC861VD_PIN_CD_NID)
12031 snd_hda_codec_write(codec, nid, 0,
12032 AC_VERB_SET_AMP_GAIN_MUTE,
12033 AMP_OUT_MUTE);
12034 }
12035 }
12036}
12037
12038#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12039#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12040
12041/* add playback controls from the parsed DAC table */
12042/* Based on ALC880 version. But ALC861VD has separate,
12043 * different NIDs for mute/unmute switch and volume control */
12044static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12045 const struct auto_pin_cfg *cfg)
12046{
12047 char name[32];
12048 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12049 hda_nid_t nid_v, nid_s;
12050 int i, err;
12051
12052 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012053 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012054 continue;
12055 nid_v = alc861vd_idx_to_mixer_vol(
12056 alc880_dac_to_idx(
12057 spec->multiout.dac_nids[i]));
12058 nid_s = alc861vd_idx_to_mixer_switch(
12059 alc880_dac_to_idx(
12060 spec->multiout.dac_nids[i]));
12061
12062 if (i == 2) {
12063 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012064 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12065 "Center Playback Volume",
12066 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12067 HDA_OUTPUT));
12068 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012069 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012070 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12071 "LFE Playback Volume",
12072 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12073 HDA_OUTPUT));
12074 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012075 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012076 err = add_control(spec, ALC_CTL_BIND_MUTE,
12077 "Center Playback Switch",
12078 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12079 HDA_INPUT));
12080 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012081 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012082 err = add_control(spec, ALC_CTL_BIND_MUTE,
12083 "LFE Playback Switch",
12084 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12085 HDA_INPUT));
12086 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012087 return err;
12088 } else {
12089 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012090 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12091 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12092 HDA_OUTPUT));
12093 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012094 return err;
12095 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012096 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012097 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012098 HDA_INPUT));
12099 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012100 return err;
12101 }
12102 }
12103 return 0;
12104}
12105
12106/* add playback controls for speaker and HP outputs */
12107/* Based on ALC880 version. But ALC861VD has separate,
12108 * different NIDs for mute/unmute switch and volume control */
12109static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12110 hda_nid_t pin, const char *pfx)
12111{
12112 hda_nid_t nid_v, nid_s;
12113 int err;
12114 char name[32];
12115
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012116 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012117 return 0;
12118
12119 if (alc880_is_fixed_pin(pin)) {
12120 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12121 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012122 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012123 spec->multiout.hp_nid = nid_v;
12124 else
12125 spec->multiout.extra_out_nid[0] = nid_v;
12126 /* control HP volume/switch on the output mixer amp */
12127 nid_v = alc861vd_idx_to_mixer_vol(
12128 alc880_fixed_pin_idx(pin));
12129 nid_s = alc861vd_idx_to_mixer_switch(
12130 alc880_fixed_pin_idx(pin));
12131
12132 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012133 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12134 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12135 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012136 return err;
12137 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012138 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12139 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12140 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012141 return err;
12142 } else if (alc880_is_multi_pin(pin)) {
12143 /* set manual connection */
12144 /* we have only a switch on HP-out PIN */
12145 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012146 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12147 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12148 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012149 return err;
12150 }
12151 return 0;
12152}
12153
12154/* parse the BIOS configuration and set up the alc_spec
12155 * return 1 if successful, 0 if the proper config is not found,
12156 * or a negative error code
12157 * Based on ALC880 version - had to change it to override
12158 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12159static int alc861vd_parse_auto_config(struct hda_codec *codec)
12160{
12161 struct alc_spec *spec = codec->spec;
12162 int err;
12163 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012165 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12166 alc861vd_ignore);
12167 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012168 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012169 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012170 return 0; /* can't find valid BIOS pin config */
12171
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012172 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12173 if (err < 0)
12174 return err;
12175 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12176 if (err < 0)
12177 return err;
12178 err = alc861vd_auto_create_extra_out(spec,
12179 spec->autocfg.speaker_pins[0],
12180 "Speaker");
12181 if (err < 0)
12182 return err;
12183 err = alc861vd_auto_create_extra_out(spec,
12184 spec->autocfg.hp_pins[0],
12185 "Headphone");
12186 if (err < 0)
12187 return err;
12188 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12189 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012190 return err;
12191
12192 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12193
12194 if (spec->autocfg.dig_out_pin)
12195 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12196
12197 if (spec->kctl_alloc)
12198 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12199
12200 spec->init_verbs[spec->num_init_verbs++]
12201 = alc861vd_volume_init_verbs;
12202
12203 spec->num_mux_defs = 1;
12204 spec->input_mux = &spec->private_imux;
12205
Takashi Iwai776e1842007-08-29 15:07:11 +020012206 err = alc_auto_add_mic_boost(codec);
12207 if (err < 0)
12208 return err;
12209
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012210 return 1;
12211}
12212
12213/* additional initialization for auto-configuration model */
12214static void alc861vd_auto_init(struct hda_codec *codec)
12215{
12216 alc861vd_auto_init_multi_out(codec);
12217 alc861vd_auto_init_hp_out(codec);
12218 alc861vd_auto_init_analog_input(codec);
12219}
12220
12221static int patch_alc861vd(struct hda_codec *codec)
12222{
12223 struct alc_spec *spec;
12224 int err, board_config;
12225
12226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12227 if (spec == NULL)
12228 return -ENOMEM;
12229
12230 codec->spec = spec;
12231
12232 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12233 alc861vd_models,
12234 alc861vd_cfg_tbl);
12235
12236 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12237 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12238 "ALC861VD, trying auto-probe from BIOS...\n");
12239 board_config = ALC861VD_AUTO;
12240 }
12241
12242 if (board_config == ALC861VD_AUTO) {
12243 /* automatic parse from the BIOS config */
12244 err = alc861vd_parse_auto_config(codec);
12245 if (err < 0) {
12246 alc_free(codec);
12247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012248 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012249 printk(KERN_INFO
12250 "hda_codec: Cannot set up configuration "
12251 "from BIOS. Using base mode...\n");
12252 board_config = ALC861VD_3ST;
12253 }
12254 }
12255
12256 if (board_config != ALC861VD_AUTO)
12257 setup_preset(spec, &alc861vd_presets[board_config]);
12258
12259 spec->stream_name_analog = "ALC861VD Analog";
12260 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12261 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12262
12263 spec->stream_name_digital = "ALC861VD Digital";
12264 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12265 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12266
12267 spec->adc_nids = alc861vd_adc_nids;
12268 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12269
12270 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12271 spec->num_mixers++;
12272
12273 codec->patch_ops = alc_patch_ops;
12274
12275 if (board_config == ALC861VD_AUTO)
12276 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012277#ifdef CONFIG_SND_HDA_POWER_SAVE
12278 if (!spec->loopback.amplist)
12279 spec->loopback.amplist = alc861vd_loopbacks;
12280#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012281
12282 return 0;
12283}
12284
12285/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012286 * ALC662 support
12287 *
12288 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12289 * configuration. Each pin widget can choose any input DACs and a mixer.
12290 * Each ADC is connected from a mixer of all inputs. This makes possible
12291 * 6-channel independent captures.
12292 *
12293 * In addition, an independent DAC for the multi-playback (not used in this
12294 * driver yet).
12295 */
12296#define ALC662_DIGOUT_NID 0x06
12297#define ALC662_DIGIN_NID 0x0a
12298
12299static hda_nid_t alc662_dac_nids[4] = {
12300 /* front, rear, clfe, rear_surr */
12301 0x02, 0x03, 0x04
12302};
12303
12304static hda_nid_t alc662_adc_nids[1] = {
12305 /* ADC1-2 */
12306 0x09,
12307};
12308/* input MUX */
12309/* FIXME: should be a matrix-type input source selection */
12310
12311static struct hda_input_mux alc662_capture_source = {
12312 .num_items = 4,
12313 .items = {
12314 { "Mic", 0x0 },
12315 { "Front Mic", 0x1 },
12316 { "Line", 0x2 },
12317 { "CD", 0x4 },
12318 },
12319};
12320
12321static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12322 .num_items = 2,
12323 .items = {
12324 { "Mic", 0x1 },
12325 { "Line", 0x2 },
12326 },
12327};
Kailang Yang291702f2007-10-16 14:28:03 +020012328
12329static struct hda_input_mux alc662_eeepc_capture_source = {
12330 .num_items = 2,
12331 .items = {
12332 { "i-Mic", 0x1 },
12333 { "e-Mic", 0x0 },
12334 },
12335};
12336
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012337#define alc662_mux_enum_info alc_mux_enum_info
12338#define alc662_mux_enum_get alc_mux_enum_get
12339
12340static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12341 struct snd_ctl_elem_value *ucontrol)
12342{
12343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12344 struct alc_spec *spec = codec->spec;
12345 const struct hda_input_mux *imux = spec->input_mux;
12346 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020012347 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012348 hda_nid_t nid = capture_mixers[adc_idx];
12349 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12350 unsigned int i, idx;
12351
12352 idx = ucontrol->value.enumerated.item[0];
12353 if (idx >= imux->num_items)
12354 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020012355 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012356 return 0;
12357 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020012358 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12359 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12360 imux->items[i].index,
12361 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012362 }
12363 *cur_val = idx;
12364 return 1;
12365}
12366/*
12367 * 2ch mode
12368 */
12369static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12370 { 2, NULL }
12371};
12372
12373/*
12374 * 2ch mode
12375 */
12376static struct hda_verb alc662_3ST_ch2_init[] = {
12377 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12378 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12379 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12380 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12381 { } /* end */
12382};
12383
12384/*
12385 * 6ch mode
12386 */
12387static struct hda_verb alc662_3ST_ch6_init[] = {
12388 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12389 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12390 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12393 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12394 { } /* end */
12395};
12396
12397static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12398 { 2, alc662_3ST_ch2_init },
12399 { 6, alc662_3ST_ch6_init },
12400};
12401
12402/*
12403 * 2ch mode
12404 */
12405static struct hda_verb alc662_sixstack_ch6_init[] = {
12406 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12407 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12408 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12409 { } /* end */
12410};
12411
12412/*
12413 * 6ch mode
12414 */
12415static struct hda_verb alc662_sixstack_ch8_init[] = {
12416 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12417 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12418 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12419 { } /* end */
12420};
12421
12422static struct hda_channel_mode alc662_5stack_modes[2] = {
12423 { 2, alc662_sixstack_ch6_init },
12424 { 6, alc662_sixstack_ch8_init },
12425};
12426
12427/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12428 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12429 */
12430
12431static struct snd_kcontrol_new alc662_base_mixer[] = {
12432 /* output mixer control */
12433 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12434 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12435 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12436 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12437 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12438 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12439 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12440 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12441 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12442
12443 /*Input mixer control */
12444 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12445 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12446 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12447 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12448 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12449 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12450 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12451 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012452 { } /* end */
12453};
12454
12455static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12456 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12457 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12459 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12460 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12461 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12462 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12463 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12464 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12467 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12468 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012469 { } /* end */
12470};
12471
12472static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12473 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12474 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12475 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12476 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12477 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12478 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12479 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12480 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12482 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12483 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12484 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12485 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12488 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12490 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12491 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012492 { } /* end */
12493};
12494
12495static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12496 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12497 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12498 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12499 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12501 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12502 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012505 { } /* end */
12506};
12507
Kailang Yang291702f2007-10-16 14:28:03 +020012508static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12509 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12510
12511 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12512 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12513
12514 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12515 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12516 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12517
12518 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12519 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12520 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12521 { } /* end */
12522};
12523
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012524static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12525 {
12526 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12527 .name = "Channel Mode",
12528 .info = alc_ch_mode_info,
12529 .get = alc_ch_mode_get,
12530 .put = alc_ch_mode_put,
12531 },
12532 { } /* end */
12533};
12534
12535static struct hda_verb alc662_init_verbs[] = {
12536 /* ADC: mute amp left and right */
12537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12538 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12539 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12540
Takashi Iwaicb53c622007-08-10 17:21:45 +020012541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012546
Kailang Yangb60dd392007-09-20 12:50:29 +020012547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012553
12554 /* Front Pin: output 0 (0x0c) */
12555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12557
12558 /* Rear Pin: output 1 (0x0d) */
12559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12561
12562 /* CLFE Pin: output 2 (0x0e) */
12563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12564 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12565
12566 /* Mic (rear) pin: input vref at 80% */
12567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12569 /* Front Mic pin: input vref at 80% */
12570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12572 /* Line In pin: input */
12573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12575 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12577 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12578 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12579 /* CD pin widget for input */
12580 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12581
12582 /* FIXME: use matrix-type input source selection */
12583 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12584 /* Input mixer */
12585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020012589
12590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012594 { }
12595};
12596
12597static struct hda_verb alc662_sue_init_verbs[] = {
12598 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12599 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020012600 {}
12601};
12602
12603static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12604 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12605 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12606 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012607};
12608
12609/*
12610 * generic initialization of ADC, input mixers and output mixers
12611 */
12612static struct hda_verb alc662_auto_init_verbs[] = {
12613 /*
12614 * Unmute ADC and set the default input to mic-in
12615 */
12616 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12618
12619 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12620 * mixer widget
12621 * Note: PASD motherboards uses the Line In 2 as the input for front
12622 * panel mic (mic 2)
12623 */
12624 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012630
12631 /*
12632 * Set up output mixers (0x0c - 0x0f)
12633 */
12634 /* set vol=0 to output mixers */
12635 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12636 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12637 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12638
12639 /* set up input amps for analog loopback */
12640 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020012641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12644 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012647
12648
12649 /* FIXME: use matrix-type input source selection */
12650 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12651 /* Input mixer */
12652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020012653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012654 { }
12655};
12656
12657/* capture mixer elements */
12658static struct snd_kcontrol_new alc662_capture_mixer[] = {
12659 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12660 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12661 {
12662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12663 /* The multiple "Capture Source" controls confuse alsamixer
12664 * So call somewhat different..
12665 * FIXME: the controls appear in the "playback" view!
12666 */
12667 /* .name = "Capture Source", */
12668 .name = "Input Source",
12669 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010012670 .info = alc662_mux_enum_info,
12671 .get = alc662_mux_enum_get,
12672 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012673 },
12674 { } /* end */
12675};
12676
12677static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
12678{
12679 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012680 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012681
12682 present = snd_hda_codec_read(codec, 0x14, 0,
12683 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012684 bits = present ? HDA_AMP_MUTE : 0;
12685 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12686 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012687}
12688
12689static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
12690{
12691 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012692 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012693
12694 present = snd_hda_codec_read(codec, 0x1b, 0,
12695 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012696 bits = present ? HDA_AMP_MUTE : 0;
12697 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12698 HDA_AMP_MUTE, bits);
12699 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12700 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012701}
12702
12703static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
12704 unsigned int res)
12705{
12706 if ((res >> 26) == ALC880_HP_EVENT)
12707 alc662_lenovo_101e_all_automute(codec);
12708 if ((res >> 26) == ALC880_FRONT_EVENT)
12709 alc662_lenovo_101e_ispeaker_automute(codec);
12710}
12711
Kailang Yang291702f2007-10-16 14:28:03 +020012712static void alc662_eeepc_mic_automute(struct hda_codec *codec)
12713{
12714 unsigned int present;
12715
12716 present = snd_hda_codec_read(codec, 0x18, 0,
12717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12718 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12719 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12720 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12721 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12722 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12723 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12724 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12725 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12726}
12727
12728/* unsolicited event for HP jack sensing */
12729static void alc662_eeepc_unsol_event(struct hda_codec *codec,
12730 unsigned int res)
12731{
12732 if ((res >> 26) == ALC880_HP_EVENT)
12733 alc262_hippo1_automute( codec );
12734
12735 if ((res >> 26) == ALC880_MIC_EVENT)
12736 alc662_eeepc_mic_automute(codec);
12737}
12738
12739static void alc662_eeepc_inithook(struct hda_codec *codec)
12740{
12741 alc262_hippo1_automute( codec );
12742 alc662_eeepc_mic_automute(codec);
12743}
12744
Takashi Iwaicb53c622007-08-10 17:21:45 +020012745#ifdef CONFIG_SND_HDA_POWER_SAVE
12746#define alc662_loopbacks alc880_loopbacks
12747#endif
12748
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012749
12750/* pcm configuration: identiacal with ALC880 */
12751#define alc662_pcm_analog_playback alc880_pcm_analog_playback
12752#define alc662_pcm_analog_capture alc880_pcm_analog_capture
12753#define alc662_pcm_digital_playback alc880_pcm_digital_playback
12754#define alc662_pcm_digital_capture alc880_pcm_digital_capture
12755
12756/*
12757 * configuration and preset
12758 */
12759static const char *alc662_models[ALC662_MODEL_LAST] = {
12760 [ALC662_3ST_2ch_DIG] = "3stack-dig",
12761 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
12762 [ALC662_3ST_6ch] = "3stack-6ch",
12763 [ALC662_5ST_DIG] = "6stack-dig",
12764 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020012765 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012766 [ALC662_AUTO] = "auto",
12767};
12768
12769static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012770 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012771 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012772 {}
12773};
12774
12775static struct alc_config_preset alc662_presets[] = {
12776 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012777 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012778 .init_verbs = { alc662_init_verbs },
12779 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12780 .dac_nids = alc662_dac_nids,
12781 .dig_out_nid = ALC662_DIGOUT_NID,
12782 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12783 .adc_nids = alc662_adc_nids,
12784 .dig_in_nid = ALC662_DIGIN_NID,
12785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12786 .channel_mode = alc662_3ST_2ch_modes,
12787 .input_mux = &alc662_capture_source,
12788 },
12789 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012790 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12791 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012792 .init_verbs = { alc662_init_verbs },
12793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12794 .dac_nids = alc662_dac_nids,
12795 .dig_out_nid = ALC662_DIGOUT_NID,
12796 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12797 .adc_nids = alc662_adc_nids,
12798 .dig_in_nid = ALC662_DIGIN_NID,
12799 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12800 .channel_mode = alc662_3ST_6ch_modes,
12801 .need_dac_fix = 1,
12802 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012803 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012804 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012805 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12806 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012807 .init_verbs = { alc662_init_verbs },
12808 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12809 .dac_nids = alc662_dac_nids,
12810 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12811 .adc_nids = alc662_adc_nids,
12812 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12813 .channel_mode = alc662_3ST_6ch_modes,
12814 .need_dac_fix = 1,
12815 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012816 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012817 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012818 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
12819 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012820 .init_verbs = { alc662_init_verbs },
12821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12822 .dac_nids = alc662_dac_nids,
12823 .dig_out_nid = ALC662_DIGOUT_NID,
12824 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12825 .adc_nids = alc662_adc_nids,
12826 .dig_in_nid = ALC662_DIGIN_NID,
12827 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
12828 .channel_mode = alc662_5stack_modes,
12829 .input_mux = &alc662_capture_source,
12830 },
12831 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020012832 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012833 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
12834 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12835 .dac_nids = alc662_dac_nids,
12836 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12837 .adc_nids = alc662_adc_nids,
12838 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12839 .channel_mode = alc662_3ST_2ch_modes,
12840 .input_mux = &alc662_lenovo_101e_capture_source,
12841 .unsol_event = alc662_lenovo_101e_unsol_event,
12842 .init_hook = alc662_lenovo_101e_all_automute,
12843 },
Kailang Yang291702f2007-10-16 14:28:03 +020012844 [ALC662_ASUS_EEEPC_P701] = {
12845 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
12846 .init_verbs = { alc662_init_verbs,
12847 alc662_eeepc_sue_init_verbs },
12848 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12849 .dac_nids = alc662_dac_nids,
12850 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12851 .adc_nids = alc662_adc_nids,
12852 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12853 .channel_mode = alc662_3ST_2ch_modes,
12854 .input_mux = &alc662_eeepc_capture_source,
12855 .unsol_event = alc662_eeepc_unsol_event,
12856 .init_hook = alc662_eeepc_inithook,
12857 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012858
12859};
12860
12861
12862/*
12863 * BIOS auto configuration
12864 */
12865
12866/* add playback controls from the parsed DAC table */
12867static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
12868 const struct auto_pin_cfg *cfg)
12869{
12870 char name[32];
12871 static const char *chname[4] = {
12872 "Front", "Surround", NULL /*CLFE*/, "Side"
12873 };
12874 hda_nid_t nid;
12875 int i, err;
12876
12877 for (i = 0; i < cfg->line_outs; i++) {
12878 if (!spec->multiout.dac_nids[i])
12879 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020012880 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012881 if (i == 2) {
12882 /* Center/LFE */
12883 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12884 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012885 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12886 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012887 if (err < 0)
12888 return err;
12889 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12890 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012891 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12892 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012893 if (err < 0)
12894 return err;
12895 err = add_control(spec, ALC_CTL_BIND_MUTE,
12896 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012897 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
12898 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012899 if (err < 0)
12900 return err;
12901 err = add_control(spec, ALC_CTL_BIND_MUTE,
12902 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012903 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
12904 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012905 if (err < 0)
12906 return err;
12907 } else {
12908 sprintf(name, "%s Playback Volume", chname[i]);
12909 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012910 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12911 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012912 if (err < 0)
12913 return err;
12914 sprintf(name, "%s Playback Switch", chname[i]);
12915 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012916 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
12917 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012918 if (err < 0)
12919 return err;
12920 }
12921 }
12922 return 0;
12923}
12924
12925/* add playback controls for speaker and HP outputs */
12926static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
12927 const char *pfx)
12928{
12929 hda_nid_t nid;
12930 int err;
12931 char name[32];
12932
12933 if (!pin)
12934 return 0;
12935
12936 if (alc880_is_fixed_pin(pin)) {
12937 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12938 /* printk("DAC nid=%x\n",nid); */
12939 /* specify the DAC as the extra output */
12940 if (!spec->multiout.hp_nid)
12941 spec->multiout.hp_nid = nid;
12942 else
12943 spec->multiout.extra_out_nid[0] = nid;
12944 /* control HP volume/switch on the output mixer amp */
12945 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12946 sprintf(name, "%s Playback Volume", pfx);
12947 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12948 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12949 if (err < 0)
12950 return err;
12951 sprintf(name, "%s Playback Switch", pfx);
12952 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12953 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
12954 if (err < 0)
12955 return err;
12956 } else if (alc880_is_multi_pin(pin)) {
12957 /* set manual connection */
12958 /* we have only a switch on HP-out PIN */
12959 sprintf(name, "%s Playback Switch", pfx);
12960 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12961 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12962 if (err < 0)
12963 return err;
12964 }
12965 return 0;
12966}
12967
12968/* create playback/capture controls for input pins */
12969static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
12970 const struct auto_pin_cfg *cfg)
12971{
12972 struct hda_input_mux *imux = &spec->private_imux;
12973 int i, err, idx;
12974
12975 for (i = 0; i < AUTO_PIN_LAST; i++) {
12976 if (alc880_is_input_pin(cfg->input_pins[i])) {
12977 idx = alc880_input_pin_idx(cfg->input_pins[i]);
12978 err = new_analog_input(spec, cfg->input_pins[i],
12979 auto_pin_cfg_labels[i],
12980 idx, 0x0b);
12981 if (err < 0)
12982 return err;
12983 imux->items[imux->num_items].label =
12984 auto_pin_cfg_labels[i];
12985 imux->items[imux->num_items].index =
12986 alc880_input_pin_idx(cfg->input_pins[i]);
12987 imux->num_items++;
12988 }
12989 }
12990 return 0;
12991}
12992
12993static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
12994 hda_nid_t nid, int pin_type,
12995 int dac_idx)
12996{
12997 /* set as output */
12998 snd_hda_codec_write(codec, nid, 0,
12999 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13000 snd_hda_codec_write(codec, nid, 0,
13001 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13002 /* need the manual connection? */
13003 if (alc880_is_multi_pin(nid)) {
13004 struct alc_spec *spec = codec->spec;
13005 int idx = alc880_multi_pin_idx(nid);
13006 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13007 AC_VERB_SET_CONNECT_SEL,
13008 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13009 }
13010}
13011
13012static void alc662_auto_init_multi_out(struct hda_codec *codec)
13013{
13014 struct alc_spec *spec = codec->spec;
13015 int i;
13016
13017 for (i = 0; i <= HDA_SIDE; i++) {
13018 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013019 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013020 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013021 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013022 i);
13023 }
13024}
13025
13026static void alc662_auto_init_hp_out(struct hda_codec *codec)
13027{
13028 struct alc_spec *spec = codec->spec;
13029 hda_nid_t pin;
13030
13031 pin = spec->autocfg.hp_pins[0];
13032 if (pin) /* connect to front */
13033 /* use dac 0 */
13034 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13035}
13036
13037#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13038#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13039
13040static void alc662_auto_init_analog_input(struct hda_codec *codec)
13041{
13042 struct alc_spec *spec = codec->spec;
13043 int i;
13044
13045 for (i = 0; i < AUTO_PIN_LAST; i++) {
13046 hda_nid_t nid = spec->autocfg.input_pins[i];
13047 if (alc662_is_input_pin(nid)) {
13048 snd_hda_codec_write(codec, nid, 0,
13049 AC_VERB_SET_PIN_WIDGET_CONTROL,
13050 (i <= AUTO_PIN_FRONT_MIC ?
13051 PIN_VREF80 : PIN_IN));
13052 if (nid != ALC662_PIN_CD_NID)
13053 snd_hda_codec_write(codec, nid, 0,
13054 AC_VERB_SET_AMP_GAIN_MUTE,
13055 AMP_OUT_MUTE);
13056 }
13057 }
13058}
13059
13060static int alc662_parse_auto_config(struct hda_codec *codec)
13061{
13062 struct alc_spec *spec = codec->spec;
13063 int err;
13064 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13065
13066 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13067 alc662_ignore);
13068 if (err < 0)
13069 return err;
13070 if (!spec->autocfg.line_outs)
13071 return 0; /* can't find valid BIOS pin config */
13072
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013073 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13074 if (err < 0)
13075 return err;
13076 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13077 if (err < 0)
13078 return err;
13079 err = alc662_auto_create_extra_out(spec,
13080 spec->autocfg.speaker_pins[0],
13081 "Speaker");
13082 if (err < 0)
13083 return err;
13084 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13085 "Headphone");
13086 if (err < 0)
13087 return err;
13088 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13089 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013090 return err;
13091
13092 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13093
13094 if (spec->autocfg.dig_out_pin)
13095 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13096
13097 if (spec->kctl_alloc)
13098 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13099
13100 spec->num_mux_defs = 1;
13101 spec->input_mux = &spec->private_imux;
13102
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013103 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013104 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13105 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013106 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013107}
13108
13109/* additional initialization for auto-configuration model */
13110static void alc662_auto_init(struct hda_codec *codec)
13111{
13112 alc662_auto_init_multi_out(codec);
13113 alc662_auto_init_hp_out(codec);
13114 alc662_auto_init_analog_input(codec);
13115}
13116
13117static int patch_alc662(struct hda_codec *codec)
13118{
13119 struct alc_spec *spec;
13120 int err, board_config;
13121
13122 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13123 if (!spec)
13124 return -ENOMEM;
13125
13126 codec->spec = spec;
13127
13128 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13129 alc662_models,
13130 alc662_cfg_tbl);
13131 if (board_config < 0) {
13132 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13133 "trying auto-probe from BIOS...\n");
13134 board_config = ALC662_AUTO;
13135 }
13136
13137 if (board_config == ALC662_AUTO) {
13138 /* automatic parse from the BIOS config */
13139 err = alc662_parse_auto_config(codec);
13140 if (err < 0) {
13141 alc_free(codec);
13142 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013143 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013144 printk(KERN_INFO
13145 "hda_codec: Cannot set up configuration "
13146 "from BIOS. Using base mode...\n");
13147 board_config = ALC662_3ST_2ch_DIG;
13148 }
13149 }
13150
13151 if (board_config != ALC662_AUTO)
13152 setup_preset(spec, &alc662_presets[board_config]);
13153
13154 spec->stream_name_analog = "ALC662 Analog";
13155 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13156 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13157
13158 spec->stream_name_digital = "ALC662 Digital";
13159 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13160 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13161
13162 if (!spec->adc_nids && spec->input_mux) {
13163 spec->adc_nids = alc662_adc_nids;
13164 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13165 }
13166
13167 codec->patch_ops = alc_patch_ops;
13168 if (board_config == ALC662_AUTO)
13169 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013170#ifdef CONFIG_SND_HDA_POWER_SAVE
13171 if (!spec->loopback.amplist)
13172 spec->loopback.amplist = alc662_loopbacks;
13173#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013174
13175 return 0;
13176}
13177
13178/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013179 * patch entries
13180 */
13181struct hda_codec_preset snd_hda_preset_realtek[] = {
13182 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013183 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013184 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013185 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013186 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013187 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013188 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013189 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13190 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13191 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013192 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13193 .patch = patch_alc883 },
13194 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13195 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013196 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013197 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013198 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013199 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013200 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013201 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013202 {} /* terminator */
13203};