blob: bf729f518f879265d0fa49f84fe8313eb89bba00 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
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,
Kailang Yang8c427222008-01-10 13:03:59 +010096 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020097 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020098 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020099 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200100 ALC262_ULTRA,
Kailang Yangdf694da2005-12-05 19:42:22 +0100101 ALC262_AUTO,
102 ALC262_MODEL_LAST /* last tag */
103};
104
Kailang Yanga361d842007-06-05 12:30:55 +0200105/* ALC268 models */
106enum {
107 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200108 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200109 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100110 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100111 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100112#ifdef CONFIG_SND_DEBUG
113 ALC268_TEST,
114#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200115 ALC268_AUTO,
116 ALC268_MODEL_LAST /* last tag */
117};
118
Kailang Yangf6a92242007-12-13 16:52:54 +0100119/* ALC269 models */
120enum {
121 ALC269_BASIC,
122 ALC269_AUTO,
123 ALC269_MODEL_LAST /* last tag */
124};
125
Kailang Yangdf694da2005-12-05 19:42:22 +0100126/* ALC861 models */
127enum {
128 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200129 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100130 ALC861_3ST_DIG,
131 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200132 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200133 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200134 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100135 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100136 ALC861_AUTO,
137 ALC861_MODEL_LAST,
138};
139
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100140/* ALC861-VD models */
141enum {
142 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200143 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100144 ALC861VD_3ST,
145 ALC861VD_3ST_DIG,
146 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200147 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200148 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200149 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100150 ALC861VD_AUTO,
151 ALC861VD_MODEL_LAST,
152};
153
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200154/* ALC662 models */
155enum {
156 ALC662_3ST_2ch_DIG,
157 ALC662_3ST_6ch_DIG,
158 ALC662_3ST_6ch,
159 ALC662_5ST_DIG,
160 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200161 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100162 ALC662_ASUS_EEEPC_EP20,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200163 ALC662_AUTO,
164 ALC662_MODEL_LAST,
165};
166
Kailang Yangdf694da2005-12-05 19:42:22 +0100167/* ALC882 models */
168enum {
169 ALC882_3ST_DIG,
170 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200171 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200172 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200173 ALC882_TARGA,
174 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200175 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100176 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200177 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200178 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200179 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100180 ALC882_MODEL_LAST,
181};
182
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200183/* ALC883 models */
184enum {
185 ALC883_3ST_2ch_DIG,
186 ALC883_3ST_6ch_DIG,
187 ALC883_3ST_6ch,
188 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200189 ALC883_TARGA_DIG,
190 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200191 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200192 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200193 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200194 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100195 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200196 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200197 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200198 ALC888_LENOVO_MS7195_DIG,
199 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200200 ALC888_6ST_HP,
201 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100202 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100203 ALC883_MITAC,
Jiang zhe368c7a92008-03-04 11:20:33 +0100204 ALC883_CLEVO_M720R,
Jiang zhefb97dc62008-03-06 11:07:11 +0100205 ALC883_FUJITSU_PI2515,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200206 ALC883_AUTO,
207 ALC883_MODEL_LAST,
208};
209
Kailang Yangdf694da2005-12-05 19:42:22 +0100210/* for GPIO Poll */
211#define GPIO_MASK 0x03
212
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213struct alc_spec {
214 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100215 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 unsigned int num_mixers;
217
Kailang Yangdf694da2005-12-05 19:42:22 +0100218 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200219 * don't forget NULL
220 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200221 */
222 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Takashi Iwai16ded522005-06-10 19:58:24 +0200224 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 struct hda_pcm_stream *stream_analog_playback;
226 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100227 struct hda_pcm_stream *stream_analog_alt_playback;
228 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200230 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 struct hda_pcm_stream *stream_digital_playback;
232 struct hda_pcm_stream *stream_digital_capture;
233
234 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200235 struct hda_multi_out multiout; /* playback set-up
236 * max_channels, dacs must be set
237 * dig_out_nid and hp_nid are optional
238 */
Takashi Iwai63300792008-01-24 15:31:36 +0100239 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
241 /* capture */
242 unsigned int num_adc_nids;
243 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100244 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200245 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200248 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 const struct hda_input_mux *input_mux;
250 unsigned int cur_mux[3];
251
252 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100253 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200255 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100258 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200259
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200260 /* dynamic controls, init_verbs and input_mux */
261 struct auto_pin_cfg autocfg;
262 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100263 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200264 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200265 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100266
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100267 /* hooks */
268 void (*init_hook)(struct hda_codec *codec);
269 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
270
Takashi Iwai834be882006-03-01 14:16:17 +0100271 /* for pin sensing */
272 unsigned int sense_updated: 1;
273 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100274 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200275
Takashi Iwai2134ea42008-01-10 16:53:55 +0100276 /* for virtual master */
277 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200278#ifdef CONFIG_SND_HDA_POWER_SAVE
279 struct hda_loopback_check loopback;
280#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100281};
282
283/*
284 * configuration template - to be copied to the spec instance
285 */
286struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200287 struct snd_kcontrol_new *mixers[5]; /* should be identical size
288 * with spec
289 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100290 const struct hda_verb *init_verbs[5];
291 unsigned int num_dacs;
292 hda_nid_t *dac_nids;
293 hda_nid_t dig_out_nid; /* optional */
294 hda_nid_t hp_nid; /* optional */
295 unsigned int num_adc_nids;
296 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100297 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100298 hda_nid_t dig_in_nid;
299 unsigned int num_channel_mode;
300 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200301 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200302 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100303 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100304 void (*unsol_event)(struct hda_codec *, unsigned int);
305 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200306#ifdef CONFIG_SND_HDA_POWER_SAVE
307 struct hda_amp_list *loopbacks;
308#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312/*
313 * input MUX handling
314 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200315static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
316 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317{
318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
319 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200320 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
321 if (mux_idx >= spec->num_mux_defs)
322 mux_idx = 0;
323 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324}
325
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200326static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
327 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
329 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
330 struct alc_spec *spec = codec->spec;
331 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
332
333 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
334 return 0;
335}
336
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200337static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
338 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339{
340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
341 struct alc_spec *spec = codec->spec;
342 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200343 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100344 hda_nid_t nid = spec->capsrc_nids ?
345 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200346 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100347 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348}
349
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351/*
352 * channel mode setting
353 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
355 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356{
357 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
358 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100359 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
360 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361}
362
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365{
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100368 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369 spec->num_channel_mode,
370 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371}
372
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375{
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200378 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
379 spec->num_channel_mode,
380 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200381 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200382 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
383 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384}
385
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100387 * Control the mode of pin widget settings via the mixer. "pc" is used
388 * instead of "%" to avoid consequences of accidently treating the % as
389 * being part of a format specifier. Maximum allowed length of a value is
390 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100391 *
392 * Note: some retasking pin complexes seem to ignore requests for input
393 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
394 * are requested. Therefore order this list so that this behaviour will not
395 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200396 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
397 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200398 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100399static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100400 "Mic 50pc bias", "Mic 80pc bias",
401 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100402};
403static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100404 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405};
406/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407 * in the pin being assumed to be exclusively an input or an output pin. In
408 * addition, "input" pins may or may not process the mic bias option
409 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
410 * accept requests for bias as of chip versions up to March 2006) and/or
411 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200413#define ALC_PIN_DIR_IN 0x00
414#define ALC_PIN_DIR_OUT 0x01
415#define ALC_PIN_DIR_INOUT 0x02
416#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
417#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200419/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420 * For each direction the minimum and maximum values are given.
421 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200422static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 { 0, 2 }, /* ALC_PIN_DIR_IN */
424 { 3, 4 }, /* ALC_PIN_DIR_OUT */
425 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200426 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
427 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428};
429#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
430#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
431#define alc_pin_mode_n_items(_dir) \
432 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
433
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200436{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 unsigned int item_num = uinfo->value.enumerated.item;
438 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
439
440 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200441 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100442 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
443
444 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
445 item_num = alc_pin_mode_min(dir);
446 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447 return 0;
448}
449
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200450static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200452{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
455 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200457 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
459 AC_VERB_GET_PIN_WIDGET_CONTROL,
460 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200461
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462 /* Find enumerated value for current pinctl setting */
463 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 return 0;
468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472{
473 signed int change;
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 hda_nid_t nid = kcontrol->private_value & 0xffff;
476 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
477 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200478 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
479 AC_VERB_GET_PIN_WIDGET_CONTROL,
480 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200482 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 val = alc_pin_mode_min(dir);
484
485 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100486 if (change) {
487 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200488 snd_hda_codec_write_cache(codec, nid, 0,
489 AC_VERB_SET_PIN_WIDGET_CONTROL,
490 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100491
492 /* Also enable the retasking pin's input/output as required
493 * for the requested pin mode. Enum values of 2 or less are
494 * input modes.
495 *
496 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200497 * reduces noise slightly (particularly on input) so we'll
498 * do it. However, having both input and output buffers
499 * enabled simultaneously doesn't seem to be problematic if
500 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100501 */
502 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200503 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
504 HDA_AMP_MUTE, HDA_AMP_MUTE);
505 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
506 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100507 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200508 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
509 HDA_AMP_MUTE, HDA_AMP_MUTE);
510 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
511 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100512 }
513 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200514 return change;
515}
516
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200518 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 .info = alc_pin_mode_info, \
520 .get = alc_pin_mode_get, \
521 .put = alc_pin_mode_put, \
522 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100523
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100524/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
525 * together using a mask with more than one bit set. This control is
526 * currently used only by the ALC260 test model. At this stage they are not
527 * needed for any "production" models.
528 */
529#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200530#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200531
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100534{
535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
536 hda_nid_t nid = kcontrol->private_value & 0xffff;
537 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
538 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539 unsigned int val = snd_hda_codec_read(codec, nid, 0,
540 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100541
542 *valp = (val & mask) != 0;
543 return 0;
544}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100547{
548 signed int change;
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 hda_nid_t nid = kcontrol->private_value & 0xffff;
551 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
552 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
554 AC_VERB_GET_GPIO_DATA,
555 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100556
557 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
559 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100560 gpio_data &= ~mask;
561 else
562 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200563 snd_hda_codec_write_cache(codec, nid, 0,
564 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100565
566 return change;
567}
568#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
569 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
570 .info = alc_gpio_data_info, \
571 .get = alc_gpio_data_get, \
572 .put = alc_gpio_data_put, \
573 .private_value = nid | (mask<<16) }
574#endif /* CONFIG_SND_DEBUG */
575
Jonathan Woithe92621f12006-02-28 11:47:47 +0100576/* A switch control to allow the enabling of the digital IO pins on the
577 * ALC260. This is incredibly simplistic; the intention of this control is
578 * to provide something in the test model allowing digital outputs to be
579 * identified if present. If models are found which can utilise these
580 * outputs a more complete mixer control can be devised for those models if
581 * necessary.
582 */
583#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200584#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200585
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
587 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100588{
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 hda_nid_t nid = kcontrol->private_value & 0xffff;
591 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
592 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200593 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100594 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100595
596 *valp = (val & mask) != 0;
597 return 0;
598}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100601{
602 signed int change;
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 hda_nid_t nid = kcontrol->private_value & 0xffff;
605 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
606 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100608 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100610
611 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100613 if (val==0)
614 ctrl_data &= ~mask;
615 else
616 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200617 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
618 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100619
620 return change;
621}
622#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
623 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
624 .info = alc_spdif_ctrl_info, \
625 .get = alc_spdif_ctrl_get, \
626 .put = alc_spdif_ctrl_put, \
627 .private_value = nid | (mask<<16) }
628#endif /* CONFIG_SND_DEBUG */
629
Jonathan Woithef8225f62008-01-08 12:16:54 +0100630/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
631 * Again, this is only used in the ALC26x test models to help identify when
632 * the EAPD line must be asserted for features to work.
633 */
634#ifdef CONFIG_SND_DEBUG
635#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
636
637static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 hda_nid_t nid = kcontrol->private_value & 0xffff;
642 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
643 long *valp = ucontrol->value.integer.value;
644 unsigned int val = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
646
647 *valp = (val & mask) != 0;
648 return 0;
649}
650
651static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 int change;
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 hda_nid_t nid = kcontrol->private_value & 0xffff;
657 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
658 long val = *ucontrol->value.integer.value;
659 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
660 AC_VERB_GET_EAPD_BTLENABLE,
661 0x00);
662
663 /* Set/unset the masked control bit(s) as needed */
664 change = (!val ? 0 : mask) != (ctrl_data & mask);
665 if (!val)
666 ctrl_data &= ~mask;
667 else
668 ctrl_data |= mask;
669 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
670 ctrl_data);
671
672 return change;
673}
674
675#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
676 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
677 .info = alc_eapd_ctrl_info, \
678 .get = alc_eapd_ctrl_get, \
679 .put = alc_eapd_ctrl_put, \
680 .private_value = nid | (mask<<16) }
681#endif /* CONFIG_SND_DEBUG */
682
Kailang Yangdf694da2005-12-05 19:42:22 +0100683/*
684 * set up from the preset table
685 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200686static void setup_preset(struct alc_spec *spec,
687 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100688{
689 int i;
690
691 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
692 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
694 i++)
695 spec->init_verbs[spec->num_init_verbs++] =
696 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100697
698 spec->channel_mode = preset->channel_mode;
699 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200700 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100701
702 spec->multiout.max_channels = spec->channel_mode[0].channels;
703
704 spec->multiout.num_dacs = preset->num_dacs;
705 spec->multiout.dac_nids = preset->dac_nids;
706 spec->multiout.dig_out_nid = preset->dig_out_nid;
707 spec->multiout.hp_nid = preset->hp_nid;
708
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200709 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200710 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200711 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100712 spec->input_mux = preset->input_mux;
713
714 spec->num_adc_nids = preset->num_adc_nids;
715 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100716 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100717 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100718
719 spec->unsol_event = preset->unsol_event;
720 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200721#ifdef CONFIG_SND_HDA_POWER_SAVE
722 spec->loopback.amplist = preset->loopbacks;
723#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100724}
725
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200726/* Enable GPIO mask and set output */
727static struct hda_verb alc_gpio1_init_verbs[] = {
728 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
729 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
730 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
731 { }
732};
733
734static struct hda_verb alc_gpio2_init_verbs[] = {
735 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
737 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
738 { }
739};
740
Kailang Yangbdd148a2007-05-08 15:19:08 +0200741static struct hda_verb alc_gpio3_init_verbs[] = {
742 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
743 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
744 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
745 { }
746};
747
Kailang Yangc9b58002007-10-16 14:30:01 +0200748static void alc_sku_automute(struct hda_codec *codec)
749{
750 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200751 unsigned int present;
752 unsigned int hp_nid = spec->autocfg.hp_pins[0];
753 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
754
755 /* need to execute and sync at first */
756 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
757 present = snd_hda_codec_read(codec, hp_nid, 0,
758 AC_VERB_GET_PIN_SENSE, 0);
759 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100760 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
761 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200762}
763
764/* unsolicited event for HP jack sensing */
765static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
766{
767 if (codec->vendor_id == 0x10ec0880)
768 res >>= 28;
769 else
770 res >>= 26;
771 if (res != ALC880_HP_EVENT)
772 return;
773
774 alc_sku_automute(codec);
775}
776
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200777/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
778 * 31 ~ 16 : Manufacture ID
779 * 15 ~ 8 : SKU ID
780 * 7 ~ 0 : Assembly ID
781 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
782 */
783static void alc_subsystem_id(struct hda_codec *codec,
784 unsigned int porta, unsigned int porte,
785 unsigned int portd)
786{
Kailang Yangc9b58002007-10-16 14:30:01 +0200787 unsigned int ass, tmp, i;
788 unsigned nid;
789 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200790
Kailang Yangc9b58002007-10-16 14:30:01 +0200791 ass = codec->subsystem_id & 0xffff;
792 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
793 goto do_sku;
794
795 /*
796 * 31~30 : port conetcivity
797 * 29~21 : reserve
798 * 20 : PCBEEP input
799 * 19~16 : Check sum (15:1)
800 * 15~1 : Custom
801 * 0 : override
802 */
803 nid = 0x1d;
804 if (codec->vendor_id == 0x10ec0260)
805 nid = 0x17;
806 ass = snd_hda_codec_read(codec, nid, 0,
807 AC_VERB_GET_CONFIG_DEFAULT, 0);
808 if (!(ass & 1) && !(ass & 0x100000))
809 return;
810 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200811 return;
812
Kailang Yangc9b58002007-10-16 14:30:01 +0200813 /* check sum */
814 tmp = 0;
815 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100816 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200817 tmp++;
818 }
819 if (((ass >> 16) & 0xf) != tmp)
820 return;
821do_sku:
822 /*
823 * 0 : override
824 * 1 : Swap Jack
825 * 2 : 0 --> Desktop, 1 --> Laptop
826 * 3~5 : External Amplifier control
827 * 7~6 : Reserved
828 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200829 tmp = (ass & 0x38) >> 3; /* external Amp control */
830 switch (tmp) {
831 case 1:
832 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
833 break;
834 case 3:
835 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
836 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200837 case 7:
838 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
839 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200840 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200841 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200842 case 0x10ec0260:
843 snd_hda_codec_write(codec, 0x0f, 0,
844 AC_VERB_SET_EAPD_BTLENABLE, 2);
845 snd_hda_codec_write(codec, 0x10, 0,
846 AC_VERB_SET_EAPD_BTLENABLE, 2);
847 break;
848 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200849 case 0x10ec0267:
850 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200851 case 0x10ec0269:
852 case 0x10ec0862:
853 case 0x10ec0662:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200854 snd_hda_codec_write(codec, 0x14, 0,
855 AC_VERB_SET_EAPD_BTLENABLE, 2);
856 snd_hda_codec_write(codec, 0x15, 0,
857 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200858 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200859 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200860 switch (codec->vendor_id) {
861 case 0x10ec0260:
862 snd_hda_codec_write(codec, 0x1a, 0,
863 AC_VERB_SET_COEF_INDEX, 7);
864 tmp = snd_hda_codec_read(codec, 0x1a, 0,
865 AC_VERB_GET_PROC_COEF, 0);
866 snd_hda_codec_write(codec, 0x1a, 0,
867 AC_VERB_SET_COEF_INDEX, 7);
868 snd_hda_codec_write(codec, 0x1a, 0,
869 AC_VERB_SET_PROC_COEF,
870 tmp | 0x2010);
871 break;
872 case 0x10ec0262:
873 case 0x10ec0880:
874 case 0x10ec0882:
875 case 0x10ec0883:
876 case 0x10ec0885:
877 case 0x10ec0888:
878 snd_hda_codec_write(codec, 0x20, 0,
879 AC_VERB_SET_COEF_INDEX, 7);
880 tmp = snd_hda_codec_read(codec, 0x20, 0,
881 AC_VERB_GET_PROC_COEF, 0);
882 snd_hda_codec_write(codec, 0x20, 0,
883 AC_VERB_SET_COEF_INDEX, 7);
884 snd_hda_codec_write(codec, 0x20, 0,
885 AC_VERB_SET_PROC_COEF,
886 tmp | 0x2010);
887 break;
888 case 0x10ec0267:
889 case 0x10ec0268:
890 snd_hda_codec_write(codec, 0x20, 0,
891 AC_VERB_SET_COEF_INDEX, 7);
892 tmp = snd_hda_codec_read(codec, 0x20, 0,
893 AC_VERB_GET_PROC_COEF, 0);
894 snd_hda_codec_write(codec, 0x20, 0,
895 AC_VERB_SET_COEF_INDEX, 7);
896 snd_hda_codec_write(codec, 0x20, 0,
897 AC_VERB_SET_PROC_COEF,
898 tmp | 0x3000);
899 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200900 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200901 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200902 break;
903 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200904
Kailang Yang8c427222008-01-10 13:03:59 +0100905 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 * when the external headphone out jack is plugged"
907 */
Kailang Yang8c427222008-01-10 13:03:59 +0100908 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200909 return;
910 /*
911 * 10~8 : Jack location
912 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
913 * 14~13: Resvered
914 * 15 : 1 --> enable the function "Mute internal speaker
915 * when the external headphone out jack is plugged"
916 */
917 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100918 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100920 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200921 else
922 return;
923 }
924
925 if (!spec->autocfg.hp_pins[0]) {
926 tmp = (ass >> 11) & 0x3; /* HP to chassis */
927 if (tmp == 0)
928 spec->autocfg.hp_pins[0] = porta;
929 else if (tmp == 1)
930 spec->autocfg.hp_pins[0] = porte;
931 else if (tmp == 2)
932 spec->autocfg.hp_pins[0] = portd;
933 else
934 return;
935 }
936
937 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
938 AC_VERB_SET_UNSOLICITED_ENABLE,
939 AC_USRSP_EN | ALC880_HP_EVENT);
940 spec->unsol_event = alc_sku_unsol_event;
941 spec->init_hook = alc_sku_automute;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200942}
943
Takashi Iwai41e41f12005-06-08 14:48:49 +0200944/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200945 * Fix-up pin default configurations
946 */
947
948struct alc_pincfg {
949 hda_nid_t nid;
950 u32 val;
951};
952
953static void alc_fix_pincfg(struct hda_codec *codec,
954 const struct snd_pci_quirk *quirk,
955 const struct alc_pincfg **pinfix)
956{
957 const struct alc_pincfg *cfg;
958
959 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
960 if (!quirk)
961 return;
962
963 cfg = pinfix[quirk->value];
964 for (; cfg->nid; cfg++) {
965 int i;
966 u32 val = cfg->val;
967 for (i = 0; i < 4; i++) {
968 snd_hda_codec_write(codec, cfg->nid, 0,
969 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
970 val & 0xff);
971 val >>= 8;
972 }
973 }
974}
975
976/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200977 * ALC880 3-stack model
978 *
979 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200980 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
981 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 */
983
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200984static hda_nid_t alc880_dac_nids[4] = {
985 /* front, rear, clfe, rear_surr */
986 0x02, 0x05, 0x04, 0x03
987};
988
989static hda_nid_t alc880_adc_nids[3] = {
990 /* ADC0-2 */
991 0x07, 0x08, 0x09,
992};
993
994/* The datasheet says the node 0x07 is connected from inputs,
995 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100996 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200998static hda_nid_t alc880_adc_nids_alt[2] = {
999 /* ADC1-2 */
1000 0x08, 0x09,
1001};
1002
1003#define ALC880_DIGOUT_NID 0x06
1004#define ALC880_DIGIN_NID 0x0a
1005
1006static struct hda_input_mux alc880_capture_source = {
1007 .num_items = 4,
1008 .items = {
1009 { "Mic", 0x0 },
1010 { "Front Mic", 0x3 },
1011 { "Line", 0x2 },
1012 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001014};
1015
1016/* channel source setting (2/6 channel selection for 3-stack) */
1017/* 2ch mode */
1018static struct hda_verb alc880_threestack_ch2_init[] = {
1019 /* set line-in to input, mute it */
1020 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1021 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1022 /* set mic-in to input vref 80%, mute it */
1023 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1024 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 { } /* end */
1026};
1027
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001028/* 6ch mode */
1029static struct hda_verb alc880_threestack_ch6_init[] = {
1030 /* set line-in to output, unmute it */
1031 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1032 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1033 /* set mic-in to output, unmute it */
1034 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1035 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1036 { } /* end */
1037};
1038
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001039static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001040 { 2, alc880_threestack_ch2_init },
1041 { 6, alc880_threestack_ch6_init },
1042};
1043
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001044static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001048 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1054 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1055 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1056 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1060 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1061 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1062 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001064 {
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1066 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001067 .info = alc_ch_mode_info,
1068 .get = alc_ch_mode_get,
1069 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001070 },
1071 { } /* end */
1072};
1073
1074/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001075static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001076 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1082 {
1083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1084 /* The multiple "Capture Source" controls confuse alsamixer
1085 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001086 */
1087 /* .name = "Capture Source", */
1088 .name = "Input Source",
1089 .count = 3,
1090 .info = alc_mux_enum_info,
1091 .get = alc_mux_enum_get,
1092 .put = alc_mux_enum_put,
1093 },
1094 { } /* end */
1095};
1096
1097/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001098static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001099 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1100 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 {
1104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1105 /* The multiple "Capture Source" controls confuse alsamixer
1106 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 */
1108 /* .name = "Capture Source", */
1109 .name = "Input Source",
1110 .count = 2,
1111 .info = alc_mux_enum_info,
1112 .get = alc_mux_enum_get,
1113 .put = alc_mux_enum_put,
1114 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 { } /* end */
1116};
1117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001118
1119
1120/*
1121 * ALC880 5-stack model
1122 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001123 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1124 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1126 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1127 */
1128
1129/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001130static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001131 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001132 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 { } /* end */
1134};
1135
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001136/* channel source setting (6/8 channel selection for 5-stack) */
1137/* 6ch mode */
1138static struct hda_verb alc880_fivestack_ch6_init[] = {
1139 /* set line-in to input, mute it */
1140 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1141 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001142 { } /* end */
1143};
1144
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001145/* 8ch mode */
1146static struct hda_verb alc880_fivestack_ch8_init[] = {
1147 /* set line-in to output, unmute it */
1148 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1149 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1150 { } /* end */
1151};
1152
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001153static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001154 { 6, alc880_fivestack_ch6_init },
1155 { 8, alc880_fivestack_ch8_init },
1156};
1157
1158
1159/*
1160 * ALC880 6-stack model
1161 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001162 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1163 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001164 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1165 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1166 */
1167
1168static hda_nid_t alc880_6st_dac_nids[4] = {
1169 /* front, rear, clfe, rear_surr */
1170 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001171};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001172
1173static struct hda_input_mux alc880_6stack_capture_source = {
1174 .num_items = 4,
1175 .items = {
1176 { "Mic", 0x0 },
1177 { "Front Mic", 0x1 },
1178 { "Line", 0x2 },
1179 { "CD", 0x4 },
1180 },
1181};
1182
1183/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001184static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001185 { 8, NULL },
1186};
1187
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001188static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001192 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001195 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1196 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001197 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001198 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001199 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1200 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1206 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1208 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001209 {
1210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1211 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001212 .info = alc_ch_mode_info,
1213 .get = alc_ch_mode_get,
1214 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001215 },
1216 { } /* end */
1217};
1218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001219
1220/*
1221 * ALC880 W810 model
1222 *
1223 * W810 has rear IO for:
1224 * Front (DAC 02)
1225 * Surround (DAC 03)
1226 * Center/LFE (DAC 04)
1227 * Digital out (06)
1228 *
1229 * The system also has a pair of internal speakers, and a headphone jack.
1230 * These are both connected to Line2 on the codec, hence to DAC 02.
1231 *
1232 * There is a variable resistor to control the speaker or headphone
1233 * volume. This is a hardware-only device without a software API.
1234 *
1235 * Plugging headphones in will disable the internal speakers. This is
1236 * implemented in hardware, not via the driver using jack sense. In
1237 * a similar fashion, plugging into the rear socket marked "front" will
1238 * disable both the speakers and headphones.
1239 *
1240 * For input, there's a microphone jack, and an "audio in" jack.
1241 * These may not do anything useful with this driver yet, because I
1242 * haven't setup any initialization verbs for these yet...
1243 */
1244
1245static hda_nid_t alc880_w810_dac_nids[3] = {
1246 /* front, rear/surround, clfe */
1247 0x02, 0x03, 0x04
1248};
1249
1250/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001251static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001252 { 6, NULL }
1253};
1254
1255/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001256static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001260 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001261 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1262 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001263 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1264 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001265 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1266 { } /* end */
1267};
1268
1269
1270/*
1271 * Z710V model
1272 *
1273 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001274 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1275 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001276 */
1277
1278static hda_nid_t alc880_z71v_dac_nids[1] = {
1279 0x02
1280};
1281#define ALC880_Z71V_HP_DAC 0x03
1282
1283/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001284static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285 { 2, NULL }
1286};
1287
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001288static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001289 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001290 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001292 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1294 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1297 { } /* end */
1298};
1299
1300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001301/*
1302 * ALC880 F1734 model
1303 *
1304 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1305 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1306 */
1307
1308static hda_nid_t alc880_f1734_dac_nids[1] = {
1309 0x03
1310};
1311#define ALC880_F1734_HP_DAC 0x02
1312
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001313static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001315 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001316 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1317 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001318 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1319 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1321 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001322 { } /* end */
1323};
1324
Takashi Iwai937b4162008-02-11 14:52:36 +01001325static struct hda_input_mux alc880_f1734_capture_source = {
1326 .num_items = 2,
1327 .items = {
1328 { "Mic", 0x1 },
1329 { "CD", 0x4 },
1330 },
1331};
1332
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001333
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001334/*
1335 * ALC880 ASUS model
1336 *
1337 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1338 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1339 * Mic = 0x18, Line = 0x1a
1340 */
1341
1342#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1343#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1344
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001345static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001346 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001347 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001348 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001349 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001350 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1351 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001352 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1353 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001360 {
1361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1362 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001363 .info = alc_ch_mode_info,
1364 .get = alc_ch_mode_get,
1365 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001366 },
1367 { } /* end */
1368};
1369
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001370/*
1371 * ALC880 ASUS W1V model
1372 *
1373 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1374 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1375 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1376 */
1377
1378/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001379static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001380 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1381 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001382 { } /* end */
1383};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001385/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001386static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001387 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1388 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1389 { } /* end */
1390};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001391
Kailang Yangdf694da2005-12-05 19:42:22 +01001392/* TCL S700 */
1393static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1395 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1398 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1401 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1402 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1403 {
1404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1405 /* The multiple "Capture Source" controls confuse alsamixer
1406 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001407 */
1408 /* .name = "Capture Source", */
1409 .name = "Input Source",
1410 .count = 1,
1411 .info = alc_mux_enum_info,
1412 .get = alc_mux_enum_get,
1413 .put = alc_mux_enum_put,
1414 },
1415 { } /* end */
1416};
1417
Kailang Yangccc656c2006-10-17 12:32:26 +02001418/* Uniwill */
1419static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001420 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1421 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1422 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1423 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001424 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1425 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1426 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1427 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1436 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1437 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1438 {
1439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1440 .name = "Channel Mode",
1441 .info = alc_ch_mode_info,
1442 .get = alc_ch_mode_get,
1443 .put = alc_ch_mode_put,
1444 },
1445 { } /* end */
1446};
1447
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001448static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1449 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1450 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1452 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1453 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1454 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1455 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1456 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1457 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1458 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1459 { } /* end */
1460};
1461
Kailang Yangccc656c2006-10-17 12:32:26 +02001462static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001463 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1464 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1465 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1466 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1469 { } /* end */
1470};
1471
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001473 * virtual master controls
1474 */
1475
1476/*
1477 * slave controls for virtual master
1478 */
1479static const char *alc_slave_vols[] = {
1480 "Front Playback Volume",
1481 "Surround Playback Volume",
1482 "Center Playback Volume",
1483 "LFE Playback Volume",
1484 "Side Playback Volume",
1485 "Headphone Playback Volume",
1486 "Speaker Playback Volume",
1487 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001488 "Line-Out Playback Volume",
1489 NULL,
1490};
1491
1492static const char *alc_slave_sws[] = {
1493 "Front Playback Switch",
1494 "Surround Playback Switch",
1495 "Center Playback Switch",
1496 "LFE Playback Switch",
1497 "Side Playback Switch",
1498 "Headphone Playback Switch",
1499 "Speaker Playback Switch",
1500 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001501 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001502 NULL,
1503};
1504
1505/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 */
1508static int alc_build_controls(struct hda_codec *codec)
1509{
1510 struct alc_spec *spec = codec->spec;
1511 int err;
1512 int i;
1513
1514 for (i = 0; i < spec->num_mixers; i++) {
1515 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1516 if (err < 0)
1517 return err;
1518 }
1519
1520 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001521 err = snd_hda_create_spdif_out_ctls(codec,
1522 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 if (err < 0)
1524 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001525 err = snd_hda_create_spdif_share_sw(codec,
1526 &spec->multiout);
1527 if (err < 0)
1528 return err;
1529 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 }
1531 if (spec->dig_in_nid) {
1532 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1533 if (err < 0)
1534 return err;
1535 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001536
1537 /* if we have no master control, let's create it */
1538 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001539 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001540 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001541 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001542 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001543 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001544 if (err < 0)
1545 return err;
1546 }
1547 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1548 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1549 NULL, alc_slave_sws);
1550 if (err < 0)
1551 return err;
1552 }
1553
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 return 0;
1555}
1556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001557
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558/*
1559 * initialize the codec volumes, etc
1560 */
1561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562/*
1563 * generic initialization of ADC, input mixers and output mixers
1564 */
1565static struct hda_verb alc880_volume_init_verbs[] = {
1566 /*
1567 * Unmute ADC0-2 and set the default input to mic-in
1568 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001569 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001571 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001573 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001576 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1577 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001578 * Note: PASD motherboards uses the Line In 2 as the input for front
1579 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001581 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001590 /*
1591 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001593 /* set vol=0 to output mixers */
1594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1597 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1598 /* set up input amps for analog loopback */
1599 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001604 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608
1609 { }
1610};
1611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001612/*
1613 * 3-stack pin configuration:
1614 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1615 */
1616static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1617 /*
1618 * preset connection lists of input pins
1619 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1620 */
1621 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1622 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1623 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1624
1625 /*
1626 * Set pin mode and muting
1627 */
1628 /* set front pin widgets 0x14 for output */
1629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1631 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1632 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1633 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1634 /* Mic2 (as headphone out) for HP output */
1635 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1636 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 /* Line In pin widget for input */
1638 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1640 /* Line2 (as front mic) pin widget for input and vref at 80% */
1641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1643 /* CD pin widget for input */
1644 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1645
1646 { }
1647};
1648
1649/*
1650 * 5-stack pin configuration:
1651 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1652 * line-in/side = 0x1a, f-mic = 0x1b
1653 */
1654static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1655 /*
1656 * preset connection lists of input pins
1657 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1658 */
1659 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1660 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1661
1662 /*
1663 * Set pin mode and muting
1664 */
1665 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1668 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001670 /* unmute pins for output (no gain on this amp) */
1671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1674 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001677 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1679 /* Mic2 (as headphone out) for HP output */
1680 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001681 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001682 /* Line In pin widget for input */
1683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1685 /* Line2 (as front mic) pin widget for input and vref at 80% */
1686 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1687 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1688 /* CD pin widget for input */
1689 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690
1691 { }
1692};
1693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001694/*
1695 * W810 pin configuration:
1696 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1697 */
1698static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 /* hphone/speaker input selector: front DAC */
1700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1701
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1707 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708
1709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 { }
1713};
1714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001715/*
1716 * Z71V pin configuration:
1717 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1718 */
1719static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001724
Takashi Iwai16ded522005-06-10 19:58:24 +02001725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001729
1730 { }
1731};
1732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733/*
1734 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001735 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1736 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 */
1738static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1739 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1740
Takashi Iwai16ded522005-06-10 19:58:24 +02001741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001745 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001747 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1749
Takashi Iwai16ded522005-06-10 19:58:24 +02001750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001752 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001756 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1759
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760 { }
1761};
Takashi Iwai16ded522005-06-10 19:58:24 +02001762
Kailang Yangccc656c2006-10-17 12:32:26 +02001763/*
1764 * Uniwill pin configuration:
1765 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1766 * line = 0x1a
1767 */
1768static struct hda_verb alc880_uniwill_init_verbs[] = {
1769 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1770
1771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1775 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1778 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1785
1786 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1787 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1792 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1793 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1794 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1795
1796 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1797 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1798
1799 { }
1800};
1801
1802/*
1803* Uniwill P53
1804* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1805 */
1806static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1807 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1808
1809 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1811 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1813 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1814 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1820 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1821
1822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1824 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1826 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1828
1829 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1830 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1831
1832 { }
1833};
1834
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001835static struct hda_verb alc880_beep_init_verbs[] = {
1836 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1837 { }
1838};
1839
Kailang Yangccc656c2006-10-17 12:32:26 +02001840/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001841static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001842{
1843 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001844 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001845
1846 present = snd_hda_codec_read(codec, 0x14, 0,
1847 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001848 bits = present ? HDA_AMP_MUTE : 0;
1849 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1850 HDA_AMP_MUTE, bits);
1851 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1852 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001853}
1854
1855/* auto-toggle front mic */
1856static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1857{
1858 unsigned int present;
1859 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001860
1861 present = snd_hda_codec_read(codec, 0x18, 0,
1862 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001863 bits = present ? HDA_AMP_MUTE : 0;
1864 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001865}
1866
1867static void alc880_uniwill_automute(struct hda_codec *codec)
1868{
1869 alc880_uniwill_hp_automute(codec);
1870 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001871}
1872
1873static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1874 unsigned int res)
1875{
1876 /* Looks like the unsol event is incompatible with the standard
1877 * definition. 4bit tag is placed at 28 bit!
1878 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001879 switch (res >> 28) {
1880 case ALC880_HP_EVENT:
1881 alc880_uniwill_hp_automute(codec);
1882 break;
1883 case ALC880_MIC_EVENT:
1884 alc880_uniwill_mic_automute(codec);
1885 break;
1886 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001887}
1888
1889static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1890{
1891 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001892 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001893
1894 present = snd_hda_codec_read(codec, 0x14, 0,
1895 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001896 bits = present ? HDA_AMP_MUTE : 0;
1897 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001898}
1899
1900static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1901{
1902 unsigned int present;
1903
1904 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001905 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1906 present &= HDA_AMP_VOLMASK;
1907 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1908 HDA_AMP_VOLMASK, present);
1909 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1910 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001911}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001912
Kailang Yangccc656c2006-10-17 12:32:26 +02001913static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1914 unsigned int res)
1915{
1916 /* Looks like the unsol event is incompatible with the standard
1917 * definition. 4bit tag is placed at 28 bit!
1918 */
1919 if ((res >> 28) == ALC880_HP_EVENT)
1920 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001921 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001922 alc880_uniwill_p53_dcvol_automute(codec);
1923}
1924
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925/*
1926 * F1734 pin configuration:
1927 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1928 */
1929static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01001930 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1932 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1933 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1934 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1935
1936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1940
1941 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01001943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1949 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001950
Takashi Iwai937b4162008-02-11 14:52:36 +01001951 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1952 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1953
Takashi Iwai16ded522005-06-10 19:58:24 +02001954 { }
1955};
1956
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001957/*
1958 * ASUS pin configuration:
1959 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1960 */
1961static struct hda_verb alc880_pin_asus_init_verbs[] = {
1962 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1963 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1964 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1965 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1966
1967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1973 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1975
1976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1985
1986 { }
1987};
1988
1989/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001990#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1991#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001992
Kailang Yangdf694da2005-12-05 19:42:22 +01001993/* Clevo m520g init */
1994static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1995 /* headphone output */
1996 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1997 /* line-out */
1998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1999 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2000 /* Line-in */
2001 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2003 /* CD */
2004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2005 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 /* Mic1 (rear panel) */
2007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 /* Mic2 (front panel) */
2010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2011 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 /* headphone */
2013 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 /* change to EAPD mode */
2016 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2017 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2018
2019 { }
2020};
2021
2022static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002023 /* change to EAPD mode */
2024 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2025 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2026
Kailang Yangdf694da2005-12-05 19:42:22 +01002027 /* Headphone output */
2028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2029 /* Front output*/
2030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2032
2033 /* Line In pin widget for input */
2034 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2035 /* CD pin widget for input */
2036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2037 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2039
2040 /* change to EAPD mode */
2041 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2042 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2043
2044 { }
2045};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002046
2047/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002048 * LG m1 express dual
2049 *
2050 * Pin assignment:
2051 * Rear Line-In/Out (blue): 0x14
2052 * Build-in Mic-In: 0x15
2053 * Speaker-out: 0x17
2054 * HP-Out (green): 0x1b
2055 * Mic-In/Out (red): 0x19
2056 * SPDIF-Out: 0x1e
2057 */
2058
2059/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2060static hda_nid_t alc880_lg_dac_nids[3] = {
2061 0x05, 0x02, 0x03
2062};
2063
2064/* seems analog CD is not working */
2065static struct hda_input_mux alc880_lg_capture_source = {
2066 .num_items = 3,
2067 .items = {
2068 { "Mic", 0x1 },
2069 { "Line", 0x5 },
2070 { "Internal Mic", 0x6 },
2071 },
2072};
2073
2074/* 2,4,6 channel modes */
2075static struct hda_verb alc880_lg_ch2_init[] = {
2076 /* set line-in and mic-in to input */
2077 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2078 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2079 { }
2080};
2081
2082static struct hda_verb alc880_lg_ch4_init[] = {
2083 /* set line-in to out and mic-in to input */
2084 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2085 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2086 { }
2087};
2088
2089static struct hda_verb alc880_lg_ch6_init[] = {
2090 /* set line-in and mic-in to output */
2091 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2092 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2093 { }
2094};
2095
2096static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2097 { 2, alc880_lg_ch2_init },
2098 { 4, alc880_lg_ch4_init },
2099 { 6, alc880_lg_ch6_init },
2100};
2101
2102static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2104 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002105 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2106 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2107 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2108 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2109 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2110 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2116 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2117 {
2118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2119 .name = "Channel Mode",
2120 .info = alc_ch_mode_info,
2121 .get = alc_ch_mode_get,
2122 .put = alc_ch_mode_put,
2123 },
2124 { } /* end */
2125};
2126
2127static struct hda_verb alc880_lg_init_verbs[] = {
2128 /* set capture source to mic-in */
2129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2132 /* mute all amp mixer inputs */
2133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002136 /* line-in to input */
2137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2139 /* built-in mic */
2140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2142 /* speaker-out */
2143 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2144 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2145 /* mic-in to input */
2146 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2147 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2149 /* HP-out */
2150 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2151 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2152 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2153 /* jack sense */
2154 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2155 { }
2156};
2157
2158/* toggle speaker-output according to the hp-jack state */
2159static void alc880_lg_automute(struct hda_codec *codec)
2160{
2161 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002162 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002163
2164 present = snd_hda_codec_read(codec, 0x1b, 0,
2165 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002166 bits = present ? HDA_AMP_MUTE : 0;
2167 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2168 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002169}
2170
2171static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2172{
2173 /* Looks like the unsol event is incompatible with the standard
2174 * definition. 4bit tag is placed at 28 bit!
2175 */
2176 if ((res >> 28) == 0x01)
2177 alc880_lg_automute(codec);
2178}
2179
2180/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002181 * LG LW20
2182 *
2183 * Pin assignment:
2184 * Speaker-out: 0x14
2185 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002186 * Built-in Mic-In: 0x19
2187 * Line-In: 0x1b
2188 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002189 * SPDIF-Out: 0x1e
2190 */
2191
Takashi Iwaid6815182006-03-23 16:06:23 +01002192static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002193 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002194 .items = {
2195 { "Mic", 0x0 },
2196 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002197 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002198 },
2199};
2200
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002201#define alc880_lg_lw_modes alc880_threestack_modes
2202
Takashi Iwaid6815182006-03-23 16:06:23 +01002203static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2206 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2209 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2210 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2211 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2216 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2217 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002218 {
2219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2220 .name = "Channel Mode",
2221 .info = alc_ch_mode_info,
2222 .get = alc_ch_mode_get,
2223 .put = alc_ch_mode_put,
2224 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002225 { } /* end */
2226};
2227
2228static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002229 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2230 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2231 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2232
Takashi Iwaid6815182006-03-23 16:06:23 +01002233 /* set capture source to mic-in */
2234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002238 /* speaker-out */
2239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2241 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2244 /* mic-in to input */
2245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2247 /* built-in mic */
2248 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2250 /* jack sense */
2251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2252 { }
2253};
2254
2255/* toggle speaker-output according to the hp-jack state */
2256static void alc880_lg_lw_automute(struct hda_codec *codec)
2257{
2258 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002259 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002260
2261 present = snd_hda_codec_read(codec, 0x1b, 0,
2262 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002263 bits = present ? HDA_AMP_MUTE : 0;
2264 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2265 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002266}
2267
2268static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2269{
2270 /* Looks like the unsol event is incompatible with the standard
2271 * definition. 4bit tag is placed at 28 bit!
2272 */
2273 if ((res >> 28) == 0x01)
2274 alc880_lg_lw_automute(codec);
2275}
2276
Takashi Iwaicb53c622007-08-10 17:21:45 +02002277#ifdef CONFIG_SND_HDA_POWER_SAVE
2278static struct hda_amp_list alc880_loopbacks[] = {
2279 { 0x0b, HDA_INPUT, 0 },
2280 { 0x0b, HDA_INPUT, 1 },
2281 { 0x0b, HDA_INPUT, 2 },
2282 { 0x0b, HDA_INPUT, 3 },
2283 { 0x0b, HDA_INPUT, 4 },
2284 { } /* end */
2285};
2286
2287static struct hda_amp_list alc880_lg_loopbacks[] = {
2288 { 0x0b, HDA_INPUT, 1 },
2289 { 0x0b, HDA_INPUT, 6 },
2290 { 0x0b, HDA_INPUT, 7 },
2291 { } /* end */
2292};
2293#endif
2294
Takashi Iwaid6815182006-03-23 16:06:23 +01002295/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002296 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002298
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299static int alc_init(struct hda_codec *codec)
2300{
2301 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002302 unsigned int i;
2303
2304 for (i = 0; i < spec->num_init_verbs; i++)
2305 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002306
2307 if (spec->init_hook)
2308 spec->init_hook(codec);
2309
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 return 0;
2311}
2312
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002313static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2314{
2315 struct alc_spec *spec = codec->spec;
2316
2317 if (spec->unsol_event)
2318 spec->unsol_event(codec, res);
2319}
2320
Takashi Iwaicb53c622007-08-10 17:21:45 +02002321#ifdef CONFIG_SND_HDA_POWER_SAVE
2322static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2323{
2324 struct alc_spec *spec = codec->spec;
2325 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2326}
2327#endif
2328
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329/*
2330 * Analog playback callbacks
2331 */
2332static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335{
2336 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002337 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2338 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339}
2340
2341static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2342 struct hda_codec *codec,
2343 unsigned int stream_tag,
2344 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346{
2347 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002348 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2349 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350}
2351
2352static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2353 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002354 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355{
2356 struct alc_spec *spec = codec->spec;
2357 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2358}
2359
2360/*
2361 * Digital out
2362 */
2363static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002365 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366{
2367 struct alc_spec *spec = codec->spec;
2368 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2369}
2370
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002371static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2372 struct hda_codec *codec,
2373 unsigned int stream_tag,
2374 unsigned int format,
2375 struct snd_pcm_substream *substream)
2376{
2377 struct alc_spec *spec = codec->spec;
2378 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2379 stream_tag, format, substream);
2380}
2381
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2383 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002384 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385{
2386 struct alc_spec *spec = codec->spec;
2387 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2388}
2389
2390/*
2391 * Analog capture
2392 */
Takashi Iwai63300792008-01-24 15:31:36 +01002393static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 struct hda_codec *codec,
2395 unsigned int stream_tag,
2396 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002397 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398{
2399 struct alc_spec *spec = codec->spec;
2400
Takashi Iwai63300792008-01-24 15:31:36 +01002401 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 stream_tag, 0, format);
2403 return 0;
2404}
2405
Takashi Iwai63300792008-01-24 15:31:36 +01002406static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002408 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409{
2410 struct alc_spec *spec = codec->spec;
2411
Takashi Iwai63300792008-01-24 15:31:36 +01002412 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002413 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 return 0;
2415}
2416
2417
2418/*
2419 */
2420static struct hda_pcm_stream alc880_pcm_analog_playback = {
2421 .substreams = 1,
2422 .channels_min = 2,
2423 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 .ops = {
2426 .open = alc880_playback_pcm_open,
2427 .prepare = alc880_playback_pcm_prepare,
2428 .cleanup = alc880_playback_pcm_cleanup
2429 },
2430};
2431
2432static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002433 .substreams = 1,
2434 .channels_min = 2,
2435 .channels_max = 2,
2436 /* NID is set in alc_build_pcms */
2437};
2438
2439static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2440 .substreams = 1,
2441 .channels_min = 2,
2442 .channels_max = 2,
2443 /* NID is set in alc_build_pcms */
2444};
2445
2446static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2447 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 .channels_min = 2,
2449 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002450 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002452 .prepare = alc880_alt_capture_pcm_prepare,
2453 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 },
2455};
2456
2457static struct hda_pcm_stream alc880_pcm_digital_playback = {
2458 .substreams = 1,
2459 .channels_min = 2,
2460 .channels_max = 2,
2461 /* NID is set in alc_build_pcms */
2462 .ops = {
2463 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002464 .close = alc880_dig_playback_pcm_close,
2465 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466 },
2467};
2468
2469static struct hda_pcm_stream alc880_pcm_digital_capture = {
2470 .substreams = 1,
2471 .channels_min = 2,
2472 .channels_max = 2,
2473 /* NID is set in alc_build_pcms */
2474};
2475
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002476/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002477static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002478 .substreams = 0,
2479 .channels_min = 0,
2480 .channels_max = 0,
2481};
2482
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483static int alc_build_pcms(struct hda_codec *codec)
2484{
2485 struct alc_spec *spec = codec->spec;
2486 struct hda_pcm *info = spec->pcm_rec;
2487 int i;
2488
2489 codec->num_pcms = 1;
2490 codec->pcm_info = info;
2491
2492 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002493 if (spec->stream_analog_playback) {
2494 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2497 }
2498 if (spec->stream_analog_capture) {
2499 snd_assert(spec->adc_nids, return -EINVAL);
2500 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2501 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2502 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503
Takashi Iwai4a471b72005-12-07 13:56:29 +01002504 if (spec->channel_mode) {
2505 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2506 for (i = 0; i < spec->num_channel_mode; i++) {
2507 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2508 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2509 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 }
2511 }
2512
Takashi Iwaie08a0072006-09-07 17:52:14 +02002513 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002515 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002516 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002518 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002519 if (spec->multiout.dig_out_nid &&
2520 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2522 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2523 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002524 if (spec->dig_in_nid &&
2525 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2527 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2528 }
2529 }
2530
Takashi Iwaie08a0072006-09-07 17:52:14 +02002531 /* If the use of more than one ADC is requested for the current
2532 * model, configure a second analog capture-only PCM.
2533 */
2534 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002535 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2536 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002537 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002538 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002539 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002540 if (spec->alt_dac_nid) {
2541 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2542 *spec->stream_analog_alt_playback;
2543 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2544 spec->alt_dac_nid;
2545 } else {
2546 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2547 alc_pcm_null_stream;
2548 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2549 }
2550 if (spec->num_adc_nids > 1) {
2551 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2552 *spec->stream_analog_alt_capture;
2553 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2554 spec->adc_nids[1];
2555 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2556 spec->num_adc_nids - 1;
2557 } else {
2558 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2559 alc_pcm_null_stream;
2560 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002561 }
2562 }
2563
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 return 0;
2565}
2566
2567static void alc_free(struct hda_codec *codec)
2568{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 struct alc_spec *spec = codec->spec;
2570 unsigned int i;
2571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002572 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002573 return;
2574
2575 if (spec->kctl_alloc) {
2576 for (i = 0; i < spec->num_kctl_used; i++)
2577 kfree(spec->kctl_alloc[i].name);
2578 kfree(spec->kctl_alloc);
2579 }
2580 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581}
2582
2583/*
2584 */
2585static struct hda_codec_ops alc_patch_ops = {
2586 .build_controls = alc_build_controls,
2587 .build_pcms = alc_build_pcms,
2588 .init = alc_init,
2589 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002590 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002591#ifdef CONFIG_SND_HDA_POWER_SAVE
2592 .check_power_status = alc_check_power_status,
2593#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594};
2595
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002596
2597/*
2598 * Test configuration for debugging
2599 *
2600 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2601 * enum controls.
2602 */
2603#ifdef CONFIG_SND_DEBUG
2604static hda_nid_t alc880_test_dac_nids[4] = {
2605 0x02, 0x03, 0x04, 0x05
2606};
2607
2608static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002609 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002610 .items = {
2611 { "In-1", 0x0 },
2612 { "In-2", 0x1 },
2613 { "In-3", 0x2 },
2614 { "In-4", 0x3 },
2615 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002616 { "Front", 0x5 },
2617 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002618 },
2619};
2620
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002621static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002622 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002623 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002624 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002625 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002626};
2627
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002628static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2629 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002630{
2631 static char *texts[] = {
2632 "N/A", "Line Out", "HP Out",
2633 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2634 };
2635 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2636 uinfo->count = 1;
2637 uinfo->value.enumerated.items = 8;
2638 if (uinfo->value.enumerated.item >= 8)
2639 uinfo->value.enumerated.item = 7;
2640 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2641 return 0;
2642}
2643
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002644static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2645 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002646{
2647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2648 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2649 unsigned int pin_ctl, item = 0;
2650
2651 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2652 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2653 if (pin_ctl & AC_PINCTL_OUT_EN) {
2654 if (pin_ctl & AC_PINCTL_HP_EN)
2655 item = 2;
2656 else
2657 item = 1;
2658 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2659 switch (pin_ctl & AC_PINCTL_VREFEN) {
2660 case AC_PINCTL_VREF_HIZ: item = 3; break;
2661 case AC_PINCTL_VREF_50: item = 4; break;
2662 case AC_PINCTL_VREF_GRD: item = 5; break;
2663 case AC_PINCTL_VREF_80: item = 6; break;
2664 case AC_PINCTL_VREF_100: item = 7; break;
2665 }
2666 }
2667 ucontrol->value.enumerated.item[0] = item;
2668 return 0;
2669}
2670
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002671static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2672 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002673{
2674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2675 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2676 static unsigned int ctls[] = {
2677 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2678 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2679 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2680 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2681 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2682 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2683 };
2684 unsigned int old_ctl, new_ctl;
2685
2686 old_ctl = snd_hda_codec_read(codec, nid, 0,
2687 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2688 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2689 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002690 int val;
2691 snd_hda_codec_write_cache(codec, nid, 0,
2692 AC_VERB_SET_PIN_WIDGET_CONTROL,
2693 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002694 val = ucontrol->value.enumerated.item[0] >= 3 ?
2695 HDA_AMP_MUTE : 0;
2696 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2697 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002698 return 1;
2699 }
2700 return 0;
2701}
2702
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002703static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2704 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002705{
2706 static char *texts[] = {
2707 "Front", "Surround", "CLFE", "Side"
2708 };
2709 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2710 uinfo->count = 1;
2711 uinfo->value.enumerated.items = 4;
2712 if (uinfo->value.enumerated.item >= 4)
2713 uinfo->value.enumerated.item = 3;
2714 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2715 return 0;
2716}
2717
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002718static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2719 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002720{
2721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2722 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2723 unsigned int sel;
2724
2725 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2726 ucontrol->value.enumerated.item[0] = sel & 3;
2727 return 0;
2728}
2729
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002730static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2731 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002732{
2733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2734 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2735 unsigned int sel;
2736
2737 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2738 if (ucontrol->value.enumerated.item[0] != sel) {
2739 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002740 snd_hda_codec_write_cache(codec, nid, 0,
2741 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002742 return 1;
2743 }
2744 return 0;
2745}
2746
2747#define PIN_CTL_TEST(xname,nid) { \
2748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2749 .name = xname, \
2750 .info = alc_test_pin_ctl_info, \
2751 .get = alc_test_pin_ctl_get, \
2752 .put = alc_test_pin_ctl_put, \
2753 .private_value = nid \
2754 }
2755
2756#define PIN_SRC_TEST(xname,nid) { \
2757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2758 .name = xname, \
2759 .info = alc_test_pin_src_info, \
2760 .get = alc_test_pin_src_get, \
2761 .put = alc_test_pin_src_put, \
2762 .private_value = nid \
2763 }
2764
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002765static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2767 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2768 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2769 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2772 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2773 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002774 PIN_CTL_TEST("Front Pin Mode", 0x14),
2775 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2776 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2777 PIN_CTL_TEST("Side Pin Mode", 0x17),
2778 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2779 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2780 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2781 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2782 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2783 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2784 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2785 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2786 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2787 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2788 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2789 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2790 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2791 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2792 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2793 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002796 {
2797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2798 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002799 .info = alc_ch_mode_info,
2800 .get = alc_ch_mode_get,
2801 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002802 },
2803 { } /* end */
2804};
2805
2806static struct hda_verb alc880_test_init_verbs[] = {
2807 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2815 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002816 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002821 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2823 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2824 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2825 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002826 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002831 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2833 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002834 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002837 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2841 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002842 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002844 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002848 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002849 /* Analog input/passthru */
2850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002855 { }
2856};
2857#endif
2858
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859/*
2860 */
2861
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002862static const char *alc880_models[ALC880_MODEL_LAST] = {
2863 [ALC880_3ST] = "3stack",
2864 [ALC880_TCL_S700] = "tcl",
2865 [ALC880_3ST_DIG] = "3stack-digout",
2866 [ALC880_CLEVO] = "clevo",
2867 [ALC880_5ST] = "5stack",
2868 [ALC880_5ST_DIG] = "5stack-digout",
2869 [ALC880_W810] = "w810",
2870 [ALC880_Z71V] = "z71v",
2871 [ALC880_6ST] = "6stack",
2872 [ALC880_6ST_DIG] = "6stack-digout",
2873 [ALC880_ASUS] = "asus",
2874 [ALC880_ASUS_W1V] = "asus-w1v",
2875 [ALC880_ASUS_DIG] = "asus-dig",
2876 [ALC880_ASUS_DIG2] = "asus-dig2",
2877 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002878 [ALC880_UNIWILL_P53] = "uniwill-p53",
2879 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002880 [ALC880_F1734] = "F1734",
2881 [ALC880_LG] = "lg",
2882 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002883#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002884 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002885#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002886 [ALC880_AUTO] = "auto",
2887};
2888
2889static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002890 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002891 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2892 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2893 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2894 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2895 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2896 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2897 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2898 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002899 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2900 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002901 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2902 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2903 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2904 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2905 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2906 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2907 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2908 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2909 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2910 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002911 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002912 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2913 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2914 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002915 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002916 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002917 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2918 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002919 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2920 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002921 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2922 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2923 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2924 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002925 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2926 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002927 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002928 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002929 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002930 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002931 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2932 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002933 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2934 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002935 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002936 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002937 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002938 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002939 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002940 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2941 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002942 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002943 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2944 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2945 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2946 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002947 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2948 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002949 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002950 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002951 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2952 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002953 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2954 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2955 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002956 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2957 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2958 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002959 {}
2960};
2961
Takashi Iwai16ded522005-06-10 19:58:24 +02002962/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002963 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002964 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002965static struct alc_config_preset alc880_presets[] = {
2966 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002968 .init_verbs = { alc880_volume_init_verbs,
2969 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002971 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002972 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2973 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002974 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002975 .input_mux = &alc880_capture_source,
2976 },
2977 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002979 .init_verbs = { alc880_volume_init_verbs,
2980 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002982 .dac_nids = alc880_dac_nids,
2983 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002984 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2985 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002986 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002987 .input_mux = &alc880_capture_source,
2988 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002989 [ALC880_TCL_S700] = {
2990 .mixers = { alc880_tcl_s700_mixer },
2991 .init_verbs = { alc880_volume_init_verbs,
2992 alc880_pin_tcl_S700_init_verbs,
2993 alc880_gpio2_init_verbs },
2994 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2995 .dac_nids = alc880_dac_nids,
2996 .hp_nid = 0x03,
2997 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2998 .channel_mode = alc880_2_jack_modes,
2999 .input_mux = &alc880_capture_source,
3000 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003001 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003002 .mixers = { alc880_three_stack_mixer,
3003 alc880_five_stack_mixer},
3004 .init_verbs = { alc880_volume_init_verbs,
3005 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003006 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3007 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003008 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3009 .channel_mode = alc880_fivestack_modes,
3010 .input_mux = &alc880_capture_source,
3011 },
3012 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003013 .mixers = { alc880_three_stack_mixer,
3014 alc880_five_stack_mixer },
3015 .init_verbs = { alc880_volume_init_verbs,
3016 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003017 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3018 .dac_nids = alc880_dac_nids,
3019 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003020 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3021 .channel_mode = alc880_fivestack_modes,
3022 .input_mux = &alc880_capture_source,
3023 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003024 [ALC880_6ST] = {
3025 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003026 .init_verbs = { alc880_volume_init_verbs,
3027 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003028 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3029 .dac_nids = alc880_6st_dac_nids,
3030 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3031 .channel_mode = alc880_sixstack_modes,
3032 .input_mux = &alc880_6stack_capture_source,
3033 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003034 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003035 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003036 .init_verbs = { alc880_volume_init_verbs,
3037 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003038 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3039 .dac_nids = alc880_6st_dac_nids,
3040 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003041 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3042 .channel_mode = alc880_sixstack_modes,
3043 .input_mux = &alc880_6stack_capture_source,
3044 },
3045 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003047 .init_verbs = { alc880_volume_init_verbs,
3048 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003049 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003050 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3051 .dac_nids = alc880_w810_dac_nids,
3052 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003053 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3054 .channel_mode = alc880_w810_modes,
3055 .input_mux = &alc880_capture_source,
3056 },
3057 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003058 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003059 .init_verbs = { alc880_volume_init_verbs,
3060 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003061 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3062 .dac_nids = alc880_z71v_dac_nids,
3063 .dig_out_nid = ALC880_DIGOUT_NID,
3064 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003065 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3066 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003067 .input_mux = &alc880_capture_source,
3068 },
3069 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003070 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003071 .init_verbs = { alc880_volume_init_verbs,
3072 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3074 .dac_nids = alc880_f1734_dac_nids,
3075 .hp_nid = 0x02,
3076 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3077 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003078 .input_mux = &alc880_f1734_capture_source,
3079 .unsol_event = alc880_uniwill_p53_unsol_event,
3080 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003081 },
3082 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003083 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003084 .init_verbs = { alc880_volume_init_verbs,
3085 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 alc880_gpio1_init_verbs },
3087 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3088 .dac_nids = alc880_asus_dac_nids,
3089 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3090 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003091 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003092 .input_mux = &alc880_capture_source,
3093 },
3094 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003096 .init_verbs = { alc880_volume_init_verbs,
3097 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098 alc880_gpio1_init_verbs },
3099 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3100 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003101 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3103 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003104 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 .input_mux = &alc880_capture_source,
3106 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003107 [ALC880_ASUS_DIG2] = {
3108 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003109 .init_verbs = { alc880_volume_init_verbs,
3110 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003111 alc880_gpio2_init_verbs }, /* use GPIO2 */
3112 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3113 .dac_nids = alc880_asus_dac_nids,
3114 .dig_out_nid = ALC880_DIGOUT_NID,
3115 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3116 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003117 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003118 .input_mux = &alc880_capture_source,
3119 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003120 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003122 .init_verbs = { alc880_volume_init_verbs,
3123 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 alc880_gpio1_init_verbs },
3125 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3126 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3129 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003130 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003131 .input_mux = &alc880_capture_source,
3132 },
3133 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003134 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003135 .init_verbs = { alc880_volume_init_verbs,
3136 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3138 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003140 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3141 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003142 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003143 .input_mux = &alc880_capture_source,
3144 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003145 [ALC880_UNIWILL] = {
3146 .mixers = { alc880_uniwill_mixer },
3147 .init_verbs = { alc880_volume_init_verbs,
3148 alc880_uniwill_init_verbs },
3149 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3150 .dac_nids = alc880_asus_dac_nids,
3151 .dig_out_nid = ALC880_DIGOUT_NID,
3152 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3153 .channel_mode = alc880_threestack_modes,
3154 .need_dac_fix = 1,
3155 .input_mux = &alc880_capture_source,
3156 .unsol_event = alc880_uniwill_unsol_event,
3157 .init_hook = alc880_uniwill_automute,
3158 },
3159 [ALC880_UNIWILL_P53] = {
3160 .mixers = { alc880_uniwill_p53_mixer },
3161 .init_verbs = { alc880_volume_init_verbs,
3162 alc880_uniwill_p53_init_verbs },
3163 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3164 .dac_nids = alc880_asus_dac_nids,
3165 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003166 .channel_mode = alc880_threestack_modes,
3167 .input_mux = &alc880_capture_source,
3168 .unsol_event = alc880_uniwill_p53_unsol_event,
3169 .init_hook = alc880_uniwill_p53_hp_automute,
3170 },
3171 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003172 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003173 alc880_pcbeep_mixer, },
3174 .init_verbs = { alc880_volume_init_verbs,
3175 alc880_uniwill_p53_init_verbs,
3176 alc880_beep_init_verbs },
3177 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3178 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003179 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003180 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3181 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003182 .input_mux = &alc880_capture_source,
3183 .unsol_event = alc880_uniwill_p53_unsol_event,
3184 .init_hook = alc880_uniwill_p53_hp_automute,
3185 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003186 [ALC880_CLEVO] = {
3187 .mixers = { alc880_three_stack_mixer },
3188 .init_verbs = { alc880_volume_init_verbs,
3189 alc880_pin_clevo_init_verbs },
3190 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3191 .dac_nids = alc880_dac_nids,
3192 .hp_nid = 0x03,
3193 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3194 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003195 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003196 .input_mux = &alc880_capture_source,
3197 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003198 [ALC880_LG] = {
3199 .mixers = { alc880_lg_mixer },
3200 .init_verbs = { alc880_volume_init_verbs,
3201 alc880_lg_init_verbs },
3202 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3203 .dac_nids = alc880_lg_dac_nids,
3204 .dig_out_nid = ALC880_DIGOUT_NID,
3205 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3206 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003207 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003208 .input_mux = &alc880_lg_capture_source,
3209 .unsol_event = alc880_lg_unsol_event,
3210 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003211#ifdef CONFIG_SND_HDA_POWER_SAVE
3212 .loopbacks = alc880_lg_loopbacks,
3213#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003214 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003215 [ALC880_LG_LW] = {
3216 .mixers = { alc880_lg_lw_mixer },
3217 .init_verbs = { alc880_volume_init_verbs,
3218 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003219 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003220 .dac_nids = alc880_dac_nids,
3221 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003222 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3223 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003224 .input_mux = &alc880_lg_lw_capture_source,
3225 .unsol_event = alc880_lg_lw_unsol_event,
3226 .init_hook = alc880_lg_lw_automute,
3227 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003228#ifdef CONFIG_SND_DEBUG
3229 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230 .mixers = { alc880_test_mixer },
3231 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003232 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3233 .dac_nids = alc880_test_dac_nids,
3234 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003235 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3236 .channel_mode = alc880_test_modes,
3237 .input_mux = &alc880_test_capture_source,
3238 },
3239#endif
3240};
3241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242/*
3243 * Automatic parse of I/O pins from the BIOS configuration
3244 */
3245
3246#define NUM_CONTROL_ALLOC 32
3247#define NUM_VERB_ALLOC 32
3248
3249enum {
3250 ALC_CTL_WIDGET_VOL,
3251 ALC_CTL_WIDGET_MUTE,
3252 ALC_CTL_BIND_MUTE,
3253};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003254static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3256 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003257 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258};
3259
3260/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003261static int add_control(struct alc_spec *spec, int type, const char *name,
3262 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003264 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265
3266 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3267 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3268
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003269 /* array + terminator */
3270 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3271 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 return -ENOMEM;
3273 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003274 memcpy(knew, spec->kctl_alloc,
3275 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 kfree(spec->kctl_alloc);
3277 }
3278 spec->kctl_alloc = knew;
3279 spec->num_kctl_alloc = num;
3280 }
3281
3282 knew = &spec->kctl_alloc[spec->num_kctl_used];
3283 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003284 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003285 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 return -ENOMEM;
3287 knew->private_value = val;
3288 spec->num_kctl_used++;
3289 return 0;
3290}
3291
3292#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3293#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3294#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3295#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3296#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3297#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3298#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3299#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3300#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3301#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3302#define ALC880_PIN_CD_NID 0x1c
3303
3304/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003305static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3306 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003307{
3308 hda_nid_t nid;
3309 int assigned[4];
3310 int i, j;
3311
3312 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003313 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003314
3315 /* check the pins hardwired to audio widget */
3316 for (i = 0; i < cfg->line_outs; i++) {
3317 nid = cfg->line_out_pins[i];
3318 if (alc880_is_fixed_pin(nid)) {
3319 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003320 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321 assigned[idx] = 1;
3322 }
3323 }
3324 /* left pins can be connect to any audio widget */
3325 for (i = 0; i < cfg->line_outs; i++) {
3326 nid = cfg->line_out_pins[i];
3327 if (alc880_is_fixed_pin(nid))
3328 continue;
3329 /* search for an empty channel */
3330 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003331 if (!assigned[j]) {
3332 spec->multiout.dac_nids[i] =
3333 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003334 assigned[j] = 1;
3335 break;
3336 }
3337 }
3338 }
3339 spec->multiout.num_dacs = cfg->line_outs;
3340 return 0;
3341}
3342
3343/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003344static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3345 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346{
3347 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003348 static const char *chname[4] = {
3349 "Front", "Surround", NULL /*CLFE*/, "Side"
3350 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351 hda_nid_t nid;
3352 int i, err;
3353
3354 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003355 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356 continue;
3357 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3358 if (i == 2) {
3359 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003360 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3361 "Center Playback Volume",
3362 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3363 HDA_OUTPUT));
3364 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003366 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3367 "LFE Playback Volume",
3368 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3369 HDA_OUTPUT));
3370 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003372 err = add_control(spec, ALC_CTL_BIND_MUTE,
3373 "Center Playback Switch",
3374 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3375 HDA_INPUT));
3376 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003377 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 err = add_control(spec, ALC_CTL_BIND_MUTE,
3379 "LFE Playback Switch",
3380 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3381 HDA_INPUT));
3382 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383 return err;
3384 } else {
3385 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003386 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3387 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3388 HDA_OUTPUT));
3389 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 return err;
3391 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003392 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3393 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3394 HDA_INPUT));
3395 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396 return err;
3397 }
3398 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003399 return 0;
3400}
3401
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003402/* add playback controls for speaker and HP outputs */
3403static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3404 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003405{
3406 hda_nid_t nid;
3407 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003408 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003410 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411 return 0;
3412
3413 if (alc880_is_fixed_pin(pin)) {
3414 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003415 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003416 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003418 else
3419 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420 /* control HP volume/switch on the output mixer amp */
3421 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003422 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3424 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3425 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003427 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003428 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3429 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3430 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431 return err;
3432 } else if (alc880_is_multi_pin(pin)) {
3433 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003435 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003436 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3437 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3438 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 return err;
3440 }
3441 return 0;
3442}
3443
3444/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003445static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3446 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003447 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448{
3449 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003450 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451
3452 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003453 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3454 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3455 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 return err;
3457 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003458 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3459 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3460 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461 return err;
3462 return 0;
3463}
3464
3465/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003466static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3467 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003469 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003470 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003471
3472 for (i = 0; i < AUTO_PIN_LAST; i++) {
3473 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003474 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003475 err = new_analog_input(spec, cfg->input_pins[i],
3476 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003477 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003478 if (err < 0)
3479 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003480 imux->items[imux->num_items].label =
3481 auto_pin_cfg_labels[i];
3482 imux->items[imux->num_items].index =
3483 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003484 imux->num_items++;
3485 }
3486 }
3487 return 0;
3488}
3489
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003490static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3491 unsigned int pin_type)
3492{
3493 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3494 pin_type);
3495 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003496 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3497 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003498}
3499
Kailang Yangdf694da2005-12-05 19:42:22 +01003500static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3501 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003502 int dac_idx)
3503{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003504 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 /* need the manual connection? */
3506 if (alc880_is_multi_pin(nid)) {
3507 struct alc_spec *spec = codec->spec;
3508 int idx = alc880_multi_pin_idx(nid);
3509 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3510 AC_VERB_SET_CONNECT_SEL,
3511 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3512 }
3513}
3514
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003515static int get_pin_type(int line_out_type)
3516{
3517 if (line_out_type == AUTO_PIN_HP_OUT)
3518 return PIN_HP;
3519 else
3520 return PIN_OUT;
3521}
3522
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523static void alc880_auto_init_multi_out(struct hda_codec *codec)
3524{
3525 struct alc_spec *spec = codec->spec;
3526 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003527
3528 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003529 for (i = 0; i < spec->autocfg.line_outs; i++) {
3530 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003531 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3532 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533 }
3534}
3535
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003536static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003537{
3538 struct alc_spec *spec = codec->spec;
3539 hda_nid_t pin;
3540
Takashi Iwai82bc9552006-03-21 11:24:42 +01003541 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003542 if (pin) /* connect to front */
3543 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003544 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 if (pin) /* connect to front */
3546 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3547}
3548
3549static void alc880_auto_init_analog_input(struct hda_codec *codec)
3550{
3551 struct alc_spec *spec = codec->spec;
3552 int i;
3553
3554 for (i = 0; i < AUTO_PIN_LAST; i++) {
3555 hda_nid_t nid = spec->autocfg.input_pins[i];
3556 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 snd_hda_codec_write(codec, nid, 0,
3558 AC_VERB_SET_PIN_WIDGET_CONTROL,
3559 i <= AUTO_PIN_FRONT_MIC ?
3560 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003561 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003562 snd_hda_codec_write(codec, nid, 0,
3563 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003564 AMP_OUT_MUTE);
3565 }
3566 }
3567}
3568
3569/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003570/* return 1 if successful, 0 if the proper config is not found,
3571 * or a negative error code
3572 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003573static int alc880_parse_auto_config(struct hda_codec *codec)
3574{
3575 struct alc_spec *spec = codec->spec;
3576 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003577 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003579 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3580 alc880_ignore);
3581 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003582 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003583 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003584 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003585
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003586 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3587 if (err < 0)
3588 return err;
3589 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3590 if (err < 0)
3591 return err;
3592 err = alc880_auto_create_extra_out(spec,
3593 spec->autocfg.speaker_pins[0],
3594 "Speaker");
3595 if (err < 0)
3596 return err;
3597 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3598 "Headphone");
3599 if (err < 0)
3600 return err;
3601 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3602 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603 return err;
3604
3605 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3606
3607 if (spec->autocfg.dig_out_pin)
3608 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3609 if (spec->autocfg.dig_in_pin)
3610 spec->dig_in_nid = ALC880_DIGIN_NID;
3611
3612 if (spec->kctl_alloc)
3613 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3614
3615 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3616
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003617 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618 spec->input_mux = &spec->private_imux;
3619
3620 return 1;
3621}
3622
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003623/* additional initialization for auto-configuration model */
3624static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003626 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003628 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003630 if (spec->unsol_event)
3631 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632}
3633
3634/*
3635 * OK, here we have finally the patch for ALC880
3636 */
3637
Linus Torvalds1da177e2005-04-16 15:20:36 -07003638static int patch_alc880(struct hda_codec *codec)
3639{
3640 struct alc_spec *spec;
3641 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003642 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003643
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003644 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645 if (spec == NULL)
3646 return -ENOMEM;
3647
3648 codec->spec = spec;
3649
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003650 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3651 alc880_models,
3652 alc880_cfg_tbl);
3653 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003654 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3655 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003657 }
3658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659 if (board_config == ALC880_AUTO) {
3660 /* automatic parse from the BIOS config */
3661 err = alc880_parse_auto_config(codec);
3662 if (err < 0) {
3663 alc_free(codec);
3664 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003665 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003666 printk(KERN_INFO
3667 "hda_codec: Cannot set up configuration "
3668 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003669 board_config = ALC880_3ST;
3670 }
3671 }
3672
Kailang Yangdf694da2005-12-05 19:42:22 +01003673 if (board_config != ALC880_AUTO)
3674 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003675
3676 spec->stream_name_analog = "ALC880 Analog";
3677 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3678 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003679 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003680
3681 spec->stream_name_digital = "ALC880 Digital";
3682 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3683 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3684
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003685 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003686 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003687 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003688 /* get type */
3689 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003690 if (wcap != AC_WID_AUD_IN) {
3691 spec->adc_nids = alc880_adc_nids_alt;
3692 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693 spec->mixers[spec->num_mixers] =
3694 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003695 spec->num_mixers++;
3696 } else {
3697 spec->adc_nids = alc880_adc_nids;
3698 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3699 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3700 spec->num_mixers++;
3701 }
3702 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703
Takashi Iwai2134ea42008-01-10 16:53:55 +01003704 spec->vmaster_nid = 0x0c;
3705
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003708 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003709#ifdef CONFIG_SND_HDA_POWER_SAVE
3710 if (!spec->loopback.amplist)
3711 spec->loopback.amplist = alc880_loopbacks;
3712#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003713
3714 return 0;
3715}
3716
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718/*
3719 * ALC260 support
3720 */
3721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722static hda_nid_t alc260_dac_nids[1] = {
3723 /* front */
3724 0x02,
3725};
3726
3727static hda_nid_t alc260_adc_nids[1] = {
3728 /* ADC0 */
3729 0x04,
3730};
3731
Kailang Yangdf694da2005-12-05 19:42:22 +01003732static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003733 /* ADC1 */
3734 0x05,
3735};
3736
Kailang Yangdf694da2005-12-05 19:42:22 +01003737static hda_nid_t alc260_hp_adc_nids[2] = {
3738 /* ADC1, 0 */
3739 0x05, 0x04
3740};
3741
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003742/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3743 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3744 */
3745static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003746 /* ADC0, ADC1 */
3747 0x04, 0x05
3748};
3749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003750#define ALC260_DIGOUT_NID 0x03
3751#define ALC260_DIGIN_NID 0x06
3752
3753static struct hda_input_mux alc260_capture_source = {
3754 .num_items = 4,
3755 .items = {
3756 { "Mic", 0x0 },
3757 { "Front Mic", 0x1 },
3758 { "Line", 0x2 },
3759 { "CD", 0x4 },
3760 },
3761};
3762
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003763/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003764 * headphone jack and the internal CD lines since these are the only pins at
3765 * which audio can appear. For flexibility, also allow the option of
3766 * recording the mixer output on the second ADC (ADC0 doesn't have a
3767 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003768 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003769static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3770 {
3771 .num_items = 3,
3772 .items = {
3773 { "Mic/Line", 0x0 },
3774 { "CD", 0x4 },
3775 { "Headphone", 0x2 },
3776 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003777 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003778 {
3779 .num_items = 4,
3780 .items = {
3781 { "Mic/Line", 0x0 },
3782 { "CD", 0x4 },
3783 { "Headphone", 0x2 },
3784 { "Mixer", 0x5 },
3785 },
3786 },
3787
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003788};
3789
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003790/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3791 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003792 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003793static struct hda_input_mux alc260_acer_capture_sources[2] = {
3794 {
3795 .num_items = 4,
3796 .items = {
3797 { "Mic", 0x0 },
3798 { "Line", 0x2 },
3799 { "CD", 0x4 },
3800 { "Headphone", 0x5 },
3801 },
3802 },
3803 {
3804 .num_items = 5,
3805 .items = {
3806 { "Mic", 0x0 },
3807 { "Line", 0x2 },
3808 { "CD", 0x4 },
3809 { "Headphone", 0x6 },
3810 { "Mixer", 0x5 },
3811 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003812 },
3813};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814/*
3815 * This is just place-holder, so there's something for alc_build_pcms to look
3816 * at when it calculates the maximum number of channels. ALC260 has no mixer
3817 * element which allows changing the channel mode, so the verb list is
3818 * never used.
3819 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003820static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003821 { 2, NULL },
3822};
3823
Kailang Yangdf694da2005-12-05 19:42:22 +01003824
3825/* Mixer combinations
3826 *
3827 * basic: base_output + input + pc_beep + capture
3828 * HP: base_output + input + capture_alt
3829 * HP_3013: hp_3013 + input + capture
3830 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003831 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003832 */
3833
3834static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003835 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003836 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3838 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3839 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3840 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3841 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842};
Kailang Yangdf694da2005-12-05 19:42:22 +01003843
3844static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003845 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3846 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3847 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3848 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3850 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003853 { } /* end */
3854};
3855
Kailang Yangdf694da2005-12-05 19:42:22 +01003856static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3857 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3858 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3859 { } /* end */
3860};
3861
Takashi Iwaibec15c32008-01-28 18:16:30 +01003862/* update HP, line and mono out pins according to the master switch */
3863static void alc260_hp_master_update(struct hda_codec *codec,
3864 hda_nid_t hp, hda_nid_t line,
3865 hda_nid_t mono)
3866{
3867 struct alc_spec *spec = codec->spec;
3868 unsigned int val = spec->master_sw ? PIN_HP : 0;
3869 /* change HP and line-out pins */
3870 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3871 val);
3872 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3873 val);
3874 /* mono (speaker) depending on the HP jack sense */
3875 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3876 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3877 val);
3878}
3879
3880static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3881 struct snd_ctl_elem_value *ucontrol)
3882{
3883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3884 struct alc_spec *spec = codec->spec;
3885 *ucontrol->value.integer.value = spec->master_sw;
3886 return 0;
3887}
3888
3889static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3890 struct snd_ctl_elem_value *ucontrol)
3891{
3892 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3893 struct alc_spec *spec = codec->spec;
3894 int val = !!*ucontrol->value.integer.value;
3895 hda_nid_t hp, line, mono;
3896
3897 if (val == spec->master_sw)
3898 return 0;
3899 spec->master_sw = val;
3900 hp = (kcontrol->private_value >> 16) & 0xff;
3901 line = (kcontrol->private_value >> 8) & 0xff;
3902 mono = kcontrol->private_value & 0xff;
3903 alc260_hp_master_update(codec, hp, line, mono);
3904 return 1;
3905}
3906
3907static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3908 {
3909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3910 .name = "Master Playback Switch",
3911 .info = snd_ctl_boolean_mono_info,
3912 .get = alc260_hp_master_sw_get,
3913 .put = alc260_hp_master_sw_put,
3914 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3915 },
3916 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3917 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3919 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3920 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3921 HDA_OUTPUT),
3922 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3923 { } /* end */
3924};
3925
3926static struct hda_verb alc260_hp_unsol_verbs[] = {
3927 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3928 {},
3929};
3930
3931static void alc260_hp_automute(struct hda_codec *codec)
3932{
3933 struct alc_spec *spec = codec->spec;
3934 unsigned int present;
3935
3936 present = snd_hda_codec_read(codec, 0x10, 0,
3937 AC_VERB_GET_PIN_SENSE, 0);
3938 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3939 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3940}
3941
3942static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3943{
3944 if ((res >> 26) == ALC880_HP_EVENT)
3945 alc260_hp_automute(codec);
3946}
3947
Kailang Yangdf694da2005-12-05 19:42:22 +01003948static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003949 {
3950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3951 .name = "Master Playback Switch",
3952 .info = snd_ctl_boolean_mono_info,
3953 .get = alc260_hp_master_sw_get,
3954 .put = alc260_hp_master_sw_put,
3955 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3956 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003957 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3958 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3959 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3960 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3961 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003963 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3964 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003965 { } /* end */
3966};
3967
Takashi Iwaibec15c32008-01-28 18:16:30 +01003968static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3970 {},
3971};
3972
3973static void alc260_hp_3013_automute(struct hda_codec *codec)
3974{
3975 struct alc_spec *spec = codec->spec;
3976 unsigned int present;
3977
3978 present = snd_hda_codec_read(codec, 0x15, 0,
3979 AC_VERB_GET_PIN_SENSE, 0);
3980 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3981 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3982}
3983
3984static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3985 unsigned int res)
3986{
3987 if ((res >> 26) == ALC880_HP_EVENT)
3988 alc260_hp_3013_automute(codec);
3989}
3990
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003991/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3992 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3993 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003994static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003995 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003996 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003997 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003998 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3999 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4000 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4001 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004002 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004003 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4004 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004005 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 { } /* end */
4008};
4009
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004010/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4011 * versions of the ALC260 don't act on requests to enable mic bias from NID
4012 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4013 * datasheet doesn't mention this restriction. At this stage it's not clear
4014 * whether this behaviour is intentional or is a hardware bug in chip
4015 * revisions available in early 2006. Therefore for now allow the
4016 * "Headphone Jack Mode" control to span all choices, but if it turns out
4017 * that the lack of mic bias for this NID is intentional we could change the
4018 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4019 *
4020 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4021 * don't appear to make the mic bias available from the "line" jack, even
4022 * though the NID used for this jack (0x14) can supply it. The theory is
4023 * that perhaps Acer have included blocking capacitors between the ALC260
4024 * and the output jack. If this turns out to be the case for all such
4025 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4026 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004027 *
4028 * The C20x Tablet series have a mono internal speaker which is controlled
4029 * via the chip's Mono sum widget and pin complex, so include the necessary
4030 * controls for such models. On models without a "mono speaker" the control
4031 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004032 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004033static struct snd_kcontrol_new alc260_acer_mixer[] = {
4034 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4035 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004036 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004037 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004038 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004039 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004040 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004041 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4042 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4044 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4045 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4046 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4047 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4048 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4049 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4050 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4051 { } /* end */
4052};
4053
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004054/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4055 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4056 */
4057static struct snd_kcontrol_new alc260_will_mixer[] = {
4058 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4059 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4061 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4062 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4063 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4064 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4065 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4066 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4067 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4068 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4069 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4070 { } /* end */
4071};
4072
4073/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4074 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4075 */
4076static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4077 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4078 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4080 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4081 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4082 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4083 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4084 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4085 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4086 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4087 { } /* end */
4088};
4089
Kailang Yangdf694da2005-12-05 19:42:22 +01004090/* capture mixer elements */
4091static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004092 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4093 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004094 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4095 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004096 {
4097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004098 /* The multiple "Capture Source" controls confuse alsamixer
4099 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004100 */
4101 /* .name = "Capture Source", */
4102 .name = "Input Source",
4103 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004104 .info = alc_mux_enum_info,
4105 .get = alc_mux_enum_get,
4106 .put = alc_mux_enum_put,
4107 },
4108 { } /* end */
4109};
4110
Kailang Yangdf694da2005-12-05 19:42:22 +01004111static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4112 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4113 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4114 {
4115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4116 /* The multiple "Capture Source" controls confuse alsamixer
4117 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004118 */
4119 /* .name = "Capture Source", */
4120 .name = "Input Source",
4121 .count = 1,
4122 .info = alc_mux_enum_info,
4123 .get = alc_mux_enum_get,
4124 .put = alc_mux_enum_put,
4125 },
4126 { } /* end */
4127};
4128
4129/*
4130 * initialization verbs
4131 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004132static struct hda_verb alc260_init_verbs[] = {
4133 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004136 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004137 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004138 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004141 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004144 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004145 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004146 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004147 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004148 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004149 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004150 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4151 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004152 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004153 /* set connection select to line in (default select for this ADC) */
4154 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 /* mute capture amp left and right */
4156 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4157 /* set connection select to line in (default select for this ADC) */
4158 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004159 /* set vol=0 Line-Out mixer amp left and right */
4160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4161 /* unmute pin widget amp left and right (no gain on this amp) */
4162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4163 /* set vol=0 HP mixer amp left and right */
4164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4165 /* unmute pin widget amp left and right (no gain on this amp) */
4166 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4167 /* set vol=0 Mono mixer amp left and right */
4168 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4169 /* unmute pin widget amp left and right (no gain on this amp) */
4170 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4171 /* unmute LINE-2 out pin */
4172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004173 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4174 * Line In 2 = 0x03
4175 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004176 /* mute analog inputs */
4177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4178 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4181 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004182 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004183 /* mute Front out path */
4184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4186 /* mute Headphone out path */
4187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4189 /* mute Mono out path */
4190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4191 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004192 { }
4193};
4194
Takashi Iwai474167d2006-05-17 17:17:43 +02004195#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004196static struct hda_verb alc260_hp_init_verbs[] = {
4197 /* Headphone and output */
4198 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4199 /* mono output */
4200 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4201 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4202 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4203 /* Mic2 (front panel) pin widget for input and vref at 80% */
4204 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4205 /* Line In pin widget for input */
4206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4207 /* Line-2 pin widget for output */
4208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4209 /* CD pin widget for input */
4210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4211 /* unmute amp left and right */
4212 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4213 /* set connection select to line in (default select for this ADC) */
4214 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4215 /* unmute Line-Out mixer amp left and right (volume = 0) */
4216 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4217 /* mute pin widget amp left and right (no gain on this amp) */
4218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4219 /* unmute HP mixer amp left and right (volume = 0) */
4220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4221 /* mute pin widget amp left and right (no gain on this amp) */
4222 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004223 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4224 * Line In 2 = 0x03
4225 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004226 /* mute analog inputs */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004232 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4233 /* Unmute Front out path */
4234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4236 /* Unmute Headphone out path */
4237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4239 /* Unmute Mono out path */
4240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4242 { }
4243};
Takashi Iwai474167d2006-05-17 17:17:43 +02004244#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004245
4246static struct hda_verb alc260_hp_3013_init_verbs[] = {
4247 /* Line out and output */
4248 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4249 /* mono output */
4250 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4251 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4252 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4253 /* Mic2 (front panel) pin widget for input and vref at 80% */
4254 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4255 /* Line In pin widget for input */
4256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4257 /* Headphone pin widget for output */
4258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4259 /* CD pin widget for input */
4260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4261 /* unmute amp left and right */
4262 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4263 /* set connection select to line in (default select for this ADC) */
4264 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4265 /* unmute Line-Out mixer amp left and right (volume = 0) */
4266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4267 /* mute pin widget amp left and right (no gain on this amp) */
4268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4269 /* unmute HP mixer amp left and right (volume = 0) */
4270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4271 /* mute pin widget amp left and right (no gain on this amp) */
4272 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004273 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4274 * Line In 2 = 0x03
4275 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004276 /* mute analog inputs */
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004282 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4283 /* Unmute Front out path */
4284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4286 /* Unmute Headphone out path */
4287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4289 /* Unmute Mono out path */
4290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4292 { }
4293};
4294
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004295/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004296 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4297 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004298 */
4299static struct hda_verb alc260_fujitsu_init_verbs[] = {
4300 /* Disable all GPIOs */
4301 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4302 /* Internal speaker is connected to headphone pin */
4303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4304 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004306 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4307 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4308 /* Ensure all other unused pins are disabled and muted. */
4309 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004311 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004312 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004313 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004314 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004317
Jonathan Woithef7ace402006-02-28 11:46:14 +01004318 /* Disable digital (SPDIF) pins */
4319 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4320 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004321
Jonathan Woithef7ace402006-02-28 11:46:14 +01004322 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4323 * when acting as an output.
4324 */
4325 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4326
4327 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4330 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4332 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4334 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4335 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4336 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004337
Jonathan Woithef7ace402006-02-28 11:46:14 +01004338 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4340 /* Unmute Line1 pin widget output buffer since it starts as an output.
4341 * If the pin mode is changed by the user the pin mode control will
4342 * take care of enabling the pin's input/output buffers as needed.
4343 * Therefore there's no need to enable the input buffer at this
4344 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004345 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004347 /* Unmute input buffer of pin widget used for Line-in (no equiv
4348 * mixer ctrl)
4349 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004350 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004351
Jonathan Woithef7ace402006-02-28 11:46:14 +01004352 /* Mute capture amp left and right */
4353 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4354 /* Set ADC connection select to match default mixer setting - line
4355 * in (on mic1 pin)
4356 */
4357 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004358
Jonathan Woithef7ace402006-02-28 11:46:14 +01004359 /* Do the same for the second ADC: mute capture input amp and
4360 * set ADC connection to line in (on mic1 pin)
4361 */
4362 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4363 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004364
Jonathan Woithef7ace402006-02-28 11:46:14 +01004365 /* Mute all inputs to mixer widget (even unconnected ones) */
4366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4370 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004374
4375 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004376};
4377
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004378/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4379 * similar laptops (adapted from Fujitsu init verbs).
4380 */
4381static struct hda_verb alc260_acer_init_verbs[] = {
4382 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4383 * the headphone jack. Turn this on and rely on the standard mute
4384 * methods whenever the user wants to turn these outputs off.
4385 */
4386 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4387 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4388 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4389 /* Internal speaker/Headphone jack is connected to Line-out pin */
4390 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4391 /* Internal microphone/Mic jack is connected to Mic1 pin */
4392 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4393 /* Line In jack is connected to Line1 pin */
4394 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004395 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4396 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004397 /* Ensure all other unused pins are disabled and muted. */
4398 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4399 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004400 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4401 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4404 /* Disable digital (SPDIF) pins */
4405 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4406 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4407
4408 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4409 * bus when acting as outputs.
4410 */
4411 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4412 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4413
4414 /* Start with output sum widgets muted and their output gains at min */
4415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4422 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4423 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4424
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004425 /* Unmute Line-out pin widget amp left and right
4426 * (no equiv mixer ctrl)
4427 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004429 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4430 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004431 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4432 * inputs. If the pin mode is changed by the user the pin mode control
4433 * will take care of enabling the pin's input/output buffers as needed.
4434 * Therefore there's no need to enable the input buffer at this
4435 * stage.
4436 */
4437 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4439
4440 /* Mute capture amp left and right */
4441 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4442 /* Set ADC connection select to match default mixer setting - mic
4443 * (on mic1 pin)
4444 */
4445 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4446
4447 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004448 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004449 */
4450 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004451 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004452
4453 /* Mute all inputs to mixer widget (even unconnected ones) */
4454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4462
4463 { }
4464};
4465
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004466static struct hda_verb alc260_will_verbs[] = {
4467 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4468 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4469 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4470 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4471 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4472 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4473 {}
4474};
4475
4476static struct hda_verb alc260_replacer_672v_verbs[] = {
4477 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4478 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4479 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4480
4481 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4482 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4483 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4484
4485 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4486 {}
4487};
4488
4489/* toggle speaker-output according to the hp-jack state */
4490static void alc260_replacer_672v_automute(struct hda_codec *codec)
4491{
4492 unsigned int present;
4493
4494 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4495 present = snd_hda_codec_read(codec, 0x0f, 0,
4496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4497 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004498 snd_hda_codec_write_cache(codec, 0x01, 0,
4499 AC_VERB_SET_GPIO_DATA, 1);
4500 snd_hda_codec_write_cache(codec, 0x0f, 0,
4501 AC_VERB_SET_PIN_WIDGET_CONTROL,
4502 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004503 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004504 snd_hda_codec_write_cache(codec, 0x01, 0,
4505 AC_VERB_SET_GPIO_DATA, 0);
4506 snd_hda_codec_write_cache(codec, 0x0f, 0,
4507 AC_VERB_SET_PIN_WIDGET_CONTROL,
4508 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004509 }
4510}
4511
4512static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4513 unsigned int res)
4514{
4515 if ((res >> 26) == ALC880_HP_EVENT)
4516 alc260_replacer_672v_automute(codec);
4517}
4518
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004519/* Test configuration for debugging, modelled after the ALC880 test
4520 * configuration.
4521 */
4522#ifdef CONFIG_SND_DEBUG
4523static hda_nid_t alc260_test_dac_nids[1] = {
4524 0x02,
4525};
4526static hda_nid_t alc260_test_adc_nids[2] = {
4527 0x04, 0x05,
4528};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004529/* For testing the ALC260, each input MUX needs its own definition since
4530 * the signal assignments are different. This assumes that the first ADC
4531 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004532 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004533static struct hda_input_mux alc260_test_capture_sources[2] = {
4534 {
4535 .num_items = 7,
4536 .items = {
4537 { "MIC1 pin", 0x0 },
4538 { "MIC2 pin", 0x1 },
4539 { "LINE1 pin", 0x2 },
4540 { "LINE2 pin", 0x3 },
4541 { "CD pin", 0x4 },
4542 { "LINE-OUT pin", 0x5 },
4543 { "HP-OUT pin", 0x6 },
4544 },
4545 },
4546 {
4547 .num_items = 8,
4548 .items = {
4549 { "MIC1 pin", 0x0 },
4550 { "MIC2 pin", 0x1 },
4551 { "LINE1 pin", 0x2 },
4552 { "LINE2 pin", 0x3 },
4553 { "CD pin", 0x4 },
4554 { "Mixer", 0x5 },
4555 { "LINE-OUT pin", 0x6 },
4556 { "HP-OUT pin", 0x7 },
4557 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004558 },
4559};
4560static struct snd_kcontrol_new alc260_test_mixer[] = {
4561 /* Output driver widgets */
4562 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4563 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4564 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4565 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4566 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4567 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4568
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004569 /* Modes for retasking pin widgets
4570 * Note: the ALC260 doesn't seem to act on requests to enable mic
4571 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4572 * mention this restriction. At this stage it's not clear whether
4573 * this behaviour is intentional or is a hardware bug in chip
4574 * revisions available at least up until early 2006. Therefore for
4575 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4576 * choices, but if it turns out that the lack of mic bias for these
4577 * NIDs is intentional we could change their modes from
4578 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4579 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004580 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4581 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4582 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4583 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4584 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4585 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4586
4587 /* Loopback mixer controls */
4588 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4589 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4590 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4591 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4592 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4593 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4594 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4595 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4596 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4597 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4598 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4599 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4600 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4601 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4602 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4603 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004604
4605 /* Controls for GPIO pins, assuming they are configured as outputs */
4606 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4607 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4608 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4609 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4610
Jonathan Woithe92621f12006-02-28 11:47:47 +01004611 /* Switches to allow the digital IO pins to be enabled. The datasheet
4612 * is ambigious as to which NID is which; testing on laptops which
4613 * make this output available should provide clarification.
4614 */
4615 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4616 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4617
Jonathan Woithef8225f62008-01-08 12:16:54 +01004618 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4619 * this output to turn on an external amplifier.
4620 */
4621 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4622 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4623
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004624 { } /* end */
4625};
4626static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004627 /* Enable all GPIOs as outputs with an initial value of 0 */
4628 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4629 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4630 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4631
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004632 /* Enable retasking pins as output, initially without power amp */
4633 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4634 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4637 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4639
Jonathan Woithe92621f12006-02-28 11:47:47 +01004640 /* Disable digital (SPDIF) pins initially, but users can enable
4641 * them via a mixer switch. In the case of SPDIF-out, this initverb
4642 * payload also sets the generation to 0, output to be in "consumer"
4643 * PCM format, copyright asserted, no pre-emphasis and no validity
4644 * control.
4645 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004646 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4647 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4648
Jonathan Woithef7ace402006-02-28 11:46:14 +01004649 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004650 * OUT1 sum bus when acting as an output.
4651 */
4652 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4653 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4654 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4655 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4656
4657 /* Start with output sum widgets muted and their output gains at min */
4658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4660 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4663 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4666 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4667
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004668 /* Unmute retasking pin widget output buffers since the default
4669 * state appears to be output. As the pin mode is changed by the
4670 * user the pin mode control will take care of enabling the pin's
4671 * input/output buffers as needed.
4672 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004673 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4677 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4678 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4679 /* Also unmute the mono-out pin widget */
4680 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4681
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004682 /* Mute capture amp left and right */
4683 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004684 /* Set ADC connection select to match default mixer setting (mic1
4685 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004686 */
4687 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4688
4689 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004690 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004691 */
4692 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4693 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4694
4695 /* Mute all inputs to mixer widget (even unconnected ones) */
4696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4704
4705 { }
4706};
4707#endif
4708
Takashi Iwai63300792008-01-24 15:31:36 +01004709#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4710#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004711
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004712#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4713#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4714
Kailang Yangdf694da2005-12-05 19:42:22 +01004715/*
4716 * for BIOS auto-configuration
4717 */
4718
4719static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4720 const char *pfx)
4721{
4722 hda_nid_t nid_vol;
4723 unsigned long vol_val, sw_val;
4724 char name[32];
4725 int err;
4726
4727 if (nid >= 0x0f && nid < 0x11) {
4728 nid_vol = nid - 0x7;
4729 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4730 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4731 } else if (nid == 0x11) {
4732 nid_vol = nid - 0x7;
4733 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4734 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4735 } else if (nid >= 0x12 && nid <= 0x15) {
4736 nid_vol = 0x08;
4737 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4738 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4739 } else
4740 return 0; /* N/A */
4741
4742 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004743 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4744 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004745 return err;
4746 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004747 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4748 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004749 return err;
4750 return 1;
4751}
4752
4753/* add playback controls from the parsed DAC table */
4754static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4755 const struct auto_pin_cfg *cfg)
4756{
4757 hda_nid_t nid;
4758 int err;
4759
4760 spec->multiout.num_dacs = 1;
4761 spec->multiout.dac_nids = spec->private_dac_nids;
4762 spec->multiout.dac_nids[0] = 0x02;
4763
4764 nid = cfg->line_out_pins[0];
4765 if (nid) {
4766 err = alc260_add_playback_controls(spec, nid, "Front");
4767 if (err < 0)
4768 return err;
4769 }
4770
Takashi Iwai82bc9552006-03-21 11:24:42 +01004771 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004772 if (nid) {
4773 err = alc260_add_playback_controls(spec, nid, "Speaker");
4774 if (err < 0)
4775 return err;
4776 }
4777
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004778 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004779 if (nid) {
4780 err = alc260_add_playback_controls(spec, nid, "Headphone");
4781 if (err < 0)
4782 return err;
4783 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004784 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004785}
4786
4787/* create playback/capture controls for input pins */
4788static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4789 const struct auto_pin_cfg *cfg)
4790{
Kailang Yangdf694da2005-12-05 19:42:22 +01004791 struct hda_input_mux *imux = &spec->private_imux;
4792 int i, err, idx;
4793
4794 for (i = 0; i < AUTO_PIN_LAST; i++) {
4795 if (cfg->input_pins[i] >= 0x12) {
4796 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004797 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004798 auto_pin_cfg_labels[i], idx,
4799 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004800 if (err < 0)
4801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004802 imux->items[imux->num_items].label =
4803 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 imux->items[imux->num_items].index = idx;
4805 imux->num_items++;
4806 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004809 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 auto_pin_cfg_labels[i], idx,
4811 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 if (err < 0)
4813 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004814 imux->items[imux->num_items].label =
4815 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004816 imux->items[imux->num_items].index = idx;
4817 imux->num_items++;
4818 }
4819 }
4820 return 0;
4821}
4822
4823static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4824 hda_nid_t nid, int pin_type,
4825 int sel_idx)
4826{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004827 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004828 /* need the manual connection? */
4829 if (nid >= 0x12) {
4830 int idx = nid - 0x12;
4831 snd_hda_codec_write(codec, idx + 0x0b, 0,
4832 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004833 }
4834}
4835
4836static void alc260_auto_init_multi_out(struct hda_codec *codec)
4837{
4838 struct alc_spec *spec = codec->spec;
4839 hda_nid_t nid;
4840
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004841 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004842 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004843 if (nid) {
4844 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4845 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4846 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004847
Takashi Iwai82bc9552006-03-21 11:24:42 +01004848 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004849 if (nid)
4850 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4851
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004852 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004853 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004854 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004855}
Kailang Yangdf694da2005-12-05 19:42:22 +01004856
4857#define ALC260_PIN_CD_NID 0x16
4858static void alc260_auto_init_analog_input(struct hda_codec *codec)
4859{
4860 struct alc_spec *spec = codec->spec;
4861 int i;
4862
4863 for (i = 0; i < AUTO_PIN_LAST; i++) {
4864 hda_nid_t nid = spec->autocfg.input_pins[i];
4865 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004866 snd_hda_codec_write(codec, nid, 0,
4867 AC_VERB_SET_PIN_WIDGET_CONTROL,
4868 i <= AUTO_PIN_FRONT_MIC ?
4869 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004870 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004871 snd_hda_codec_write(codec, nid, 0,
4872 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004873 AMP_OUT_MUTE);
4874 }
4875 }
4876}
4877
4878/*
4879 * generic initialization of ADC, input mixers and output mixers
4880 */
4881static struct hda_verb alc260_volume_init_verbs[] = {
4882 /*
4883 * Unmute ADC0-1 and set the default input to mic-in
4884 */
4885 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4886 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4887 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4888 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4889
4890 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4891 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004892 * Note: PASD motherboards uses the Line In 2 as the input for
4893 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004894 */
4895 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004896 /* mute analog inputs */
4897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004902
4903 /*
4904 * Set up output mixers (0x08 - 0x0a)
4905 */
4906 /* set vol=0 to output mixers */
4907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4910 /* set up input amps for analog loopback */
4911 /* Amp Indices: DAC = 0, mixer = 1 */
4912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4913 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4915 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4917 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4918
4919 { }
4920};
4921
4922static int alc260_parse_auto_config(struct hda_codec *codec)
4923{
4924 struct alc_spec *spec = codec->spec;
4925 unsigned int wcap;
4926 int err;
4927 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4928
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004929 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4930 alc260_ignore);
4931 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004932 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004933 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4934 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004935 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004936 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004937 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4939 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004940 return err;
4941
4942 spec->multiout.max_channels = 2;
4943
4944 if (spec->autocfg.dig_out_pin)
4945 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4946 if (spec->kctl_alloc)
4947 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4948
4949 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004951 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004952 spec->input_mux = &spec->private_imux;
4953
4954 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004955 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004956 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01004957 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004958 spec->adc_nids = alc260_adc_nids_alt;
4959 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4960 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004961 } else {
4962 spec->adc_nids = alc260_adc_nids;
4963 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4964 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004965 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004966 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004967
4968 return 1;
4969}
4970
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004971/* additional initialization for auto-configuration model */
4972static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004973{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004974 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 alc260_auto_init_multi_out(codec);
4976 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004977 if (spec->unsol_event)
4978 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004979}
4980
Takashi Iwaicb53c622007-08-10 17:21:45 +02004981#ifdef CONFIG_SND_HDA_POWER_SAVE
4982static struct hda_amp_list alc260_loopbacks[] = {
4983 { 0x07, HDA_INPUT, 0 },
4984 { 0x07, HDA_INPUT, 1 },
4985 { 0x07, HDA_INPUT, 2 },
4986 { 0x07, HDA_INPUT, 3 },
4987 { 0x07, HDA_INPUT, 4 },
4988 { } /* end */
4989};
4990#endif
4991
Kailang Yangdf694da2005-12-05 19:42:22 +01004992/*
4993 * ALC260 configurations
4994 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004995static const char *alc260_models[ALC260_MODEL_LAST] = {
4996 [ALC260_BASIC] = "basic",
4997 [ALC260_HP] = "hp",
4998 [ALC260_HP_3013] = "hp-3013",
4999 [ALC260_FUJITSU_S702X] = "fujitsu",
5000 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005001 [ALC260_WILL] = "will",
5002 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005003#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005004 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005005#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005006 [ALC260_AUTO] = "auto",
5007};
5008
5009static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005010 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005011 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005012 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005013 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005014 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5015 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5016 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5017 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5018 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5019 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5020 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5021 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5022 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5023 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5024 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5025 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005026 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005027 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005028 {}
5029};
5030
Kailang Yangdf694da2005-12-05 19:42:22 +01005031static struct alc_config_preset alc260_presets[] = {
5032 [ALC260_BASIC] = {
5033 .mixers = { alc260_base_output_mixer,
5034 alc260_input_mixer,
5035 alc260_pc_beep_mixer,
5036 alc260_capture_mixer },
5037 .init_verbs = { alc260_init_verbs },
5038 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5039 .dac_nids = alc260_dac_nids,
5040 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5041 .adc_nids = alc260_adc_nids,
5042 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5043 .channel_mode = alc260_modes,
5044 .input_mux = &alc260_capture_source,
5045 },
5046 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005047 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 alc260_input_mixer,
5049 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005050 .init_verbs = { alc260_init_verbs,
5051 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005052 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5053 .dac_nids = alc260_dac_nids,
5054 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5055 .adc_nids = alc260_hp_adc_nids,
5056 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5057 .channel_mode = alc260_modes,
5058 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005059 .unsol_event = alc260_hp_unsol_event,
5060 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005061 },
5062 [ALC260_HP_3013] = {
5063 .mixers = { alc260_hp_3013_mixer,
5064 alc260_input_mixer,
5065 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005066 .init_verbs = { alc260_hp_3013_init_verbs,
5067 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005068 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5069 .dac_nids = alc260_dac_nids,
5070 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5071 .adc_nids = alc260_hp_adc_nids,
5072 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5073 .channel_mode = alc260_modes,
5074 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005075 .unsol_event = alc260_hp_3013_unsol_event,
5076 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005077 },
5078 [ALC260_FUJITSU_S702X] = {
5079 .mixers = { alc260_fujitsu_mixer,
5080 alc260_capture_mixer },
5081 .init_verbs = { alc260_fujitsu_init_verbs },
5082 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5083 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005084 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5085 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005086 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5087 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005088 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5089 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005090 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005091 [ALC260_ACER] = {
5092 .mixers = { alc260_acer_mixer,
5093 alc260_capture_mixer },
5094 .init_verbs = { alc260_acer_init_verbs },
5095 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5096 .dac_nids = alc260_dac_nids,
5097 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5098 .adc_nids = alc260_dual_adc_nids,
5099 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5100 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005101 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5102 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005103 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005104 [ALC260_WILL] = {
5105 .mixers = { alc260_will_mixer,
5106 alc260_capture_mixer },
5107 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5108 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5109 .dac_nids = alc260_dac_nids,
5110 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5111 .adc_nids = alc260_adc_nids,
5112 .dig_out_nid = ALC260_DIGOUT_NID,
5113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5114 .channel_mode = alc260_modes,
5115 .input_mux = &alc260_capture_source,
5116 },
5117 [ALC260_REPLACER_672V] = {
5118 .mixers = { alc260_replacer_672v_mixer,
5119 alc260_capture_mixer },
5120 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5121 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5122 .dac_nids = alc260_dac_nids,
5123 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5124 .adc_nids = alc260_adc_nids,
5125 .dig_out_nid = ALC260_DIGOUT_NID,
5126 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5127 .channel_mode = alc260_modes,
5128 .input_mux = &alc260_capture_source,
5129 .unsol_event = alc260_replacer_672v_unsol_event,
5130 .init_hook = alc260_replacer_672v_automute,
5131 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005132#ifdef CONFIG_SND_DEBUG
5133 [ALC260_TEST] = {
5134 .mixers = { alc260_test_mixer,
5135 alc260_capture_mixer },
5136 .init_verbs = { alc260_test_init_verbs },
5137 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5138 .dac_nids = alc260_test_dac_nids,
5139 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5140 .adc_nids = alc260_test_adc_nids,
5141 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5142 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005143 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5144 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005145 },
5146#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005147};
5148
Linus Torvalds1da177e2005-04-16 15:20:36 -07005149static int patch_alc260(struct hda_codec *codec)
5150{
5151 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005152 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005153
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005155 if (spec == NULL)
5156 return -ENOMEM;
5157
5158 codec->spec = spec;
5159
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005160 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5161 alc260_models,
5162 alc260_cfg_tbl);
5163 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005164 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5165 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005166 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005167 }
5168
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 if (board_config == ALC260_AUTO) {
5170 /* automatic parse from the BIOS config */
5171 err = alc260_parse_auto_config(codec);
5172 if (err < 0) {
5173 alc_free(codec);
5174 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005175 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005176 printk(KERN_INFO
5177 "hda_codec: Cannot set up configuration "
5178 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005179 board_config = ALC260_BASIC;
5180 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005182
Kailang Yangdf694da2005-12-05 19:42:22 +01005183 if (board_config != ALC260_AUTO)
5184 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005185
5186 spec->stream_name_analog = "ALC260 Analog";
5187 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5188 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5189
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005190 spec->stream_name_digital = "ALC260 Digital";
5191 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5192 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5193
Takashi Iwai2134ea42008-01-10 16:53:55 +01005194 spec->vmaster_nid = 0x08;
5195
Linus Torvalds1da177e2005-04-16 15:20:36 -07005196 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005197 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005198 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005199#ifdef CONFIG_SND_HDA_POWER_SAVE
5200 if (!spec->loopback.amplist)
5201 spec->loopback.amplist = alc260_loopbacks;
5202#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005203
5204 return 0;
5205}
5206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005207
Linus Torvalds1da177e2005-04-16 15:20:36 -07005208/*
5209 * ALC882 support
5210 *
5211 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5212 * configuration. Each pin widget can choose any input DACs and a mixer.
5213 * Each ADC is connected from a mixer of all inputs. This makes possible
5214 * 6-channel independent captures.
5215 *
5216 * In addition, an independent DAC for the multi-playback (not used in this
5217 * driver yet).
5218 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005219#define ALC882_DIGOUT_NID 0x06
5220#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005221
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005222static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005223 { 8, NULL }
5224};
5225
5226static hda_nid_t alc882_dac_nids[4] = {
5227 /* front, rear, clfe, rear_surr */
5228 0x02, 0x03, 0x04, 0x05
5229};
5230
Kailang Yangdf694da2005-12-05 19:42:22 +01005231/* identical with ALC880 */
5232#define alc882_adc_nids alc880_adc_nids
5233#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005234
Takashi Iwaie1406342008-02-11 18:32:32 +01005235static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5236static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5237
Linus Torvalds1da177e2005-04-16 15:20:36 -07005238/* input MUX */
5239/* FIXME: should be a matrix-type input source selection */
5240
5241static struct hda_input_mux alc882_capture_source = {
5242 .num_items = 4,
5243 .items = {
5244 { "Mic", 0x0 },
5245 { "Front Mic", 0x1 },
5246 { "Line", 0x2 },
5247 { "CD", 0x4 },
5248 },
5249};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005250#define alc882_mux_enum_info alc_mux_enum_info
5251#define alc882_mux_enum_get alc_mux_enum_get
5252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005253static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5254 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005255{
5256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5257 struct alc_spec *spec = codec->spec;
5258 const struct hda_input_mux *imux = spec->input_mux;
5259 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005260 hda_nid_t nid = spec->capsrc_nids ?
5261 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005262 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5263 unsigned int i, idx;
5264
5265 idx = ucontrol->value.enumerated.item[0];
5266 if (idx >= imux->num_items)
5267 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005268 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005269 return 0;
5270 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005271 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5272 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005273 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005274 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005275 }
5276 *cur_val = idx;
5277 return 1;
5278}
5279
Kailang Yangdf694da2005-12-05 19:42:22 +01005280/*
Kailang Yang272a5272007-05-14 11:00:38 +02005281 * 2ch mode
5282 */
5283static struct hda_verb alc882_3ST_ch2_init[] = {
5284 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5285 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5286 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5287 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5288 { } /* end */
5289};
5290
5291/*
5292 * 6ch mode
5293 */
5294static struct hda_verb alc882_3ST_ch6_init[] = {
5295 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5296 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5297 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5298 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5299 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5300 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5301 { } /* end */
5302};
5303
5304static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5305 { 2, alc882_3ST_ch2_init },
5306 { 6, alc882_3ST_ch6_init },
5307};
5308
5309/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005310 * 6ch mode
5311 */
5312static struct hda_verb alc882_sixstack_ch6_init[] = {
5313 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5314 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5315 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5316 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5317 { } /* end */
5318};
5319
5320/*
5321 * 8ch mode
5322 */
5323static struct hda_verb alc882_sixstack_ch8_init[] = {
5324 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5325 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5326 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5327 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5328 { } /* end */
5329};
5330
5331static struct hda_channel_mode alc882_sixstack_modes[2] = {
5332 { 6, alc882_sixstack_ch6_init },
5333 { 8, alc882_sixstack_ch8_init },
5334};
5335
Takashi Iwai87350ad2007-08-16 18:19:38 +02005336/*
5337 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5338 */
5339
5340/*
5341 * 2ch mode
5342 */
5343static struct hda_verb alc885_mbp_ch2_init[] = {
5344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5345 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5346 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5347 { } /* end */
5348};
5349
5350/*
5351 * 6ch mode
5352 */
5353static struct hda_verb alc885_mbp_ch6_init[] = {
5354 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5355 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5356 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5357 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5358 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5359 { } /* end */
5360};
5361
5362static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5363 { 2, alc885_mbp_ch2_init },
5364 { 6, alc885_mbp_ch6_init },
5365};
5366
5367
Linus Torvalds1da177e2005-04-16 15:20:36 -07005368/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5369 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5370 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005371static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005373 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005374 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005375 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005376 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5377 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005378 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5379 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005380 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005381 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5383 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5384 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5385 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5386 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005388 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005391 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005392 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5393 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5394 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005395 { } /* end */
5396};
5397
Takashi Iwai87350ad2007-08-16 18:19:38 +02005398static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5400 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5401 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5402 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5404 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5406 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005407 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5409 { } /* end */
5410};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005411static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5414 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5415 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5421 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5422 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5423 { } /* end */
5424};
5425
Kailang Yang272a5272007-05-14 11:00:38 +02005426static struct snd_kcontrol_new alc882_targa_mixer[] = {
5427 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5428 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5429 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5430 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5431 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5432 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5433 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5435 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005437 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5438 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005439 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005440 { } /* end */
5441};
5442
5443/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5444 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5445 */
5446static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5447 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5448 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5450 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5455 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5456 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005459 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005460 { } /* end */
5461};
5462
Takashi Iwai914759b2007-09-06 14:52:04 +02005463static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5464 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5465 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5466 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5467 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5468 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5472 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5474 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5475 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5476 { } /* end */
5477};
5478
Kailang Yangdf694da2005-12-05 19:42:22 +01005479static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5480 {
5481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5482 .name = "Channel Mode",
5483 .info = alc_ch_mode_info,
5484 .get = alc_ch_mode_get,
5485 .put = alc_ch_mode_put,
5486 },
5487 { } /* end */
5488};
5489
Linus Torvalds1da177e2005-04-16 15:20:36 -07005490static struct hda_verb alc882_init_verbs[] = {
5491 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005495 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5497 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005507
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005508 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005509 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005512 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005516 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005519 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005520 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005524 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005525 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5527 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5530 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005531 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5533 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5536 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005537 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005538 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005539
5540 /* FIXME: use matrix-type input source selection */
5541 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5542 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5545 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005547 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5550 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5551 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005552 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5557 /* ADC1: mute amp left and right */
5558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005559 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005560 /* ADC2: mute amp left and right */
5561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005562 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005563 /* ADC3: mute amp left and right */
5564 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005565 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005566
5567 { }
5568};
5569
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005570static struct hda_verb alc882_eapd_verbs[] = {
5571 /* change to EAPD mode */
5572 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005573 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005574 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005575};
5576
Tobin Davis9102cd12006-12-15 10:02:12 +01005577/* Mac Pro test */
5578static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5579 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5580 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5582 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5583 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5584 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5585 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5586 { } /* end */
5587};
5588
5589static struct hda_verb alc882_macpro_init_verbs[] = {
5590 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5594 /* Front Pin: output 0 (0x0c) */
5595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5598 /* Front Mic pin: input vref at 80% */
5599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5601 /* Speaker: output */
5602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5604 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5605 /* Headphone output (output 0 - 0x0c) */
5606 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5608 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5609
5610 /* FIXME: use matrix-type input source selection */
5611 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5612 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5615 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5616 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5617 /* Input mixer2 */
5618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5622 /* Input mixer3 */
5623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5627 /* ADC1: mute amp left and right */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5629 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5630 /* ADC2: mute amp left and right */
5631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5633 /* ADC3: mute amp left and right */
5634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5635 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5636
5637 { }
5638};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005639
Takashi Iwai87350ad2007-08-16 18:19:38 +02005640/* Macbook Pro rev3 */
5641static struct hda_verb alc885_mbp3_init_verbs[] = {
5642 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5646 /* Rear mixer */
5647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5650 /* Front Pin: output 0 (0x0c) */
5651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5654 /* HP Pin: output 0 (0x0d) */
5655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5658 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5659 /* Mic (rear) pin: input vref at 80% */
5660 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5661 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5662 /* Front Mic pin: input vref at 80% */
5663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5664 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5665 /* Line In pin: use output 1 when in LineOut mode */
5666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5668 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5669
5670 /* FIXME: use matrix-type input source selection */
5671 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5672 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5677 /* Input mixer2 */
5678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5682 /* Input mixer3 */
5683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5687 /* ADC1: mute amp left and right */
5688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5689 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5690 /* ADC2: mute amp left and right */
5691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5692 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5693 /* ADC3: mute amp left and right */
5694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5695 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5696
5697 { }
5698};
5699
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005700/* iMac 24 mixer. */
5701static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5702 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5703 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5704 { } /* end */
5705};
5706
5707/* iMac 24 init verbs. */
5708static struct hda_verb alc885_imac24_init_verbs[] = {
5709 /* Internal speakers: output 0 (0x0c) */
5710 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5711 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5712 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5713 /* Internal speakers: output 0 (0x0c) */
5714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5716 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5717 /* Headphone: output 0 (0x0c) */
5718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5720 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5721 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5722 /* Front Mic: input vref at 80% */
5723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5725 { }
5726};
5727
5728/* Toggle speaker-output according to the hp-jack state */
5729static void alc885_imac24_automute(struct hda_codec *codec)
5730{
5731 unsigned int present;
5732
5733 present = snd_hda_codec_read(codec, 0x14, 0,
5734 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005735 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5736 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5737 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5738 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005739}
5740
5741/* Processes unsolicited events. */
5742static void alc885_imac24_unsol_event(struct hda_codec *codec,
5743 unsigned int res)
5744{
5745 /* Headphone insertion or removal. */
5746 if ((res >> 26) == ALC880_HP_EVENT)
5747 alc885_imac24_automute(codec);
5748}
5749
Takashi Iwai87350ad2007-08-16 18:19:38 +02005750static void alc885_mbp3_automute(struct hda_codec *codec)
5751{
5752 unsigned int present;
5753
5754 present = snd_hda_codec_read(codec, 0x15, 0,
5755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5756 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5757 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5758 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5759 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5760
5761}
5762static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5763 unsigned int res)
5764{
5765 /* Headphone insertion or removal. */
5766 if ((res >> 26) == ALC880_HP_EVENT)
5767 alc885_mbp3_automute(codec);
5768}
5769
5770
Kailang Yang272a5272007-05-14 11:00:38 +02005771static struct hda_verb alc882_targa_verbs[] = {
5772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5774
5775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5777
5778 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5779 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5780 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5781
5782 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5783 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5784 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5785 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5786 { } /* end */
5787};
5788
5789/* toggle speaker-output according to the hp-jack state */
5790static void alc882_targa_automute(struct hda_codec *codec)
5791{
5792 unsigned int present;
5793
5794 present = snd_hda_codec_read(codec, 0x14, 0,
5795 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005796 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5797 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005798 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5799 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005800}
5801
5802static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5803{
5804 /* Looks like the unsol event is incompatible with the standard
5805 * definition. 4bit tag is placed at 26 bit!
5806 */
5807 if (((res >> 26) == ALC880_HP_EVENT)) {
5808 alc882_targa_automute(codec);
5809 }
5810}
5811
5812static struct hda_verb alc882_asus_a7j_verbs[] = {
5813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5815
5816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5819
5820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5822 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5823
5824 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5825 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5827 { } /* end */
5828};
5829
Takashi Iwai914759b2007-09-06 14:52:04 +02005830static struct hda_verb alc882_asus_a7m_verbs[] = {
5831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5833
5834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5837
5838 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5840 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5841
5842 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5843 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5844 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5845 { } /* end */
5846};
5847
Tobin Davis9102cd12006-12-15 10:02:12 +01005848static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5849{
5850 unsigned int gpiostate, gpiomask, gpiodir;
5851
5852 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5853 AC_VERB_GET_GPIO_DATA, 0);
5854
5855 if (!muted)
5856 gpiostate |= (1 << pin);
5857 else
5858 gpiostate &= ~(1 << pin);
5859
5860 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5861 AC_VERB_GET_GPIO_MASK, 0);
5862 gpiomask |= (1 << pin);
5863
5864 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5865 AC_VERB_GET_GPIO_DIRECTION, 0);
5866 gpiodir |= (1 << pin);
5867
5868
5869 snd_hda_codec_write(codec, codec->afg, 0,
5870 AC_VERB_SET_GPIO_MASK, gpiomask);
5871 snd_hda_codec_write(codec, codec->afg, 0,
5872 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5873
5874 msleep(1);
5875
5876 snd_hda_codec_write(codec, codec->afg, 0,
5877 AC_VERB_SET_GPIO_DATA, gpiostate);
5878}
5879
Takashi Iwai7debbe52007-08-16 15:01:03 +02005880/* set up GPIO at initialization */
5881static void alc885_macpro_init_hook(struct hda_codec *codec)
5882{
5883 alc882_gpio_mute(codec, 0, 0);
5884 alc882_gpio_mute(codec, 1, 0);
5885}
5886
5887/* set up GPIO and update auto-muting at initialization */
5888static void alc885_imac24_init_hook(struct hda_codec *codec)
5889{
5890 alc885_macpro_init_hook(codec);
5891 alc885_imac24_automute(codec);
5892}
5893
Kailang Yangdf694da2005-12-05 19:42:22 +01005894/*
5895 * generic initialization of ADC, input mixers and output mixers
5896 */
5897static struct hda_verb alc882_auto_init_verbs[] = {
5898 /*
5899 * Unmute ADC0-2 and set the default input to mic-in
5900 */
5901 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5903 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5905 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5907
Takashi Iwaicb53c622007-08-10 17:21:45 +02005908 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005909 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005910 * Note: PASD motherboards uses the Line In 2 as the input for
5911 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005912 */
5913 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005919
5920 /*
5921 * Set up output mixers (0x0c - 0x0f)
5922 */
5923 /* set vol=0 to output mixers */
5924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5928 /* set up input amps for analog loopback */
5929 /* Amp Indices: DAC = 0, mixer = 1 */
5930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5932 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5934 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5936 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5938 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5939 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5940
5941 /* FIXME: use matrix-type input source selection */
5942 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5943 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5948 /* Input mixer2 */
5949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5953 /* Input mixer3 */
5954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5958
5959 { }
5960};
5961
5962/* capture mixer elements */
5963static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5964 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5965 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5966 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5967 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5968 {
5969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5970 /* The multiple "Capture Source" controls confuse alsamixer
5971 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005972 */
5973 /* .name = "Capture Source", */
5974 .name = "Input Source",
5975 .count = 2,
5976 .info = alc882_mux_enum_info,
5977 .get = alc882_mux_enum_get,
5978 .put = alc882_mux_enum_put,
5979 },
5980 { } /* end */
5981};
5982
5983static struct snd_kcontrol_new alc882_capture_mixer[] = {
5984 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5985 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5986 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5988 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5989 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5990 {
5991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5992 /* The multiple "Capture Source" controls confuse alsamixer
5993 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 */
5995 /* .name = "Capture Source", */
5996 .name = "Input Source",
5997 .count = 3,
5998 .info = alc882_mux_enum_info,
5999 .get = alc882_mux_enum_get,
6000 .put = alc882_mux_enum_put,
6001 },
6002 { } /* end */
6003};
6004
Takashi Iwaicb53c622007-08-10 17:21:45 +02006005#ifdef CONFIG_SND_HDA_POWER_SAVE
6006#define alc882_loopbacks alc880_loopbacks
6007#endif
6008
Kailang Yangdf694da2005-12-05 19:42:22 +01006009/* pcm configuration: identiacal with ALC880 */
6010#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6011#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6012#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6013#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6014
6015/*
6016 * configuration and preset
6017 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006018static const char *alc882_models[ALC882_MODEL_LAST] = {
6019 [ALC882_3ST_DIG] = "3stack-dig",
6020 [ALC882_6ST_DIG] = "6stack-dig",
6021 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006022 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006023 [ALC882_TARGA] = "targa",
6024 [ALC882_ASUS_A7J] = "asus-a7j",
6025 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006026 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006027 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006028 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006029 [ALC882_AUTO] = "auto",
6030};
6031
6032static struct snd_pci_quirk alc882_cfg_tbl[] = {
6033 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006034 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006035 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006036 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006037 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006038 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006039 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006040 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006041 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006042 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6043 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6044 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 {}
6046};
6047
6048static struct alc_config_preset alc882_presets[] = {
6049 [ALC882_3ST_DIG] = {
6050 .mixers = { alc882_base_mixer },
6051 .init_verbs = { alc882_init_verbs },
6052 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6053 .dac_nids = alc882_dac_nids,
6054 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 .dig_in_nid = ALC882_DIGIN_NID,
6056 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6057 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006058 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006059 .input_mux = &alc882_capture_source,
6060 },
6061 [ALC882_6ST_DIG] = {
6062 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6063 .init_verbs = { alc882_init_verbs },
6064 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6065 .dac_nids = alc882_dac_nids,
6066 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 .dig_in_nid = ALC882_DIGIN_NID,
6068 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6069 .channel_mode = alc882_sixstack_modes,
6070 .input_mux = &alc882_capture_source,
6071 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006072 [ALC882_ARIMA] = {
6073 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6074 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6075 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6076 .dac_nids = alc882_dac_nids,
6077 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6078 .channel_mode = alc882_sixstack_modes,
6079 .input_mux = &alc882_capture_source,
6080 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006081 [ALC882_W2JC] = {
6082 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6083 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6084 alc880_gpio1_init_verbs },
6085 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6086 .dac_nids = alc882_dac_nids,
6087 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6088 .channel_mode = alc880_threestack_modes,
6089 .need_dac_fix = 1,
6090 .input_mux = &alc882_capture_source,
6091 .dig_out_nid = ALC882_DIGOUT_NID,
6092 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006093 [ALC885_MBP3] = {
6094 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6095 .init_verbs = { alc885_mbp3_init_verbs,
6096 alc880_gpio1_init_verbs },
6097 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6098 .dac_nids = alc882_dac_nids,
6099 .channel_mode = alc885_mbp_6ch_modes,
6100 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6101 .input_mux = &alc882_capture_source,
6102 .dig_out_nid = ALC882_DIGOUT_NID,
6103 .dig_in_nid = ALC882_DIGIN_NID,
6104 .unsol_event = alc885_mbp3_unsol_event,
6105 .init_hook = alc885_mbp3_automute,
6106 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006107 [ALC885_MACPRO] = {
6108 .mixers = { alc882_macpro_mixer },
6109 .init_verbs = { alc882_macpro_init_verbs },
6110 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6111 .dac_nids = alc882_dac_nids,
6112 .dig_out_nid = ALC882_DIGOUT_NID,
6113 .dig_in_nid = ALC882_DIGIN_NID,
6114 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6115 .channel_mode = alc882_ch_modes,
6116 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006117 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006118 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006119 [ALC885_IMAC24] = {
6120 .mixers = { alc885_imac24_mixer },
6121 .init_verbs = { alc885_imac24_init_verbs },
6122 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6123 .dac_nids = alc882_dac_nids,
6124 .dig_out_nid = ALC882_DIGOUT_NID,
6125 .dig_in_nid = ALC882_DIGIN_NID,
6126 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6127 .channel_mode = alc882_ch_modes,
6128 .input_mux = &alc882_capture_source,
6129 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006130 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006131 },
Kailang Yang272a5272007-05-14 11:00:38 +02006132 [ALC882_TARGA] = {
6133 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6134 alc882_capture_mixer },
6135 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6136 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6137 .dac_nids = alc882_dac_nids,
6138 .dig_out_nid = ALC882_DIGOUT_NID,
6139 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6140 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006141 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006142 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6143 .channel_mode = alc882_3ST_6ch_modes,
6144 .need_dac_fix = 1,
6145 .input_mux = &alc882_capture_source,
6146 .unsol_event = alc882_targa_unsol_event,
6147 .init_hook = alc882_targa_automute,
6148 },
6149 [ALC882_ASUS_A7J] = {
6150 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6151 alc882_capture_mixer },
6152 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6153 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6154 .dac_nids = alc882_dac_nids,
6155 .dig_out_nid = ALC882_DIGOUT_NID,
6156 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6157 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006158 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006159 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6160 .channel_mode = alc882_3ST_6ch_modes,
6161 .need_dac_fix = 1,
6162 .input_mux = &alc882_capture_source,
6163 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006164 [ALC882_ASUS_A7M] = {
6165 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6166 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6167 alc880_gpio1_init_verbs,
6168 alc882_asus_a7m_verbs },
6169 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6170 .dac_nids = alc882_dac_nids,
6171 .dig_out_nid = ALC882_DIGOUT_NID,
6172 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6173 .channel_mode = alc880_threestack_modes,
6174 .need_dac_fix = 1,
6175 .input_mux = &alc882_capture_source,
6176 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006177};
6178
6179
6180/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006181 * Pin config fixes
6182 */
6183enum {
6184 PINFIX_ABIT_AW9D_MAX
6185};
6186
6187static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6188 { 0x15, 0x01080104 }, /* side */
6189 { 0x16, 0x01011012 }, /* rear */
6190 { 0x17, 0x01016011 }, /* clfe */
6191 { }
6192};
6193
6194static const struct alc_pincfg *alc882_pin_fixes[] = {
6195 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6196};
6197
6198static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6199 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6200 {}
6201};
6202
6203/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 * BIOS auto configuration
6205 */
6206static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6207 hda_nid_t nid, int pin_type,
6208 int dac_idx)
6209{
6210 /* set as output */
6211 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006212 int idx;
6213
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006214 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6216 idx = 4;
6217 else
6218 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6220
6221}
6222
6223static void alc882_auto_init_multi_out(struct hda_codec *codec)
6224{
6225 struct alc_spec *spec = codec->spec;
6226 int i;
6227
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006228 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006230 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006231 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006232 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006233 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006234 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006235 }
6236}
6237
6238static void alc882_auto_init_hp_out(struct hda_codec *codec)
6239{
6240 struct alc_spec *spec = codec->spec;
6241 hda_nid_t pin;
6242
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006243 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006244 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006245 /* use dac 0 */
6246 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006247 pin = spec->autocfg.speaker_pins[0];
6248 if (pin)
6249 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006250}
6251
6252#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6253#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6254
6255static void alc882_auto_init_analog_input(struct hda_codec *codec)
6256{
6257 struct alc_spec *spec = codec->spec;
6258 int i;
6259
6260 for (i = 0; i < AUTO_PIN_LAST; i++) {
6261 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006262 unsigned int vref;
6263 if (!nid)
6264 continue;
6265 vref = PIN_IN;
6266 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6267 if (snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) &
6268 AC_PINCAP_VREF_80)
6269 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006270 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006271 snd_hda_codec_write(codec, nid, 0,
6272 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6273 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6274 snd_hda_codec_write(codec, nid, 0,
6275 AC_VERB_SET_AMP_GAIN_MUTE,
6276 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006277 }
6278}
6279
Takashi Iwai776e1842007-08-29 15:07:11 +02006280/* add mic boosts if needed */
6281static int alc_auto_add_mic_boost(struct hda_codec *codec)
6282{
6283 struct alc_spec *spec = codec->spec;
6284 int err;
6285 hda_nid_t nid;
6286
6287 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006288 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006289 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6290 "Mic Boost",
6291 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6292 if (err < 0)
6293 return err;
6294 }
6295 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006296 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006297 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6298 "Front Mic Boost",
6299 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6300 if (err < 0)
6301 return err;
6302 }
6303 return 0;
6304}
6305
Kailang Yangdf694da2005-12-05 19:42:22 +01006306/* almost identical with ALC880 parser... */
6307static int alc882_parse_auto_config(struct hda_codec *codec)
6308{
6309 struct alc_spec *spec = codec->spec;
6310 int err = alc880_parse_auto_config(codec);
6311
6312 if (err < 0)
6313 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006314 else if (!err)
6315 return 0; /* no config found */
6316
6317 err = alc_auto_add_mic_boost(codec);
6318 if (err < 0)
6319 return err;
6320
6321 /* hack - override the init verbs */
6322 spec->init_verbs[0] = alc882_auto_init_verbs;
6323
6324 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006325}
6326
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006327/* additional initialization for auto-configuration model */
6328static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006329{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006330 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006331 alc882_auto_init_multi_out(codec);
6332 alc882_auto_init_hp_out(codec);
6333 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006334 if (spec->unsol_event)
6335 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006336}
6337
Linus Torvalds1da177e2005-04-16 15:20:36 -07006338static int patch_alc882(struct hda_codec *codec)
6339{
6340 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006341 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006342
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006343 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006344 if (spec == NULL)
6345 return -ENOMEM;
6346
Linus Torvalds1da177e2005-04-16 15:20:36 -07006347 codec->spec = spec;
6348
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006349 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6350 alc882_models,
6351 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006352
Kailang Yangdf694da2005-12-05 19:42:22 +01006353 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006354 /* Pick up systems that don't supply PCI SSID */
6355 switch (codec->subsystem_id) {
6356 case 0x106b0c00: /* Mac Pro */
6357 board_config = ALC885_MACPRO;
6358 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006359 case 0x106b1000: /* iMac 24 */
6360 board_config = ALC885_IMAC24;
6361 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006362 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006363 case 0x106b2c00: /* Macbook Pro rev3 */
6364 board_config = ALC885_MBP3;
6365 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006366 default:
6367 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6368 "trying auto-probe from BIOS...\n");
6369 board_config = ALC882_AUTO;
6370 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006371 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006372
Takashi Iwaif95474e2007-07-10 00:47:43 +02006373 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6374
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 if (board_config == ALC882_AUTO) {
6376 /* automatic parse from the BIOS config */
6377 err = alc882_parse_auto_config(codec);
6378 if (err < 0) {
6379 alc_free(codec);
6380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006381 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006382 printk(KERN_INFO
6383 "hda_codec: Cannot set up configuration "
6384 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006385 board_config = ALC882_3ST_DIG;
6386 }
6387 }
6388
6389 if (board_config != ALC882_AUTO)
6390 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006391
6392 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006393 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6394 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006395 /* FIXME: setup DAC5 */
6396 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6397 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006398
6399 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006400 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6401 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006402
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006403 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006404 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006405 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006406 /* get type */
6407 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 if (wcap != AC_WID_AUD_IN) {
6409 spec->adc_nids = alc882_adc_nids_alt;
6410 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006411 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006412 spec->mixers[spec->num_mixers] =
6413 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006414 spec->num_mixers++;
6415 } else {
6416 spec->adc_nids = alc882_adc_nids;
6417 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006418 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006419 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6420 spec->num_mixers++;
6421 }
6422 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006423
Takashi Iwai2134ea42008-01-10 16:53:55 +01006424 spec->vmaster_nid = 0x0c;
6425
Linus Torvalds1da177e2005-04-16 15:20:36 -07006426 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006428 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006429#ifdef CONFIG_SND_HDA_POWER_SAVE
6430 if (!spec->loopback.amplist)
6431 spec->loopback.amplist = alc882_loopbacks;
6432#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006433
6434 return 0;
6435}
6436
6437/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006438 * ALC883 support
6439 *
6440 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6441 * configuration. Each pin widget can choose any input DACs and a mixer.
6442 * Each ADC is connected from a mixer of all inputs. This makes possible
6443 * 6-channel independent captures.
6444 *
6445 * In addition, an independent DAC for the multi-playback (not used in this
6446 * driver yet).
6447 */
6448#define ALC883_DIGOUT_NID 0x06
6449#define ALC883_DIGIN_NID 0x0a
6450
6451static hda_nid_t alc883_dac_nids[4] = {
6452 /* front, rear, clfe, rear_surr */
6453 0x02, 0x04, 0x03, 0x05
6454};
6455
6456static hda_nid_t alc883_adc_nids[2] = {
6457 /* ADC1-2 */
6458 0x08, 0x09,
6459};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006460
Takashi Iwaie1406342008-02-11 18:32:32 +01006461static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6462
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006463/* input MUX */
6464/* FIXME: should be a matrix-type input source selection */
6465
6466static struct hda_input_mux alc883_capture_source = {
6467 .num_items = 4,
6468 .items = {
6469 { "Mic", 0x0 },
6470 { "Front Mic", 0x1 },
6471 { "Line", 0x2 },
6472 { "CD", 0x4 },
6473 },
6474};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006475
6476static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6477 .num_items = 2,
6478 .items = {
6479 { "Mic", 0x1 },
6480 { "Line", 0x2 },
6481 },
6482};
6483
Kailang Yang272a5272007-05-14 11:00:38 +02006484static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6485 .num_items = 4,
6486 .items = {
6487 { "Mic", 0x0 },
6488 { "iMic", 0x1 },
6489 { "Line", 0x2 },
6490 { "CD", 0x4 },
6491 },
6492};
6493
Jiang zhefb97dc62008-03-06 11:07:11 +01006494static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6495 .num_items = 2,
6496 .items = {
6497 { "Mic", 0x0 },
6498 { "Int Mic", 0x1 },
6499 },
6500};
6501
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006502#define alc883_mux_enum_info alc_mux_enum_info
6503#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006504/* ALC883 has the ALC882-type input selection */
6505#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006506
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006507/*
6508 * 2ch mode
6509 */
6510static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6511 { 2, NULL }
6512};
6513
6514/*
6515 * 2ch mode
6516 */
6517static struct hda_verb alc883_3ST_ch2_init[] = {
6518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6520 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6521 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6522 { } /* end */
6523};
6524
6525/*
Tobin Davisb2011312007-09-17 12:45:11 +02006526 * 4ch mode
6527 */
6528static struct hda_verb alc883_3ST_ch4_init[] = {
6529 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6530 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6531 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6532 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6533 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6534 { } /* end */
6535};
6536
6537/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006538 * 6ch mode
6539 */
6540static struct hda_verb alc883_3ST_ch6_init[] = {
6541 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6542 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6543 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6544 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6545 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6546 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6547 { } /* end */
6548};
6549
Tobin Davisb2011312007-09-17 12:45:11 +02006550static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006551 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006552 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006553 { 6, alc883_3ST_ch6_init },
6554};
6555
6556/*
6557 * 6ch mode
6558 */
6559static struct hda_verb alc883_sixstack_ch6_init[] = {
6560 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6561 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6562 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6563 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6564 { } /* end */
6565};
6566
6567/*
6568 * 8ch mode
6569 */
6570static struct hda_verb alc883_sixstack_ch8_init[] = {
6571 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6572 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6573 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6574 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6575 { } /* end */
6576};
6577
6578static struct hda_channel_mode alc883_sixstack_modes[2] = {
6579 { 6, alc883_sixstack_ch6_init },
6580 { 8, alc883_sixstack_ch8_init },
6581};
6582
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006583static struct hda_verb alc883_medion_eapd_verbs[] = {
6584 /* eanable EAPD on medion laptop */
6585 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6586 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6587 { }
6588};
6589
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006590/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6591 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6592 */
6593
6594static struct snd_kcontrol_new alc883_base_mixer[] = {
6595 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6596 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6597 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6598 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6599 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6600 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6601 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6602 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6603 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6604 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6606 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6607 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006611 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006612 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6613 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006614 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006615 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6616 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6617 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6618 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6619 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6620 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6621 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6622 {
6623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6624 /* .name = "Capture Source", */
6625 .name = "Input Source",
6626 .count = 2,
6627 .info = alc883_mux_enum_info,
6628 .get = alc883_mux_enum_get,
6629 .put = alc883_mux_enum_put,
6630 },
6631 { } /* end */
6632};
6633
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006634static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6635 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6636 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6637 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6638 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6639 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6640 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6645 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6646 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6648 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6649 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6650 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6651 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6652 {
6653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6654 /* .name = "Capture Source", */
6655 .name = "Input Source",
6656 .count = 2,
6657 .info = alc883_mux_enum_info,
6658 .get = alc883_mux_enum_get,
6659 .put = alc883_mux_enum_put,
6660 },
6661 { } /* end */
6662};
6663
Jiang zhe368c7a92008-03-04 11:20:33 +01006664static struct snd_kcontrol_new alc883_clevo_m720r_mixer[] = {
6665 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6666 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6667 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6668 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6670 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6672 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6673 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6674 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6675 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6676 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6677 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6678 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6679 {
6680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6681 /* .name = "Capture Source", */
6682 .name = "Input Source",
6683 .count = 2,
6684 .info = alc883_mux_enum_info,
6685 .get = alc883_mux_enum_get,
6686 .put = alc883_mux_enum_put,
6687 },
6688 { } /* end */
6689};
6690
Jiang zhefb97dc62008-03-06 11:07:11 +01006691static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6693 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6694 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6695 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6698 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6699 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6700 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6701 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6702 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6703 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6704 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6705 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6706 {
6707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6708 /* .name = "Capture Source", */
6709 .name = "Input Source",
6710 .count = 2,
6711 .info = alc883_mux_enum_info,
6712 .get = alc883_mux_enum_get,
6713 .put = alc883_mux_enum_put,
6714 },
6715 { } /* end */
6716};
6717
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006718static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6722 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6723 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006730 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6732 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6733 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6735 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6736 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6737 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6738 {
6739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6740 /* .name = "Capture Source", */
6741 .name = "Input Source",
6742 .count = 2,
6743 .info = alc883_mux_enum_info,
6744 .get = alc883_mux_enum_get,
6745 .put = alc883_mux_enum_put,
6746 },
6747 { } /* end */
6748};
6749
6750static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6751 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6753 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6754 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6755 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6756 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6757 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6758 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6759 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6770 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6771 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6773 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6774 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6775 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6776 {
6777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6778 /* .name = "Capture Source", */
6779 .name = "Input Source",
6780 .count = 2,
6781 .info = alc883_mux_enum_info,
6782 .get = alc883_mux_enum_get,
6783 .put = alc883_mux_enum_put,
6784 },
6785 { } /* end */
6786};
6787
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006788static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6790 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6793 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6794 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6795 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6796 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6797 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6798 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6799 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6805 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006806 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6808 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6809 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6811 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6812
6813 {
6814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6815 /* .name = "Capture Source", */
6816 .name = "Input Source",
6817 .count = 1,
6818 .info = alc883_mux_enum_info,
6819 .get = alc883_mux_enum_get,
6820 .put = alc883_mux_enum_put,
6821 },
6822 { } /* end */
6823};
6824
Kailang Yangccc656c2006-10-17 12:32:26 +02006825static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6826 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6828 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6830 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6833 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6834 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6846 {
6847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6848 /* .name = "Capture Source", */
6849 .name = "Input Source",
6850 .count = 2,
6851 .info = alc883_mux_enum_info,
6852 .get = alc883_mux_enum_get,
6853 .put = alc883_mux_enum_put,
6854 },
6855 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006856};
Kailang Yangccc656c2006-10-17 12:32:26 +02006857
6858static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6868 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6869 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6870 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6871 {
6872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6873 /* .name = "Capture Source", */
6874 .name = "Input Source",
6875 .count = 2,
6876 .info = alc883_mux_enum_info,
6877 .get = alc883_mux_enum_get,
6878 .put = alc883_mux_enum_put,
6879 },
6880 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006881};
Kailang Yangccc656c2006-10-17 12:32:26 +02006882
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006883static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6885 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006886 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6887 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6892 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6893 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6894 {
6895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6896 /* .name = "Capture Source", */
6897 .name = "Input Source",
6898 .count = 1,
6899 .info = alc883_mux_enum_info,
6900 .get = alc883_mux_enum_get,
6901 .put = alc883_mux_enum_put,
6902 },
6903 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006904};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006905
Kailang Yang272a5272007-05-14 11:00:38 +02006906static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6907 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6908 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6914 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6915 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6916 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6917 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6918 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6919 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6920 {
6921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6922 /* .name = "Capture Source", */
6923 .name = "Input Source",
6924 .count = 2,
6925 .info = alc883_mux_enum_info,
6926 .get = alc883_mux_enum_get,
6927 .put = alc883_mux_enum_put,
6928 },
6929 { } /* end */
6930};
6931
6932static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6933 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6935 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6942 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6943 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6944 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6945 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6946 {
6947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6948 /* .name = "Capture Source", */
6949 .name = "Input Source",
6950 .count = 2,
6951 .info = alc883_mux_enum_info,
6952 .get = alc883_mux_enum_get,
6953 .put = alc883_mux_enum_put,
6954 },
6955 { } /* end */
6956};
6957
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006958static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6962 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6967 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6968 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6978 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6979 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6980 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6981 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6983 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6984 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6985 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6986 {
6987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6988 /* .name = "Capture Source", */
6989 .name = "Input Source",
6990 .count = 2,
6991 .info = alc883_mux_enum_info,
6992 .get = alc883_mux_enum_get,
6993 .put = alc883_mux_enum_put,
6994 },
6995 { } /* end */
6996};
6997
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006998static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7001 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7002 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7003 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
7004 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7005 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7006 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7018 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7019 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7021 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7023 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7024 {
7025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7026 /* .name = "Capture Source", */
7027 .name = "Input Source",
7028 .count = 2,
7029 .info = alc883_mux_enum_info,
7030 .get = alc883_mux_enum_get,
7031 .put = alc883_mux_enum_put,
7032 },
7033 { } /* end */
7034};
7035
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007036static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
7037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7040 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
7042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7043 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7044 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7046 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7055 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7056 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7058 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7059 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7061 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7062 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7063 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7064 {
7065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7066 /* .name = "Capture Source", */
7067 .name = "Input Source",
7068 .count = 2,
7069 .info = alc883_mux_enum_info,
7070 .get = alc883_mux_enum_get,
7071 .put = alc883_mux_enum_put,
7072 },
7073 { } /* end */
7074};
7075
Tobin Davis2880a862007-08-07 11:50:26 +02007076static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007082 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007085 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7086 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7087 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7088 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7089 {
7090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7091 /* .name = "Capture Source", */
7092 .name = "Input Source",
7093 .count = 2,
7094 .info = alc883_mux_enum_info,
7095 .get = alc883_mux_enum_get,
7096 .put = alc883_mux_enum_put,
7097 },
7098 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007099};
Tobin Davis2880a862007-08-07 11:50:26 +02007100
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007101static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7102 {
7103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7104 .name = "Channel Mode",
7105 .info = alc_ch_mode_info,
7106 .get = alc_ch_mode_get,
7107 .put = alc_ch_mode_put,
7108 },
7109 { } /* end */
7110};
7111
7112static struct hda_verb alc883_init_verbs[] = {
7113 /* ADC1: mute amp left and right */
7114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7116 /* ADC2: mute amp left and right */
7117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7119 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7123 /* Rear mixer */
7124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7125 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7127 /* CLFE mixer */
7128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7130 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7131 /* Side mixer */
7132 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7135
Takashi Iwaicb53c622007-08-10 17:21:45 +02007136 /* mute analog input loopbacks */
7137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007142
7143 /* Front Pin: output 0 (0x0c) */
7144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7146 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7147 /* Rear Pin: output 1 (0x0d) */
7148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7149 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7151 /* CLFE Pin: output 2 (0x0e) */
7152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7153 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7154 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7155 /* Side Pin: output 3 (0x0f) */
7156 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7157 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7158 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7159 /* Mic (rear) pin: input vref at 80% */
7160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7162 /* Front Mic pin: input vref at 80% */
7163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7165 /* Line In pin: input */
7166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7168 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7169 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7171 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7172 /* CD pin widget for input */
7173 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7174
7175 /* FIXME: use matrix-type input source selection */
7176 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7177 /* Input mixer2 */
7178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7182 /* Input mixer3 */
7183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7187 { }
7188};
7189
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007190/* toggle speaker-output according to the hp-jack state */
7191static void alc883_mitac_hp_automute(struct hda_codec *codec)
7192{
7193 unsigned int present;
7194
7195 present = snd_hda_codec_read(codec, 0x15, 0,
7196 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7197 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7198 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7199 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7200 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7201}
7202
7203/* auto-toggle front mic */
7204/*
7205static void alc883_mitac_mic_automute(struct hda_codec *codec)
7206{
7207 unsigned int present;
7208 unsigned char bits;
7209
7210 present = snd_hda_codec_read(codec, 0x18, 0,
7211 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7212 bits = present ? HDA_AMP_MUTE : 0;
7213 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7214}
7215*/
7216
7217static void alc883_mitac_automute(struct hda_codec *codec)
7218{
7219 alc883_mitac_hp_automute(codec);
7220 /* alc883_mitac_mic_automute(codec); */
7221}
7222
7223static void alc883_mitac_unsol_event(struct hda_codec *codec,
7224 unsigned int res)
7225{
7226 switch (res >> 26) {
7227 case ALC880_HP_EVENT:
7228 alc883_mitac_hp_automute(codec);
7229 break;
7230 case ALC880_MIC_EVENT:
7231 /* alc883_mitac_mic_automute(codec); */
7232 break;
7233 }
7234}
7235
7236static struct hda_verb alc883_mitac_verbs[] = {
7237 /* HP */
7238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7240 /* Subwoofer */
7241 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7242 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7243
7244 /* enable unsolicited event */
7245 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7246 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7247
7248 { } /* end */
7249};
7250
Jiang zhe368c7a92008-03-04 11:20:33 +01007251static struct hda_verb alc883_clevo_m720r_verbs[] = {
7252 /* HP */
7253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7255 /* Int speaker */
7256 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7258
7259 /* enable unsolicited event */
7260 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7261
7262 { } /* end */
7263};
7264
Jiang zhefb97dc62008-03-06 11:07:11 +01007265static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7266 /* HP */
7267 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7269 /* Subwoofer */
7270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272
7273 /* enable unsolicited event */
7274 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7275
7276 { } /* end */
7277};
7278
Kailang Yangccc656c2006-10-17 12:32:26 +02007279static struct hda_verb alc883_tagra_verbs[] = {
7280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7282
7283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7285
7286 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7287 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7288 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7289
7290 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007291 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7292 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7293 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007294
7295 { } /* end */
7296};
7297
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007298static struct hda_verb alc883_lenovo_101e_verbs[] = {
7299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7300 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7301 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7302 { } /* end */
7303};
7304
Kailang Yang272a5272007-05-14 11:00:38 +02007305static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7306 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7308 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7310 { } /* end */
7311};
7312
7313static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7316 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7317 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7319 { } /* end */
7320};
7321
Kailang Yang189609a2007-08-20 11:31:23 +02007322static struct hda_verb alc883_haier_w66_verbs[] = {
7323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7325
7326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7327
7328 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7330 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7332 { } /* end */
7333};
7334
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007335static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007336 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7338 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7339 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7340 { }
7341};
7342
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007343static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007344 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7345 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7346 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7347 { }
7348};
7349
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007350static struct hda_verb alc888_6st_dell_verbs[] = {
7351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7353 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7354 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7355 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7356 { }
7357};
7358
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007359static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007360 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7361 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7362 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7363 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7364 { }
7365};
7366
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007367static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007368 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7369 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7370 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7371 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7372 { }
7373};
7374
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007375static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7376 { 2, alc888_3st_hp_2ch_init },
7377 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007378};
7379
Kailang Yang272a5272007-05-14 11:00:38 +02007380/* toggle front-jack and RCA according to the hp-jack state */
7381static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7382{
7383 unsigned int present;
7384
7385 present = snd_hda_codec_read(codec, 0x1b, 0,
7386 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007387 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7388 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7389 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7390 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007391}
7392
7393/* toggle RCA according to the front-jack state */
7394static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7395{
7396 unsigned int present;
7397
7398 present = snd_hda_codec_read(codec, 0x14, 0,
7399 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007400 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7401 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007402}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007403
Kailang Yang272a5272007-05-14 11:00:38 +02007404static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7405 unsigned int res)
7406{
7407 if ((res >> 26) == ALC880_HP_EVENT)
7408 alc888_lenovo_ms7195_front_automute(codec);
7409 if ((res >> 26) == ALC880_FRONT_EVENT)
7410 alc888_lenovo_ms7195_rca_automute(codec);
7411}
7412
7413static struct hda_verb alc883_medion_md2_verbs[] = {
7414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7416
7417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7418
7419 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7420 { } /* end */
7421};
7422
7423/* toggle speaker-output according to the hp-jack state */
7424static void alc883_medion_md2_automute(struct hda_codec *codec)
7425{
7426 unsigned int present;
7427
7428 present = snd_hda_codec_read(codec, 0x14, 0,
7429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007430 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7431 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007432}
7433
7434static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7435 unsigned int res)
7436{
7437 if ((res >> 26) == ALC880_HP_EVENT)
7438 alc883_medion_md2_automute(codec);
7439}
7440
Kailang Yangccc656c2006-10-17 12:32:26 +02007441/* toggle speaker-output according to the hp-jack state */
7442static void alc883_tagra_automute(struct hda_codec *codec)
7443{
7444 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007445 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007446
7447 present = snd_hda_codec_read(codec, 0x14, 0,
7448 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007449 bits = present ? HDA_AMP_MUTE : 0;
7450 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7451 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007452 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7453 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007454}
7455
7456static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7457{
7458 if ((res >> 26) == ALC880_HP_EVENT)
7459 alc883_tagra_automute(codec);
7460}
7461
Jiang zhe368c7a92008-03-04 11:20:33 +01007462/* toggle speaker-output according to the hp-jack state */
7463static void alc883_clevo_m720r_automute(struct hda_codec *codec)
7464{
7465 unsigned int present;
7466 unsigned char bits;
7467
7468 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7469 & AC_PINSENSE_PRESENCE;
7470 bits = present ? HDA_AMP_MUTE : 0;
7471 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7472 HDA_AMP_MUTE, bits);
7473}
7474
7475static void alc883_clevo_m720r_unsol_event(struct hda_codec *codec,
7476 unsigned int res)
7477{
7478 if ((res >> 26) == ALC880_HP_EVENT)
7479 alc883_clevo_m720r_automute(codec);
7480}
7481
Jiang zhefb97dc62008-03-06 11:07:11 +01007482/* toggle speaker-output according to the hp-jack state */
7483static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7484{
7485 unsigned int present;
7486 unsigned char bits;
7487
7488 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7489 & AC_PINSENSE_PRESENCE;
7490 bits = present ? HDA_AMP_MUTE : 0;
7491 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7492 HDA_AMP_MUTE, bits);
7493}
7494
7495static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7496 unsigned int res)
7497{
7498 if ((res >> 26) == ALC880_HP_EVENT)
7499 alc883_2ch_fujitsu_pi2515_automute(codec);
7500}
7501
Kailang Yang189609a2007-08-20 11:31:23 +02007502static void alc883_haier_w66_automute(struct hda_codec *codec)
7503{
7504 unsigned int present;
7505 unsigned char bits;
7506
7507 present = snd_hda_codec_read(codec, 0x1b, 0,
7508 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7509 bits = present ? 0x80 : 0;
7510 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7511 0x80, bits);
7512}
7513
7514static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7515 unsigned int res)
7516{
7517 if ((res >> 26) == ALC880_HP_EVENT)
7518 alc883_haier_w66_automute(codec);
7519}
7520
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007521static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7522{
7523 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007524 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007525
7526 present = snd_hda_codec_read(codec, 0x14, 0,
7527 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007528 bits = present ? HDA_AMP_MUTE : 0;
7529 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7530 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007531}
7532
7533static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7534{
7535 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007536 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007537
7538 present = snd_hda_codec_read(codec, 0x1b, 0,
7539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007540 bits = present ? HDA_AMP_MUTE : 0;
7541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7542 HDA_AMP_MUTE, bits);
7543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7544 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007545}
7546
7547static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7548 unsigned int res)
7549{
7550 if ((res >> 26) == ALC880_HP_EVENT)
7551 alc883_lenovo_101e_all_automute(codec);
7552 if ((res >> 26) == ALC880_FRONT_EVENT)
7553 alc883_lenovo_101e_ispeaker_automute(codec);
7554}
7555
Takashi Iwai676a9b52007-08-16 15:23:35 +02007556/* toggle speaker-output according to the hp-jack state */
7557static void alc883_acer_aspire_automute(struct hda_codec *codec)
7558{
7559 unsigned int present;
7560
7561 present = snd_hda_codec_read(codec, 0x14, 0,
7562 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7563 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7564 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7565 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7566 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7567}
7568
7569static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7570 unsigned int res)
7571{
7572 if ((res >> 26) == ALC880_HP_EVENT)
7573 alc883_acer_aspire_automute(codec);
7574}
7575
Kailang Yangd1a991a2007-08-15 16:21:59 +02007576static struct hda_verb alc883_acer_eapd_verbs[] = {
7577 /* HP Pin: output 0 (0x0c) */
7578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7580 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7581 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007585 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7586 /* eanable EAPD on medion laptop */
7587 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7588 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007589 /* enable unsolicited event */
7590 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007591 { }
7592};
7593
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007594static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7595{
7596 unsigned int present;
7597
7598 present = snd_hda_codec_read(codec, 0x1b, 0,
7599 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7600 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7601 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7602 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7604 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7605 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7606 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7607 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7608}
7609
7610static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7611 unsigned int res)
7612{
7613 switch (res >> 26) {
7614 case ALC880_HP_EVENT:
7615 printk("hp_event\n");
7616 alc888_6st_dell_front_automute(codec);
7617 break;
7618 }
7619}
7620
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007621/*
7622 * generic initialization of ADC, input mixers and output mixers
7623 */
7624static struct hda_verb alc883_auto_init_verbs[] = {
7625 /*
7626 * Unmute ADC0-2 and set the default input to mic-in
7627 */
7628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7632
Takashi Iwaicb53c622007-08-10 17:21:45 +02007633 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007634 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007635 * Note: PASD motherboards uses the Line In 2 as the input for
7636 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007637 */
7638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007644
7645 /*
7646 * Set up output mixers (0x0c - 0x0f)
7647 */
7648 /* set vol=0 to output mixers */
7649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7653 /* set up input amps for analog loopback */
7654 /* Amp Indices: DAC = 0, mixer = 1 */
7655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7664 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7665
7666 /* FIXME: use matrix-type input source selection */
7667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7668 /* Input mixer1 */
7669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007672 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7674 /* Input mixer2 */
7675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007678 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007680
7681 { }
7682};
7683
7684/* capture mixer elements */
7685static struct snd_kcontrol_new alc883_capture_mixer[] = {
7686 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7687 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7688 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7689 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7690 {
7691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7692 /* The multiple "Capture Source" controls confuse alsamixer
7693 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007694 */
7695 /* .name = "Capture Source", */
7696 .name = "Input Source",
7697 .count = 2,
7698 .info = alc882_mux_enum_info,
7699 .get = alc882_mux_enum_get,
7700 .put = alc882_mux_enum_put,
7701 },
7702 { } /* end */
7703};
7704
Takashi Iwaicb53c622007-08-10 17:21:45 +02007705#ifdef CONFIG_SND_HDA_POWER_SAVE
7706#define alc883_loopbacks alc880_loopbacks
7707#endif
7708
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007709/* pcm configuration: identiacal with ALC880 */
7710#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7711#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007712#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007713#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7714#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7715
7716/*
7717 * configuration and preset
7718 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007719static const char *alc883_models[ALC883_MODEL_LAST] = {
7720 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7721 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7722 [ALC883_3ST_6ch] = "3stack-6ch",
7723 [ALC883_6ST_DIG] = "6stack-dig",
7724 [ALC883_TARGA_DIG] = "targa-dig",
7725 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007726 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007727 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007728 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007729 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007730 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007731 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007732 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7733 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007734 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007735 [ALC888_6ST_HP] = "6stack-hp",
7736 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007737 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007738 [ALC883_MITAC] = "mitac",
Jiang zhe368c7a92008-03-04 11:20:33 +01007739 [ALC883_CLEVO_M720R] = "clevo-m720r",
Jiang zhefb97dc62008-03-06 11:07:11 +01007740 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007741 [ALC883_AUTO] = "auto",
7742};
7743
7744static struct snd_pci_quirk alc883_cfg_tbl[] = {
7745 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007746 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7747 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7748 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7749 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007750 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007751 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007752 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7753 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7754 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7755 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007756 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007757 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7758 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7759 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007760 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007761 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7762 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7763 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7764 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007765 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007766 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7767 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7768 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7769 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7770 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7771 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7772 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7773 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7774 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007775 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7776 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007777 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007778 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007779 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007780 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007781 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Jiang zhe368c7a92008-03-04 11:20:33 +01007782 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720R),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007783 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007784 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007785 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007786 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007787 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007788 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007789 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7790 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007791 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007792 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007793 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007794 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007795 {}
7796};
7797
7798static struct alc_config_preset alc883_presets[] = {
7799 [ALC883_3ST_2ch_DIG] = {
7800 .mixers = { alc883_3ST_2ch_mixer },
7801 .init_verbs = { alc883_init_verbs },
7802 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7803 .dac_nids = alc883_dac_nids,
7804 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007805 .dig_in_nid = ALC883_DIGIN_NID,
7806 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7807 .channel_mode = alc883_3ST_2ch_modes,
7808 .input_mux = &alc883_capture_source,
7809 },
7810 [ALC883_3ST_6ch_DIG] = {
7811 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7812 .init_verbs = { alc883_init_verbs },
7813 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7814 .dac_nids = alc883_dac_nids,
7815 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007816 .dig_in_nid = ALC883_DIGIN_NID,
7817 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7818 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007819 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007820 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007821 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007822 [ALC883_3ST_6ch] = {
7823 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7824 .init_verbs = { alc883_init_verbs },
7825 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7826 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007827 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7828 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007829 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007830 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007831 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007832 [ALC883_6ST_DIG] = {
7833 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7834 .init_verbs = { alc883_init_verbs },
7835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7836 .dac_nids = alc883_dac_nids,
7837 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007838 .dig_in_nid = ALC883_DIGIN_NID,
7839 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7840 .channel_mode = alc883_sixstack_modes,
7841 .input_mux = &alc883_capture_source,
7842 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007843 [ALC883_TARGA_DIG] = {
7844 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7845 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7847 .dac_nids = alc883_dac_nids,
7848 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7850 .channel_mode = alc883_3ST_6ch_modes,
7851 .need_dac_fix = 1,
7852 .input_mux = &alc883_capture_source,
7853 .unsol_event = alc883_tagra_unsol_event,
7854 .init_hook = alc883_tagra_automute,
7855 },
7856 [ALC883_TARGA_2ch_DIG] = {
7857 .mixers = { alc883_tagra_2ch_mixer},
7858 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7860 .dac_nids = alc883_dac_nids,
7861 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007862 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7863 .channel_mode = alc883_3ST_2ch_modes,
7864 .input_mux = &alc883_capture_source,
7865 .unsol_event = alc883_tagra_unsol_event,
7866 .init_hook = alc883_tagra_automute,
7867 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007868 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007869 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007870 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7871 * and the headphone jack. Turn this on and rely on the
7872 * standard mute methods whenever the user wants to turn
7873 * these outputs off.
7874 */
7875 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7877 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7879 .channel_mode = alc883_3ST_2ch_modes,
7880 .input_mux = &alc883_capture_source,
7881 },
Tobin Davis2880a862007-08-07 11:50:26 +02007882 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007883 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007884 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7886 .dac_nids = alc883_dac_nids,
7887 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02007888 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7889 .channel_mode = alc883_3ST_2ch_modes,
7890 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007891 .unsol_event = alc883_acer_aspire_unsol_event,
7892 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007893 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007894 [ALC883_MEDION] = {
7895 .mixers = { alc883_fivestack_mixer,
7896 alc883_chmode_mixer },
7897 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007898 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7900 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02007901 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7902 .channel_mode = alc883_sixstack_modes,
7903 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007904 },
Kailang Yang272a5272007-05-14 11:00:38 +02007905 [ALC883_MEDION_MD2] = {
7906 .mixers = { alc883_medion_md2_mixer},
7907 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7908 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7909 .dac_nids = alc883_dac_nids,
7910 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7912 .channel_mode = alc883_3ST_2ch_modes,
7913 .input_mux = &alc883_capture_source,
7914 .unsol_event = alc883_medion_md2_unsol_event,
7915 .init_hook = alc883_medion_md2_automute,
7916 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007917 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007918 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007919 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7921 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7923 .channel_mode = alc883_3ST_2ch_modes,
7924 .input_mux = &alc883_capture_source,
7925 },
Jiang zhe368c7a92008-03-04 11:20:33 +01007926 [ALC883_CLEVO_M720R] = {
7927 .mixers = { alc883_clevo_m720r_mixer },
7928 .init_verbs = { alc883_init_verbs, alc883_clevo_m720r_verbs },
7929 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7930 .dac_nids = alc883_dac_nids,
7931 .dig_out_nid = ALC883_DIGOUT_NID,
7932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7933 .channel_mode = alc883_3ST_2ch_modes,
7934 .input_mux = &alc883_capture_source,
7935 .unsol_event = alc883_clevo_m720r_unsol_event,
7936 .init_hook = alc883_clevo_m720r_automute,
7937 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007938 [ALC883_LENOVO_101E_2ch] = {
7939 .mixers = { alc883_lenovo_101e_2ch_mixer},
7940 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7941 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7942 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007943 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7944 .channel_mode = alc883_3ST_2ch_modes,
7945 .input_mux = &alc883_lenovo_101e_capture_source,
7946 .unsol_event = alc883_lenovo_101e_unsol_event,
7947 .init_hook = alc883_lenovo_101e_all_automute,
7948 },
Kailang Yang272a5272007-05-14 11:00:38 +02007949 [ALC883_LENOVO_NB0763] = {
7950 .mixers = { alc883_lenovo_nb0763_mixer },
7951 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7952 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7953 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007954 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7955 .channel_mode = alc883_3ST_2ch_modes,
7956 .need_dac_fix = 1,
7957 .input_mux = &alc883_lenovo_nb0763_capture_source,
7958 .unsol_event = alc883_medion_md2_unsol_event,
7959 .init_hook = alc883_medion_md2_automute,
7960 },
7961 [ALC888_LENOVO_MS7195_DIG] = {
7962 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7963 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7965 .dac_nids = alc883_dac_nids,
7966 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007967 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7968 .channel_mode = alc883_3ST_6ch_modes,
7969 .need_dac_fix = 1,
7970 .input_mux = &alc883_capture_source,
7971 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7972 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007973 },
7974 [ALC883_HAIER_W66] = {
7975 .mixers = { alc883_tagra_2ch_mixer},
7976 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7978 .dac_nids = alc883_dac_nids,
7979 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02007980 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7981 .channel_mode = alc883_3ST_2ch_modes,
7982 .input_mux = &alc883_capture_source,
7983 .unsol_event = alc883_haier_w66_unsol_event,
7984 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007985 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007986 [ALC888_6ST_HP] = {
7987 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7988 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7990 .dac_nids = alc883_dac_nids,
7991 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007992 .dig_in_nid = ALC883_DIGIN_NID,
7993 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7994 .channel_mode = alc883_sixstack_modes,
7995 .input_mux = &alc883_capture_source,
7996 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007997 [ALC888_3ST_HP] = {
7998 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7999 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8001 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008002 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8003 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008004 .need_dac_fix = 1,
8005 .input_mux = &alc883_capture_source,
8006 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008007 [ALC888_6ST_DELL] = {
8008 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
8009 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8011 .dac_nids = alc883_dac_nids,
8012 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008013 .dig_in_nid = ALC883_DIGIN_NID,
8014 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8015 .channel_mode = alc883_sixstack_modes,
8016 .input_mux = &alc883_capture_source,
8017 .unsol_event = alc888_6st_dell_unsol_event,
8018 .init_hook = alc888_6st_dell_front_automute,
8019 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008020 [ALC883_MITAC] = {
8021 .mixers = { alc883_mitac_mixer },
8022 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8023 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8024 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8026 .channel_mode = alc883_3ST_2ch_modes,
8027 .input_mux = &alc883_capture_source,
8028 .unsol_event = alc883_mitac_unsol_event,
8029 .init_hook = alc883_mitac_automute,
8030 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008031 [ALC883_FUJITSU_PI2515] = {
8032 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8033 .init_verbs = { alc883_init_verbs,
8034 alc883_2ch_fujitsu_pi2515_verbs},
8035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8036 .dac_nids = alc883_dac_nids,
8037 .dig_out_nid = ALC883_DIGOUT_NID,
8038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8039 .channel_mode = alc883_3ST_2ch_modes,
8040 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8041 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8042 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8043 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008044};
8045
8046
8047/*
8048 * BIOS auto configuration
8049 */
8050static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8051 hda_nid_t nid, int pin_type,
8052 int dac_idx)
8053{
8054 /* set as output */
8055 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008056 int idx;
8057
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008058 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008059 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8060 idx = 4;
8061 else
8062 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008063 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8064
8065}
8066
8067static void alc883_auto_init_multi_out(struct hda_codec *codec)
8068{
8069 struct alc_spec *spec = codec->spec;
8070 int i;
8071
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008072 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008073 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008074 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008075 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008076 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008077 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008078 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008079 }
8080}
8081
8082static void alc883_auto_init_hp_out(struct hda_codec *codec)
8083{
8084 struct alc_spec *spec = codec->spec;
8085 hda_nid_t pin;
8086
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008087 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008088 if (pin) /* connect to front */
8089 /* use dac 0 */
8090 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008091 pin = spec->autocfg.speaker_pins[0];
8092 if (pin)
8093 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008094}
8095
8096#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8097#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8098
8099static void alc883_auto_init_analog_input(struct hda_codec *codec)
8100{
8101 struct alc_spec *spec = codec->spec;
8102 int i;
8103
8104 for (i = 0; i < AUTO_PIN_LAST; i++) {
8105 hda_nid_t nid = spec->autocfg.input_pins[i];
8106 if (alc883_is_input_pin(nid)) {
8107 snd_hda_codec_write(codec, nid, 0,
8108 AC_VERB_SET_PIN_WIDGET_CONTROL,
8109 (i <= AUTO_PIN_FRONT_MIC ?
8110 PIN_VREF80 : PIN_IN));
8111 if (nid != ALC883_PIN_CD_NID)
8112 snd_hda_codec_write(codec, nid, 0,
8113 AC_VERB_SET_AMP_GAIN_MUTE,
8114 AMP_OUT_MUTE);
8115 }
8116 }
8117}
8118
8119/* almost identical with ALC880 parser... */
8120static int alc883_parse_auto_config(struct hda_codec *codec)
8121{
8122 struct alc_spec *spec = codec->spec;
8123 int err = alc880_parse_auto_config(codec);
8124
8125 if (err < 0)
8126 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008127 else if (!err)
8128 return 0; /* no config found */
8129
8130 err = alc_auto_add_mic_boost(codec);
8131 if (err < 0)
8132 return err;
8133
8134 /* hack - override the init verbs */
8135 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008136 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8137 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008138
8139 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008140}
8141
8142/* additional initialization for auto-configuration model */
8143static void alc883_auto_init(struct hda_codec *codec)
8144{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008145 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008146 alc883_auto_init_multi_out(codec);
8147 alc883_auto_init_hp_out(codec);
8148 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008149 if (spec->unsol_event)
8150 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008151}
8152
8153static int patch_alc883(struct hda_codec *codec)
8154{
8155 struct alc_spec *spec;
8156 int err, board_config;
8157
8158 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8159 if (spec == NULL)
8160 return -ENOMEM;
8161
8162 codec->spec = spec;
8163
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008164 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8165 alc883_models,
8166 alc883_cfg_tbl);
8167 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008168 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8169 "trying auto-probe from BIOS...\n");
8170 board_config = ALC883_AUTO;
8171 }
8172
8173 if (board_config == ALC883_AUTO) {
8174 /* automatic parse from the BIOS config */
8175 err = alc883_parse_auto_config(codec);
8176 if (err < 0) {
8177 alc_free(codec);
8178 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008179 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008180 printk(KERN_INFO
8181 "hda_codec: Cannot set up configuration "
8182 "from BIOS. Using base mode...\n");
8183 board_config = ALC883_3ST_2ch_DIG;
8184 }
8185 }
8186
8187 if (board_config != ALC883_AUTO)
8188 setup_preset(spec, &alc883_presets[board_config]);
8189
8190 spec->stream_name_analog = "ALC883 Analog";
8191 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8192 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008193 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008194
8195 spec->stream_name_digital = "ALC883 Digital";
8196 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8197 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8198
Takashi Iwaie1406342008-02-11 18:32:32 +01008199 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8200 spec->adc_nids = alc883_adc_nids;
8201 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008202
Takashi Iwai2134ea42008-01-10 16:53:55 +01008203 spec->vmaster_nid = 0x0c;
8204
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008205 codec->patch_ops = alc_patch_ops;
8206 if (board_config == ALC883_AUTO)
8207 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008208#ifdef CONFIG_SND_HDA_POWER_SAVE
8209 if (!spec->loopback.amplist)
8210 spec->loopback.amplist = alc883_loopbacks;
8211#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008212
8213 return 0;
8214}
8215
8216/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008217 * ALC262 support
8218 */
8219
8220#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8221#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8222
8223#define alc262_dac_nids alc260_dac_nids
8224#define alc262_adc_nids alc882_adc_nids
8225#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008226#define alc262_capsrc_nids alc882_capsrc_nids
8227#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008228
8229#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008230#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008231
8232static struct snd_kcontrol_new alc262_base_mixer[] = {
8233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8234 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8243 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008244 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008245 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008246 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008247 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8249 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8250 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008251 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008252};
8253
Kailang Yangccc656c2006-10-17 12:32:26 +02008254static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8256 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008263 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008264 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8265 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008266 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008267 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008268 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008269 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8271 { } /* end */
8272};
8273
Takashi Iwaice875f02008-01-28 18:17:43 +01008274/* update HP, line and mono-out pins according to the master switch */
8275static void alc262_hp_master_update(struct hda_codec *codec)
8276{
8277 struct alc_spec *spec = codec->spec;
8278 int val = spec->master_sw;
8279
8280 /* HP & line-out */
8281 snd_hda_codec_write_cache(codec, 0x1b, 0,
8282 AC_VERB_SET_PIN_WIDGET_CONTROL,
8283 val ? PIN_HP : 0);
8284 snd_hda_codec_write_cache(codec, 0x15, 0,
8285 AC_VERB_SET_PIN_WIDGET_CONTROL,
8286 val ? PIN_HP : 0);
8287 /* mono (speaker) depending on the HP jack sense */
8288 val = val && !spec->jack_present;
8289 snd_hda_codec_write_cache(codec, 0x16, 0,
8290 AC_VERB_SET_PIN_WIDGET_CONTROL,
8291 val ? PIN_OUT : 0);
8292}
8293
8294static void alc262_hp_bpc_automute(struct hda_codec *codec)
8295{
8296 struct alc_spec *spec = codec->spec;
8297 unsigned int presence;
8298 presence = snd_hda_codec_read(codec, 0x1b, 0,
8299 AC_VERB_GET_PIN_SENSE, 0);
8300 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8301 alc262_hp_master_update(codec);
8302}
8303
8304static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8305{
8306 if ((res >> 26) != ALC880_HP_EVENT)
8307 return;
8308 alc262_hp_bpc_automute(codec);
8309}
8310
8311static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8312{
8313 struct alc_spec *spec = codec->spec;
8314 unsigned int presence;
8315 presence = snd_hda_codec_read(codec, 0x15, 0,
8316 AC_VERB_GET_PIN_SENSE, 0);
8317 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8318 alc262_hp_master_update(codec);
8319}
8320
8321static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8322 unsigned int res)
8323{
8324 if ((res >> 26) != ALC880_HP_EVENT)
8325 return;
8326 alc262_hp_wildwest_automute(codec);
8327}
8328
8329static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8330 struct snd_ctl_elem_value *ucontrol)
8331{
8332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8333 struct alc_spec *spec = codec->spec;
8334 *ucontrol->value.integer.value = spec->master_sw;
8335 return 0;
8336}
8337
8338static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8339 struct snd_ctl_elem_value *ucontrol)
8340{
8341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8342 struct alc_spec *spec = codec->spec;
8343 int val = !!*ucontrol->value.integer.value;
8344
8345 if (val == spec->master_sw)
8346 return 0;
8347 spec->master_sw = val;
8348 alc262_hp_master_update(codec);
8349 return 1;
8350}
8351
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008352static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008353 {
8354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8355 .name = "Master Playback Switch",
8356 .info = snd_ctl_boolean_mono_info,
8357 .get = alc262_hp_master_sw_get,
8358 .put = alc262_hp_master_sw_put,
8359 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008360 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8361 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008363 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8364 HDA_OUTPUT),
8365 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8366 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008372 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8377 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8378 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8379 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8380 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8381 { } /* end */
8382};
8383
Kailang Yangcd7509a2007-01-26 18:33:17 +01008384static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008385 {
8386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8387 .name = "Master Playback Switch",
8388 .info = snd_ctl_boolean_mono_info,
8389 .get = alc262_hp_master_sw_get,
8390 .put = alc262_hp_master_sw_put,
8391 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8393 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008396 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8397 HDA_OUTPUT),
8398 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8399 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008400 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8401 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008402 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8405 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8406 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8407 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8408 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8409 { } /* end */
8410};
8411
8412static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8413 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8414 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008415 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008416 { } /* end */
8417};
8418
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008419/* mute/unmute internal speaker according to the hp jack and mute state */
8420static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8421{
8422 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008423
8424 if (force || !spec->sense_updated) {
8425 unsigned int present;
8426 present = snd_hda_codec_read(codec, 0x15, 0,
8427 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008428 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008429 spec->sense_updated = 1;
8430 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008431 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8432 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008433}
8434
8435static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8436 unsigned int res)
8437{
8438 if ((res >> 26) != ALC880_HP_EVENT)
8439 return;
8440 alc262_hp_t5735_automute(codec, 1);
8441}
8442
8443static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8444{
8445 alc262_hp_t5735_automute(codec, 1);
8446}
8447
8448static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8450 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8456 { } /* end */
8457};
8458
8459static struct hda_verb alc262_hp_t5735_verbs[] = {
8460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8462
8463 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8464 { }
8465};
8466
Kailang Yang8c427222008-01-10 13:03:59 +01008467static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008468 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8471 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8473 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8474 { } /* end */
8475};
8476
8477static struct hda_verb alc262_hp_rp5700_verbs[] = {
8478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8480 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8488 {}
8489};
8490
8491static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8492 .num_items = 1,
8493 .items = {
8494 { "Line", 0x1 },
8495 },
8496};
8497
Takashi Iwai0724ea22007-08-23 00:31:43 +02008498/* bind hp and internal speaker mute (with plug check) */
8499static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8500 struct snd_ctl_elem_value *ucontrol)
8501{
8502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8503 long *valp = ucontrol->value.integer.value;
8504 int change;
8505
8506 /* change hp mute */
8507 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8508 HDA_AMP_MUTE,
8509 valp[0] ? 0 : HDA_AMP_MUTE);
8510 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8511 HDA_AMP_MUTE,
8512 valp[1] ? 0 : HDA_AMP_MUTE);
8513 if (change) {
8514 /* change speaker according to HP jack state */
8515 struct alc_spec *spec = codec->spec;
8516 unsigned int mute;
8517 if (spec->jack_present)
8518 mute = HDA_AMP_MUTE;
8519 else
8520 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8521 HDA_OUTPUT, 0);
8522 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8523 HDA_AMP_MUTE, mute);
8524 }
8525 return change;
8526}
Takashi Iwai5b319542007-07-26 11:49:22 +02008527
Kailang Yang272a5272007-05-14 11:00:38 +02008528static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008529 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8530 {
8531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8532 .name = "Master Playback Switch",
8533 .info = snd_hda_mixer_amp_switch_info,
8534 .get = snd_hda_mixer_amp_switch_get,
8535 .put = alc262_sony_master_sw_put,
8536 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8537 },
Kailang Yang272a5272007-05-14 11:00:38 +02008538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8540 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8541 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8542 { } /* end */
8543};
8544
Kailang Yang83c34212007-07-05 11:43:05 +02008545static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8547 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8551 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8552 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8553 { } /* end */
8554};
Kailang Yang272a5272007-05-14 11:00:38 +02008555
Kailang Yangdf694da2005-12-05 19:42:22 +01008556#define alc262_capture_mixer alc882_capture_mixer
8557#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8558
8559/*
8560 * generic initialization of ADC, input mixers and output mixers
8561 */
8562static struct hda_verb alc262_init_verbs[] = {
8563 /*
8564 * Unmute ADC0-2 and set the default input to mic-in
8565 */
8566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8570 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8572
Takashi Iwaicb53c622007-08-10 17:21:45 +02008573 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008574 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008575 * Note: PASD motherboards uses the Line In 2 as the input for
8576 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008577 */
8578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008584
8585 /*
8586 * Set up output mixers (0x0c - 0x0e)
8587 */
8588 /* set vol=0 to output mixers */
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8592 /* set up input amps for analog loopback */
8593 /* Amp Indices: DAC = 0, mixer = 1 */
8594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8600
8601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8604 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8605 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8606 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8607
8608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8610 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8612 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8613
8614 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8616
8617 /* FIXME: use matrix-type input source selection */
8618 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8619 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8622 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8624 /* Input mixer2 */
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8629 /* Input mixer3 */
8630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008634
8635 { }
8636};
8637
Kailang Yangccc656c2006-10-17 12:32:26 +02008638static struct hda_verb alc262_hippo_unsol_verbs[] = {
8639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8641 {}
8642};
8643
8644static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8646 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8647 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8648
8649 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8651 {}
8652};
8653
Kailang Yang272a5272007-05-14 11:00:38 +02008654static struct hda_verb alc262_sony_unsol_verbs[] = {
8655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8658
8659 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8661};
8662
Kailang Yangccc656c2006-10-17 12:32:26 +02008663/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008664static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008665{
8666 struct alc_spec *spec = codec->spec;
8667 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008668 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008669
Takashi Iwai5b319542007-07-26 11:49:22 +02008670 /* need to execute and sync at first */
8671 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8672 present = snd_hda_codec_read(codec, 0x15, 0,
8673 AC_VERB_GET_PIN_SENSE, 0);
8674 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008675 if (spec->jack_present) {
8676 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008677 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8678 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008679 } else {
8680 /* unmute internal speaker if necessary */
8681 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008682 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8683 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008684 }
8685}
8686
8687/* unsolicited event for HP jack sensing */
8688static void alc262_hippo_unsol_event(struct hda_codec *codec,
8689 unsigned int res)
8690{
8691 if ((res >> 26) != ALC880_HP_EVENT)
8692 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008693 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008694}
8695
Takashi Iwai5b319542007-07-26 11:49:22 +02008696static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008697{
Kailang Yangccc656c2006-10-17 12:32:26 +02008698 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008699 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008700
Takashi Iwai5b319542007-07-26 11:49:22 +02008701 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8702 present = snd_hda_codec_read(codec, 0x1b, 0,
8703 AC_VERB_GET_PIN_SENSE, 0);
8704 present = (present & 0x80000000) != 0;
8705 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008706 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008707 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8708 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008709 } else {
8710 /* unmute internal speaker if necessary */
8711 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008712 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8713 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008714 }
8715}
8716
8717/* unsolicited event for HP jack sensing */
8718static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8719 unsigned int res)
8720{
8721 if ((res >> 26) != ALC880_HP_EVENT)
8722 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008723 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008724}
8725
Takashi Iwai834be882006-03-01 14:16:17 +01008726/*
8727 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008728 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8729 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008730 */
8731
8732#define ALC_HP_EVENT 0x37
8733
8734static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8735 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008737 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01008739 {}
8740};
8741
8742static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008743 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008744 .items = {
8745 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008746 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008747 { "CD", 0x4 },
8748 },
8749};
8750
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008751static struct hda_input_mux alc262_HP_capture_source = {
8752 .num_items = 5,
8753 .items = {
8754 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008755 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008756 { "Line", 0x2 },
8757 { "CD", 0x4 },
8758 { "AUX IN", 0x6 },
8759 },
8760};
8761
zhejiangaccbe492007-08-31 12:36:05 +02008762static struct hda_input_mux alc262_HP_D7000_capture_source = {
8763 .num_items = 4,
8764 .items = {
8765 { "Mic", 0x0 },
8766 { "Front Mic", 0x2 },
8767 { "Line", 0x1 },
8768 { "CD", 0x4 },
8769 },
8770};
8771
Takashi Iwai834be882006-03-01 14:16:17 +01008772/* mute/unmute internal speaker according to the hp jack and mute state */
8773static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8774{
8775 struct alc_spec *spec = codec->spec;
8776 unsigned int mute;
8777
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008778 if (force || !spec->sense_updated) {
Tony Vroon5d9fab22008-03-14 17:09:18 +01008779 unsigned int present_int_hp, present_dock_hp;
Takashi Iwai834be882006-03-01 14:16:17 +01008780 /* need to execute and sync at first */
8781 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Tony Vroon5d9fab22008-03-14 17:09:18 +01008782 present_int_hp = snd_hda_codec_read(codec, 0x14, 0,
8783 AC_VERB_GET_PIN_SENSE, 0);
8784 snd_hda_codec_read(codec, 0x1B, 0, AC_VERB_SET_PIN_SENSE, 0);
8785 present_dock_hp = snd_hda_codec_read(codec, 0x1b, 0,
8786 AC_VERB_GET_PIN_SENSE, 0);
8787 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8788 spec->jack_present |= (present_dock_hp & 0x80000000) != 0;
Takashi Iwai834be882006-03-01 14:16:17 +01008789 spec->sense_updated = 1;
8790 }
8791 if (spec->jack_present) {
8792 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008793 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8794 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008795 } else {
8796 /* unmute internal speaker if necessary */
8797 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008798 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8799 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008800 }
8801}
8802
8803/* unsolicited event for HP jack sensing */
8804static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8805 unsigned int res)
8806{
8807 if ((res >> 26) != ALC_HP_EVENT)
8808 return;
8809 alc262_fujitsu_automute(codec, 1);
8810}
8811
8812/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008813static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8814 .ops = &snd_hda_bind_vol,
8815 .values = {
8816 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8817 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8818 0
8819 },
8820};
Takashi Iwai834be882006-03-01 14:16:17 +01008821
8822/* bind hp and internal speaker mute (with plug check) */
8823static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8824 struct snd_ctl_elem_value *ucontrol)
8825{
8826 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8827 long *valp = ucontrol->value.integer.value;
8828 int change;
8829
Tony Vroon5d9fab22008-03-14 17:09:18 +01008830 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8831 HDA_AMP_MUTE,
8832 valp ? 0 : HDA_AMP_MUTE);
8833 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8834 HDA_AMP_MUTE,
8835 valp ? 0 : HDA_AMP_MUTE);
8836
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008837 if (change)
8838 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008839 return change;
8840}
8841
8842static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008843 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008844 {
8845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8846 .name = "Master Playback Switch",
8847 .info = snd_hda_mixer_amp_switch_info,
8848 .get = snd_hda_mixer_amp_switch_get,
8849 .put = alc262_fujitsu_master_sw_put,
8850 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8851 },
8852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008857 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8859 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008860 { } /* end */
8861};
8862
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008863/* additional init verbs for Benq laptops */
8864static struct hda_verb alc262_EAPD_verbs[] = {
8865 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8866 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8867 {}
8868};
8869
Kailang Yang83c34212007-07-05 11:43:05 +02008870static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8871 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8872 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8873
8874 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8875 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8876 {}
8877};
8878
Tobin Davisf651b502007-10-26 12:40:47 +02008879/* Samsung Q1 Ultra Vista model setup */
8880static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008881 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8882 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02008883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008886 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02008887 { } /* end */
8888};
8889
8890static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008891 /* output mixer */
8892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8895 /* speaker */
8896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8899 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8900 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02008901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8904 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8906 /* internal mic */
8907 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8909 /* ADC, choose mic */
8910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02008920 {}
8921};
8922
Tobin Davisf651b502007-10-26 12:40:47 +02008923/* mute/unmute internal speaker according to the hp jack and mute state */
8924static void alc262_ultra_automute(struct hda_codec *codec)
8925{
8926 struct alc_spec *spec = codec->spec;
8927 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02008928
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008929 mute = 0;
8930 /* auto-mute only when HP is used as HP */
8931 if (!spec->cur_mux[0]) {
8932 unsigned int present;
8933 /* need to execute and sync at first */
8934 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8935 present = snd_hda_codec_read(codec, 0x15, 0,
8936 AC_VERB_GET_PIN_SENSE, 0);
8937 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8938 if (spec->jack_present)
8939 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02008940 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008941 /* mute/unmute internal speaker */
8942 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8943 HDA_AMP_MUTE, mute);
8944 /* mute/unmute HP */
8945 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8946 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02008947}
8948
8949/* unsolicited event for HP jack sensing */
8950static void alc262_ultra_unsol_event(struct hda_codec *codec,
8951 unsigned int res)
8952{
8953 if ((res >> 26) != ALC880_HP_EVENT)
8954 return;
8955 alc262_ultra_automute(codec);
8956}
8957
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008958static struct hda_input_mux alc262_ultra_capture_source = {
8959 .num_items = 2,
8960 .items = {
8961 { "Mic", 0x1 },
8962 { "Headphone", 0x7 },
8963 },
8964};
8965
8966static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
8967 struct snd_ctl_elem_value *ucontrol)
8968{
8969 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8970 struct alc_spec *spec = codec->spec;
8971 int ret;
8972
8973 ret = alc882_mux_enum_put(kcontrol, ucontrol);
8974 if (!ret)
8975 return 0;
8976 /* reprogram the HP pin as mic or HP according to the input source */
8977 snd_hda_codec_write_cache(codec, 0x15, 0,
8978 AC_VERB_SET_PIN_WIDGET_CONTROL,
8979 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
8980 alc262_ultra_automute(codec); /* mute/unmute HP */
8981 return ret;
8982}
8983
8984static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
8985 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
8986 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
8987 {
8988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8989 .name = "Capture Source",
8990 .info = alc882_mux_enum_info,
8991 .get = alc882_mux_enum_get,
8992 .put = alc262_ultra_mux_enum_put,
8993 },
8994 { } /* end */
8995};
8996
Kailang Yangdf694da2005-12-05 19:42:22 +01008997/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008998static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8999 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009000{
9001 hda_nid_t nid;
9002 int err;
9003
9004 spec->multiout.num_dacs = 1; /* only use one dac */
9005 spec->multiout.dac_nids = spec->private_dac_nids;
9006 spec->multiout.dac_nids[0] = 2;
9007
9008 nid = cfg->line_out_pins[0];
9009 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009010 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9011 "Front Playback Volume",
9012 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009014 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009015 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9016 "Front Playback Switch",
9017 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9018 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009019 return err;
9020 }
9021
Takashi Iwai82bc9552006-03-21 11:24:42 +01009022 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009023 if (nid) {
9024 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009025 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9026 "Speaker Playback Volume",
9027 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9028 HDA_OUTPUT));
9029 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009030 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009031 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9032 "Speaker Playback Switch",
9033 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9034 HDA_OUTPUT));
9035 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009036 return err;
9037 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009038 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9039 "Speaker Playback Switch",
9040 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9041 HDA_OUTPUT));
9042 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009043 return err;
9044 }
9045 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009046 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009047 if (nid) {
9048 /* spec->multiout.hp_nid = 2; */
9049 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009050 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9051 "Headphone Playback Volume",
9052 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9053 HDA_OUTPUT));
9054 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009055 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009056 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9057 "Headphone Playback Switch",
9058 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9059 HDA_OUTPUT));
9060 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009061 return err;
9062 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009063 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9064 "Headphone Playback Switch",
9065 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9066 HDA_OUTPUT));
9067 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009068 return err;
9069 }
9070 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009071 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009072}
9073
9074/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009075#define alc262_auto_create_analog_input_ctls \
9076 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009077
9078/*
9079 * generic initialization of ADC, input mixers and output mixers
9080 */
9081static struct hda_verb alc262_volume_init_verbs[] = {
9082 /*
9083 * Unmute ADC0-2 and set the default input to mic-in
9084 */
9085 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9087 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9089 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9091
Takashi Iwaicb53c622007-08-10 17:21:45 +02009092 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009093 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009094 * Note: PASD motherboards uses the Line In 2 as the input for
9095 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009096 */
9097 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009103
9104 /*
9105 * Set up output mixers (0x0c - 0x0f)
9106 */
9107 /* set vol=0 to output mixers */
9108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9111
9112 /* set up input amps for analog loopback */
9113 /* Amp Indices: DAC = 0, mixer = 1 */
9114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9120
9121 /* FIXME: use matrix-type input source selection */
9122 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9123 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9128 /* Input mixer2 */
9129 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9130 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9131 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9133 /* Input mixer3 */
9134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9138
9139 { }
9140};
9141
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009142static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9143 /*
9144 * Unmute ADC0-2 and set the default input to mic-in
9145 */
9146 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9148 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9149 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9150 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9152
Takashi Iwaicb53c622007-08-10 17:21:45 +02009153 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009154 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009155 * Note: PASD motherboards uses the Line In 2 as the input for
9156 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009157 */
9158 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009166
9167 /*
9168 * Set up output mixers (0x0c - 0x0e)
9169 */
9170 /* set vol=0 to output mixers */
9171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9174
9175 /* set up input amps for analog loopback */
9176 /* Amp Indices: DAC = 0, mixer = 1 */
9177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9183
Takashi Iwaice875f02008-01-28 18:17:43 +01009184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9186 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9187
9188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9190
9191 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9193
9194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9195 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9198 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9199
9200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9204 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9205 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9206
9207
9208 /* FIXME: use matrix-type input source selection */
9209 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9210 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9214 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9215 /* Input mixer2 */
9216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9220 /* Input mixer3 */
9221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9225
Takashi Iwaice875f02008-01-28 18:17:43 +01009226 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228 { }
9229};
9230
Kailang Yangcd7509a2007-01-26 18:33:17 +01009231static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9232 /*
9233 * Unmute ADC0-2 and set the default input to mic-in
9234 */
9235 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9237 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9239 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9241
Takashi Iwaicb53c622007-08-10 17:21:45 +02009242 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009243 * mixer widget
9244 * Note: PASD motherboards uses the Line In 2 as the input for front
9245 * panel mic (mic 2)
9246 */
9247 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009256 /*
9257 * Set up output mixers (0x0c - 0x0e)
9258 */
9259 /* set vol=0 to output mixers */
9260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9263
9264 /* set up input amps for analog loopback */
9265 /* Amp Indices: DAC = 0, mixer = 1 */
9266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9272
9273
9274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9276 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9281
9282 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9284
9285 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9286 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9287
9288 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9289 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9292 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9293 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9294
9295 /* FIXME: use matrix-type input source selection */
9296 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9297 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9303 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9305 /* Input mixer2 */
9306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9311 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9313 /* Input mixer3 */
9314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9319 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9321
Takashi Iwaice875f02008-01-28 18:17:43 +01009322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9323
Kailang Yangcd7509a2007-01-26 18:33:17 +01009324 { }
9325};
9326
Takashi Iwaicb53c622007-08-10 17:21:45 +02009327#ifdef CONFIG_SND_HDA_POWER_SAVE
9328#define alc262_loopbacks alc880_loopbacks
9329#endif
9330
Kailang Yangdf694da2005-12-05 19:42:22 +01009331/* pcm configuration: identiacal with ALC880 */
9332#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9333#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9334#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9335#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9336
9337/*
9338 * BIOS auto configuration
9339 */
9340static int alc262_parse_auto_config(struct hda_codec *codec)
9341{
9342 struct alc_spec *spec = codec->spec;
9343 int err;
9344 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009346 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9347 alc262_ignore);
9348 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009349 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009350 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009351 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009352 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9353 if (err < 0)
9354 return err;
9355 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9356 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009357 return err;
9358
9359 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9360
9361 if (spec->autocfg.dig_out_pin)
9362 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9363 if (spec->autocfg.dig_in_pin)
9364 spec->dig_in_nid = ALC262_DIGIN_NID;
9365
9366 if (spec->kctl_alloc)
9367 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9368
9369 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009370 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009371 spec->input_mux = &spec->private_imux;
9372
Takashi Iwai776e1842007-08-29 15:07:11 +02009373 err = alc_auto_add_mic_boost(codec);
9374 if (err < 0)
9375 return err;
9376
Kailang Yangdf694da2005-12-05 19:42:22 +01009377 return 1;
9378}
9379
9380#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9381#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9382#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9383
9384
9385/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009386static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009387{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009388 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009389 alc262_auto_init_multi_out(codec);
9390 alc262_auto_init_hp_out(codec);
9391 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009392 if (spec->unsol_event)
9393 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009394}
9395
9396/*
9397 * configuration and preset
9398 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009399static const char *alc262_models[ALC262_MODEL_LAST] = {
9400 [ALC262_BASIC] = "basic",
9401 [ALC262_HIPPO] = "hippo",
9402 [ALC262_HIPPO_1] = "hippo_1",
9403 [ALC262_FUJITSU] = "fujitsu",
9404 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009405 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009406 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009407 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009408 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009409 [ALC262_BENQ_T31] = "benq-t31",
9410 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009411 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009412 [ALC262_AUTO] = "auto",
9413};
9414
9415static struct snd_pci_quirk alc262_cfg_tbl[] = {
9416 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9417 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009418 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009419 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9420 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009421 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009422 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009423 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009424 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009425 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009426 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009427 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009428 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009429 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009430 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009431 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009432 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009433 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9434 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9435 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009436 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9437 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009438 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009439 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009440 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009441 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9442 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9443 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009444 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009445 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009446 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009447 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009448 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009449 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009450 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 {}
9452};
9453
9454static struct alc_config_preset alc262_presets[] = {
9455 [ALC262_BASIC] = {
9456 .mixers = { alc262_base_mixer },
9457 .init_verbs = { alc262_init_verbs },
9458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9459 .dac_nids = alc262_dac_nids,
9460 .hp_nid = 0x03,
9461 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9462 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009463 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009465 [ALC262_HIPPO] = {
9466 .mixers = { alc262_base_mixer },
9467 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9468 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9469 .dac_nids = alc262_dac_nids,
9470 .hp_nid = 0x03,
9471 .dig_out_nid = ALC262_DIGOUT_NID,
9472 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9473 .channel_mode = alc262_modes,
9474 .input_mux = &alc262_capture_source,
9475 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009476 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009477 },
9478 [ALC262_HIPPO_1] = {
9479 .mixers = { alc262_hippo1_mixer },
9480 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9481 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9482 .dac_nids = alc262_dac_nids,
9483 .hp_nid = 0x02,
9484 .dig_out_nid = ALC262_DIGOUT_NID,
9485 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9486 .channel_mode = alc262_modes,
9487 .input_mux = &alc262_capture_source,
9488 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009489 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009490 },
Takashi Iwai834be882006-03-01 14:16:17 +01009491 [ALC262_FUJITSU] = {
9492 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009493 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9494 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009495 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9496 .dac_nids = alc262_dac_nids,
9497 .hp_nid = 0x03,
9498 .dig_out_nid = ALC262_DIGOUT_NID,
9499 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9500 .channel_mode = alc262_modes,
9501 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009502 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009503 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009504 [ALC262_HP_BPC] = {
9505 .mixers = { alc262_HP_BPC_mixer },
9506 .init_verbs = { alc262_HP_BPC_init_verbs },
9507 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9508 .dac_nids = alc262_dac_nids,
9509 .hp_nid = 0x03,
9510 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9511 .channel_mode = alc262_modes,
9512 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009513 .unsol_event = alc262_hp_bpc_unsol_event,
9514 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009515 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009516 [ALC262_HP_BPC_D7000_WF] = {
9517 .mixers = { alc262_HP_BPC_WildWest_mixer },
9518 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9519 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9520 .dac_nids = alc262_dac_nids,
9521 .hp_nid = 0x03,
9522 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9523 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009524 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009525 .unsol_event = alc262_hp_wildwest_unsol_event,
9526 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009527 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009528 [ALC262_HP_BPC_D7000_WL] = {
9529 .mixers = { alc262_HP_BPC_WildWest_mixer,
9530 alc262_HP_BPC_WildWest_option_mixer },
9531 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9532 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9533 .dac_nids = alc262_dac_nids,
9534 .hp_nid = 0x03,
9535 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9536 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009537 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009538 .unsol_event = alc262_hp_wildwest_unsol_event,
9539 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009540 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009541 [ALC262_HP_TC_T5735] = {
9542 .mixers = { alc262_hp_t5735_mixer },
9543 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9544 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9545 .dac_nids = alc262_dac_nids,
9546 .hp_nid = 0x03,
9547 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9548 .channel_mode = alc262_modes,
9549 .input_mux = &alc262_capture_source,
9550 .unsol_event = alc262_hp_t5735_unsol_event,
9551 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009552 },
9553 [ALC262_HP_RP5700] = {
9554 .mixers = { alc262_hp_rp5700_mixer },
9555 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9557 .dac_nids = alc262_dac_nids,
9558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9559 .channel_mode = alc262_modes,
9560 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009561 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009562 [ALC262_BENQ_ED8] = {
9563 .mixers = { alc262_base_mixer },
9564 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9565 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9566 .dac_nids = alc262_dac_nids,
9567 .hp_nid = 0x03,
9568 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9569 .channel_mode = alc262_modes,
9570 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009571 },
Kailang Yang272a5272007-05-14 11:00:38 +02009572 [ALC262_SONY_ASSAMD] = {
9573 .mixers = { alc262_sony_mixer },
9574 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9575 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9576 .dac_nids = alc262_dac_nids,
9577 .hp_nid = 0x02,
9578 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9579 .channel_mode = alc262_modes,
9580 .input_mux = &alc262_capture_source,
9581 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009582 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009583 },
9584 [ALC262_BENQ_T31] = {
9585 .mixers = { alc262_benq_t31_mixer },
9586 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9588 .dac_nids = alc262_dac_nids,
9589 .hp_nid = 0x03,
9590 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9591 .channel_mode = alc262_modes,
9592 .input_mux = &alc262_capture_source,
9593 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009594 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009595 },
Tobin Davisf651b502007-10-26 12:40:47 +02009596 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009597 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9598 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009599 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9600 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009601 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9602 .channel_mode = alc262_modes,
9603 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009604 .adc_nids = alc262_adc_nids, /* ADC0 */
9605 .capsrc_nids = alc262_capsrc_nids,
9606 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009607 .unsol_event = alc262_ultra_unsol_event,
9608 .init_hook = alc262_ultra_automute,
9609 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009610};
9611
9612static int patch_alc262(struct hda_codec *codec)
9613{
9614 struct alc_spec *spec;
9615 int board_config;
9616 int err;
9617
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009618 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009619 if (spec == NULL)
9620 return -ENOMEM;
9621
9622 codec->spec = spec;
9623#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009624 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9625 * under-run
9626 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009627 {
9628 int tmp;
9629 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9630 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9631 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9632 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9633 }
9634#endif
9635
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009636 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9637 alc262_models,
9638 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009639
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009640 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009641 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9642 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009643 board_config = ALC262_AUTO;
9644 }
9645
9646 if (board_config == ALC262_AUTO) {
9647 /* automatic parse from the BIOS config */
9648 err = alc262_parse_auto_config(codec);
9649 if (err < 0) {
9650 alc_free(codec);
9651 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009652 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009653 printk(KERN_INFO
9654 "hda_codec: Cannot set up configuration "
9655 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009656 board_config = ALC262_BASIC;
9657 }
9658 }
9659
9660 if (board_config != ALC262_AUTO)
9661 setup_preset(spec, &alc262_presets[board_config]);
9662
9663 spec->stream_name_analog = "ALC262 Analog";
9664 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9665 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9666
9667 spec->stream_name_digital = "ALC262 Digital";
9668 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9669 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9670
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009671 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009672 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009673 unsigned int wcap = get_wcaps(codec, 0x07);
9674
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009675 /* get type */
9676 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009677 if (wcap != AC_WID_AUD_IN) {
9678 spec->adc_nids = alc262_adc_nids_alt;
9679 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009680 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009681 spec->mixers[spec->num_mixers] =
9682 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009683 spec->num_mixers++;
9684 } else {
9685 spec->adc_nids = alc262_adc_nids;
9686 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009687 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009688 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9689 spec->num_mixers++;
9690 }
9691 }
9692
Takashi Iwai2134ea42008-01-10 16:53:55 +01009693 spec->vmaster_nid = 0x0c;
9694
Kailang Yangdf694da2005-12-05 19:42:22 +01009695 codec->patch_ops = alc_patch_ops;
9696 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009697 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009698#ifdef CONFIG_SND_HDA_POWER_SAVE
9699 if (!spec->loopback.amplist)
9700 spec->loopback.amplist = alc262_loopbacks;
9701#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009702
Kailang Yangdf694da2005-12-05 19:42:22 +01009703 return 0;
9704}
9705
Kailang Yangdf694da2005-12-05 19:42:22 +01009706/*
Kailang Yanga361d842007-06-05 12:30:55 +02009707 * ALC268 channel source setting (2 channel)
9708 */
9709#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9710#define alc268_modes alc260_modes
9711
9712static hda_nid_t alc268_dac_nids[2] = {
9713 /* front, hp */
9714 0x02, 0x03
9715};
9716
9717static hda_nid_t alc268_adc_nids[2] = {
9718 /* ADC0-1 */
9719 0x08, 0x07
9720};
9721
9722static hda_nid_t alc268_adc_nids_alt[1] = {
9723 /* ADC0 */
9724 0x08
9725};
9726
Takashi Iwaie1406342008-02-11 18:32:32 +01009727static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9728
Kailang Yanga361d842007-06-05 12:30:55 +02009729static struct snd_kcontrol_new alc268_base_mixer[] = {
9730 /* output mixer control */
9731 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9732 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9734 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009735 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9736 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9737 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009738 { }
9739};
9740
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009741/* bind Beep switches of both NID 0x0f and 0x10 */
9742static struct hda_bind_ctls alc268_bind_beep_sw = {
9743 .ops = &snd_hda_bind_sw,
9744 .values = {
9745 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9746 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
9747 0
9748 },
9749};
9750
9751static struct snd_kcontrol_new alc268_beep_mixer[] = {
9752 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
9753 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
9754 { }
9755};
9756
Kailang Yangd1a991a2007-08-15 16:21:59 +02009757static struct hda_verb alc268_eapd_verbs[] = {
9758 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9759 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9760 { }
9761};
9762
Takashi Iwaid2738092007-08-16 14:59:45 +02009763/* Toshiba specific */
9764#define alc268_toshiba_automute alc262_hippo_automute
9765
9766static struct hda_verb alc268_toshiba_verbs[] = {
9767 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9768 { } /* end */
9769};
9770
9771/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009772/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009773static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9774 .ops = &snd_hda_bind_vol,
9775 .values = {
9776 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9777 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9778 0
9779 },
9780};
9781
Takashi Iwai889c4392007-08-23 18:56:52 +02009782/* mute/unmute internal speaker according to the hp jack and mute state */
9783static void alc268_acer_automute(struct hda_codec *codec, int force)
9784{
9785 struct alc_spec *spec = codec->spec;
9786 unsigned int mute;
9787
9788 if (force || !spec->sense_updated) {
9789 unsigned int present;
9790 present = snd_hda_codec_read(codec, 0x14, 0,
9791 AC_VERB_GET_PIN_SENSE, 0);
9792 spec->jack_present = (present & 0x80000000) != 0;
9793 spec->sense_updated = 1;
9794 }
9795 if (spec->jack_present)
9796 mute = HDA_AMP_MUTE; /* mute internal speaker */
9797 else /* unmute internal speaker if necessary */
9798 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9799 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9800 HDA_AMP_MUTE, mute);
9801}
9802
9803
9804/* bind hp and internal speaker mute (with plug check) */
9805static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9806 struct snd_ctl_elem_value *ucontrol)
9807{
9808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9809 long *valp = ucontrol->value.integer.value;
9810 int change;
9811
9812 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9813 HDA_AMP_MUTE,
9814 valp[0] ? 0 : HDA_AMP_MUTE);
9815 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9816 HDA_AMP_MUTE,
9817 valp[1] ? 0 : HDA_AMP_MUTE);
9818 if (change)
9819 alc268_acer_automute(codec, 0);
9820 return change;
9821}
Takashi Iwaid2738092007-08-16 14:59:45 +02009822
9823static struct snd_kcontrol_new alc268_acer_mixer[] = {
9824 /* output mixer control */
9825 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9826 {
9827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9828 .name = "Master Playback Switch",
9829 .info = snd_hda_mixer_amp_switch_info,
9830 .get = snd_hda_mixer_amp_switch_get,
9831 .put = alc268_acer_master_sw_put,
9832 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9833 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9835 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9836 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009837 { }
9838};
9839
9840static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +01009841 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
9842 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +02009843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +01009845 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +02009847
9848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9849 { }
9850};
9851
9852/* unsolicited event for HP jack sensing */
9853static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9854 unsigned int res)
9855{
Takashi Iwai889c4392007-08-23 18:56:52 +02009856 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009857 return;
9858 alc268_toshiba_automute(codec);
9859}
9860
9861static void alc268_acer_unsol_event(struct hda_codec *codec,
9862 unsigned int res)
9863{
Takashi Iwai889c4392007-08-23 18:56:52 +02009864 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009865 return;
9866 alc268_acer_automute(codec, 1);
9867}
9868
Takashi Iwai889c4392007-08-23 18:56:52 +02009869static void alc268_acer_init_hook(struct hda_codec *codec)
9870{
9871 alc268_acer_automute(codec, 1);
9872}
9873
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009874static struct snd_kcontrol_new alc268_dell_mixer[] = {
9875 /* output mixer control */
9876 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9877 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9878 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9881 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9882 { }
9883};
9884
9885static struct hda_verb alc268_dell_verbs[] = {
9886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9888 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9889 { }
9890};
9891
9892/* mute/unmute internal speaker according to the hp jack and mute state */
9893static void alc268_dell_automute(struct hda_codec *codec)
9894{
9895 unsigned int present;
9896 unsigned int mute;
9897
9898 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9899 if (present & 0x80000000)
9900 mute = HDA_AMP_MUTE;
9901 else
9902 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9903 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9904 HDA_AMP_MUTE, mute);
9905}
9906
9907static void alc268_dell_unsol_event(struct hda_codec *codec,
9908 unsigned int res)
9909{
9910 if ((res >> 26) != ALC880_HP_EVENT)
9911 return;
9912 alc268_dell_automute(codec);
9913}
9914
9915#define alc268_dell_init_hook alc268_dell_automute
9916
Kailang Yanga361d842007-06-05 12:30:55 +02009917/*
9918 * generic initialization of ADC, input mixers and output mixers
9919 */
9920static struct hda_verb alc268_base_init_verbs[] = {
9921 /* Unmute DAC0-1 and set vol = 0 */
9922 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9923 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9925 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9926 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9927 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9928
9929 /*
9930 * Set up output mixers (0x0c - 0x0e)
9931 */
9932 /* set vol=0 to output mixers */
9933 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9934 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9936 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9937
9938 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9939 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9940
9941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9943 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9948 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9949
9950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9952 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9955 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9956 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009957
9958 /* set PCBEEP vol = 0, mute connections */
9959 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9960 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9961 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +02009962
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009963 /* Unmute Selector 23h,24h and set the default input to mic-in */
9964
9965 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9967 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009969
Kailang Yanga361d842007-06-05 12:30:55 +02009970 { }
9971};
9972
9973/*
9974 * generic initialization of ADC, input mixers and output mixers
9975 */
9976static struct hda_verb alc268_volume_init_verbs[] = {
9977 /* set output DAC */
9978 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9979 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9980 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9981 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9982
9983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9986 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9987 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9988
9989 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9990 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9992 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9993 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9994
9995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9996 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9998 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9999
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010000 /* set PCBEEP vol = 0, mute connections */
10001 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10003 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010004
10005 { }
10006};
10007
10008#define alc268_mux_enum_info alc_mux_enum_info
10009#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010010#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010011
10012static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10013 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10014 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10015 {
10016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10017 /* The multiple "Capture Source" controls confuse alsamixer
10018 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010019 */
10020 /* .name = "Capture Source", */
10021 .name = "Input Source",
10022 .count = 1,
10023 .info = alc268_mux_enum_info,
10024 .get = alc268_mux_enum_get,
10025 .put = alc268_mux_enum_put,
10026 },
10027 { } /* end */
10028};
10029
10030static struct snd_kcontrol_new alc268_capture_mixer[] = {
10031 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10032 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10033 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10034 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10035 {
10036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10037 /* The multiple "Capture Source" controls confuse alsamixer
10038 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010039 */
10040 /* .name = "Capture Source", */
10041 .name = "Input Source",
10042 .count = 2,
10043 .info = alc268_mux_enum_info,
10044 .get = alc268_mux_enum_get,
10045 .put = alc268_mux_enum_put,
10046 },
10047 { } /* end */
10048};
10049
10050static struct hda_input_mux alc268_capture_source = {
10051 .num_items = 4,
10052 .items = {
10053 { "Mic", 0x0 },
10054 { "Front Mic", 0x1 },
10055 { "Line", 0x2 },
10056 { "CD", 0x3 },
10057 },
10058};
10059
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010060static struct hda_input_mux alc268_acer_capture_source = {
10061 .num_items = 3,
10062 .items = {
10063 { "Mic", 0x0 },
10064 { "Internal Mic", 0x6 },
10065 { "Line", 0x2 },
10066 },
10067};
10068
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010069#ifdef CONFIG_SND_DEBUG
10070static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010071 /* Volume widgets */
10072 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10073 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10074 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10075 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10076 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10077 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10078 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10079 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10080 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10081 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10082 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10083 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10084 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010085 /* The below appears problematic on some hardwares */
10086 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010087 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10088 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10089 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10090 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10091
10092 /* Modes for retasking pin widgets */
10093 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10094 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10095 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10096 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10097
10098 /* Controls for GPIO pins, assuming they are configured as outputs */
10099 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10100 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10101 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10102 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10103
10104 /* Switches to allow the digital SPDIF output pin to be enabled.
10105 * The ALC268 does not have an SPDIF input.
10106 */
10107 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10108
10109 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10110 * this output to turn on an external amplifier.
10111 */
10112 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10113 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10114
10115 { } /* end */
10116};
10117#endif
10118
Kailang Yanga361d842007-06-05 12:30:55 +020010119/* create input playback/capture controls for the given pin */
10120static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10121 const char *ctlname, int idx)
10122{
10123 char name[32];
10124 int err;
10125
10126 sprintf(name, "%s Playback Volume", ctlname);
10127 if (nid == 0x14) {
10128 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10129 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10130 HDA_OUTPUT));
10131 if (err < 0)
10132 return err;
10133 } else if (nid == 0x15) {
10134 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10135 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10136 HDA_OUTPUT));
10137 if (err < 0)
10138 return err;
10139 } else
10140 return -1;
10141 sprintf(name, "%s Playback Switch", ctlname);
10142 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10143 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10144 if (err < 0)
10145 return err;
10146 return 0;
10147}
10148
10149/* add playback controls from the parsed DAC table */
10150static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10151 const struct auto_pin_cfg *cfg)
10152{
10153 hda_nid_t nid;
10154 int err;
10155
10156 spec->multiout.num_dacs = 2; /* only use one dac */
10157 spec->multiout.dac_nids = spec->private_dac_nids;
10158 spec->multiout.dac_nids[0] = 2;
10159 spec->multiout.dac_nids[1] = 3;
10160
10161 nid = cfg->line_out_pins[0];
10162 if (nid)
10163 alc268_new_analog_output(spec, nid, "Front", 0);
10164
10165 nid = cfg->speaker_pins[0];
10166 if (nid == 0x1d) {
10167 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10168 "Speaker Playback Volume",
10169 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10170 if (err < 0)
10171 return err;
10172 }
10173 nid = cfg->hp_pins[0];
10174 if (nid)
10175 alc268_new_analog_output(spec, nid, "Headphone", 0);
10176
10177 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10178 if (nid == 0x16) {
10179 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10180 "Mono Playback Switch",
10181 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10182 if (err < 0)
10183 return err;
10184 }
10185 return 0;
10186}
10187
10188/* create playback/capture controls for input pins */
10189static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10190 const struct auto_pin_cfg *cfg)
10191{
10192 struct hda_input_mux *imux = &spec->private_imux;
10193 int i, idx1;
10194
10195 for (i = 0; i < AUTO_PIN_LAST; i++) {
10196 switch(cfg->input_pins[i]) {
10197 case 0x18:
10198 idx1 = 0; /* Mic 1 */
10199 break;
10200 case 0x19:
10201 idx1 = 1; /* Mic 2 */
10202 break;
10203 case 0x1a:
10204 idx1 = 2; /* Line In */
10205 break;
10206 case 0x1c:
10207 idx1 = 3; /* CD */
10208 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010209 case 0x12:
10210 case 0x13:
10211 idx1 = 6; /* digital mics */
10212 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010213 default:
10214 continue;
10215 }
10216 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10217 imux->items[imux->num_items].index = idx1;
10218 imux->num_items++;
10219 }
10220 return 0;
10221}
10222
10223static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10224{
10225 struct alc_spec *spec = codec->spec;
10226 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10227 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10228 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10229 unsigned int dac_vol1, dac_vol2;
10230
10231 if (speaker_nid) {
10232 snd_hda_codec_write(codec, speaker_nid, 0,
10233 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10234 snd_hda_codec_write(codec, 0x0f, 0,
10235 AC_VERB_SET_AMP_GAIN_MUTE,
10236 AMP_IN_UNMUTE(1));
10237 snd_hda_codec_write(codec, 0x10, 0,
10238 AC_VERB_SET_AMP_GAIN_MUTE,
10239 AMP_IN_UNMUTE(1));
10240 } else {
10241 snd_hda_codec_write(codec, 0x0f, 0,
10242 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10243 snd_hda_codec_write(codec, 0x10, 0,
10244 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10245 }
10246
10247 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10248 if (line_nid == 0x14)
10249 dac_vol2 = AMP_OUT_ZERO;
10250 else if (line_nid == 0x15)
10251 dac_vol1 = AMP_OUT_ZERO;
10252 if (hp_nid == 0x14)
10253 dac_vol2 = AMP_OUT_ZERO;
10254 else if (hp_nid == 0x15)
10255 dac_vol1 = AMP_OUT_ZERO;
10256 if (line_nid != 0x16 || hp_nid != 0x16 ||
10257 spec->autocfg.line_out_pins[1] != 0x16 ||
10258 spec->autocfg.line_out_pins[2] != 0x16)
10259 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10260
10261 snd_hda_codec_write(codec, 0x02, 0,
10262 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10263 snd_hda_codec_write(codec, 0x03, 0,
10264 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10265}
10266
10267/* pcm configuration: identiacal with ALC880 */
10268#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10269#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010270#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010271#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10272
10273/*
10274 * BIOS auto configuration
10275 */
10276static int alc268_parse_auto_config(struct hda_codec *codec)
10277{
10278 struct alc_spec *spec = codec->spec;
10279 int err;
10280 static hda_nid_t alc268_ignore[] = { 0 };
10281
10282 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10283 alc268_ignore);
10284 if (err < 0)
10285 return err;
10286 if (!spec->autocfg.line_outs)
10287 return 0; /* can't find valid BIOS pin config */
10288
10289 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10290 if (err < 0)
10291 return err;
10292 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10293 if (err < 0)
10294 return err;
10295
10296 spec->multiout.max_channels = 2;
10297
10298 /* digital only support output */
10299 if (spec->autocfg.dig_out_pin)
10300 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10301
10302 if (spec->kctl_alloc)
10303 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10304
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010305 if (spec->autocfg.speaker_pins[0] != 0x1d)
10306 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10307
Kailang Yanga361d842007-06-05 12:30:55 +020010308 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10309 spec->num_mux_defs = 1;
10310 spec->input_mux = &spec->private_imux;
10311
Takashi Iwai776e1842007-08-29 15:07:11 +020010312 err = alc_auto_add_mic_boost(codec);
10313 if (err < 0)
10314 return err;
10315
Kailang Yanga361d842007-06-05 12:30:55 +020010316 return 1;
10317}
10318
10319#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10320#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10321#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10322
10323/* init callback for auto-configuration model -- overriding the default init */
10324static void alc268_auto_init(struct hda_codec *codec)
10325{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010326 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010327 alc268_auto_init_multi_out(codec);
10328 alc268_auto_init_hp_out(codec);
10329 alc268_auto_init_mono_speaker_out(codec);
10330 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010331 if (spec->unsol_event)
10332 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010333}
10334
10335/*
10336 * configuration and preset
10337 */
10338static const char *alc268_models[ALC268_MODEL_LAST] = {
10339 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010340 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010341 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010342 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010343 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010344#ifdef CONFIG_SND_DEBUG
10345 [ALC268_TEST] = "test",
10346#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010347 [ALC268_AUTO] = "auto",
10348};
10349
10350static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010351 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010352 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010353 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010354 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010355 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010356 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010357 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010358 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010359 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010360 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010361 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010362 {}
10363};
10364
10365static struct alc_config_preset alc268_presets[] = {
10366 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010367 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10368 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010369 .init_verbs = { alc268_base_init_verbs },
10370 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10371 .dac_nids = alc268_dac_nids,
10372 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10373 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010374 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010375 .hp_nid = 0x03,
10376 .dig_out_nid = ALC268_DIGOUT_NID,
10377 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10378 .channel_mode = alc268_modes,
10379 .input_mux = &alc268_capture_source,
10380 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010381 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010382 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10383 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010384 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10385 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010386 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10387 .dac_nids = alc268_dac_nids,
10388 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10389 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010390 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010391 .hp_nid = 0x03,
10392 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10393 .channel_mode = alc268_modes,
10394 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010395 .unsol_event = alc268_toshiba_unsol_event,
10396 .init_hook = alc268_toshiba_automute,
10397 },
10398 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010399 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10400 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010401 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10402 alc268_acer_verbs },
10403 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10404 .dac_nids = alc268_dac_nids,
10405 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10406 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010407 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010408 .hp_nid = 0x02,
10409 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10410 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010411 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010412 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010413 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010414 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010415 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010416 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010417 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10418 alc268_dell_verbs },
10419 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10420 .dac_nids = alc268_dac_nids,
10421 .hp_nid = 0x02,
10422 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10423 .channel_mode = alc268_modes,
10424 .unsol_event = alc268_dell_unsol_event,
10425 .init_hook = alc268_dell_init_hook,
10426 .input_mux = &alc268_capture_source,
10427 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010428 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010429 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10430 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010431 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10432 alc268_toshiba_verbs },
10433 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10434 .dac_nids = alc268_dac_nids,
10435 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10436 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010437 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010438 .hp_nid = 0x03,
10439 .dig_out_nid = ALC268_DIGOUT_NID,
10440 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10441 .channel_mode = alc268_modes,
10442 .input_mux = &alc268_capture_source,
10443 .unsol_event = alc268_toshiba_unsol_event,
10444 .init_hook = alc268_toshiba_automute
10445 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010446#ifdef CONFIG_SND_DEBUG
10447 [ALC268_TEST] = {
10448 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10449 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10450 alc268_volume_init_verbs },
10451 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10452 .dac_nids = alc268_dac_nids,
10453 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10454 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010455 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010456 .hp_nid = 0x03,
10457 .dig_out_nid = ALC268_DIGOUT_NID,
10458 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10459 .channel_mode = alc268_modes,
10460 .input_mux = &alc268_capture_source,
10461 },
10462#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010463};
10464
10465static int patch_alc268(struct hda_codec *codec)
10466{
10467 struct alc_spec *spec;
10468 int board_config;
10469 int err;
10470
10471 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10472 if (spec == NULL)
10473 return -ENOMEM;
10474
10475 codec->spec = spec;
10476
10477 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10478 alc268_models,
10479 alc268_cfg_tbl);
10480
10481 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10482 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10483 "trying auto-probe from BIOS...\n");
10484 board_config = ALC268_AUTO;
10485 }
10486
10487 if (board_config == ALC268_AUTO) {
10488 /* automatic parse from the BIOS config */
10489 err = alc268_parse_auto_config(codec);
10490 if (err < 0) {
10491 alc_free(codec);
10492 return err;
10493 } else if (!err) {
10494 printk(KERN_INFO
10495 "hda_codec: Cannot set up configuration "
10496 "from BIOS. Using base mode...\n");
10497 board_config = ALC268_3ST;
10498 }
10499 }
10500
10501 if (board_config != ALC268_AUTO)
10502 setup_preset(spec, &alc268_presets[board_config]);
10503
10504 spec->stream_name_analog = "ALC268 Analog";
10505 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10506 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010507 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010508
10509 spec->stream_name_digital = "ALC268 Digital";
10510 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10511
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010512 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10513 /* override the amp caps for beep generator */
10514 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10515 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10516 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10517 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10518 (0 << AC_AMPCAP_MUTE_SHIFT));
10519
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010520 if (!spec->adc_nids && spec->input_mux) {
10521 /* check whether NID 0x07 is valid */
10522 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010523 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010524
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010525 /* get type */
10526 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010527 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010528 spec->adc_nids = alc268_adc_nids_alt;
10529 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10530 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010531 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010532 spec->num_mixers++;
10533 } else {
10534 spec->adc_nids = alc268_adc_nids;
10535 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10536 spec->mixers[spec->num_mixers] =
10537 alc268_capture_mixer;
10538 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010539 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010540 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010541 /* set default input source */
10542 for (i = 0; i < spec->num_adc_nids; i++)
10543 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10544 0, AC_VERB_SET_CONNECT_SEL,
10545 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010546 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010547
10548 spec->vmaster_nid = 0x02;
10549
Kailang Yanga361d842007-06-05 12:30:55 +020010550 codec->patch_ops = alc_patch_ops;
10551 if (board_config == ALC268_AUTO)
10552 spec->init_hook = alc268_auto_init;
10553
10554 return 0;
10555}
10556
10557/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010558 * ALC269 channel source setting (2 channel)
10559 */
10560#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10561
10562#define alc269_dac_nids alc260_dac_nids
10563
10564static hda_nid_t alc269_adc_nids[1] = {
10565 /* ADC1 */
10566 0x07,
10567};
10568
10569#define alc269_modes alc260_modes
10570#define alc269_capture_source alc880_lg_lw_capture_source
10571
10572static struct snd_kcontrol_new alc269_base_mixer[] = {
10573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10574 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10579 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10582 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10584 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10585 { } /* end */
10586};
10587
10588/* capture mixer elements */
10589static struct snd_kcontrol_new alc269_capture_mixer[] = {
10590 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10591 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10592 {
10593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10594 /* The multiple "Capture Source" controls confuse alsamixer
10595 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010596 */
10597 /* .name = "Capture Source", */
10598 .name = "Input Source",
10599 .count = 1,
10600 .info = alc_mux_enum_info,
10601 .get = alc_mux_enum_get,
10602 .put = alc_mux_enum_put,
10603 },
10604 { } /* end */
10605};
10606
10607/*
10608 * generic initialization of ADC, input mixers and output mixers
10609 */
10610static struct hda_verb alc269_init_verbs[] = {
10611 /*
10612 * Unmute ADC0 and set the default input to mic-in
10613 */
10614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10615
10616 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10617 * analog-loopback mixer widget
10618 * Note: PASD motherboards uses the Line In 2 as the input for
10619 * front panel mic (mic 2)
10620 */
10621 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10627
10628 /*
10629 * Set up output mixers (0x0c - 0x0e)
10630 */
10631 /* set vol=0 to output mixers */
10632 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10634
10635 /* set up input amps for analog loopback */
10636 /* Amp Indices: DAC = 0, mixer = 1 */
10637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10643
10644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10647 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10648 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10649 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10651
10652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10659
10660 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10662
10663 /* FIXME: use matrix-type input source selection */
10664 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10665 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10670
10671 /* set EAPD */
10672 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10673 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10674 { }
10675};
10676
10677/* add playback controls from the parsed DAC table */
10678static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10679 const struct auto_pin_cfg *cfg)
10680{
10681 hda_nid_t nid;
10682 int err;
10683
10684 spec->multiout.num_dacs = 1; /* only use one dac */
10685 spec->multiout.dac_nids = spec->private_dac_nids;
10686 spec->multiout.dac_nids[0] = 2;
10687
10688 nid = cfg->line_out_pins[0];
10689 if (nid) {
10690 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10691 "Front Playback Volume",
10692 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10693 if (err < 0)
10694 return err;
10695 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10696 "Front Playback Switch",
10697 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10698 if (err < 0)
10699 return err;
10700 }
10701
10702 nid = cfg->speaker_pins[0];
10703 if (nid) {
10704 if (!cfg->line_out_pins[0]) {
10705 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10706 "Speaker Playback Volume",
10707 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10708 HDA_OUTPUT));
10709 if (err < 0)
10710 return err;
10711 }
10712 if (nid == 0x16) {
10713 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10714 "Speaker Playback Switch",
10715 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10716 HDA_OUTPUT));
10717 if (err < 0)
10718 return err;
10719 } else {
10720 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10721 "Speaker Playback Switch",
10722 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10723 HDA_OUTPUT));
10724 if (err < 0)
10725 return err;
10726 }
10727 }
10728 nid = cfg->hp_pins[0];
10729 if (nid) {
10730 /* spec->multiout.hp_nid = 2; */
10731 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10732 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10733 "Headphone Playback Volume",
10734 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10735 HDA_OUTPUT));
10736 if (err < 0)
10737 return err;
10738 }
10739 if (nid == 0x16) {
10740 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10741 "Headphone Playback Switch",
10742 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10743 HDA_OUTPUT));
10744 if (err < 0)
10745 return err;
10746 } else {
10747 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10748 "Headphone Playback Switch",
10749 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10750 HDA_OUTPUT));
10751 if (err < 0)
10752 return err;
10753 }
10754 }
10755 return 0;
10756}
10757
10758#define alc269_auto_create_analog_input_ctls \
10759 alc880_auto_create_analog_input_ctls
10760
10761#ifdef CONFIG_SND_HDA_POWER_SAVE
10762#define alc269_loopbacks alc880_loopbacks
10763#endif
10764
10765/* pcm configuration: identiacal with ALC880 */
10766#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10767#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10768#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10769#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10770
10771/*
10772 * BIOS auto configuration
10773 */
10774static int alc269_parse_auto_config(struct hda_codec *codec)
10775{
10776 struct alc_spec *spec = codec->spec;
10777 int err;
10778 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10779
10780 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10781 alc269_ignore);
10782 if (err < 0)
10783 return err;
10784
10785 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10786 if (err < 0)
10787 return err;
10788 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10789 if (err < 0)
10790 return err;
10791
10792 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10793
10794 if (spec->autocfg.dig_out_pin)
10795 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10796
10797 if (spec->kctl_alloc)
10798 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10799
10800 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10801 spec->num_mux_defs = 1;
10802 spec->input_mux = &spec->private_imux;
10803
10804 err = alc_auto_add_mic_boost(codec);
10805 if (err < 0)
10806 return err;
10807
10808 return 1;
10809}
10810
10811#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10812#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10813#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10814
10815
10816/* init callback for auto-configuration model -- overriding the default init */
10817static void alc269_auto_init(struct hda_codec *codec)
10818{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010819 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010010820 alc269_auto_init_multi_out(codec);
10821 alc269_auto_init_hp_out(codec);
10822 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010823 if (spec->unsol_event)
10824 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010010825}
10826
10827/*
10828 * configuration and preset
10829 */
10830static const char *alc269_models[ALC269_MODEL_LAST] = {
10831 [ALC269_BASIC] = "basic",
10832};
10833
10834static struct snd_pci_quirk alc269_cfg_tbl[] = {
10835 {}
10836};
10837
10838static struct alc_config_preset alc269_presets[] = {
10839 [ALC269_BASIC] = {
10840 .mixers = { alc269_base_mixer },
10841 .init_verbs = { alc269_init_verbs },
10842 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10843 .dac_nids = alc269_dac_nids,
10844 .hp_nid = 0x03,
10845 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10846 .channel_mode = alc269_modes,
10847 .input_mux = &alc269_capture_source,
10848 },
10849};
10850
10851static int patch_alc269(struct hda_codec *codec)
10852{
10853 struct alc_spec *spec;
10854 int board_config;
10855 int err;
10856
10857 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10858 if (spec == NULL)
10859 return -ENOMEM;
10860
10861 codec->spec = spec;
10862
10863 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10864 alc269_models,
10865 alc269_cfg_tbl);
10866
10867 if (board_config < 0) {
10868 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10869 "trying auto-probe from BIOS...\n");
10870 board_config = ALC269_AUTO;
10871 }
10872
10873 if (board_config == ALC269_AUTO) {
10874 /* automatic parse from the BIOS config */
10875 err = alc269_parse_auto_config(codec);
10876 if (err < 0) {
10877 alc_free(codec);
10878 return err;
10879 } else if (!err) {
10880 printk(KERN_INFO
10881 "hda_codec: Cannot set up configuration "
10882 "from BIOS. Using base mode...\n");
10883 board_config = ALC269_BASIC;
10884 }
10885 }
10886
10887 if (board_config != ALC269_AUTO)
10888 setup_preset(spec, &alc269_presets[board_config]);
10889
10890 spec->stream_name_analog = "ALC269 Analog";
10891 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10892 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10893
10894 spec->stream_name_digital = "ALC269 Digital";
10895 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10896 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10897
10898 spec->adc_nids = alc269_adc_nids;
10899 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10900 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10901 spec->num_mixers++;
10902
10903 codec->patch_ops = alc_patch_ops;
10904 if (board_config == ALC269_AUTO)
10905 spec->init_hook = alc269_auto_init;
10906#ifdef CONFIG_SND_HDA_POWER_SAVE
10907 if (!spec->loopback.amplist)
10908 spec->loopback.amplist = alc269_loopbacks;
10909#endif
10910
10911 return 0;
10912}
10913
10914/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010915 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10916 */
10917
10918/*
10919 * set the path ways for 2 channel output
10920 * need to set the codec line out and mic 1 pin widgets to inputs
10921 */
10922static struct hda_verb alc861_threestack_ch2_init[] = {
10923 /* set pin widget 1Ah (line in) for input */
10924 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010925 /* set pin widget 18h (mic1/2) for input, for mic also enable
10926 * the vref
10927 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010928 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10929
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010930 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10931#if 0
10932 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10934#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 { } /* end */
10936};
10937/*
10938 * 6ch mode
10939 * need to set the codec line out and mic 1 pin widgets to outputs
10940 */
10941static struct hda_verb alc861_threestack_ch6_init[] = {
10942 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10943 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10944 /* set pin widget 18h (mic1) for output (CLFE)*/
10945 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10946
10947 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010948 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010949
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010950 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10951#if 0
10952 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10953 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10954#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010955 { } /* end */
10956};
10957
10958static struct hda_channel_mode alc861_threestack_modes[2] = {
10959 { 2, alc861_threestack_ch2_init },
10960 { 6, alc861_threestack_ch6_init },
10961};
Takashi Iwai22309c32006-08-09 16:57:28 +020010962/* Set mic1 as input and unmute the mixer */
10963static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10964 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10965 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10966 { } /* end */
10967};
10968/* Set mic1 as output and mute mixer */
10969static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10970 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10971 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10972 { } /* end */
10973};
10974
10975static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10976 { 2, alc861_uniwill_m31_ch2_init },
10977 { 4, alc861_uniwill_m31_ch4_init },
10978};
Kailang Yangdf694da2005-12-05 19:42:22 +010010979
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010980/* Set mic1 and line-in as input and unmute the mixer */
10981static struct hda_verb alc861_asus_ch2_init[] = {
10982 /* set pin widget 1Ah (line in) for input */
10983 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 /* set pin widget 18h (mic1/2) for input, for mic also enable
10985 * the vref
10986 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010987 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10988
10989 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10990#if 0
10991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10992 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10993#endif
10994 { } /* end */
10995};
10996/* Set mic1 nad line-in as output and mute mixer */
10997static struct hda_verb alc861_asus_ch6_init[] = {
10998 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10999 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11000 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11001 /* set pin widget 18h (mic1) for output (CLFE)*/
11002 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11003 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11004 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11005 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11006
11007 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11008#if 0
11009 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11010 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11011#endif
11012 { } /* end */
11013};
11014
11015static struct hda_channel_mode alc861_asus_modes[2] = {
11016 { 2, alc861_asus_ch2_init },
11017 { 6, alc861_asus_ch6_init },
11018};
11019
Kailang Yangdf694da2005-12-05 19:42:22 +010011020/* patch-ALC861 */
11021
11022static struct snd_kcontrol_new alc861_base_mixer[] = {
11023 /* output mixer control */
11024 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11025 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11026 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11027 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11028 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11029
11030 /*Input mixer control */
11031 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11032 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11033 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11034 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11035 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11036 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11038 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11039 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011041
Kailang Yangdf694da2005-12-05 19:42:22 +010011042 /* Capture mixer control */
11043 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11044 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11045 {
11046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11047 .name = "Capture Source",
11048 .count = 1,
11049 .info = alc_mux_enum_info,
11050 .get = alc_mux_enum_get,
11051 .put = alc_mux_enum_put,
11052 },
11053 { } /* end */
11054};
11055
11056static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11057 /* output mixer control */
11058 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11059 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11060 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11061 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11062 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11063
11064 /* Input mixer control */
11065 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11066 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11067 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11068 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11069 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11070 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11072 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11073 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11074 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011075
Kailang Yangdf694da2005-12-05 19:42:22 +010011076 /* Capture mixer control */
11077 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11078 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11079 {
11080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11081 .name = "Capture Source",
11082 .count = 1,
11083 .info = alc_mux_enum_info,
11084 .get = alc_mux_enum_get,
11085 .put = alc_mux_enum_put,
11086 },
11087 {
11088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11089 .name = "Channel Mode",
11090 .info = alc_ch_mode_info,
11091 .get = alc_ch_mode_get,
11092 .put = alc_ch_mode_put,
11093 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11094 },
11095 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011096};
11097
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011098static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011099 /* output mixer control */
11100 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11102 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11103
11104 /*Capture mixer control */
11105 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11106 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11107 {
11108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11109 .name = "Capture Source",
11110 .count = 1,
11111 .info = alc_mux_enum_info,
11112 .get = alc_mux_enum_get,
11113 .put = alc_mux_enum_put,
11114 },
11115
11116 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011117};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011118
Takashi Iwai22309c32006-08-09 16:57:28 +020011119static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11120 /* output mixer control */
11121 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11122 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11123 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11124 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11125 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11126
11127 /* Input mixer control */
11128 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11129 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11130 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11131 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11132 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11133 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11135 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11136 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011138
Takashi Iwai22309c32006-08-09 16:57:28 +020011139 /* Capture mixer control */
11140 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11141 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11142 {
11143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11144 .name = "Capture Source",
11145 .count = 1,
11146 .info = alc_mux_enum_info,
11147 .get = alc_mux_enum_get,
11148 .put = alc_mux_enum_put,
11149 },
11150 {
11151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11152 .name = "Channel Mode",
11153 .info = alc_ch_mode_info,
11154 .get = alc_ch_mode_get,
11155 .put = alc_ch_mode_put,
11156 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11157 },
11158 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011159};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011160
11161static struct snd_kcontrol_new alc861_asus_mixer[] = {
11162 /* output mixer control */
11163 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11164 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11165 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11166 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11167 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11168
11169 /* Input mixer control */
11170 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11171 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11172 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11173 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11174 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11175 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11177 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11178 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11180
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011181 /* Capture mixer control */
11182 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11183 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11184 {
11185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11186 .name = "Capture Source",
11187 .count = 1,
11188 .info = alc_mux_enum_info,
11189 .get = alc_mux_enum_get,
11190 .put = alc_mux_enum_put,
11191 },
11192 {
11193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11194 .name = "Channel Mode",
11195 .info = alc_ch_mode_info,
11196 .get = alc_ch_mode_get,
11197 .put = alc_ch_mode_put,
11198 .private_value = ARRAY_SIZE(alc861_asus_modes),
11199 },
11200 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011201};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011202
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011203/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011204static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011205 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11206 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11207 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11208 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11209 { }
11210};
11211
Kailang Yangdf694da2005-12-05 19:42:22 +010011212/*
11213 * generic initialization of ADC, input mixers and output mixers
11214 */
11215static struct hda_verb alc861_base_init_verbs[] = {
11216 /*
11217 * Unmute ADC0 and set the default input to mic-in
11218 */
11219 /* port-A for surround (rear panel) */
11220 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11221 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11222 /* port-B for mic-in (rear panel) with vref */
11223 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11224 /* port-C for line-in (rear panel) */
11225 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11226 /* port-D for Front */
11227 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11228 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11229 /* port-E for HP out (front panel) */
11230 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11231 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011232 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011233 /* port-F for mic-in (front panel) with vref */
11234 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11235 /* port-G for CLFE (rear panel) */
11236 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11237 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11238 /* port-H for side (rear panel) */
11239 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11240 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11241 /* CD-in */
11242 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11243 /* route front mic to ADC1*/
11244 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11246
11247 /* Unmute DAC0~3 & spdif out*/
11248 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11249 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11250 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11251 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11253
11254 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11255 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11256 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11257 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11258 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11259
11260 /* Unmute Stereo Mixer 15 */
11261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011265
11266 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11267 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11268 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11269 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11271 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11273 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011274 /* hp used DAC 3 (Front) */
11275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11277
11278 { }
11279};
11280
11281static struct hda_verb alc861_threestack_init_verbs[] = {
11282 /*
11283 * Unmute ADC0 and set the default input to mic-in
11284 */
11285 /* port-A for surround (rear panel) */
11286 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11287 /* port-B for mic-in (rear panel) with vref */
11288 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11289 /* port-C for line-in (rear panel) */
11290 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11291 /* port-D for Front */
11292 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11293 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11294 /* port-E for HP out (front panel) */
11295 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11296 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011297 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011298 /* port-F for mic-in (front panel) with vref */
11299 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11300 /* port-G for CLFE (rear panel) */
11301 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11302 /* port-H for side (rear panel) */
11303 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11304 /* CD-in */
11305 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11306 /* route front mic to ADC1*/
11307 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11309 /* Unmute DAC0~3 & spdif out*/
11310 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11311 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11312 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11313 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11315
11316 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11317 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11318 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11319 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11320 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11321
11322 /* Unmute Stereo Mixer 15 */
11323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011327
11328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11330 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11331 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11335 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011336 /* hp used DAC 3 (Front) */
11337 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11339 { }
11340};
Takashi Iwai22309c32006-08-09 16:57:28 +020011341
11342static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11343 /*
11344 * Unmute ADC0 and set the default input to mic-in
11345 */
11346 /* port-A for surround (rear panel) */
11347 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11348 /* port-B for mic-in (rear panel) with vref */
11349 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11350 /* port-C for line-in (rear panel) */
11351 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11352 /* port-D for Front */
11353 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11354 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11355 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011356 /* this has to be set to VREF80 */
11357 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011358 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011359 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011360 /* port-F for mic-in (front panel) with vref */
11361 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11362 /* port-G for CLFE (rear panel) */
11363 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11364 /* port-H for side (rear panel) */
11365 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11366 /* CD-in */
11367 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11368 /* route front mic to ADC1*/
11369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11371 /* Unmute DAC0~3 & spdif out*/
11372 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11373 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11374 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11375 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11377
11378 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11379 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11380 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11381 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11382 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11383
11384 /* Unmute Stereo Mixer 15 */
11385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011389
11390 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11394 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011398 /* hp used DAC 3 (Front) */
11399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11401 { }
11402};
11403
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011404static struct hda_verb alc861_asus_init_verbs[] = {
11405 /*
11406 * Unmute ADC0 and set the default input to mic-in
11407 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011408 /* port-A for surround (rear panel)
11409 * according to codec#0 this is the HP jack
11410 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011411 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11412 /* route front PCM to HP */
11413 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11414 /* port-B for mic-in (rear panel) with vref */
11415 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11416 /* port-C for line-in (rear panel) */
11417 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11418 /* port-D for Front */
11419 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11420 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11421 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011422 /* this has to be set to VREF80 */
11423 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011424 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011425 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011426 /* port-F for mic-in (front panel) with vref */
11427 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11428 /* port-G for CLFE (rear panel) */
11429 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11430 /* port-H for side (rear panel) */
11431 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11432 /* CD-in */
11433 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11434 /* route front mic to ADC1*/
11435 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11437 /* Unmute DAC0~3 & spdif out*/
11438 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11439 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11440 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11441 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11443 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11444 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11445 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11446 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11447 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11448
11449 /* Unmute Stereo Mixer 15 */
11450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011454
11455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11456 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11457 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011463 /* hp used DAC 3 (Front) */
11464 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011465 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11466 { }
11467};
11468
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011469/* additional init verbs for ASUS laptops */
11470static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11471 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11472 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11473 { }
11474};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011475
Kailang Yangdf694da2005-12-05 19:42:22 +010011476/*
11477 * generic initialization of ADC, input mixers and output mixers
11478 */
11479static struct hda_verb alc861_auto_init_verbs[] = {
11480 /*
11481 * Unmute ADC0 and set the default input to mic-in
11482 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011483 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11485
11486 /* Unmute DAC0~3 & spdif out*/
11487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11488 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11489 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11490 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11492
11493 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11494 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11495 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11496 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11497 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11498
11499 /* Unmute Stereo Mixer 15 */
11500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11504
11505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11507 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11508 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11513
11514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011518 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011522
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011524
11525 { }
11526};
11527
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011528static struct hda_verb alc861_toshiba_init_verbs[] = {
11529 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011530
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011531 { }
11532};
11533
11534/* toggle speaker-output according to the hp-jack state */
11535static void alc861_toshiba_automute(struct hda_codec *codec)
11536{
11537 unsigned int present;
11538
11539 present = snd_hda_codec_read(codec, 0x0f, 0,
11540 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011541 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11542 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11543 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11544 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011545}
11546
11547static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11548 unsigned int res)
11549{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011550 if ((res >> 26) == ALC880_HP_EVENT)
11551 alc861_toshiba_automute(codec);
11552}
11553
Kailang Yangdf694da2005-12-05 19:42:22 +010011554/* pcm configuration: identiacal with ALC880 */
11555#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11556#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11557#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11558#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11559
11560
11561#define ALC861_DIGOUT_NID 0x07
11562
11563static struct hda_channel_mode alc861_8ch_modes[1] = {
11564 { 8, NULL }
11565};
11566
11567static hda_nid_t alc861_dac_nids[4] = {
11568 /* front, surround, clfe, side */
11569 0x03, 0x06, 0x05, 0x04
11570};
11571
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011572static hda_nid_t alc660_dac_nids[3] = {
11573 /* front, clfe, surround */
11574 0x03, 0x05, 0x06
11575};
11576
Kailang Yangdf694da2005-12-05 19:42:22 +010011577static hda_nid_t alc861_adc_nids[1] = {
11578 /* ADC0-2 */
11579 0x08,
11580};
11581
11582static struct hda_input_mux alc861_capture_source = {
11583 .num_items = 5,
11584 .items = {
11585 { "Mic", 0x0 },
11586 { "Front Mic", 0x3 },
11587 { "Line", 0x1 },
11588 { "CD", 0x4 },
11589 { "Mixer", 0x5 },
11590 },
11591};
11592
11593/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011594static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11595 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011596{
11597 int i;
11598 hda_nid_t nid;
11599
11600 spec->multiout.dac_nids = spec->private_dac_nids;
11601 for (i = 0; i < cfg->line_outs; i++) {
11602 nid = cfg->line_out_pins[i];
11603 if (nid) {
11604 if (i >= ARRAY_SIZE(alc861_dac_nids))
11605 continue;
11606 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11607 }
11608 }
11609 spec->multiout.num_dacs = cfg->line_outs;
11610 return 0;
11611}
11612
11613/* add playback controls from the parsed DAC table */
11614static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11615 const struct auto_pin_cfg *cfg)
11616{
11617 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011618 static const char *chname[4] = {
11619 "Front", "Surround", NULL /*CLFE*/, "Side"
11620 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011621 hda_nid_t nid;
11622 int i, idx, err;
11623
11624 for (i = 0; i < cfg->line_outs; i++) {
11625 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011626 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011627 continue;
11628 if (nid == 0x05) {
11629 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011630 err = add_control(spec, ALC_CTL_BIND_MUTE,
11631 "Center Playback Switch",
11632 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11633 HDA_OUTPUT));
11634 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011635 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011636 err = add_control(spec, ALC_CTL_BIND_MUTE,
11637 "LFE Playback Switch",
11638 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11639 HDA_OUTPUT));
11640 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011641 return err;
11642 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011643 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11644 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011645 if (nid == alc861_dac_nids[idx])
11646 break;
11647 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011648 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11649 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11650 HDA_OUTPUT));
11651 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011652 return err;
11653 }
11654 }
11655 return 0;
11656}
11657
11658static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11659{
11660 int err;
11661 hda_nid_t nid;
11662
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011663 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011664 return 0;
11665
11666 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11667 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011668 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11669 "Headphone Playback Switch",
11670 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11671 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011672 return err;
11673 spec->multiout.hp_nid = nid;
11674 }
11675 return 0;
11676}
11677
11678/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011679static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11680 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011681{
Kailang Yangdf694da2005-12-05 19:42:22 +010011682 struct hda_input_mux *imux = &spec->private_imux;
11683 int i, err, idx, idx1;
11684
11685 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011686 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011687 case 0x0c:
11688 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011689 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011690 break;
11691 case 0x0f:
11692 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011693 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011694 break;
11695 case 0x0d:
11696 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011697 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011698 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011699 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011700 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011701 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011702 break;
11703 case 0x11:
11704 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011705 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011706 break;
11707 default:
11708 continue;
11709 }
11710
Takashi Iwai4a471b72005-12-07 13:56:29 +010011711 err = new_analog_input(spec, cfg->input_pins[i],
11712 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011713 if (err < 0)
11714 return err;
11715
Takashi Iwai4a471b72005-12-07 13:56:29 +010011716 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011717 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011718 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011719 }
11720 return 0;
11721}
11722
11723static struct snd_kcontrol_new alc861_capture_mixer[] = {
11724 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11725 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11726
11727 {
11728 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11729 /* The multiple "Capture Source" controls confuse alsamixer
11730 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011731 */
11732 /* .name = "Capture Source", */
11733 .name = "Input Source",
11734 .count = 1,
11735 .info = alc_mux_enum_info,
11736 .get = alc_mux_enum_get,
11737 .put = alc_mux_enum_put,
11738 },
11739 { } /* end */
11740};
11741
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011742static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11743 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011744 int pin_type, int dac_idx)
11745{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011746 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011747}
11748
11749static void alc861_auto_init_multi_out(struct hda_codec *codec)
11750{
11751 struct alc_spec *spec = codec->spec;
11752 int i;
11753
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011754 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011755 for (i = 0; i < spec->autocfg.line_outs; i++) {
11756 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011757 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011758 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011759 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011760 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011761 }
11762}
11763
11764static void alc861_auto_init_hp_out(struct hda_codec *codec)
11765{
11766 struct alc_spec *spec = codec->spec;
11767 hda_nid_t pin;
11768
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011769 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011770 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011771 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11772 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011773 pin = spec->autocfg.speaker_pins[0];
11774 if (pin)
11775 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010011776}
11777
11778static void alc861_auto_init_analog_input(struct hda_codec *codec)
11779{
11780 struct alc_spec *spec = codec->spec;
11781 int i;
11782
11783 for (i = 0; i < AUTO_PIN_LAST; i++) {
11784 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011785 if (nid >= 0x0c && nid <= 0x11) {
11786 snd_hda_codec_write(codec, nid, 0,
11787 AC_VERB_SET_PIN_WIDGET_CONTROL,
11788 i <= AUTO_PIN_FRONT_MIC ?
11789 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011790 }
11791 }
11792}
11793
11794/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011795/* return 1 if successful, 0 if the proper config is not found,
11796 * or a negative error code
11797 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011798static int alc861_parse_auto_config(struct hda_codec *codec)
11799{
11800 struct alc_spec *spec = codec->spec;
11801 int err;
11802 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11803
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011804 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11805 alc861_ignore);
11806 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011807 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011808 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011809 return 0; /* can't find valid BIOS pin config */
11810
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011811 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11812 if (err < 0)
11813 return err;
11814 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11815 if (err < 0)
11816 return err;
11817 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11818 if (err < 0)
11819 return err;
11820 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11821 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011822 return err;
11823
11824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11825
11826 if (spec->autocfg.dig_out_pin)
11827 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11828
11829 if (spec->kctl_alloc)
11830 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11831
11832 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11833
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011834 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011835 spec->input_mux = &spec->private_imux;
11836
11837 spec->adc_nids = alc861_adc_nids;
11838 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11839 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11840 spec->num_mixers++;
11841
11842 return 1;
11843}
11844
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011845/* additional initialization for auto-configuration model */
11846static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011847{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011848 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011849 alc861_auto_init_multi_out(codec);
11850 alc861_auto_init_hp_out(codec);
11851 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011852 if (spec->unsol_event)
11853 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011854}
11855
Takashi Iwaicb53c622007-08-10 17:21:45 +020011856#ifdef CONFIG_SND_HDA_POWER_SAVE
11857static struct hda_amp_list alc861_loopbacks[] = {
11858 { 0x15, HDA_INPUT, 0 },
11859 { 0x15, HDA_INPUT, 1 },
11860 { 0x15, HDA_INPUT, 2 },
11861 { 0x15, HDA_INPUT, 3 },
11862 { } /* end */
11863};
11864#endif
11865
Kailang Yangdf694da2005-12-05 19:42:22 +010011866
11867/*
11868 * configuration and preset
11869 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011870static const char *alc861_models[ALC861_MODEL_LAST] = {
11871 [ALC861_3ST] = "3stack",
11872 [ALC660_3ST] = "3stack-660",
11873 [ALC861_3ST_DIG] = "3stack-dig",
11874 [ALC861_6ST_DIG] = "6stack-dig",
11875 [ALC861_UNIWILL_M31] = "uniwill-m31",
11876 [ALC861_TOSHIBA] = "toshiba",
11877 [ALC861_ASUS] = "asus",
11878 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11879 [ALC861_AUTO] = "auto",
11880};
11881
11882static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011883 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011884 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11885 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11886 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011887 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011888 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011889 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011890 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11891 * Any other models that need this preset?
11892 */
11893 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011894 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11895 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011896 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11897 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11898 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11899 /* FIXME: the below seems conflict */
11900 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11901 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11902 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011903 {}
11904};
11905
11906static struct alc_config_preset alc861_presets[] = {
11907 [ALC861_3ST] = {
11908 .mixers = { alc861_3ST_mixer },
11909 .init_verbs = { alc861_threestack_init_verbs },
11910 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11911 .dac_nids = alc861_dac_nids,
11912 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11913 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011914 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011915 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11916 .adc_nids = alc861_adc_nids,
11917 .input_mux = &alc861_capture_source,
11918 },
11919 [ALC861_3ST_DIG] = {
11920 .mixers = { alc861_base_mixer },
11921 .init_verbs = { alc861_threestack_init_verbs },
11922 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11923 .dac_nids = alc861_dac_nids,
11924 .dig_out_nid = ALC861_DIGOUT_NID,
11925 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11926 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011927 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011928 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11929 .adc_nids = alc861_adc_nids,
11930 .input_mux = &alc861_capture_source,
11931 },
11932 [ALC861_6ST_DIG] = {
11933 .mixers = { alc861_base_mixer },
11934 .init_verbs = { alc861_base_init_verbs },
11935 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11936 .dac_nids = alc861_dac_nids,
11937 .dig_out_nid = ALC861_DIGOUT_NID,
11938 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11939 .channel_mode = alc861_8ch_modes,
11940 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11941 .adc_nids = alc861_adc_nids,
11942 .input_mux = &alc861_capture_source,
11943 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011944 [ALC660_3ST] = {
11945 .mixers = { alc861_3ST_mixer },
11946 .init_verbs = { alc861_threestack_init_verbs },
11947 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11948 .dac_nids = alc660_dac_nids,
11949 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11950 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011951 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011952 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11953 .adc_nids = alc861_adc_nids,
11954 .input_mux = &alc861_capture_source,
11955 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011956 [ALC861_UNIWILL_M31] = {
11957 .mixers = { alc861_uniwill_m31_mixer },
11958 .init_verbs = { alc861_uniwill_m31_init_verbs },
11959 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11960 .dac_nids = alc861_dac_nids,
11961 .dig_out_nid = ALC861_DIGOUT_NID,
11962 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11963 .channel_mode = alc861_uniwill_m31_modes,
11964 .need_dac_fix = 1,
11965 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11966 .adc_nids = alc861_adc_nids,
11967 .input_mux = &alc861_capture_source,
11968 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011969 [ALC861_TOSHIBA] = {
11970 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011971 .init_verbs = { alc861_base_init_verbs,
11972 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011973 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11974 .dac_nids = alc861_dac_nids,
11975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11976 .channel_mode = alc883_3ST_2ch_modes,
11977 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11978 .adc_nids = alc861_adc_nids,
11979 .input_mux = &alc861_capture_source,
11980 .unsol_event = alc861_toshiba_unsol_event,
11981 .init_hook = alc861_toshiba_automute,
11982 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011983 [ALC861_ASUS] = {
11984 .mixers = { alc861_asus_mixer },
11985 .init_verbs = { alc861_asus_init_verbs },
11986 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11987 .dac_nids = alc861_dac_nids,
11988 .dig_out_nid = ALC861_DIGOUT_NID,
11989 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11990 .channel_mode = alc861_asus_modes,
11991 .need_dac_fix = 1,
11992 .hp_nid = 0x06,
11993 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11994 .adc_nids = alc861_adc_nids,
11995 .input_mux = &alc861_capture_source,
11996 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011997 [ALC861_ASUS_LAPTOP] = {
11998 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11999 .init_verbs = { alc861_asus_init_verbs,
12000 alc861_asus_laptop_init_verbs },
12001 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12002 .dac_nids = alc861_dac_nids,
12003 .dig_out_nid = ALC861_DIGOUT_NID,
12004 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12005 .channel_mode = alc883_3ST_2ch_modes,
12006 .need_dac_fix = 1,
12007 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12008 .adc_nids = alc861_adc_nids,
12009 .input_mux = &alc861_capture_source,
12010 },
12011};
Kailang Yangdf694da2005-12-05 19:42:22 +010012012
12013
12014static int patch_alc861(struct hda_codec *codec)
12015{
12016 struct alc_spec *spec;
12017 int board_config;
12018 int err;
12019
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012021 if (spec == NULL)
12022 return -ENOMEM;
12023
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012024 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012025
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012026 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12027 alc861_models,
12028 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012029
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012030 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012031 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12032 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012033 board_config = ALC861_AUTO;
12034 }
12035
12036 if (board_config == ALC861_AUTO) {
12037 /* automatic parse from the BIOS config */
12038 err = alc861_parse_auto_config(codec);
12039 if (err < 0) {
12040 alc_free(codec);
12041 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012042 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012043 printk(KERN_INFO
12044 "hda_codec: Cannot set up configuration "
12045 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012046 board_config = ALC861_3ST_DIG;
12047 }
12048 }
12049
12050 if (board_config != ALC861_AUTO)
12051 setup_preset(spec, &alc861_presets[board_config]);
12052
12053 spec->stream_name_analog = "ALC861 Analog";
12054 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12055 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12056
12057 spec->stream_name_digital = "ALC861 Digital";
12058 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12059 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12060
Takashi Iwai2134ea42008-01-10 16:53:55 +010012061 spec->vmaster_nid = 0x03;
12062
Kailang Yangdf694da2005-12-05 19:42:22 +010012063 codec->patch_ops = alc_patch_ops;
12064 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012065 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012066#ifdef CONFIG_SND_HDA_POWER_SAVE
12067 if (!spec->loopback.amplist)
12068 spec->loopback.amplist = alc861_loopbacks;
12069#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012070
12071 return 0;
12072}
12073
12074/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012075 * ALC861-VD support
12076 *
12077 * Based on ALC882
12078 *
12079 * In addition, an independent DAC
12080 */
12081#define ALC861VD_DIGOUT_NID 0x06
12082
12083static hda_nid_t alc861vd_dac_nids[4] = {
12084 /* front, surr, clfe, side surr */
12085 0x02, 0x03, 0x04, 0x05
12086};
12087
12088/* dac_nids for ALC660vd are in a different order - according to
12089 * Realtek's driver.
12090 * This should probably tesult in a different mixer for 6stack models
12091 * of ALC660vd codecs, but for now there is only 3stack mixer
12092 * - and it is the same as in 861vd.
12093 * adc_nids in ALC660vd are (is) the same as in 861vd
12094 */
12095static hda_nid_t alc660vd_dac_nids[3] = {
12096 /* front, rear, clfe, rear_surr */
12097 0x02, 0x04, 0x03
12098};
12099
12100static hda_nid_t alc861vd_adc_nids[1] = {
12101 /* ADC0 */
12102 0x09,
12103};
12104
Takashi Iwaie1406342008-02-11 18:32:32 +010012105static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12106
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012107/* input MUX */
12108/* FIXME: should be a matrix-type input source selection */
12109static struct hda_input_mux alc861vd_capture_source = {
12110 .num_items = 4,
12111 .items = {
12112 { "Mic", 0x0 },
12113 { "Front Mic", 0x1 },
12114 { "Line", 0x2 },
12115 { "CD", 0x4 },
12116 },
12117};
12118
Kailang Yang272a5272007-05-14 11:00:38 +020012119static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012120 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012121 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012122 { "Ext Mic", 0x0 },
12123 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012124 },
12125};
12126
Kailang Yangd1a991a2007-08-15 16:21:59 +020012127static struct hda_input_mux alc861vd_hp_capture_source = {
12128 .num_items = 2,
12129 .items = {
12130 { "Front Mic", 0x0 },
12131 { "ATAPI Mic", 0x1 },
12132 },
12133};
12134
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012135#define alc861vd_mux_enum_info alc_mux_enum_info
12136#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012137/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12138#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012139
12140/*
12141 * 2ch mode
12142 */
12143static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12144 { 2, NULL }
12145};
12146
12147/*
12148 * 6ch mode
12149 */
12150static struct hda_verb alc861vd_6stack_ch6_init[] = {
12151 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12152 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12153 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12154 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12155 { } /* end */
12156};
12157
12158/*
12159 * 8ch mode
12160 */
12161static struct hda_verb alc861vd_6stack_ch8_init[] = {
12162 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12163 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12164 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12165 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12166 { } /* end */
12167};
12168
12169static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12170 { 6, alc861vd_6stack_ch6_init },
12171 { 8, alc861vd_6stack_ch8_init },
12172};
12173
12174static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12175 {
12176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12177 .name = "Channel Mode",
12178 .info = alc_ch_mode_info,
12179 .get = alc_ch_mode_get,
12180 .put = alc_ch_mode_put,
12181 },
12182 { } /* end */
12183};
12184
12185static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12186 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12187 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12188
12189 {
12190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12191 /* The multiple "Capture Source" controls confuse alsamixer
12192 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012193 */
12194 /* .name = "Capture Source", */
12195 .name = "Input Source",
12196 .count = 1,
12197 .info = alc861vd_mux_enum_info,
12198 .get = alc861vd_mux_enum_get,
12199 .put = alc861vd_mux_enum_put,
12200 },
12201 { } /* end */
12202};
12203
12204/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12205 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12206 */
12207static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12208 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12209 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12210
12211 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12212 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12213
12214 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12215 HDA_OUTPUT),
12216 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12217 HDA_OUTPUT),
12218 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12219 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12220
12221 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12222 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12223
12224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12225
12226 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12229
12230 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12233
12234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12236
12237 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12238 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12239
12240 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12241 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12242
12243 { } /* end */
12244};
12245
12246static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12247 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12248 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12249
12250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12251
12252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12255
12256 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12257 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12258 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12259
12260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12262
12263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12265
12266 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12267 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12268
12269 { } /* end */
12270};
12271
Kailang Yangbdd148a2007-05-08 15:19:08 +020012272static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12273 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12274 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12275 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12276
12277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12278
12279 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12282
12283 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12284 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12285 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12286
12287 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12288 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12289
12290 { } /* end */
12291};
12292
Tobin Davisb419f342008-03-07 11:57:51 +010012293/* Pin assignment: Speaker=0x14, HP = 0x15,
12294 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012295 */
12296static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012297 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12298 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012299 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12300 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012301 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12302 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12303 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12304 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12305 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12306 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12307 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12308 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012309 { } /* end */
12310};
12311
Kailang Yangd1a991a2007-08-15 16:21:59 +020012312/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12313 * Front Mic=0x18, ATAPI Mic = 0x19,
12314 */
12315static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12316 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12318 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12319 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12322 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12323 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12324
12325 { } /* end */
12326};
12327
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012328/*
12329 * generic initialization of ADC, input mixers and output mixers
12330 */
12331static struct hda_verb alc861vd_volume_init_verbs[] = {
12332 /*
12333 * Unmute ADC0 and set the default input to mic-in
12334 */
12335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12337
12338 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12339 * the analog-loopback mixer widget
12340 */
12341 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012347
12348 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012353
12354 /*
12355 * Set up output mixers (0x02 - 0x05)
12356 */
12357 /* set vol=0 to output mixers */
12358 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12359 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12361 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12362
12363 /* set up input amps for analog loopback */
12364 /* Amp Indices: DAC = 0, mixer = 1 */
12365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12371 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12373
12374 { }
12375};
12376
12377/*
12378 * 3-stack pin configuration:
12379 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12380 */
12381static struct hda_verb alc861vd_3stack_init_verbs[] = {
12382 /*
12383 * Set pin mode and muting
12384 */
12385 /* set front pin widgets 0x14 for output */
12386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12388 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12389
12390 /* Mic (rear) pin: input vref at 80% */
12391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12393 /* Front Mic pin: input vref at 80% */
12394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12396 /* Line In pin: input */
12397 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12399 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12402 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12403 /* CD pin widget for input */
12404 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12405
12406 { }
12407};
12408
12409/*
12410 * 6-stack pin configuration:
12411 */
12412static struct hda_verb alc861vd_6stack_init_verbs[] = {
12413 /*
12414 * Set pin mode and muting
12415 */
12416 /* set front pin widgets 0x14 for output */
12417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12419 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12420
12421 /* Rear Pin: output 1 (0x0d) */
12422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12425 /* CLFE Pin: output 2 (0x0e) */
12426 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12428 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12429 /* Side Pin: output 3 (0x0f) */
12430 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12431 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12432 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12433
12434 /* Mic (rear) pin: input vref at 80% */
12435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12437 /* Front Mic pin: input vref at 80% */
12438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12440 /* Line In pin: input */
12441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12443 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12447 /* CD pin widget for input */
12448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12449
12450 { }
12451};
12452
Kailang Yangbdd148a2007-05-08 15:19:08 +020012453static struct hda_verb alc861vd_eapd_verbs[] = {
12454 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12455 { }
12456};
12457
12458static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12461 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12462 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12463 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12464 {}
12465};
12466
12467/* toggle speaker-output according to the hp-jack state */
12468static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12469{
12470 unsigned int present;
12471 unsigned char bits;
12472
12473 present = snd_hda_codec_read(codec, 0x1b, 0,
12474 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012475 bits = present ? HDA_AMP_MUTE : 0;
12476 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12477 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012478}
12479
12480static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12481{
12482 unsigned int present;
12483 unsigned char bits;
12484
12485 present = snd_hda_codec_read(codec, 0x18, 0,
12486 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012487 bits = present ? HDA_AMP_MUTE : 0;
12488 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12489 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012490}
12491
12492static void alc861vd_lenovo_automute(struct hda_codec *codec)
12493{
12494 alc861vd_lenovo_hp_automute(codec);
12495 alc861vd_lenovo_mic_automute(codec);
12496}
12497
12498static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12499 unsigned int res)
12500{
12501 switch (res >> 26) {
12502 case ALC880_HP_EVENT:
12503 alc861vd_lenovo_hp_automute(codec);
12504 break;
12505 case ALC880_MIC_EVENT:
12506 alc861vd_lenovo_mic_automute(codec);
12507 break;
12508 }
12509}
12510
Kailang Yang272a5272007-05-14 11:00:38 +020012511static struct hda_verb alc861vd_dallas_verbs[] = {
12512 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12513 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12514 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12515 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12516
12517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12525
12526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12531 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12532 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12534
12535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12537 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12540 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12541 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12542 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12543
12544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12548
12549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12550 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12551 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12552
12553 { } /* end */
12554};
12555
12556/* toggle speaker-output according to the hp-jack state */
12557static void alc861vd_dallas_automute(struct hda_codec *codec)
12558{
12559 unsigned int present;
12560
12561 present = snd_hda_codec_read(codec, 0x15, 0,
12562 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012563 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12564 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012565}
12566
12567static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12568{
12569 if ((res >> 26) == ALC880_HP_EVENT)
12570 alc861vd_dallas_automute(codec);
12571}
12572
Takashi Iwaicb53c622007-08-10 17:21:45 +020012573#ifdef CONFIG_SND_HDA_POWER_SAVE
12574#define alc861vd_loopbacks alc880_loopbacks
12575#endif
12576
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012577/* pcm configuration: identiacal with ALC880 */
12578#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12579#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12580#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12581#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12582
12583/*
12584 * configuration and preset
12585 */
12586static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12587 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012588 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012589 [ALC861VD_3ST] = "3stack",
12590 [ALC861VD_3ST_DIG] = "3stack-digout",
12591 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012592 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012593 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012594 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012595 [ALC861VD_AUTO] = "auto",
12596};
12597
12598static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012599 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12600 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012601 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012602 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012603 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012604 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012605 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012606 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012607 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012608 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010012609 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012610 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012611 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12612 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012613 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012614 {}
12615};
12616
12617static struct alc_config_preset alc861vd_presets[] = {
12618 [ALC660VD_3ST] = {
12619 .mixers = { alc861vd_3st_mixer },
12620 .init_verbs = { alc861vd_volume_init_verbs,
12621 alc861vd_3stack_init_verbs },
12622 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12623 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012624 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12625 .channel_mode = alc861vd_3stack_2ch_modes,
12626 .input_mux = &alc861vd_capture_source,
12627 },
Mike Crash6963f842007-06-25 12:12:51 +020012628 [ALC660VD_3ST_DIG] = {
12629 .mixers = { alc861vd_3st_mixer },
12630 .init_verbs = { alc861vd_volume_init_verbs,
12631 alc861vd_3stack_init_verbs },
12632 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12633 .dac_nids = alc660vd_dac_nids,
12634 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020012635 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12636 .channel_mode = alc861vd_3stack_2ch_modes,
12637 .input_mux = &alc861vd_capture_source,
12638 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012639 [ALC861VD_3ST] = {
12640 .mixers = { alc861vd_3st_mixer },
12641 .init_verbs = { alc861vd_volume_init_verbs,
12642 alc861vd_3stack_init_verbs },
12643 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12644 .dac_nids = alc861vd_dac_nids,
12645 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12646 .channel_mode = alc861vd_3stack_2ch_modes,
12647 .input_mux = &alc861vd_capture_source,
12648 },
12649 [ALC861VD_3ST_DIG] = {
12650 .mixers = { alc861vd_3st_mixer },
12651 .init_verbs = { alc861vd_volume_init_verbs,
12652 alc861vd_3stack_init_verbs },
12653 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12654 .dac_nids = alc861vd_dac_nids,
12655 .dig_out_nid = ALC861VD_DIGOUT_NID,
12656 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12657 .channel_mode = alc861vd_3stack_2ch_modes,
12658 .input_mux = &alc861vd_capture_source,
12659 },
12660 [ALC861VD_6ST_DIG] = {
12661 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12662 .init_verbs = { alc861vd_volume_init_verbs,
12663 alc861vd_6stack_init_verbs },
12664 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12665 .dac_nids = alc861vd_dac_nids,
12666 .dig_out_nid = ALC861VD_DIGOUT_NID,
12667 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12668 .channel_mode = alc861vd_6stack_modes,
12669 .input_mux = &alc861vd_capture_source,
12670 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012671 [ALC861VD_LENOVO] = {
12672 .mixers = { alc861vd_lenovo_mixer },
12673 .init_verbs = { alc861vd_volume_init_verbs,
12674 alc861vd_3stack_init_verbs,
12675 alc861vd_eapd_verbs,
12676 alc861vd_lenovo_unsol_verbs },
12677 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12678 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012679 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12680 .channel_mode = alc861vd_3stack_2ch_modes,
12681 .input_mux = &alc861vd_capture_source,
12682 .unsol_event = alc861vd_lenovo_unsol_event,
12683 .init_hook = alc861vd_lenovo_automute,
12684 },
Kailang Yang272a5272007-05-14 11:00:38 +020012685 [ALC861VD_DALLAS] = {
12686 .mixers = { alc861vd_dallas_mixer },
12687 .init_verbs = { alc861vd_dallas_verbs },
12688 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12689 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020012690 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12691 .channel_mode = alc861vd_3stack_2ch_modes,
12692 .input_mux = &alc861vd_dallas_capture_source,
12693 .unsol_event = alc861vd_dallas_unsol_event,
12694 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012695 },
12696 [ALC861VD_HP] = {
12697 .mixers = { alc861vd_hp_mixer },
12698 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12699 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12700 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012701 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012702 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12703 .channel_mode = alc861vd_3stack_2ch_modes,
12704 .input_mux = &alc861vd_hp_capture_source,
12705 .unsol_event = alc861vd_dallas_unsol_event,
12706 .init_hook = alc861vd_dallas_automute,
12707 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012708};
12709
12710/*
12711 * BIOS auto configuration
12712 */
12713static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12714 hda_nid_t nid, int pin_type, int dac_idx)
12715{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012716 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012717}
12718
12719static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12720{
12721 struct alc_spec *spec = codec->spec;
12722 int i;
12723
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012724 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012725 for (i = 0; i <= HDA_SIDE; i++) {
12726 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012727 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012728 if (nid)
12729 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012730 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012731 }
12732}
12733
12734
12735static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12736{
12737 struct alc_spec *spec = codec->spec;
12738 hda_nid_t pin;
12739
12740 pin = spec->autocfg.hp_pins[0];
12741 if (pin) /* connect to front and use dac 0 */
12742 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012743 pin = spec->autocfg.speaker_pins[0];
12744 if (pin)
12745 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012746}
12747
12748#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12749#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12750
12751static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12752{
12753 struct alc_spec *spec = codec->spec;
12754 int i;
12755
12756 for (i = 0; i < AUTO_PIN_LAST; i++) {
12757 hda_nid_t nid = spec->autocfg.input_pins[i];
12758 if (alc861vd_is_input_pin(nid)) {
12759 snd_hda_codec_write(codec, nid, 0,
12760 AC_VERB_SET_PIN_WIDGET_CONTROL,
12761 i <= AUTO_PIN_FRONT_MIC ?
12762 PIN_VREF80 : PIN_IN);
12763 if (nid != ALC861VD_PIN_CD_NID)
12764 snd_hda_codec_write(codec, nid, 0,
12765 AC_VERB_SET_AMP_GAIN_MUTE,
12766 AMP_OUT_MUTE);
12767 }
12768 }
12769}
12770
12771#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12772#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12773
12774/* add playback controls from the parsed DAC table */
12775/* Based on ALC880 version. But ALC861VD has separate,
12776 * different NIDs for mute/unmute switch and volume control */
12777static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12778 const struct auto_pin_cfg *cfg)
12779{
12780 char name[32];
12781 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12782 hda_nid_t nid_v, nid_s;
12783 int i, err;
12784
12785 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012786 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012787 continue;
12788 nid_v = alc861vd_idx_to_mixer_vol(
12789 alc880_dac_to_idx(
12790 spec->multiout.dac_nids[i]));
12791 nid_s = alc861vd_idx_to_mixer_switch(
12792 alc880_dac_to_idx(
12793 spec->multiout.dac_nids[i]));
12794
12795 if (i == 2) {
12796 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012797 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12798 "Center Playback Volume",
12799 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12800 HDA_OUTPUT));
12801 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012803 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12804 "LFE Playback Volume",
12805 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12806 HDA_OUTPUT));
12807 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012808 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012809 err = add_control(spec, ALC_CTL_BIND_MUTE,
12810 "Center Playback Switch",
12811 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12812 HDA_INPUT));
12813 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012815 err = add_control(spec, ALC_CTL_BIND_MUTE,
12816 "LFE Playback Switch",
12817 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12818 HDA_INPUT));
12819 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012820 return err;
12821 } else {
12822 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012823 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12824 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12825 HDA_OUTPUT));
12826 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012827 return err;
12828 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012829 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012830 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012831 HDA_INPUT));
12832 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012833 return err;
12834 }
12835 }
12836 return 0;
12837}
12838
12839/* add playback controls for speaker and HP outputs */
12840/* Based on ALC880 version. But ALC861VD has separate,
12841 * different NIDs for mute/unmute switch and volume control */
12842static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12843 hda_nid_t pin, const char *pfx)
12844{
12845 hda_nid_t nid_v, nid_s;
12846 int err;
12847 char name[32];
12848
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012849 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012850 return 0;
12851
12852 if (alc880_is_fixed_pin(pin)) {
12853 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12854 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012855 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012856 spec->multiout.hp_nid = nid_v;
12857 else
12858 spec->multiout.extra_out_nid[0] = nid_v;
12859 /* control HP volume/switch on the output mixer amp */
12860 nid_v = alc861vd_idx_to_mixer_vol(
12861 alc880_fixed_pin_idx(pin));
12862 nid_s = alc861vd_idx_to_mixer_switch(
12863 alc880_fixed_pin_idx(pin));
12864
12865 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012866 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12867 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12868 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012869 return err;
12870 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012871 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12872 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12873 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012874 return err;
12875 } else if (alc880_is_multi_pin(pin)) {
12876 /* set manual connection */
12877 /* we have only a switch on HP-out PIN */
12878 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012879 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12880 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12881 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012882 return err;
12883 }
12884 return 0;
12885}
12886
12887/* parse the BIOS configuration and set up the alc_spec
12888 * return 1 if successful, 0 if the proper config is not found,
12889 * or a negative error code
12890 * Based on ALC880 version - had to change it to override
12891 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12892static int alc861vd_parse_auto_config(struct hda_codec *codec)
12893{
12894 struct alc_spec *spec = codec->spec;
12895 int err;
12896 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012898 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12899 alc861vd_ignore);
12900 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012901 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012902 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012903 return 0; /* can't find valid BIOS pin config */
12904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012905 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12906 if (err < 0)
12907 return err;
12908 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12909 if (err < 0)
12910 return err;
12911 err = alc861vd_auto_create_extra_out(spec,
12912 spec->autocfg.speaker_pins[0],
12913 "Speaker");
12914 if (err < 0)
12915 return err;
12916 err = alc861vd_auto_create_extra_out(spec,
12917 spec->autocfg.hp_pins[0],
12918 "Headphone");
12919 if (err < 0)
12920 return err;
12921 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12922 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012923 return err;
12924
12925 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12926
12927 if (spec->autocfg.dig_out_pin)
12928 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12929
12930 if (spec->kctl_alloc)
12931 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12932
12933 spec->init_verbs[spec->num_init_verbs++]
12934 = alc861vd_volume_init_verbs;
12935
12936 spec->num_mux_defs = 1;
12937 spec->input_mux = &spec->private_imux;
12938
Takashi Iwai776e1842007-08-29 15:07:11 +020012939 err = alc_auto_add_mic_boost(codec);
12940 if (err < 0)
12941 return err;
12942
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012943 return 1;
12944}
12945
12946/* additional initialization for auto-configuration model */
12947static void alc861vd_auto_init(struct hda_codec *codec)
12948{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012949 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012950 alc861vd_auto_init_multi_out(codec);
12951 alc861vd_auto_init_hp_out(codec);
12952 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012953 if (spec->unsol_event)
12954 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012955}
12956
12957static int patch_alc861vd(struct hda_codec *codec)
12958{
12959 struct alc_spec *spec;
12960 int err, board_config;
12961
12962 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12963 if (spec == NULL)
12964 return -ENOMEM;
12965
12966 codec->spec = spec;
12967
12968 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12969 alc861vd_models,
12970 alc861vd_cfg_tbl);
12971
12972 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12973 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12974 "ALC861VD, trying auto-probe from BIOS...\n");
12975 board_config = ALC861VD_AUTO;
12976 }
12977
12978 if (board_config == ALC861VD_AUTO) {
12979 /* automatic parse from the BIOS config */
12980 err = alc861vd_parse_auto_config(codec);
12981 if (err < 0) {
12982 alc_free(codec);
12983 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012984 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012985 printk(KERN_INFO
12986 "hda_codec: Cannot set up configuration "
12987 "from BIOS. Using base mode...\n");
12988 board_config = ALC861VD_3ST;
12989 }
12990 }
12991
12992 if (board_config != ALC861VD_AUTO)
12993 setup_preset(spec, &alc861vd_presets[board_config]);
12994
12995 spec->stream_name_analog = "ALC861VD Analog";
12996 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12997 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12998
12999 spec->stream_name_digital = "ALC861VD Digital";
13000 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13001 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13002
13003 spec->adc_nids = alc861vd_adc_nids;
13004 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013005 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013006
13007 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13008 spec->num_mixers++;
13009
Takashi Iwai2134ea42008-01-10 16:53:55 +010013010 spec->vmaster_nid = 0x02;
13011
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013012 codec->patch_ops = alc_patch_ops;
13013
13014 if (board_config == ALC861VD_AUTO)
13015 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013016#ifdef CONFIG_SND_HDA_POWER_SAVE
13017 if (!spec->loopback.amplist)
13018 spec->loopback.amplist = alc861vd_loopbacks;
13019#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013020
13021 return 0;
13022}
13023
13024/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013025 * ALC662 support
13026 *
13027 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13028 * configuration. Each pin widget can choose any input DACs and a mixer.
13029 * Each ADC is connected from a mixer of all inputs. This makes possible
13030 * 6-channel independent captures.
13031 *
13032 * In addition, an independent DAC for the multi-playback (not used in this
13033 * driver yet).
13034 */
13035#define ALC662_DIGOUT_NID 0x06
13036#define ALC662_DIGIN_NID 0x0a
13037
13038static hda_nid_t alc662_dac_nids[4] = {
13039 /* front, rear, clfe, rear_surr */
13040 0x02, 0x03, 0x04
13041};
13042
13043static hda_nid_t alc662_adc_nids[1] = {
13044 /* ADC1-2 */
13045 0x09,
13046};
Takashi Iwaie1406342008-02-11 18:32:32 +010013047
Kailang Yang77a261b2008-02-19 11:38:05 +010013048static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013049
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013050/* input MUX */
13051/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013052static struct hda_input_mux alc662_capture_source = {
13053 .num_items = 4,
13054 .items = {
13055 { "Mic", 0x0 },
13056 { "Front Mic", 0x1 },
13057 { "Line", 0x2 },
13058 { "CD", 0x4 },
13059 },
13060};
13061
13062static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13063 .num_items = 2,
13064 .items = {
13065 { "Mic", 0x1 },
13066 { "Line", 0x2 },
13067 },
13068};
Kailang Yang291702f2007-10-16 14:28:03 +020013069
13070static struct hda_input_mux alc662_eeepc_capture_source = {
13071 .num_items = 2,
13072 .items = {
13073 { "i-Mic", 0x1 },
13074 { "e-Mic", 0x0 },
13075 },
13076};
13077
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013078#define alc662_mux_enum_info alc_mux_enum_info
13079#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013080#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013081
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013082/*
13083 * 2ch mode
13084 */
13085static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13086 { 2, NULL }
13087};
13088
13089/*
13090 * 2ch mode
13091 */
13092static struct hda_verb alc662_3ST_ch2_init[] = {
13093 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13094 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13095 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13096 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13097 { } /* end */
13098};
13099
13100/*
13101 * 6ch mode
13102 */
13103static struct hda_verb alc662_3ST_ch6_init[] = {
13104 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13105 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13106 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13107 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13108 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13109 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13110 { } /* end */
13111};
13112
13113static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13114 { 2, alc662_3ST_ch2_init },
13115 { 6, alc662_3ST_ch6_init },
13116};
13117
13118/*
13119 * 2ch mode
13120 */
13121static struct hda_verb alc662_sixstack_ch6_init[] = {
13122 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13123 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13124 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13125 { } /* end */
13126};
13127
13128/*
13129 * 6ch mode
13130 */
13131static struct hda_verb alc662_sixstack_ch8_init[] = {
13132 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13133 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13135 { } /* end */
13136};
13137
13138static struct hda_channel_mode alc662_5stack_modes[2] = {
13139 { 2, alc662_sixstack_ch6_init },
13140 { 6, alc662_sixstack_ch8_init },
13141};
13142
13143/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13144 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13145 */
13146
13147static struct snd_kcontrol_new alc662_base_mixer[] = {
13148 /* output mixer control */
13149 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013150 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013152 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13154 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013155 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13156 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13158
13159 /*Input mixer control */
13160 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13161 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13162 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13163 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13164 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13165 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13166 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13167 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013168 { } /* end */
13169};
13170
13171static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013173 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13178 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13182 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13183 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13184 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013185 { } /* end */
13186};
13187
13188static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13189 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013190 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013192 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13204 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13206 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13207 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013208 { } /* end */
13209};
13210
13211static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13212 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13213 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13215 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013221 { } /* end */
13222};
13223
Kailang Yang291702f2007-10-16 14:28:03 +020013224static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013225 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013226
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013227 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13228 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013229
13230 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13231 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13232 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13233
13234 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13235 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13236 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13237 { } /* end */
13238};
13239
Kailang Yang8c427222008-01-10 13:03:59 +010013240static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013241 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13242 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13244 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013249 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013250 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13255 { } /* end */
13256};
13257
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013258static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13259 {
13260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13261 .name = "Channel Mode",
13262 .info = alc_ch_mode_info,
13263 .get = alc_ch_mode_get,
13264 .put = alc_ch_mode_put,
13265 },
13266 { } /* end */
13267};
13268
13269static struct hda_verb alc662_init_verbs[] = {
13270 /* ADC: mute amp left and right */
13271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13272 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13273 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13274
Takashi Iwaicb53c622007-08-10 17:21:45 +020013275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013280
Kailang Yangb60dd392007-09-20 12:50:29 +020013281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013287
13288 /* Front Pin: output 0 (0x0c) */
13289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13291
13292 /* Rear Pin: output 1 (0x0d) */
13293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13295
13296 /* CLFE Pin: output 2 (0x0e) */
13297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13299
13300 /* Mic (rear) pin: input vref at 80% */
13301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13303 /* Front Mic pin: input vref at 80% */
13304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13306 /* Line In pin: input */
13307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13309 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13310 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13312 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13313 /* CD pin widget for input */
13314 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13315
13316 /* FIXME: use matrix-type input source selection */
13317 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13318 /* Input mixer */
13319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013323
13324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013328 { }
13329};
13330
13331static struct hda_verb alc662_sue_init_verbs[] = {
13332 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13333 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013334 {}
13335};
13336
13337static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13338 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13339 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13340 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013341};
13342
Kailang Yang8c427222008-01-10 13:03:59 +010013343/* Set Unsolicited Event*/
13344static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13345 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13347 {}
13348};
13349
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013350/*
13351 * generic initialization of ADC, input mixers and output mixers
13352 */
13353static struct hda_verb alc662_auto_init_verbs[] = {
13354 /*
13355 * Unmute ADC and set the default input to mic-in
13356 */
13357 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13359
13360 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13361 * mixer widget
13362 * Note: PASD motherboards uses the Line In 2 as the input for front
13363 * panel mic (mic 2)
13364 */
13365 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013371
13372 /*
13373 * Set up output mixers (0x0c - 0x0f)
13374 */
13375 /* set vol=0 to output mixers */
13376 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13377 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13378 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13379
13380 /* set up input amps for analog loopback */
13381 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013388
13389
13390 /* FIXME: use matrix-type input source selection */
13391 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13392 /* Input mixer */
13393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013395 { }
13396};
13397
13398/* capture mixer elements */
13399static struct snd_kcontrol_new alc662_capture_mixer[] = {
13400 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13401 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13402 {
13403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13404 /* The multiple "Capture Source" controls confuse alsamixer
13405 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013406 */
13407 /* .name = "Capture Source", */
13408 .name = "Input Source",
13409 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013410 .info = alc662_mux_enum_info,
13411 .get = alc662_mux_enum_get,
13412 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013413 },
13414 { } /* end */
13415};
13416
13417static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13418{
13419 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013420 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013421
13422 present = snd_hda_codec_read(codec, 0x14, 0,
13423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013424 bits = present ? HDA_AMP_MUTE : 0;
13425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13426 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013427}
13428
13429static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13430{
13431 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013432 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013433
13434 present = snd_hda_codec_read(codec, 0x1b, 0,
13435 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013436 bits = present ? HDA_AMP_MUTE : 0;
13437 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13438 HDA_AMP_MUTE, bits);
13439 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13440 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013441}
13442
13443static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13444 unsigned int res)
13445{
13446 if ((res >> 26) == ALC880_HP_EVENT)
13447 alc662_lenovo_101e_all_automute(codec);
13448 if ((res >> 26) == ALC880_FRONT_EVENT)
13449 alc662_lenovo_101e_ispeaker_automute(codec);
13450}
13451
Kailang Yang291702f2007-10-16 14:28:03 +020013452static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13453{
13454 unsigned int present;
13455
13456 present = snd_hda_codec_read(codec, 0x18, 0,
13457 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13458 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13459 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13460 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13461 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13462 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13463 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13464 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13465 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13466}
13467
13468/* unsolicited event for HP jack sensing */
13469static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13470 unsigned int res)
13471{
13472 if ((res >> 26) == ALC880_HP_EVENT)
13473 alc262_hippo1_automute( codec );
13474
13475 if ((res >> 26) == ALC880_MIC_EVENT)
13476 alc662_eeepc_mic_automute(codec);
13477}
13478
13479static void alc662_eeepc_inithook(struct hda_codec *codec)
13480{
13481 alc262_hippo1_automute( codec );
13482 alc662_eeepc_mic_automute(codec);
13483}
13484
Kailang Yang8c427222008-01-10 13:03:59 +010013485static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13486{
13487 unsigned int mute;
13488 unsigned int present;
13489
13490 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13491 present = snd_hda_codec_read(codec, 0x14, 0,
13492 AC_VERB_GET_PIN_SENSE, 0);
13493 present = (present & 0x80000000) != 0;
13494 if (present) {
13495 /* mute internal speaker */
13496 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13497 HDA_AMP_MUTE, HDA_AMP_MUTE);
13498 } else {
13499 /* unmute internal speaker if necessary */
13500 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13501 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13502 HDA_AMP_MUTE, mute);
13503 }
13504}
13505
13506/* unsolicited event for HP jack sensing */
13507static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13508 unsigned int res)
13509{
13510 if ((res >> 26) == ALC880_HP_EVENT)
13511 alc662_eeepc_ep20_automute(codec);
13512}
13513
13514static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13515{
13516 alc662_eeepc_ep20_automute(codec);
13517}
13518
Takashi Iwaicb53c622007-08-10 17:21:45 +020013519#ifdef CONFIG_SND_HDA_POWER_SAVE
13520#define alc662_loopbacks alc880_loopbacks
13521#endif
13522
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013523
13524/* pcm configuration: identiacal with ALC880 */
13525#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13526#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13527#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13528#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13529
13530/*
13531 * configuration and preset
13532 */
13533static const char *alc662_models[ALC662_MODEL_LAST] = {
13534 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13535 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13536 [ALC662_3ST_6ch] = "3stack-6ch",
13537 [ALC662_5ST_DIG] = "6stack-dig",
13538 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013539 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013540 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013541 [ALC662_AUTO] = "auto",
13542};
13543
13544static struct snd_pci_quirk alc662_cfg_tbl[] = {
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010013545 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020013546 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013547 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013548 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013549 {}
13550};
13551
13552static struct alc_config_preset alc662_presets[] = {
13553 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013554 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013555 .init_verbs = { alc662_init_verbs },
13556 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13557 .dac_nids = alc662_dac_nids,
13558 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013559 .dig_in_nid = ALC662_DIGIN_NID,
13560 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13561 .channel_mode = alc662_3ST_2ch_modes,
13562 .input_mux = &alc662_capture_source,
13563 },
13564 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013565 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13566 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013567 .init_verbs = { alc662_init_verbs },
13568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13569 .dac_nids = alc662_dac_nids,
13570 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013571 .dig_in_nid = ALC662_DIGIN_NID,
13572 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13573 .channel_mode = alc662_3ST_6ch_modes,
13574 .need_dac_fix = 1,
13575 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013576 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013577 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013578 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13579 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013580 .init_verbs = { alc662_init_verbs },
13581 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13582 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013583 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13584 .channel_mode = alc662_3ST_6ch_modes,
13585 .need_dac_fix = 1,
13586 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013588 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013589 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13590 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013591 .init_verbs = { alc662_init_verbs },
13592 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13593 .dac_nids = alc662_dac_nids,
13594 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013595 .dig_in_nid = ALC662_DIGIN_NID,
13596 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13597 .channel_mode = alc662_5stack_modes,
13598 .input_mux = &alc662_capture_source,
13599 },
13600 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013601 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013602 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13603 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13604 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013605 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13606 .channel_mode = alc662_3ST_2ch_modes,
13607 .input_mux = &alc662_lenovo_101e_capture_source,
13608 .unsol_event = alc662_lenovo_101e_unsol_event,
13609 .init_hook = alc662_lenovo_101e_all_automute,
13610 },
Kailang Yang291702f2007-10-16 14:28:03 +020013611 [ALC662_ASUS_EEEPC_P701] = {
13612 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13613 .init_verbs = { alc662_init_verbs,
13614 alc662_eeepc_sue_init_verbs },
13615 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13616 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020013617 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13618 .channel_mode = alc662_3ST_2ch_modes,
13619 .input_mux = &alc662_eeepc_capture_source,
13620 .unsol_event = alc662_eeepc_unsol_event,
13621 .init_hook = alc662_eeepc_inithook,
13622 },
Kailang Yang8c427222008-01-10 13:03:59 +010013623 [ALC662_ASUS_EEEPC_EP20] = {
13624 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13625 alc662_chmode_mixer },
13626 .init_verbs = { alc662_init_verbs,
13627 alc662_eeepc_ep20_sue_init_verbs },
13628 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13629 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010013630 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13631 .channel_mode = alc662_3ST_6ch_modes,
13632 .input_mux = &alc662_lenovo_101e_capture_source,
13633 .unsol_event = alc662_eeepc_ep20_unsol_event,
13634 .init_hook = alc662_eeepc_ep20_inithook,
13635 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013636
13637};
13638
13639
13640/*
13641 * BIOS auto configuration
13642 */
13643
13644/* add playback controls from the parsed DAC table */
13645static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13646 const struct auto_pin_cfg *cfg)
13647{
13648 char name[32];
13649 static const char *chname[4] = {
13650 "Front", "Surround", NULL /*CLFE*/, "Side"
13651 };
13652 hda_nid_t nid;
13653 int i, err;
13654
13655 for (i = 0; i < cfg->line_outs; i++) {
13656 if (!spec->multiout.dac_nids[i])
13657 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013658 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013659 if (i == 2) {
13660 /* Center/LFE */
13661 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13662 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013663 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13664 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013665 if (err < 0)
13666 return err;
13667 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13668 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013669 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13670 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013671 if (err < 0)
13672 return err;
13673 err = add_control(spec, ALC_CTL_BIND_MUTE,
13674 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013675 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13676 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013677 if (err < 0)
13678 return err;
13679 err = add_control(spec, ALC_CTL_BIND_MUTE,
13680 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013681 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13682 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013683 if (err < 0)
13684 return err;
13685 } else {
13686 sprintf(name, "%s Playback Volume", chname[i]);
13687 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13689 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013690 if (err < 0)
13691 return err;
13692 sprintf(name, "%s Playback Switch", chname[i]);
13693 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013694 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13695 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013696 if (err < 0)
13697 return err;
13698 }
13699 }
13700 return 0;
13701}
13702
13703/* add playback controls for speaker and HP outputs */
13704static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13705 const char *pfx)
13706{
13707 hda_nid_t nid;
13708 int err;
13709 char name[32];
13710
13711 if (!pin)
13712 return 0;
13713
13714 if (alc880_is_fixed_pin(pin)) {
13715 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13716 /* printk("DAC nid=%x\n",nid); */
13717 /* specify the DAC as the extra output */
13718 if (!spec->multiout.hp_nid)
13719 spec->multiout.hp_nid = nid;
13720 else
13721 spec->multiout.extra_out_nid[0] = nid;
13722 /* control HP volume/switch on the output mixer amp */
13723 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13724 sprintf(name, "%s Playback Volume", pfx);
13725 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13726 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13727 if (err < 0)
13728 return err;
13729 sprintf(name, "%s Playback Switch", pfx);
13730 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13731 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13732 if (err < 0)
13733 return err;
13734 } else if (alc880_is_multi_pin(pin)) {
13735 /* set manual connection */
13736 /* we have only a switch on HP-out PIN */
13737 sprintf(name, "%s Playback Switch", pfx);
13738 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13739 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13740 if (err < 0)
13741 return err;
13742 }
13743 return 0;
13744}
13745
13746/* create playback/capture controls for input pins */
13747static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13748 const struct auto_pin_cfg *cfg)
13749{
13750 struct hda_input_mux *imux = &spec->private_imux;
13751 int i, err, idx;
13752
13753 for (i = 0; i < AUTO_PIN_LAST; i++) {
13754 if (alc880_is_input_pin(cfg->input_pins[i])) {
13755 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13756 err = new_analog_input(spec, cfg->input_pins[i],
13757 auto_pin_cfg_labels[i],
13758 idx, 0x0b);
13759 if (err < 0)
13760 return err;
13761 imux->items[imux->num_items].label =
13762 auto_pin_cfg_labels[i];
13763 imux->items[imux->num_items].index =
13764 alc880_input_pin_idx(cfg->input_pins[i]);
13765 imux->num_items++;
13766 }
13767 }
13768 return 0;
13769}
13770
13771static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13772 hda_nid_t nid, int pin_type,
13773 int dac_idx)
13774{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013775 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013776 /* need the manual connection? */
13777 if (alc880_is_multi_pin(nid)) {
13778 struct alc_spec *spec = codec->spec;
13779 int idx = alc880_multi_pin_idx(nid);
13780 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13781 AC_VERB_SET_CONNECT_SEL,
13782 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13783 }
13784}
13785
13786static void alc662_auto_init_multi_out(struct hda_codec *codec)
13787{
13788 struct alc_spec *spec = codec->spec;
13789 int i;
13790
Kailang Yang8c427222008-01-10 13:03:59 +010013791 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013792 for (i = 0; i <= HDA_SIDE; i++) {
13793 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013794 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013795 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013796 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013797 i);
13798 }
13799}
13800
13801static void alc662_auto_init_hp_out(struct hda_codec *codec)
13802{
13803 struct alc_spec *spec = codec->spec;
13804 hda_nid_t pin;
13805
13806 pin = spec->autocfg.hp_pins[0];
13807 if (pin) /* connect to front */
13808 /* use dac 0 */
13809 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013810 pin = spec->autocfg.speaker_pins[0];
13811 if (pin)
13812 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013813}
13814
13815#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13816#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13817
13818static void alc662_auto_init_analog_input(struct hda_codec *codec)
13819{
13820 struct alc_spec *spec = codec->spec;
13821 int i;
13822
13823 for (i = 0; i < AUTO_PIN_LAST; i++) {
13824 hda_nid_t nid = spec->autocfg.input_pins[i];
13825 if (alc662_is_input_pin(nid)) {
13826 snd_hda_codec_write(codec, nid, 0,
13827 AC_VERB_SET_PIN_WIDGET_CONTROL,
13828 (i <= AUTO_PIN_FRONT_MIC ?
13829 PIN_VREF80 : PIN_IN));
13830 if (nid != ALC662_PIN_CD_NID)
13831 snd_hda_codec_write(codec, nid, 0,
13832 AC_VERB_SET_AMP_GAIN_MUTE,
13833 AMP_OUT_MUTE);
13834 }
13835 }
13836}
13837
13838static int alc662_parse_auto_config(struct hda_codec *codec)
13839{
13840 struct alc_spec *spec = codec->spec;
13841 int err;
13842 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13843
13844 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13845 alc662_ignore);
13846 if (err < 0)
13847 return err;
13848 if (!spec->autocfg.line_outs)
13849 return 0; /* can't find valid BIOS pin config */
13850
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013851 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13852 if (err < 0)
13853 return err;
13854 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13855 if (err < 0)
13856 return err;
13857 err = alc662_auto_create_extra_out(spec,
13858 spec->autocfg.speaker_pins[0],
13859 "Speaker");
13860 if (err < 0)
13861 return err;
13862 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13863 "Headphone");
13864 if (err < 0)
13865 return err;
13866 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13867 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013868 return err;
13869
13870 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13871
13872 if (spec->autocfg.dig_out_pin)
13873 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13874
13875 if (spec->kctl_alloc)
13876 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13877
13878 spec->num_mux_defs = 1;
13879 spec->input_mux = &spec->private_imux;
13880
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013881 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013882 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13883 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013884 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013885}
13886
13887/* additional initialization for auto-configuration model */
13888static void alc662_auto_init(struct hda_codec *codec)
13889{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013890 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013891 alc662_auto_init_multi_out(codec);
13892 alc662_auto_init_hp_out(codec);
13893 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013894 if (spec->unsol_event)
13895 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013896}
13897
13898static int patch_alc662(struct hda_codec *codec)
13899{
13900 struct alc_spec *spec;
13901 int err, board_config;
13902
13903 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13904 if (!spec)
13905 return -ENOMEM;
13906
13907 codec->spec = spec;
13908
13909 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13910 alc662_models,
13911 alc662_cfg_tbl);
13912 if (board_config < 0) {
13913 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13914 "trying auto-probe from BIOS...\n");
13915 board_config = ALC662_AUTO;
13916 }
13917
13918 if (board_config == ALC662_AUTO) {
13919 /* automatic parse from the BIOS config */
13920 err = alc662_parse_auto_config(codec);
13921 if (err < 0) {
13922 alc_free(codec);
13923 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013924 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013925 printk(KERN_INFO
13926 "hda_codec: Cannot set up configuration "
13927 "from BIOS. Using base mode...\n");
13928 board_config = ALC662_3ST_2ch_DIG;
13929 }
13930 }
13931
13932 if (board_config != ALC662_AUTO)
13933 setup_preset(spec, &alc662_presets[board_config]);
13934
13935 spec->stream_name_analog = "ALC662 Analog";
13936 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13937 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13938
13939 spec->stream_name_digital = "ALC662 Digital";
13940 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13941 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13942
Takashi Iwaie1406342008-02-11 18:32:32 +010013943 spec->adc_nids = alc662_adc_nids;
13944 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13945 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013946
Takashi Iwai2134ea42008-01-10 16:53:55 +010013947 spec->vmaster_nid = 0x02;
13948
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013949 codec->patch_ops = alc_patch_ops;
13950 if (board_config == ALC662_AUTO)
13951 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013952#ifdef CONFIG_SND_HDA_POWER_SAVE
13953 if (!spec->loopback.amplist)
13954 spec->loopback.amplist = alc662_loopbacks;
13955#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013956
13957 return 0;
13958}
13959
13960/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013961 * patch entries
13962 */
13963struct hda_codec_preset snd_hda_preset_realtek[] = {
13964 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013965 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013966 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013967 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013968 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013969 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013970 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013971 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13972 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13973 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013974 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13975 .patch = patch_alc883 },
13976 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13977 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013978 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013979 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013980 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013981 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013982 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013983 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013984 {} /* terminator */
13985};