blob: c67c32faa9032e464f4b56d1421102b3a1148e99 [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[] = {
1930 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1931 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1932 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1933 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1934
1935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939
1940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1942 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1945 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1946 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1948 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001949
Takashi Iwai937b4162008-02-11 14:52:36 +01001950 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1951 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1952
Takashi Iwai16ded522005-06-10 19:58:24 +02001953 { }
1954};
1955
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001956/*
1957 * ASUS pin configuration:
1958 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1959 */
1960static struct hda_verb alc880_pin_asus_init_verbs[] = {
1961 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1962 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1963 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1964 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1965
1966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1972 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1974
1975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1977 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1984
1985 { }
1986};
1987
1988/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001989#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1990#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001991
Kailang Yangdf694da2005-12-05 19:42:22 +01001992/* Clevo m520g init */
1993static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1994 /* headphone output */
1995 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1996 /* line-out */
1997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* Line-in */
2000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002 /* CD */
2003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2004 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2005 /* Mic1 (rear panel) */
2006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2008 /* Mic2 (front panel) */
2009 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2010 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011 /* headphone */
2012 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 /* change to EAPD mode */
2015 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2016 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2017
2018 { }
2019};
2020
2021static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002022 /* change to EAPD mode */
2023 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2024 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2025
Kailang Yangdf694da2005-12-05 19:42:22 +01002026 /* Headphone output */
2027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2028 /* Front output*/
2029 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2030 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2031
2032 /* Line In pin widget for input */
2033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2034 /* CD pin widget for input */
2035 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2036 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2037 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2038
2039 /* change to EAPD mode */
2040 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2041 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2042
2043 { }
2044};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045
2046/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002047 * LG m1 express dual
2048 *
2049 * Pin assignment:
2050 * Rear Line-In/Out (blue): 0x14
2051 * Build-in Mic-In: 0x15
2052 * Speaker-out: 0x17
2053 * HP-Out (green): 0x1b
2054 * Mic-In/Out (red): 0x19
2055 * SPDIF-Out: 0x1e
2056 */
2057
2058/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2059static hda_nid_t alc880_lg_dac_nids[3] = {
2060 0x05, 0x02, 0x03
2061};
2062
2063/* seems analog CD is not working */
2064static struct hda_input_mux alc880_lg_capture_source = {
2065 .num_items = 3,
2066 .items = {
2067 { "Mic", 0x1 },
2068 { "Line", 0x5 },
2069 { "Internal Mic", 0x6 },
2070 },
2071};
2072
2073/* 2,4,6 channel modes */
2074static struct hda_verb alc880_lg_ch2_init[] = {
2075 /* set line-in and mic-in to input */
2076 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2077 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2078 { }
2079};
2080
2081static struct hda_verb alc880_lg_ch4_init[] = {
2082 /* set line-in to out and mic-in to input */
2083 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2084 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2085 { }
2086};
2087
2088static struct hda_verb alc880_lg_ch6_init[] = {
2089 /* set line-in and mic-in to output */
2090 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2091 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2092 { }
2093};
2094
2095static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2096 { 2, alc880_lg_ch2_init },
2097 { 4, alc880_lg_ch4_init },
2098 { 6, alc880_lg_ch6_init },
2099};
2100
2101static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2103 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2115 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2116 {
2117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2118 .name = "Channel Mode",
2119 .info = alc_ch_mode_info,
2120 .get = alc_ch_mode_get,
2121 .put = alc_ch_mode_put,
2122 },
2123 { } /* end */
2124};
2125
2126static struct hda_verb alc880_lg_init_verbs[] = {
2127 /* set capture source to mic-in */
2128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2131 /* mute all amp mixer inputs */
2132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002135 /* line-in to input */
2136 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2137 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2138 /* built-in mic */
2139 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2141 /* speaker-out */
2142 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2144 /* mic-in to input */
2145 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2148 /* HP-out */
2149 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2151 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2152 /* jack sense */
2153 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2154 { }
2155};
2156
2157/* toggle speaker-output according to the hp-jack state */
2158static void alc880_lg_automute(struct hda_codec *codec)
2159{
2160 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002161 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002162
2163 present = snd_hda_codec_read(codec, 0x1b, 0,
2164 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002165 bits = present ? HDA_AMP_MUTE : 0;
2166 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2167 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002168}
2169
2170static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2171{
2172 /* Looks like the unsol event is incompatible with the standard
2173 * definition. 4bit tag is placed at 28 bit!
2174 */
2175 if ((res >> 28) == 0x01)
2176 alc880_lg_automute(codec);
2177}
2178
2179/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002180 * LG LW20
2181 *
2182 * Pin assignment:
2183 * Speaker-out: 0x14
2184 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002185 * Built-in Mic-In: 0x19
2186 * Line-In: 0x1b
2187 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002188 * SPDIF-Out: 0x1e
2189 */
2190
Takashi Iwaid6815182006-03-23 16:06:23 +01002191static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002192 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002193 .items = {
2194 { "Mic", 0x0 },
2195 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002196 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002197 },
2198};
2199
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002200#define alc880_lg_lw_modes alc880_threestack_modes
2201
Takashi Iwaid6815182006-03-23 16:06:23 +01002202static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002203 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2204 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2205 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2206 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2207 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2208 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2210 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2216 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002217 {
2218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2219 .name = "Channel Mode",
2220 .info = alc_ch_mode_info,
2221 .get = alc_ch_mode_get,
2222 .put = alc_ch_mode_put,
2223 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002224 { } /* end */
2225};
2226
2227static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002228 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2229 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2230 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2231
Takashi Iwaid6815182006-03-23 16:06:23 +01002232 /* set capture source to mic-in */
2233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2235 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002237 /* speaker-out */
2238 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2240 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2242 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2243 /* mic-in to input */
2244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2246 /* built-in mic */
2247 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2249 /* jack sense */
2250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2251 { }
2252};
2253
2254/* toggle speaker-output according to the hp-jack state */
2255static void alc880_lg_lw_automute(struct hda_codec *codec)
2256{
2257 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002258 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002259
2260 present = snd_hda_codec_read(codec, 0x1b, 0,
2261 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002262 bits = present ? HDA_AMP_MUTE : 0;
2263 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2264 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002265}
2266
2267static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2268{
2269 /* Looks like the unsol event is incompatible with the standard
2270 * definition. 4bit tag is placed at 28 bit!
2271 */
2272 if ((res >> 28) == 0x01)
2273 alc880_lg_lw_automute(codec);
2274}
2275
Takashi Iwaicb53c622007-08-10 17:21:45 +02002276#ifdef CONFIG_SND_HDA_POWER_SAVE
2277static struct hda_amp_list alc880_loopbacks[] = {
2278 { 0x0b, HDA_INPUT, 0 },
2279 { 0x0b, HDA_INPUT, 1 },
2280 { 0x0b, HDA_INPUT, 2 },
2281 { 0x0b, HDA_INPUT, 3 },
2282 { 0x0b, HDA_INPUT, 4 },
2283 { } /* end */
2284};
2285
2286static struct hda_amp_list alc880_lg_loopbacks[] = {
2287 { 0x0b, HDA_INPUT, 1 },
2288 { 0x0b, HDA_INPUT, 6 },
2289 { 0x0b, HDA_INPUT, 7 },
2290 { } /* end */
2291};
2292#endif
2293
Takashi Iwaid6815182006-03-23 16:06:23 +01002294/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002295 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002296 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002297
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298static int alc_init(struct hda_codec *codec)
2299{
2300 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 unsigned int i;
2302
2303 for (i = 0; i < spec->num_init_verbs; i++)
2304 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002305
2306 if (spec->init_hook)
2307 spec->init_hook(codec);
2308
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 return 0;
2310}
2311
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002312static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2313{
2314 struct alc_spec *spec = codec->spec;
2315
2316 if (spec->unsol_event)
2317 spec->unsol_event(codec, res);
2318}
2319
Takashi Iwaicb53c622007-08-10 17:21:45 +02002320#ifdef CONFIG_SND_HDA_POWER_SAVE
2321static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2322{
2323 struct alc_spec *spec = codec->spec;
2324 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2325}
2326#endif
2327
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328/*
2329 * Analog playback callbacks
2330 */
2331static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2332 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002333 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334{
2335 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002336 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2337 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338}
2339
2340static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
2342 unsigned int stream_tag,
2343 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002344 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345{
2346 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002347 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2348 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349}
2350
2351static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002353 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354{
2355 struct alc_spec *spec = codec->spec;
2356 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2357}
2358
2359/*
2360 * Digital out
2361 */
2362static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2363 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365{
2366 struct alc_spec *spec = codec->spec;
2367 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2368}
2369
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002370static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2371 struct hda_codec *codec,
2372 unsigned int stream_tag,
2373 unsigned int format,
2374 struct snd_pcm_substream *substream)
2375{
2376 struct alc_spec *spec = codec->spec;
2377 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2378 stream_tag, format, substream);
2379}
2380
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2382 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384{
2385 struct alc_spec *spec = codec->spec;
2386 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2387}
2388
2389/*
2390 * Analog capture
2391 */
Takashi Iwai63300792008-01-24 15:31:36 +01002392static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 struct hda_codec *codec,
2394 unsigned int stream_tag,
2395 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002396 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397{
2398 struct alc_spec *spec = codec->spec;
2399
Takashi Iwai63300792008-01-24 15:31:36 +01002400 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 stream_tag, 0, format);
2402 return 0;
2403}
2404
Takashi Iwai63300792008-01-24 15:31:36 +01002405static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002407 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408{
2409 struct alc_spec *spec = codec->spec;
2410
Takashi Iwai63300792008-01-24 15:31:36 +01002411 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002412 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 return 0;
2414}
2415
2416
2417/*
2418 */
2419static struct hda_pcm_stream alc880_pcm_analog_playback = {
2420 .substreams = 1,
2421 .channels_min = 2,
2422 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002423 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 .ops = {
2425 .open = alc880_playback_pcm_open,
2426 .prepare = alc880_playback_pcm_prepare,
2427 .cleanup = alc880_playback_pcm_cleanup
2428 },
2429};
2430
2431static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002432 .substreams = 1,
2433 .channels_min = 2,
2434 .channels_max = 2,
2435 /* NID is set in alc_build_pcms */
2436};
2437
2438static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2439 .substreams = 1,
2440 .channels_min = 2,
2441 .channels_max = 2,
2442 /* NID is set in alc_build_pcms */
2443};
2444
2445static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2446 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 .channels_min = 2,
2448 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002451 .prepare = alc880_alt_capture_pcm_prepare,
2452 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 },
2454};
2455
2456static struct hda_pcm_stream alc880_pcm_digital_playback = {
2457 .substreams = 1,
2458 .channels_min = 2,
2459 .channels_max = 2,
2460 /* NID is set in alc_build_pcms */
2461 .ops = {
2462 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002463 .close = alc880_dig_playback_pcm_close,
2464 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 },
2466};
2467
2468static struct hda_pcm_stream alc880_pcm_digital_capture = {
2469 .substreams = 1,
2470 .channels_min = 2,
2471 .channels_max = 2,
2472 /* NID is set in alc_build_pcms */
2473};
2474
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002475/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002476static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002477 .substreams = 0,
2478 .channels_min = 0,
2479 .channels_max = 0,
2480};
2481
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482static int alc_build_pcms(struct hda_codec *codec)
2483{
2484 struct alc_spec *spec = codec->spec;
2485 struct hda_pcm *info = spec->pcm_rec;
2486 int i;
2487
2488 codec->num_pcms = 1;
2489 codec->pcm_info = info;
2490
2491 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002492 if (spec->stream_analog_playback) {
2493 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2496 }
2497 if (spec->stream_analog_capture) {
2498 snd_assert(spec->adc_nids, return -EINVAL);
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2500 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2501 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502
Takashi Iwai4a471b72005-12-07 13:56:29 +01002503 if (spec->channel_mode) {
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2505 for (i = 0; i < spec->num_channel_mode; i++) {
2506 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2507 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2508 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 }
2510 }
2511
Takashi Iwaie08a0072006-09-07 17:52:14 +02002512 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002514 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002515 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002517 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002518 if (spec->multiout.dig_out_nid &&
2519 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2521 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2522 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002523 if (spec->dig_in_nid &&
2524 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2526 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2527 }
2528 }
2529
Takashi Iwaie08a0072006-09-07 17:52:14 +02002530 /* If the use of more than one ADC is requested for the current
2531 * model, configure a second analog capture-only PCM.
2532 */
2533 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002534 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2535 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002536 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002537 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002538 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002539 if (spec->alt_dac_nid) {
2540 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2541 *spec->stream_analog_alt_playback;
2542 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2543 spec->alt_dac_nid;
2544 } else {
2545 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2546 alc_pcm_null_stream;
2547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2548 }
2549 if (spec->num_adc_nids > 1) {
2550 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2551 *spec->stream_analog_alt_capture;
2552 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2553 spec->adc_nids[1];
2554 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2555 spec->num_adc_nids - 1;
2556 } else {
2557 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2558 alc_pcm_null_stream;
2559 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002560 }
2561 }
2562
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 return 0;
2564}
2565
2566static void alc_free(struct hda_codec *codec)
2567{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 struct alc_spec *spec = codec->spec;
2569 unsigned int i;
2570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002571 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002572 return;
2573
2574 if (spec->kctl_alloc) {
2575 for (i = 0; i < spec->num_kctl_used; i++)
2576 kfree(spec->kctl_alloc[i].name);
2577 kfree(spec->kctl_alloc);
2578 }
2579 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580}
2581
2582/*
2583 */
2584static struct hda_codec_ops alc_patch_ops = {
2585 .build_controls = alc_build_controls,
2586 .build_pcms = alc_build_pcms,
2587 .init = alc_init,
2588 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002589 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002590#ifdef CONFIG_SND_HDA_POWER_SAVE
2591 .check_power_status = alc_check_power_status,
2592#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593};
2594
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002595
2596/*
2597 * Test configuration for debugging
2598 *
2599 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2600 * enum controls.
2601 */
2602#ifdef CONFIG_SND_DEBUG
2603static hda_nid_t alc880_test_dac_nids[4] = {
2604 0x02, 0x03, 0x04, 0x05
2605};
2606
2607static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002608 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002609 .items = {
2610 { "In-1", 0x0 },
2611 { "In-2", 0x1 },
2612 { "In-3", 0x2 },
2613 { "In-4", 0x3 },
2614 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002615 { "Front", 0x5 },
2616 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002617 },
2618};
2619
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002620static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002621 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002622 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002623 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002624 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002625};
2626
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002627static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2628 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002629{
2630 static char *texts[] = {
2631 "N/A", "Line Out", "HP Out",
2632 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2633 };
2634 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2635 uinfo->count = 1;
2636 uinfo->value.enumerated.items = 8;
2637 if (uinfo->value.enumerated.item >= 8)
2638 uinfo->value.enumerated.item = 7;
2639 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2640 return 0;
2641}
2642
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002643static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2644 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002645{
2646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2647 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2648 unsigned int pin_ctl, item = 0;
2649
2650 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2651 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2652 if (pin_ctl & AC_PINCTL_OUT_EN) {
2653 if (pin_ctl & AC_PINCTL_HP_EN)
2654 item = 2;
2655 else
2656 item = 1;
2657 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2658 switch (pin_ctl & AC_PINCTL_VREFEN) {
2659 case AC_PINCTL_VREF_HIZ: item = 3; break;
2660 case AC_PINCTL_VREF_50: item = 4; break;
2661 case AC_PINCTL_VREF_GRD: item = 5; break;
2662 case AC_PINCTL_VREF_80: item = 6; break;
2663 case AC_PINCTL_VREF_100: item = 7; break;
2664 }
2665 }
2666 ucontrol->value.enumerated.item[0] = item;
2667 return 0;
2668}
2669
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002670static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2671 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002672{
2673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2674 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2675 static unsigned int ctls[] = {
2676 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2677 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2678 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2679 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2680 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2681 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2682 };
2683 unsigned int old_ctl, new_ctl;
2684
2685 old_ctl = snd_hda_codec_read(codec, nid, 0,
2686 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2687 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2688 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002689 int val;
2690 snd_hda_codec_write_cache(codec, nid, 0,
2691 AC_VERB_SET_PIN_WIDGET_CONTROL,
2692 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002693 val = ucontrol->value.enumerated.item[0] >= 3 ?
2694 HDA_AMP_MUTE : 0;
2695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2696 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002697 return 1;
2698 }
2699 return 0;
2700}
2701
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002702static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2703 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002704{
2705 static char *texts[] = {
2706 "Front", "Surround", "CLFE", "Side"
2707 };
2708 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2709 uinfo->count = 1;
2710 uinfo->value.enumerated.items = 4;
2711 if (uinfo->value.enumerated.item >= 4)
2712 uinfo->value.enumerated.item = 3;
2713 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2714 return 0;
2715}
2716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002717static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2718 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002719{
2720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2721 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2722 unsigned int sel;
2723
2724 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2725 ucontrol->value.enumerated.item[0] = sel & 3;
2726 return 0;
2727}
2728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002729static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2730 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002731{
2732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2733 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2734 unsigned int sel;
2735
2736 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2737 if (ucontrol->value.enumerated.item[0] != sel) {
2738 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002739 snd_hda_codec_write_cache(codec, nid, 0,
2740 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002741 return 1;
2742 }
2743 return 0;
2744}
2745
2746#define PIN_CTL_TEST(xname,nid) { \
2747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2748 .name = xname, \
2749 .info = alc_test_pin_ctl_info, \
2750 .get = alc_test_pin_ctl_get, \
2751 .put = alc_test_pin_ctl_put, \
2752 .private_value = nid \
2753 }
2754
2755#define PIN_SRC_TEST(xname,nid) { \
2756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2757 .name = xname, \
2758 .info = alc_test_pin_src_info, \
2759 .get = alc_test_pin_src_get, \
2760 .put = alc_test_pin_src_put, \
2761 .private_value = nid \
2762 }
2763
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002764static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002765 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2766 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2767 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2770 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2771 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002773 PIN_CTL_TEST("Front Pin Mode", 0x14),
2774 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2775 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2776 PIN_CTL_TEST("Side Pin Mode", 0x17),
2777 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2778 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2779 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2780 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2781 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2782 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2783 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2784 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2785 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2786 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2787 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2788 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2789 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2790 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2791 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2792 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002795 {
2796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2797 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002798 .info = alc_ch_mode_info,
2799 .get = alc_ch_mode_get,
2800 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002801 },
2802 { } /* end */
2803};
2804
2805static struct hda_verb alc880_test_init_verbs[] = {
2806 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002815 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002820 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2823 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2824 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002825 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002830 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002831 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2832 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2834 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2835 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002836 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002841 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002843 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002845 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002847 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002848 /* Analog input/passthru */
2849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002854 { }
2855};
2856#endif
2857
Linus Torvalds1da177e2005-04-16 15:20:36 -07002858/*
2859 */
2860
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002861static const char *alc880_models[ALC880_MODEL_LAST] = {
2862 [ALC880_3ST] = "3stack",
2863 [ALC880_TCL_S700] = "tcl",
2864 [ALC880_3ST_DIG] = "3stack-digout",
2865 [ALC880_CLEVO] = "clevo",
2866 [ALC880_5ST] = "5stack",
2867 [ALC880_5ST_DIG] = "5stack-digout",
2868 [ALC880_W810] = "w810",
2869 [ALC880_Z71V] = "z71v",
2870 [ALC880_6ST] = "6stack",
2871 [ALC880_6ST_DIG] = "6stack-digout",
2872 [ALC880_ASUS] = "asus",
2873 [ALC880_ASUS_W1V] = "asus-w1v",
2874 [ALC880_ASUS_DIG] = "asus-dig",
2875 [ALC880_ASUS_DIG2] = "asus-dig2",
2876 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002877 [ALC880_UNIWILL_P53] = "uniwill-p53",
2878 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002879 [ALC880_F1734] = "F1734",
2880 [ALC880_LG] = "lg",
2881 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002882#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002883 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002884#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002885 [ALC880_AUTO] = "auto",
2886};
2887
2888static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002889 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002890 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2891 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2892 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2893 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2894 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2895 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2896 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2897 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002898 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2899 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002900 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2901 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2902 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2903 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2904 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2905 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2906 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2907 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2908 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2909 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002910 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002911 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2912 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2913 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002914 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002915 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002916 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2917 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002918 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2919 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002920 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2921 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2922 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2923 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002924 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2925 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002926 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002927 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002928 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002929 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002930 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2931 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002932 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2933 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002934 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002935 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002936 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002937 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002938 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002939 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2940 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002941 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002942 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2943 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2944 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2945 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002946 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2947 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002948 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002949 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002950 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2951 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002952 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2953 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2954 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002955 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2956 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2957 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 {}
2959};
2960
Takashi Iwai16ded522005-06-10 19:58:24 +02002961/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002962 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002963 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002964static struct alc_config_preset alc880_presets[] = {
2965 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002967 .init_verbs = { alc880_volume_init_verbs,
2968 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002969 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002971 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2972 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002973 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002974 .input_mux = &alc880_capture_source,
2975 },
2976 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002978 .init_verbs = { alc880_volume_init_verbs,
2979 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002980 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 .dac_nids = alc880_dac_nids,
2982 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2984 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002985 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002986 .input_mux = &alc880_capture_source,
2987 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002988 [ALC880_TCL_S700] = {
2989 .mixers = { alc880_tcl_s700_mixer },
2990 .init_verbs = { alc880_volume_init_verbs,
2991 alc880_pin_tcl_S700_init_verbs,
2992 alc880_gpio2_init_verbs },
2993 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2994 .dac_nids = alc880_dac_nids,
2995 .hp_nid = 0x03,
2996 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2997 .channel_mode = alc880_2_jack_modes,
2998 .input_mux = &alc880_capture_source,
2999 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003001 .mixers = { alc880_three_stack_mixer,
3002 alc880_five_stack_mixer},
3003 .init_verbs = { alc880_volume_init_verbs,
3004 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003005 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3006 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003007 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3008 .channel_mode = alc880_fivestack_modes,
3009 .input_mux = &alc880_capture_source,
3010 },
3011 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003012 .mixers = { alc880_three_stack_mixer,
3013 alc880_five_stack_mixer },
3014 .init_verbs = { alc880_volume_init_verbs,
3015 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003016 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3017 .dac_nids = alc880_dac_nids,
3018 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003019 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3020 .channel_mode = alc880_fivestack_modes,
3021 .input_mux = &alc880_capture_source,
3022 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003023 [ALC880_6ST] = {
3024 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003025 .init_verbs = { alc880_volume_init_verbs,
3026 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003027 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3028 .dac_nids = alc880_6st_dac_nids,
3029 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3030 .channel_mode = alc880_sixstack_modes,
3031 .input_mux = &alc880_6stack_capture_source,
3032 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003033 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003035 .init_verbs = { alc880_volume_init_verbs,
3036 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003037 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3038 .dac_nids = alc880_6st_dac_nids,
3039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003040 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3041 .channel_mode = alc880_sixstack_modes,
3042 .input_mux = &alc880_6stack_capture_source,
3043 },
3044 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003046 .init_verbs = { alc880_volume_init_verbs,
3047 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003048 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3050 .dac_nids = alc880_w810_dac_nids,
3051 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003052 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3053 .channel_mode = alc880_w810_modes,
3054 .input_mux = &alc880_capture_source,
3055 },
3056 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 .init_verbs = { alc880_volume_init_verbs,
3059 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3061 .dac_nids = alc880_z71v_dac_nids,
3062 .dig_out_nid = ALC880_DIGOUT_NID,
3063 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3065 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003066 .input_mux = &alc880_capture_source,
3067 },
3068 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003070 .init_verbs = { alc880_volume_init_verbs,
3071 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3073 .dac_nids = alc880_f1734_dac_nids,
3074 .hp_nid = 0x02,
3075 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3076 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003077 .input_mux = &alc880_f1734_capture_source,
3078 .unsol_event = alc880_uniwill_p53_unsol_event,
3079 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003080 },
3081 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003083 .init_verbs = { alc880_volume_init_verbs,
3084 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 alc880_gpio1_init_verbs },
3086 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3087 .dac_nids = alc880_asus_dac_nids,
3088 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3089 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003090 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003091 .input_mux = &alc880_capture_source,
3092 },
3093 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003095 .init_verbs = { alc880_volume_init_verbs,
3096 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 alc880_gpio1_init_verbs },
3098 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3099 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003100 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3102 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003103 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003104 .input_mux = &alc880_capture_source,
3105 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003106 [ALC880_ASUS_DIG2] = {
3107 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003108 .init_verbs = { alc880_volume_init_verbs,
3109 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003110 alc880_gpio2_init_verbs }, /* use GPIO2 */
3111 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3112 .dac_nids = alc880_asus_dac_nids,
3113 .dig_out_nid = ALC880_DIGOUT_NID,
3114 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3115 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003116 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 .input_mux = &alc880_capture_source,
3118 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 .init_verbs = { alc880_volume_init_verbs,
3122 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003123 alc880_gpio1_init_verbs },
3124 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3125 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003126 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3128 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003129 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 .input_mux = &alc880_capture_source,
3131 },
3132 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003133 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003134 .init_verbs = { alc880_volume_init_verbs,
3135 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3137 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3140 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003141 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003142 .input_mux = &alc880_capture_source,
3143 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003144 [ALC880_UNIWILL] = {
3145 .mixers = { alc880_uniwill_mixer },
3146 .init_verbs = { alc880_volume_init_verbs,
3147 alc880_uniwill_init_verbs },
3148 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3149 .dac_nids = alc880_asus_dac_nids,
3150 .dig_out_nid = ALC880_DIGOUT_NID,
3151 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3152 .channel_mode = alc880_threestack_modes,
3153 .need_dac_fix = 1,
3154 .input_mux = &alc880_capture_source,
3155 .unsol_event = alc880_uniwill_unsol_event,
3156 .init_hook = alc880_uniwill_automute,
3157 },
3158 [ALC880_UNIWILL_P53] = {
3159 .mixers = { alc880_uniwill_p53_mixer },
3160 .init_verbs = { alc880_volume_init_verbs,
3161 alc880_uniwill_p53_init_verbs },
3162 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3163 .dac_nids = alc880_asus_dac_nids,
3164 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003165 .channel_mode = alc880_threestack_modes,
3166 .input_mux = &alc880_capture_source,
3167 .unsol_event = alc880_uniwill_p53_unsol_event,
3168 .init_hook = alc880_uniwill_p53_hp_automute,
3169 },
3170 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003171 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003172 alc880_pcbeep_mixer, },
3173 .init_verbs = { alc880_volume_init_verbs,
3174 alc880_uniwill_p53_init_verbs,
3175 alc880_beep_init_verbs },
3176 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3177 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003178 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003179 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3180 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003181 .input_mux = &alc880_capture_source,
3182 .unsol_event = alc880_uniwill_p53_unsol_event,
3183 .init_hook = alc880_uniwill_p53_hp_automute,
3184 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003185 [ALC880_CLEVO] = {
3186 .mixers = { alc880_three_stack_mixer },
3187 .init_verbs = { alc880_volume_init_verbs,
3188 alc880_pin_clevo_init_verbs },
3189 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3190 .dac_nids = alc880_dac_nids,
3191 .hp_nid = 0x03,
3192 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3193 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003194 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003195 .input_mux = &alc880_capture_source,
3196 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003197 [ALC880_LG] = {
3198 .mixers = { alc880_lg_mixer },
3199 .init_verbs = { alc880_volume_init_verbs,
3200 alc880_lg_init_verbs },
3201 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3202 .dac_nids = alc880_lg_dac_nids,
3203 .dig_out_nid = ALC880_DIGOUT_NID,
3204 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3205 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003206 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003207 .input_mux = &alc880_lg_capture_source,
3208 .unsol_event = alc880_lg_unsol_event,
3209 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003210#ifdef CONFIG_SND_HDA_POWER_SAVE
3211 .loopbacks = alc880_lg_loopbacks,
3212#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003213 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003214 [ALC880_LG_LW] = {
3215 .mixers = { alc880_lg_lw_mixer },
3216 .init_verbs = { alc880_volume_init_verbs,
3217 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003218 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 .dac_nids = alc880_dac_nids,
3220 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003221 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3222 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003223 .input_mux = &alc880_lg_lw_capture_source,
3224 .unsol_event = alc880_lg_lw_unsol_event,
3225 .init_hook = alc880_lg_lw_automute,
3226 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003227#ifdef CONFIG_SND_DEBUG
3228 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229 .mixers = { alc880_test_mixer },
3230 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003231 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3232 .dac_nids = alc880_test_dac_nids,
3233 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003234 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3235 .channel_mode = alc880_test_modes,
3236 .input_mux = &alc880_test_capture_source,
3237 },
3238#endif
3239};
3240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241/*
3242 * Automatic parse of I/O pins from the BIOS configuration
3243 */
3244
3245#define NUM_CONTROL_ALLOC 32
3246#define NUM_VERB_ALLOC 32
3247
3248enum {
3249 ALC_CTL_WIDGET_VOL,
3250 ALC_CTL_WIDGET_MUTE,
3251 ALC_CTL_BIND_MUTE,
3252};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003253static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3255 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003256 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257};
3258
3259/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003260static int add_control(struct alc_spec *spec, int type, const char *name,
3261 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003263 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264
3265 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3266 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3267
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003268 /* array + terminator */
3269 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3270 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271 return -ENOMEM;
3272 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 memcpy(knew, spec->kctl_alloc,
3274 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 kfree(spec->kctl_alloc);
3276 }
3277 spec->kctl_alloc = knew;
3278 spec->num_kctl_alloc = num;
3279 }
3280
3281 knew = &spec->kctl_alloc[spec->num_kctl_used];
3282 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003283 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003284 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 return -ENOMEM;
3286 knew->private_value = val;
3287 spec->num_kctl_used++;
3288 return 0;
3289}
3290
3291#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3292#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3293#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3294#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3295#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3296#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3297#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3298#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3299#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3300#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3301#define ALC880_PIN_CD_NID 0x1c
3302
3303/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003304static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3305 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003306{
3307 hda_nid_t nid;
3308 int assigned[4];
3309 int i, j;
3310
3311 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003312 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313
3314 /* check the pins hardwired to audio widget */
3315 for (i = 0; i < cfg->line_outs; i++) {
3316 nid = cfg->line_out_pins[i];
3317 if (alc880_is_fixed_pin(nid)) {
3318 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003319 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 assigned[idx] = 1;
3321 }
3322 }
3323 /* left pins can be connect to any audio widget */
3324 for (i = 0; i < cfg->line_outs; i++) {
3325 nid = cfg->line_out_pins[i];
3326 if (alc880_is_fixed_pin(nid))
3327 continue;
3328 /* search for an empty channel */
3329 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003330 if (!assigned[j]) {
3331 spec->multiout.dac_nids[i] =
3332 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003333 assigned[j] = 1;
3334 break;
3335 }
3336 }
3337 }
3338 spec->multiout.num_dacs = cfg->line_outs;
3339 return 0;
3340}
3341
3342/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003343static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3344 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003345{
3346 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003347 static const char *chname[4] = {
3348 "Front", "Surround", NULL /*CLFE*/, "Side"
3349 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 hda_nid_t nid;
3351 int i, err;
3352
3353 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 continue;
3356 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3357 if (i == 2) {
3358 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003359 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3360 "Center Playback Volume",
3361 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3362 HDA_OUTPUT));
3363 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003365 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3366 "LFE Playback Volume",
3367 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003371 err = add_control(spec, ALC_CTL_BIND_MUTE,
3372 "Center Playback Switch",
3373 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3374 HDA_INPUT));
3375 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003377 err = add_control(spec, ALC_CTL_BIND_MUTE,
3378 "LFE Playback Switch",
3379 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3380 HDA_INPUT));
3381 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382 return err;
3383 } else {
3384 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003385 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3386 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3387 HDA_OUTPUT));
3388 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 return err;
3390 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003391 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3392 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3393 HDA_INPUT));
3394 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 return err;
3396 }
3397 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 return 0;
3399}
3400
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003401/* add playback controls for speaker and HP outputs */
3402static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3403 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404{
3405 hda_nid_t nid;
3406 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003407 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003409 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410 return 0;
3411
3412 if (alc880_is_fixed_pin(pin)) {
3413 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003414 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003415 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003417 else
3418 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 /* control HP volume/switch on the output mixer amp */
3420 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003421 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003422 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3424 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003425 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003426 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003427 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3428 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3429 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 return err;
3431 } else if (alc880_is_multi_pin(pin)) {
3432 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003434 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003435 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3436 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3437 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 return err;
3439 }
3440 return 0;
3441}
3442
3443/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003444static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3445 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003446 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447{
3448 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003449 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003450
3451 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3453 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3454 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455 return err;
3456 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003457 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3458 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3459 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460 return err;
3461 return 0;
3462}
3463
3464/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003465static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3466 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003467{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003469 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470
3471 for (i = 0; i < AUTO_PIN_LAST; i++) {
3472 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003473 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003474 err = new_analog_input(spec, cfg->input_pins[i],
3475 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003476 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003477 if (err < 0)
3478 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003479 imux->items[imux->num_items].label =
3480 auto_pin_cfg_labels[i];
3481 imux->items[imux->num_items].index =
3482 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 imux->num_items++;
3484 }
3485 }
3486 return 0;
3487}
3488
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003489static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3490 unsigned int pin_type)
3491{
3492 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3493 pin_type);
3494 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003495 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3496 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003497}
3498
Kailang Yangdf694da2005-12-05 19:42:22 +01003499static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3500 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 int dac_idx)
3502{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003503 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003504 /* need the manual connection? */
3505 if (alc880_is_multi_pin(nid)) {
3506 struct alc_spec *spec = codec->spec;
3507 int idx = alc880_multi_pin_idx(nid);
3508 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3509 AC_VERB_SET_CONNECT_SEL,
3510 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3511 }
3512}
3513
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003514static int get_pin_type(int line_out_type)
3515{
3516 if (line_out_type == AUTO_PIN_HP_OUT)
3517 return PIN_HP;
3518 else
3519 return PIN_OUT;
3520}
3521
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522static void alc880_auto_init_multi_out(struct hda_codec *codec)
3523{
3524 struct alc_spec *spec = codec->spec;
3525 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003526
3527 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003528 for (i = 0; i < spec->autocfg.line_outs; i++) {
3529 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003530 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3531 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003532 }
3533}
3534
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003535static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003536{
3537 struct alc_spec *spec = codec->spec;
3538 hda_nid_t pin;
3539
Takashi Iwai82bc9552006-03-21 11:24:42 +01003540 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003541 if (pin) /* connect to front */
3542 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003543 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 if (pin) /* connect to front */
3545 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3546}
3547
3548static void alc880_auto_init_analog_input(struct hda_codec *codec)
3549{
3550 struct alc_spec *spec = codec->spec;
3551 int i;
3552
3553 for (i = 0; i < AUTO_PIN_LAST; i++) {
3554 hda_nid_t nid = spec->autocfg.input_pins[i];
3555 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003556 snd_hda_codec_write(codec, nid, 0,
3557 AC_VERB_SET_PIN_WIDGET_CONTROL,
3558 i <= AUTO_PIN_FRONT_MIC ?
3559 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003560 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003561 snd_hda_codec_write(codec, nid, 0,
3562 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563 AMP_OUT_MUTE);
3564 }
3565 }
3566}
3567
3568/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003569/* return 1 if successful, 0 if the proper config is not found,
3570 * or a negative error code
3571 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572static int alc880_parse_auto_config(struct hda_codec *codec)
3573{
3574 struct alc_spec *spec = codec->spec;
3575 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003576 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003578 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3579 alc880_ignore);
3580 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003581 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003582 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003583 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003584
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003585 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3586 if (err < 0)
3587 return err;
3588 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3589 if (err < 0)
3590 return err;
3591 err = alc880_auto_create_extra_out(spec,
3592 spec->autocfg.speaker_pins[0],
3593 "Speaker");
3594 if (err < 0)
3595 return err;
3596 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3597 "Headphone");
3598 if (err < 0)
3599 return err;
3600 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3601 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602 return err;
3603
3604 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3605
3606 if (spec->autocfg.dig_out_pin)
3607 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3608 if (spec->autocfg.dig_in_pin)
3609 spec->dig_in_nid = ALC880_DIGIN_NID;
3610
3611 if (spec->kctl_alloc)
3612 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3613
3614 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3615
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003616 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003617 spec->input_mux = &spec->private_imux;
3618
3619 return 1;
3620}
3621
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003622/* additional initialization for auto-configuration model */
3623static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003624{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003625 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003626 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003627 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003629 if (spec->unsol_event)
3630 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003631}
3632
3633/*
3634 * OK, here we have finally the patch for ALC880
3635 */
3636
Linus Torvalds1da177e2005-04-16 15:20:36 -07003637static int patch_alc880(struct hda_codec *codec)
3638{
3639 struct alc_spec *spec;
3640 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003641 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003642
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003643 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644 if (spec == NULL)
3645 return -ENOMEM;
3646
3647 codec->spec = spec;
3648
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003649 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3650 alc880_models,
3651 alc880_cfg_tbl);
3652 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003653 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3654 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003655 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656 }
3657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003658 if (board_config == ALC880_AUTO) {
3659 /* automatic parse from the BIOS config */
3660 err = alc880_parse_auto_config(codec);
3661 if (err < 0) {
3662 alc_free(codec);
3663 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003665 printk(KERN_INFO
3666 "hda_codec: Cannot set up configuration "
3667 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003668 board_config = ALC880_3ST;
3669 }
3670 }
3671
Kailang Yangdf694da2005-12-05 19:42:22 +01003672 if (board_config != ALC880_AUTO)
3673 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674
3675 spec->stream_name_analog = "ALC880 Analog";
3676 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3677 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003678 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003679
3680 spec->stream_name_digital = "ALC880 Digital";
3681 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3682 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3683
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003684 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003685 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003686 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003687 /* get type */
3688 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003689 if (wcap != AC_WID_AUD_IN) {
3690 spec->adc_nids = alc880_adc_nids_alt;
3691 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003692 spec->mixers[spec->num_mixers] =
3693 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003694 spec->num_mixers++;
3695 } else {
3696 spec->adc_nids = alc880_adc_nids;
3697 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3698 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3699 spec->num_mixers++;
3700 }
3701 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702
Takashi Iwai2134ea42008-01-10 16:53:55 +01003703 spec->vmaster_nid = 0x0c;
3704
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003706 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003707 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003708#ifdef CONFIG_SND_HDA_POWER_SAVE
3709 if (!spec->loopback.amplist)
3710 spec->loopback.amplist = alc880_loopbacks;
3711#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712
3713 return 0;
3714}
3715
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717/*
3718 * ALC260 support
3719 */
3720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721static hda_nid_t alc260_dac_nids[1] = {
3722 /* front */
3723 0x02,
3724};
3725
3726static hda_nid_t alc260_adc_nids[1] = {
3727 /* ADC0 */
3728 0x04,
3729};
3730
Kailang Yangdf694da2005-12-05 19:42:22 +01003731static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732 /* ADC1 */
3733 0x05,
3734};
3735
Kailang Yangdf694da2005-12-05 19:42:22 +01003736static hda_nid_t alc260_hp_adc_nids[2] = {
3737 /* ADC1, 0 */
3738 0x05, 0x04
3739};
3740
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003741/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3742 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3743 */
3744static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003745 /* ADC0, ADC1 */
3746 0x04, 0x05
3747};
3748
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003749#define ALC260_DIGOUT_NID 0x03
3750#define ALC260_DIGIN_NID 0x06
3751
3752static struct hda_input_mux alc260_capture_source = {
3753 .num_items = 4,
3754 .items = {
3755 { "Mic", 0x0 },
3756 { "Front Mic", 0x1 },
3757 { "Line", 0x2 },
3758 { "CD", 0x4 },
3759 },
3760};
3761
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003762/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003763 * headphone jack and the internal CD lines since these are the only pins at
3764 * which audio can appear. For flexibility, also allow the option of
3765 * recording the mixer output on the second ADC (ADC0 doesn't have a
3766 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003767 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003768static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3769 {
3770 .num_items = 3,
3771 .items = {
3772 { "Mic/Line", 0x0 },
3773 { "CD", 0x4 },
3774 { "Headphone", 0x2 },
3775 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003776 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003777 {
3778 .num_items = 4,
3779 .items = {
3780 { "Mic/Line", 0x0 },
3781 { "CD", 0x4 },
3782 { "Headphone", 0x2 },
3783 { "Mixer", 0x5 },
3784 },
3785 },
3786
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003787};
3788
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003789/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3790 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003791 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003792static struct hda_input_mux alc260_acer_capture_sources[2] = {
3793 {
3794 .num_items = 4,
3795 .items = {
3796 { "Mic", 0x0 },
3797 { "Line", 0x2 },
3798 { "CD", 0x4 },
3799 { "Headphone", 0x5 },
3800 },
3801 },
3802 {
3803 .num_items = 5,
3804 .items = {
3805 { "Mic", 0x0 },
3806 { "Line", 0x2 },
3807 { "CD", 0x4 },
3808 { "Headphone", 0x6 },
3809 { "Mixer", 0x5 },
3810 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003811 },
3812};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003813/*
3814 * This is just place-holder, so there's something for alc_build_pcms to look
3815 * at when it calculates the maximum number of channels. ALC260 has no mixer
3816 * element which allows changing the channel mode, so the verb list is
3817 * never used.
3818 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003819static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003820 { 2, NULL },
3821};
3822
Kailang Yangdf694da2005-12-05 19:42:22 +01003823
3824/* Mixer combinations
3825 *
3826 * basic: base_output + input + pc_beep + capture
3827 * HP: base_output + input + capture_alt
3828 * HP_3013: hp_3013 + input + capture
3829 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003830 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003831 */
3832
3833static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003834 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003835 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003836 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3837 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3838 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3839 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3840 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003841};
Kailang Yangdf694da2005-12-05 19:42:22 +01003842
3843static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003844 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3845 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3846 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3847 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3849 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003852 { } /* end */
3853};
3854
Kailang Yangdf694da2005-12-05 19:42:22 +01003855static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3856 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3857 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3858 { } /* end */
3859};
3860
Takashi Iwaibec15c32008-01-28 18:16:30 +01003861/* update HP, line and mono out pins according to the master switch */
3862static void alc260_hp_master_update(struct hda_codec *codec,
3863 hda_nid_t hp, hda_nid_t line,
3864 hda_nid_t mono)
3865{
3866 struct alc_spec *spec = codec->spec;
3867 unsigned int val = spec->master_sw ? PIN_HP : 0;
3868 /* change HP and line-out pins */
3869 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3870 val);
3871 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3872 val);
3873 /* mono (speaker) depending on the HP jack sense */
3874 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3875 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3876 val);
3877}
3878
3879static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3880 struct snd_ctl_elem_value *ucontrol)
3881{
3882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3883 struct alc_spec *spec = codec->spec;
3884 *ucontrol->value.integer.value = spec->master_sw;
3885 return 0;
3886}
3887
3888static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3889 struct snd_ctl_elem_value *ucontrol)
3890{
3891 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3892 struct alc_spec *spec = codec->spec;
3893 int val = !!*ucontrol->value.integer.value;
3894 hda_nid_t hp, line, mono;
3895
3896 if (val == spec->master_sw)
3897 return 0;
3898 spec->master_sw = val;
3899 hp = (kcontrol->private_value >> 16) & 0xff;
3900 line = (kcontrol->private_value >> 8) & 0xff;
3901 mono = kcontrol->private_value & 0xff;
3902 alc260_hp_master_update(codec, hp, line, mono);
3903 return 1;
3904}
3905
3906static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3907 {
3908 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3909 .name = "Master Playback Switch",
3910 .info = snd_ctl_boolean_mono_info,
3911 .get = alc260_hp_master_sw_get,
3912 .put = alc260_hp_master_sw_put,
3913 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3914 },
3915 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3916 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3918 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3919 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3920 HDA_OUTPUT),
3921 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3922 { } /* end */
3923};
3924
3925static struct hda_verb alc260_hp_unsol_verbs[] = {
3926 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3927 {},
3928};
3929
3930static void alc260_hp_automute(struct hda_codec *codec)
3931{
3932 struct alc_spec *spec = codec->spec;
3933 unsigned int present;
3934
3935 present = snd_hda_codec_read(codec, 0x10, 0,
3936 AC_VERB_GET_PIN_SENSE, 0);
3937 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3938 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3939}
3940
3941static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3942{
3943 if ((res >> 26) == ALC880_HP_EVENT)
3944 alc260_hp_automute(codec);
3945}
3946
Kailang Yangdf694da2005-12-05 19:42:22 +01003947static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01003948 {
3949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3950 .name = "Master Playback Switch",
3951 .info = snd_ctl_boolean_mono_info,
3952 .get = alc260_hp_master_sw_get,
3953 .put = alc260_hp_master_sw_put,
3954 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3955 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003956 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3957 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3958 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3959 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01003962 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3963 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003964 { } /* end */
3965};
3966
Takashi Iwaibec15c32008-01-28 18:16:30 +01003967static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3969 {},
3970};
3971
3972static void alc260_hp_3013_automute(struct hda_codec *codec)
3973{
3974 struct alc_spec *spec = codec->spec;
3975 unsigned int present;
3976
3977 present = snd_hda_codec_read(codec, 0x15, 0,
3978 AC_VERB_GET_PIN_SENSE, 0);
3979 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3980 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3981}
3982
3983static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3984 unsigned int res)
3985{
3986 if ((res >> 26) == ALC880_HP_EVENT)
3987 alc260_hp_3013_automute(codec);
3988}
3989
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003990/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3991 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3992 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003993static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003994 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003995 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003996 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003997 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3998 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3999 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4000 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004001 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004002 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4003 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4005 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004006 { } /* end */
4007};
4008
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004009/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4010 * versions of the ALC260 don't act on requests to enable mic bias from NID
4011 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4012 * datasheet doesn't mention this restriction. At this stage it's not clear
4013 * whether this behaviour is intentional or is a hardware bug in chip
4014 * revisions available in early 2006. Therefore for now allow the
4015 * "Headphone Jack Mode" control to span all choices, but if it turns out
4016 * that the lack of mic bias for this NID is intentional we could change the
4017 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4018 *
4019 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4020 * don't appear to make the mic bias available from the "line" jack, even
4021 * though the NID used for this jack (0x14) can supply it. The theory is
4022 * that perhaps Acer have included blocking capacitors between the ALC260
4023 * and the output jack. If this turns out to be the case for all such
4024 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4025 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004026 *
4027 * The C20x Tablet series have a mono internal speaker which is controlled
4028 * via the chip's Mono sum widget and pin complex, so include the necessary
4029 * controls for such models. On models without a "mono speaker" the control
4030 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004031 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004032static struct snd_kcontrol_new alc260_acer_mixer[] = {
4033 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4034 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004035 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004036 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004037 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004038 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004039 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004040 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4041 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4043 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4044 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4045 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4046 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4047 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4048 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4049 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4050 { } /* end */
4051};
4052
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004053/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4054 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4055 */
4056static struct snd_kcontrol_new alc260_will_mixer[] = {
4057 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4058 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4060 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4061 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4062 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4063 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4064 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4065 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4066 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4067 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4068 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4069 { } /* end */
4070};
4071
4072/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4073 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4074 */
4075static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4076 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4077 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4079 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4080 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4081 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4082 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4083 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4084 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4085 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4086 { } /* end */
4087};
4088
Kailang Yangdf694da2005-12-05 19:42:22 +01004089/* capture mixer elements */
4090static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004091 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4092 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004093 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4094 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004095 {
4096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004097 /* The multiple "Capture Source" controls confuse alsamixer
4098 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004099 */
4100 /* .name = "Capture Source", */
4101 .name = "Input Source",
4102 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004103 .info = alc_mux_enum_info,
4104 .get = alc_mux_enum_get,
4105 .put = alc_mux_enum_put,
4106 },
4107 { } /* end */
4108};
4109
Kailang Yangdf694da2005-12-05 19:42:22 +01004110static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4111 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4112 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4113 {
4114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4115 /* The multiple "Capture Source" controls confuse alsamixer
4116 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004117 */
4118 /* .name = "Capture Source", */
4119 .name = "Input Source",
4120 .count = 1,
4121 .info = alc_mux_enum_info,
4122 .get = alc_mux_enum_get,
4123 .put = alc_mux_enum_put,
4124 },
4125 { } /* end */
4126};
4127
4128/*
4129 * initialization verbs
4130 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131static struct hda_verb alc260_init_verbs[] = {
4132 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004134 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004137 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004139 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004140 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004142 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004143 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004144 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004145 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004146 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004147 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004149 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4150 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004152 /* set connection select to line in (default select for this ADC) */
4153 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004154 /* mute capture amp left and right */
4155 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4156 /* set connection select to line in (default select for this ADC) */
4157 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004158 /* set vol=0 Line-Out mixer amp left and right */
4159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4160 /* unmute pin widget amp left and right (no gain on this amp) */
4161 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4162 /* set vol=0 HP mixer amp left and right */
4163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4164 /* unmute pin widget amp left and right (no gain on this amp) */
4165 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4166 /* set vol=0 Mono mixer amp left and right */
4167 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4168 /* unmute pin widget amp left and right (no gain on this amp) */
4169 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4170 /* unmute LINE-2 out pin */
4171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004172 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4173 * Line In 2 = 0x03
4174 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004175 /* mute analog inputs */
4176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4178 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004181 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004182 /* mute Front out path */
4183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4185 /* mute Headphone out path */
4186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4188 /* mute Mono out path */
4189 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004191 { }
4192};
4193
Takashi Iwai474167d2006-05-17 17:17:43 +02004194#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004195static struct hda_verb alc260_hp_init_verbs[] = {
4196 /* Headphone and output */
4197 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4198 /* mono output */
4199 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4200 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4202 /* Mic2 (front panel) pin widget for input and vref at 80% */
4203 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4204 /* Line In pin widget for input */
4205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4206 /* Line-2 pin widget for output */
4207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4208 /* CD pin widget for input */
4209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4210 /* unmute amp left and right */
4211 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4212 /* set connection select to line in (default select for this ADC) */
4213 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4214 /* unmute Line-Out mixer amp left and right (volume = 0) */
4215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4216 /* mute pin widget amp left and right (no gain on this amp) */
4217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4218 /* unmute HP mixer amp left and right (volume = 0) */
4219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4220 /* mute pin widget amp left and right (no gain on this amp) */
4221 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004222 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4223 * Line In 2 = 0x03
4224 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004225 /* mute analog inputs */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004231 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4232 /* Unmute Front out path */
4233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4235 /* Unmute Headphone out path */
4236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4238 /* Unmute Mono out path */
4239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4241 { }
4242};
Takashi Iwai474167d2006-05-17 17:17:43 +02004243#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004244
4245static struct hda_verb alc260_hp_3013_init_verbs[] = {
4246 /* Line out and output */
4247 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4248 /* mono output */
4249 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4250 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4252 /* Mic2 (front panel) pin widget for input and vref at 80% */
4253 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4254 /* Line In pin widget for input */
4255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4256 /* Headphone pin widget for output */
4257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4258 /* CD pin widget for input */
4259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4260 /* unmute amp left and right */
4261 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4262 /* set connection select to line in (default select for this ADC) */
4263 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4264 /* unmute Line-Out mixer amp left and right (volume = 0) */
4265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4266 /* mute pin widget amp left and right (no gain on this amp) */
4267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4268 /* unmute HP mixer amp left and right (volume = 0) */
4269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4270 /* mute pin widget amp left and right (no gain on this amp) */
4271 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004272 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4273 * Line In 2 = 0x03
4274 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004275 /* mute analog inputs */
4276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004281 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4282 /* Unmute Front out path */
4283 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4285 /* Unmute Headphone out path */
4286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4288 /* Unmute Mono out path */
4289 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4291 { }
4292};
4293
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004294/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004295 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4296 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004297 */
4298static struct hda_verb alc260_fujitsu_init_verbs[] = {
4299 /* Disable all GPIOs */
4300 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4301 /* Internal speaker is connected to headphone pin */
4302 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4303 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004305 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4306 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4307 /* Ensure all other unused pins are disabled and muted. */
4308 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004310 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004311 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004312 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004313 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004316
Jonathan Woithef7ace402006-02-28 11:46:14 +01004317 /* Disable digital (SPDIF) pins */
4318 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4319 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004320
Jonathan Woithef7ace402006-02-28 11:46:14 +01004321 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4322 * when acting as an output.
4323 */
4324 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4325
4326 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4332 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4333 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4334 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4335 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004336
Jonathan Woithef7ace402006-02-28 11:46:14 +01004337 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4338 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4339 /* Unmute Line1 pin widget output buffer since it starts as an output.
4340 * If the pin mode is changed by the user the pin mode control will
4341 * take care of enabling the pin's input/output buffers as needed.
4342 * Therefore there's no need to enable the input buffer at this
4343 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004344 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004346 /* Unmute input buffer of pin widget used for Line-in (no equiv
4347 * mixer ctrl)
4348 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004349 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004350
Jonathan Woithef7ace402006-02-28 11:46:14 +01004351 /* Mute capture amp left and right */
4352 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4353 /* Set ADC connection select to match default mixer setting - line
4354 * in (on mic1 pin)
4355 */
4356 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004357
Jonathan Woithef7ace402006-02-28 11:46:14 +01004358 /* Do the same for the second ADC: mute capture input amp and
4359 * set ADC connection to line in (on mic1 pin)
4360 */
4361 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4362 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004363
Jonathan Woithef7ace402006-02-28 11:46:14 +01004364 /* Mute all inputs to mixer widget (even unconnected ones) */
4365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4370 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004373
4374 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004375};
4376
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004377/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4378 * similar laptops (adapted from Fujitsu init verbs).
4379 */
4380static struct hda_verb alc260_acer_init_verbs[] = {
4381 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4382 * the headphone jack. Turn this on and rely on the standard mute
4383 * methods whenever the user wants to turn these outputs off.
4384 */
4385 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4386 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4387 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4388 /* Internal speaker/Headphone jack is connected to Line-out pin */
4389 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4390 /* Internal microphone/Mic jack is connected to Mic1 pin */
4391 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4392 /* Line In jack is connected to Line1 pin */
4393 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004394 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4395 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004396 /* Ensure all other unused pins are disabled and muted. */
4397 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4398 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004399 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4400 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4401 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4403 /* Disable digital (SPDIF) pins */
4404 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4405 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4406
4407 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4408 * bus when acting as outputs.
4409 */
4410 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4411 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4412
4413 /* Start with output sum widgets muted and their output gains at min */
4414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4422 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4423
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004424 /* Unmute Line-out pin widget amp left and right
4425 * (no equiv mixer ctrl)
4426 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004427 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004428 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4429 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004430 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4431 * inputs. If the pin mode is changed by the user the pin mode control
4432 * will take care of enabling the pin's input/output buffers as needed.
4433 * Therefore there's no need to enable the input buffer at this
4434 * stage.
4435 */
4436 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4438
4439 /* Mute capture amp left and right */
4440 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4441 /* Set ADC connection select to match default mixer setting - mic
4442 * (on mic1 pin)
4443 */
4444 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4445
4446 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004447 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004448 */
4449 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004450 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004451
4452 /* Mute all inputs to mixer widget (even unconnected ones) */
4453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4461
4462 { }
4463};
4464
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004465static struct hda_verb alc260_will_verbs[] = {
4466 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4467 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4468 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4469 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4470 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4471 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4472 {}
4473};
4474
4475static struct hda_verb alc260_replacer_672v_verbs[] = {
4476 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4477 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4478 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4479
4480 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4481 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4482 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4483
4484 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4485 {}
4486};
4487
4488/* toggle speaker-output according to the hp-jack state */
4489static void alc260_replacer_672v_automute(struct hda_codec *codec)
4490{
4491 unsigned int present;
4492
4493 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4494 present = snd_hda_codec_read(codec, 0x0f, 0,
4495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4496 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004497 snd_hda_codec_write_cache(codec, 0x01, 0,
4498 AC_VERB_SET_GPIO_DATA, 1);
4499 snd_hda_codec_write_cache(codec, 0x0f, 0,
4500 AC_VERB_SET_PIN_WIDGET_CONTROL,
4501 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004502 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004503 snd_hda_codec_write_cache(codec, 0x01, 0,
4504 AC_VERB_SET_GPIO_DATA, 0);
4505 snd_hda_codec_write_cache(codec, 0x0f, 0,
4506 AC_VERB_SET_PIN_WIDGET_CONTROL,
4507 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004508 }
4509}
4510
4511static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4512 unsigned int res)
4513{
4514 if ((res >> 26) == ALC880_HP_EVENT)
4515 alc260_replacer_672v_automute(codec);
4516}
4517
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004518/* Test configuration for debugging, modelled after the ALC880 test
4519 * configuration.
4520 */
4521#ifdef CONFIG_SND_DEBUG
4522static hda_nid_t alc260_test_dac_nids[1] = {
4523 0x02,
4524};
4525static hda_nid_t alc260_test_adc_nids[2] = {
4526 0x04, 0x05,
4527};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004528/* For testing the ALC260, each input MUX needs its own definition since
4529 * the signal assignments are different. This assumes that the first ADC
4530 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004531 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004532static struct hda_input_mux alc260_test_capture_sources[2] = {
4533 {
4534 .num_items = 7,
4535 .items = {
4536 { "MIC1 pin", 0x0 },
4537 { "MIC2 pin", 0x1 },
4538 { "LINE1 pin", 0x2 },
4539 { "LINE2 pin", 0x3 },
4540 { "CD pin", 0x4 },
4541 { "LINE-OUT pin", 0x5 },
4542 { "HP-OUT pin", 0x6 },
4543 },
4544 },
4545 {
4546 .num_items = 8,
4547 .items = {
4548 { "MIC1 pin", 0x0 },
4549 { "MIC2 pin", 0x1 },
4550 { "LINE1 pin", 0x2 },
4551 { "LINE2 pin", 0x3 },
4552 { "CD pin", 0x4 },
4553 { "Mixer", 0x5 },
4554 { "LINE-OUT pin", 0x6 },
4555 { "HP-OUT pin", 0x7 },
4556 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004557 },
4558};
4559static struct snd_kcontrol_new alc260_test_mixer[] = {
4560 /* Output driver widgets */
4561 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4562 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4563 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4564 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4565 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4566 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4567
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004568 /* Modes for retasking pin widgets
4569 * Note: the ALC260 doesn't seem to act on requests to enable mic
4570 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4571 * mention this restriction. At this stage it's not clear whether
4572 * this behaviour is intentional or is a hardware bug in chip
4573 * revisions available at least up until early 2006. Therefore for
4574 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4575 * choices, but if it turns out that the lack of mic bias for these
4576 * NIDs is intentional we could change their modes from
4577 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4578 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004579 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4580 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4581 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4582 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4583 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4584 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4585
4586 /* Loopback mixer controls */
4587 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4588 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4589 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4590 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4591 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4592 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4593 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4594 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4595 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4596 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4597 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4598 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4599 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4600 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4601 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4602 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004603
4604 /* Controls for GPIO pins, assuming they are configured as outputs */
4605 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4606 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4607 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4608 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4609
Jonathan Woithe92621f12006-02-28 11:47:47 +01004610 /* Switches to allow the digital IO pins to be enabled. The datasheet
4611 * is ambigious as to which NID is which; testing on laptops which
4612 * make this output available should provide clarification.
4613 */
4614 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4615 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4616
Jonathan Woithef8225f62008-01-08 12:16:54 +01004617 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4618 * this output to turn on an external amplifier.
4619 */
4620 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4621 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4622
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004623 { } /* end */
4624};
4625static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004626 /* Enable all GPIOs as outputs with an initial value of 0 */
4627 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4628 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4629 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4630
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004631 /* Enable retasking pins as output, initially without power amp */
4632 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4633 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4636 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4637 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4638
Jonathan Woithe92621f12006-02-28 11:47:47 +01004639 /* Disable digital (SPDIF) pins initially, but users can enable
4640 * them via a mixer switch. In the case of SPDIF-out, this initverb
4641 * payload also sets the generation to 0, output to be in "consumer"
4642 * PCM format, copyright asserted, no pre-emphasis and no validity
4643 * control.
4644 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004645 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4646 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4647
Jonathan Woithef7ace402006-02-28 11:46:14 +01004648 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004649 * OUT1 sum bus when acting as an output.
4650 */
4651 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4652 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4653 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4654 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4655
4656 /* Start with output sum widgets muted and their output gains at min */
4657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4666
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004667 /* Unmute retasking pin widget output buffers since the default
4668 * state appears to be output. As the pin mode is changed by the
4669 * user the pin mode control will take care of enabling the pin's
4670 * input/output buffers as needed.
4671 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004672 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4676 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4677 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4678 /* Also unmute the mono-out pin widget */
4679 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4680
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004681 /* Mute capture amp left and right */
4682 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004683 /* Set ADC connection select to match default mixer setting (mic1
4684 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004685 */
4686 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4687
4688 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004689 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004690 */
4691 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4692 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4693
4694 /* Mute all inputs to mixer widget (even unconnected ones) */
4695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4703
4704 { }
4705};
4706#endif
4707
Takashi Iwai63300792008-01-24 15:31:36 +01004708#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4709#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004710
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004711#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4712#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4713
Kailang Yangdf694da2005-12-05 19:42:22 +01004714/*
4715 * for BIOS auto-configuration
4716 */
4717
4718static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4719 const char *pfx)
4720{
4721 hda_nid_t nid_vol;
4722 unsigned long vol_val, sw_val;
4723 char name[32];
4724 int err;
4725
4726 if (nid >= 0x0f && nid < 0x11) {
4727 nid_vol = nid - 0x7;
4728 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4729 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4730 } else if (nid == 0x11) {
4731 nid_vol = nid - 0x7;
4732 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4733 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4734 } else if (nid >= 0x12 && nid <= 0x15) {
4735 nid_vol = 0x08;
4736 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4737 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4738 } else
4739 return 0; /* N/A */
4740
4741 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4743 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004744 return err;
4745 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4747 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004748 return err;
4749 return 1;
4750}
4751
4752/* add playback controls from the parsed DAC table */
4753static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4754 const struct auto_pin_cfg *cfg)
4755{
4756 hda_nid_t nid;
4757 int err;
4758
4759 spec->multiout.num_dacs = 1;
4760 spec->multiout.dac_nids = spec->private_dac_nids;
4761 spec->multiout.dac_nids[0] = 0x02;
4762
4763 nid = cfg->line_out_pins[0];
4764 if (nid) {
4765 err = alc260_add_playback_controls(spec, nid, "Front");
4766 if (err < 0)
4767 return err;
4768 }
4769
Takashi Iwai82bc9552006-03-21 11:24:42 +01004770 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004771 if (nid) {
4772 err = alc260_add_playback_controls(spec, nid, "Speaker");
4773 if (err < 0)
4774 return err;
4775 }
4776
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004777 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004778 if (nid) {
4779 err = alc260_add_playback_controls(spec, nid, "Headphone");
4780 if (err < 0)
4781 return err;
4782 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004783 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004784}
4785
4786/* create playback/capture controls for input pins */
4787static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4788 const struct auto_pin_cfg *cfg)
4789{
Kailang Yangdf694da2005-12-05 19:42:22 +01004790 struct hda_input_mux *imux = &spec->private_imux;
4791 int i, err, idx;
4792
4793 for (i = 0; i < AUTO_PIN_LAST; i++) {
4794 if (cfg->input_pins[i] >= 0x12) {
4795 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004796 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004797 auto_pin_cfg_labels[i], idx,
4798 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004799 if (err < 0)
4800 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004801 imux->items[imux->num_items].label =
4802 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004803 imux->items[imux->num_items].index = idx;
4804 imux->num_items++;
4805 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004806 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004807 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004808 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004809 auto_pin_cfg_labels[i], idx,
4810 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004811 if (err < 0)
4812 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 imux->items[imux->num_items].label =
4814 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004815 imux->items[imux->num_items].index = idx;
4816 imux->num_items++;
4817 }
4818 }
4819 return 0;
4820}
4821
4822static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4823 hda_nid_t nid, int pin_type,
4824 int sel_idx)
4825{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004826 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004827 /* need the manual connection? */
4828 if (nid >= 0x12) {
4829 int idx = nid - 0x12;
4830 snd_hda_codec_write(codec, idx + 0x0b, 0,
4831 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004832 }
4833}
4834
4835static void alc260_auto_init_multi_out(struct hda_codec *codec)
4836{
4837 struct alc_spec *spec = codec->spec;
4838 hda_nid_t nid;
4839
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004840 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004841 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004842 if (nid) {
4843 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4844 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4845 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004846
Takashi Iwai82bc9552006-03-21 11:24:42 +01004847 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004848 if (nid)
4849 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4850
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004851 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004852 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004853 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004854}
Kailang Yangdf694da2005-12-05 19:42:22 +01004855
4856#define ALC260_PIN_CD_NID 0x16
4857static void alc260_auto_init_analog_input(struct hda_codec *codec)
4858{
4859 struct alc_spec *spec = codec->spec;
4860 int i;
4861
4862 for (i = 0; i < AUTO_PIN_LAST; i++) {
4863 hda_nid_t nid = spec->autocfg.input_pins[i];
4864 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004865 snd_hda_codec_write(codec, nid, 0,
4866 AC_VERB_SET_PIN_WIDGET_CONTROL,
4867 i <= AUTO_PIN_FRONT_MIC ?
4868 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004869 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004870 snd_hda_codec_write(codec, nid, 0,
4871 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004872 AMP_OUT_MUTE);
4873 }
4874 }
4875}
4876
4877/*
4878 * generic initialization of ADC, input mixers and output mixers
4879 */
4880static struct hda_verb alc260_volume_init_verbs[] = {
4881 /*
4882 * Unmute ADC0-1 and set the default input to mic-in
4883 */
4884 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4885 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4886 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4887 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4888
4889 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4890 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004891 * Note: PASD motherboards uses the Line In 2 as the input for
4892 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004893 */
4894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004895 /* mute analog inputs */
4896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004901
4902 /*
4903 * Set up output mixers (0x08 - 0x0a)
4904 */
4905 /* set vol=0 to output mixers */
4906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4909 /* set up input amps for analog loopback */
4910 /* Amp Indices: DAC = 0, mixer = 1 */
4911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4917
4918 { }
4919};
4920
4921static int alc260_parse_auto_config(struct hda_codec *codec)
4922{
4923 struct alc_spec *spec = codec->spec;
4924 unsigned int wcap;
4925 int err;
4926 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4927
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004928 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4929 alc260_ignore);
4930 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004931 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4933 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004934 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004935 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004936 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004937 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4938 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004939 return err;
4940
4941 spec->multiout.max_channels = 2;
4942
4943 if (spec->autocfg.dig_out_pin)
4944 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4945 if (spec->kctl_alloc)
4946 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4947
4948 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004950 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004951 spec->input_mux = &spec->private_imux;
4952
4953 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004954 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004955 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01004956 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004957 spec->adc_nids = alc260_adc_nids_alt;
4958 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4959 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004960 } else {
4961 spec->adc_nids = alc260_adc_nids;
4962 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4963 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004964 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004965 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004966
4967 return 1;
4968}
4969
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004970/* additional initialization for auto-configuration model */
4971static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004972{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004973 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004974 alc260_auto_init_multi_out(codec);
4975 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004976 if (spec->unsol_event)
4977 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004978}
4979
Takashi Iwaicb53c622007-08-10 17:21:45 +02004980#ifdef CONFIG_SND_HDA_POWER_SAVE
4981static struct hda_amp_list alc260_loopbacks[] = {
4982 { 0x07, HDA_INPUT, 0 },
4983 { 0x07, HDA_INPUT, 1 },
4984 { 0x07, HDA_INPUT, 2 },
4985 { 0x07, HDA_INPUT, 3 },
4986 { 0x07, HDA_INPUT, 4 },
4987 { } /* end */
4988};
4989#endif
4990
Kailang Yangdf694da2005-12-05 19:42:22 +01004991/*
4992 * ALC260 configurations
4993 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004994static const char *alc260_models[ALC260_MODEL_LAST] = {
4995 [ALC260_BASIC] = "basic",
4996 [ALC260_HP] = "hp",
4997 [ALC260_HP_3013] = "hp-3013",
4998 [ALC260_FUJITSU_S702X] = "fujitsu",
4999 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005000 [ALC260_WILL] = "will",
5001 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005002#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005003 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005004#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005005 [ALC260_AUTO] = "auto",
5006};
5007
5008static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005009 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005010 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005011 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005012 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005013 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5014 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5015 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5016 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5017 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5018 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5019 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5020 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5021 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5022 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5023 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5024 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005025 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005026 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005027 {}
5028};
5029
Kailang Yangdf694da2005-12-05 19:42:22 +01005030static struct alc_config_preset alc260_presets[] = {
5031 [ALC260_BASIC] = {
5032 .mixers = { alc260_base_output_mixer,
5033 alc260_input_mixer,
5034 alc260_pc_beep_mixer,
5035 alc260_capture_mixer },
5036 .init_verbs = { alc260_init_verbs },
5037 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5038 .dac_nids = alc260_dac_nids,
5039 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5040 .adc_nids = alc260_adc_nids,
5041 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5042 .channel_mode = alc260_modes,
5043 .input_mux = &alc260_capture_source,
5044 },
5045 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005046 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005047 alc260_input_mixer,
5048 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005049 .init_verbs = { alc260_init_verbs,
5050 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005051 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5052 .dac_nids = alc260_dac_nids,
5053 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5054 .adc_nids = alc260_hp_adc_nids,
5055 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5056 .channel_mode = alc260_modes,
5057 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005058 .unsol_event = alc260_hp_unsol_event,
5059 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005060 },
5061 [ALC260_HP_3013] = {
5062 .mixers = { alc260_hp_3013_mixer,
5063 alc260_input_mixer,
5064 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005065 .init_verbs = { alc260_hp_3013_init_verbs,
5066 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005067 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5068 .dac_nids = alc260_dac_nids,
5069 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5070 .adc_nids = alc260_hp_adc_nids,
5071 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5072 .channel_mode = alc260_modes,
5073 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005074 .unsol_event = alc260_hp_3013_unsol_event,
5075 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005076 },
5077 [ALC260_FUJITSU_S702X] = {
5078 .mixers = { alc260_fujitsu_mixer,
5079 alc260_capture_mixer },
5080 .init_verbs = { alc260_fujitsu_init_verbs },
5081 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5082 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005083 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5084 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5086 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005087 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5088 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005089 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005090 [ALC260_ACER] = {
5091 .mixers = { alc260_acer_mixer,
5092 alc260_capture_mixer },
5093 .init_verbs = { alc260_acer_init_verbs },
5094 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5095 .dac_nids = alc260_dac_nids,
5096 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5097 .adc_nids = alc260_dual_adc_nids,
5098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5099 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005100 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5101 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005102 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005103 [ALC260_WILL] = {
5104 .mixers = { alc260_will_mixer,
5105 alc260_capture_mixer },
5106 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5107 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5108 .dac_nids = alc260_dac_nids,
5109 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5110 .adc_nids = alc260_adc_nids,
5111 .dig_out_nid = ALC260_DIGOUT_NID,
5112 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5113 .channel_mode = alc260_modes,
5114 .input_mux = &alc260_capture_source,
5115 },
5116 [ALC260_REPLACER_672V] = {
5117 .mixers = { alc260_replacer_672v_mixer,
5118 alc260_capture_mixer },
5119 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5120 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5121 .dac_nids = alc260_dac_nids,
5122 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5123 .adc_nids = alc260_adc_nids,
5124 .dig_out_nid = ALC260_DIGOUT_NID,
5125 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5126 .channel_mode = alc260_modes,
5127 .input_mux = &alc260_capture_source,
5128 .unsol_event = alc260_replacer_672v_unsol_event,
5129 .init_hook = alc260_replacer_672v_automute,
5130 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005131#ifdef CONFIG_SND_DEBUG
5132 [ALC260_TEST] = {
5133 .mixers = { alc260_test_mixer,
5134 alc260_capture_mixer },
5135 .init_verbs = { alc260_test_init_verbs },
5136 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5137 .dac_nids = alc260_test_dac_nids,
5138 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5139 .adc_nids = alc260_test_adc_nids,
5140 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5141 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005142 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5143 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005144 },
5145#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005146};
5147
Linus Torvalds1da177e2005-04-16 15:20:36 -07005148static int patch_alc260(struct hda_codec *codec)
5149{
5150 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005151 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005152
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005154 if (spec == NULL)
5155 return -ENOMEM;
5156
5157 codec->spec = spec;
5158
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005159 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5160 alc260_models,
5161 alc260_cfg_tbl);
5162 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005163 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5164 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005165 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005166 }
5167
Kailang Yangdf694da2005-12-05 19:42:22 +01005168 if (board_config == ALC260_AUTO) {
5169 /* automatic parse from the BIOS config */
5170 err = alc260_parse_auto_config(codec);
5171 if (err < 0) {
5172 alc_free(codec);
5173 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005174 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005175 printk(KERN_INFO
5176 "hda_codec: Cannot set up configuration "
5177 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005178 board_config = ALC260_BASIC;
5179 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005180 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005181
Kailang Yangdf694da2005-12-05 19:42:22 +01005182 if (board_config != ALC260_AUTO)
5183 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005184
5185 spec->stream_name_analog = "ALC260 Analog";
5186 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5187 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5188
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005189 spec->stream_name_digital = "ALC260 Digital";
5190 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5191 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5192
Takashi Iwai2134ea42008-01-10 16:53:55 +01005193 spec->vmaster_nid = 0x08;
5194
Linus Torvalds1da177e2005-04-16 15:20:36 -07005195 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005197 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005198#ifdef CONFIG_SND_HDA_POWER_SAVE
5199 if (!spec->loopback.amplist)
5200 spec->loopback.amplist = alc260_loopbacks;
5201#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005202
5203 return 0;
5204}
5205
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005206
Linus Torvalds1da177e2005-04-16 15:20:36 -07005207/*
5208 * ALC882 support
5209 *
5210 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5211 * configuration. Each pin widget can choose any input DACs and a mixer.
5212 * Each ADC is connected from a mixer of all inputs. This makes possible
5213 * 6-channel independent captures.
5214 *
5215 * In addition, an independent DAC for the multi-playback (not used in this
5216 * driver yet).
5217 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005218#define ALC882_DIGOUT_NID 0x06
5219#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005220
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005221static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005222 { 8, NULL }
5223};
5224
5225static hda_nid_t alc882_dac_nids[4] = {
5226 /* front, rear, clfe, rear_surr */
5227 0x02, 0x03, 0x04, 0x05
5228};
5229
Kailang Yangdf694da2005-12-05 19:42:22 +01005230/* identical with ALC880 */
5231#define alc882_adc_nids alc880_adc_nids
5232#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005233
Takashi Iwaie1406342008-02-11 18:32:32 +01005234static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5235static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5236
Linus Torvalds1da177e2005-04-16 15:20:36 -07005237/* input MUX */
5238/* FIXME: should be a matrix-type input source selection */
5239
5240static struct hda_input_mux alc882_capture_source = {
5241 .num_items = 4,
5242 .items = {
5243 { "Mic", 0x0 },
5244 { "Front Mic", 0x1 },
5245 { "Line", 0x2 },
5246 { "CD", 0x4 },
5247 },
5248};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005249#define alc882_mux_enum_info alc_mux_enum_info
5250#define alc882_mux_enum_get alc_mux_enum_get
5251
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005252static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5253 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005254{
5255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5256 struct alc_spec *spec = codec->spec;
5257 const struct hda_input_mux *imux = spec->input_mux;
5258 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005259 hda_nid_t nid = spec->capsrc_nids ?
5260 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005261 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5262 unsigned int i, idx;
5263
5264 idx = ucontrol->value.enumerated.item[0];
5265 if (idx >= imux->num_items)
5266 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005267 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005268 return 0;
5269 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005270 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5271 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005272 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005273 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005274 }
5275 *cur_val = idx;
5276 return 1;
5277}
5278
Kailang Yangdf694da2005-12-05 19:42:22 +01005279/*
Kailang Yang272a5272007-05-14 11:00:38 +02005280 * 2ch mode
5281 */
5282static struct hda_verb alc882_3ST_ch2_init[] = {
5283 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5284 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5285 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5286 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5287 { } /* end */
5288};
5289
5290/*
5291 * 6ch mode
5292 */
5293static struct hda_verb alc882_3ST_ch6_init[] = {
5294 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5295 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5296 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5299 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5300 { } /* end */
5301};
5302
5303static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5304 { 2, alc882_3ST_ch2_init },
5305 { 6, alc882_3ST_ch6_init },
5306};
5307
5308/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005309 * 6ch mode
5310 */
5311static struct hda_verb alc882_sixstack_ch6_init[] = {
5312 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5313 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5314 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5315 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5316 { } /* end */
5317};
5318
5319/*
5320 * 8ch mode
5321 */
5322static struct hda_verb alc882_sixstack_ch8_init[] = {
5323 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5324 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5325 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5326 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5327 { } /* end */
5328};
5329
5330static struct hda_channel_mode alc882_sixstack_modes[2] = {
5331 { 6, alc882_sixstack_ch6_init },
5332 { 8, alc882_sixstack_ch8_init },
5333};
5334
Takashi Iwai87350ad2007-08-16 18:19:38 +02005335/*
5336 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5337 */
5338
5339/*
5340 * 2ch mode
5341 */
5342static struct hda_verb alc885_mbp_ch2_init[] = {
5343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5344 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5345 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5346 { } /* end */
5347};
5348
5349/*
5350 * 6ch mode
5351 */
5352static struct hda_verb alc885_mbp_ch6_init[] = {
5353 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5354 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5355 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5356 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5357 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5358 { } /* end */
5359};
5360
5361static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5362 { 2, alc885_mbp_ch2_init },
5363 { 6, alc885_mbp_ch6_init },
5364};
5365
5366
Linus Torvalds1da177e2005-04-16 15:20:36 -07005367/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5368 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5369 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005370static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005371 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005372 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005373 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005374 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005375 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5376 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005377 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5378 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005379 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005380 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5384 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5385 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5389 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005390 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5392 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5393 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005394 { } /* end */
5395};
5396
Takashi Iwai87350ad2007-08-16 18:19:38 +02005397static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005398 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5399 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5400 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5401 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5402 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5403 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5405 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005406 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5408 { } /* end */
5409};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005410static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5411 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5412 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5413 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5414 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5415 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5416 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5420 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5421 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5422 { } /* end */
5423};
5424
Kailang Yang272a5272007-05-14 11:00:38 +02005425static struct snd_kcontrol_new alc882_targa_mixer[] = {
5426 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5427 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5429 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5430 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5431 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5432 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005438 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005439 { } /* end */
5440};
5441
5442/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5443 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5444 */
5445static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5446 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5447 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5448 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5449 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5454 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5455 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005459 { } /* end */
5460};
5461
Takashi Iwai914759b2007-09-06 14:52:04 +02005462static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5463 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5464 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5467 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5471 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5473 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5474 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5475 { } /* end */
5476};
5477
Kailang Yangdf694da2005-12-05 19:42:22 +01005478static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5479 {
5480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5481 .name = "Channel Mode",
5482 .info = alc_ch_mode_info,
5483 .get = alc_ch_mode_get,
5484 .put = alc_ch_mode_put,
5485 },
5486 { } /* end */
5487};
5488
Linus Torvalds1da177e2005-04-16 15:20:36 -07005489static struct hda_verb alc882_init_verbs[] = {
5490 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005494 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5497 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005502 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005507 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005508 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005511 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005514 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005515 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005516 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005519 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005520 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005523 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005524 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005525 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5526 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005527 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5529 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5532 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5534 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5535 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005536 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005537 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005538
5539 /* FIXME: use matrix-type input source selection */
5540 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5541 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5545 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5550 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005551 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5556 /* ADC1: mute amp left and right */
5557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005558 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005559 /* ADC2: mute amp left and right */
5560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005561 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005562 /* ADC3: mute amp left and right */
5563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005564 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005565
5566 { }
5567};
5568
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005569static struct hda_verb alc882_eapd_verbs[] = {
5570 /* change to EAPD mode */
5571 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005572 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005573 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005574};
5575
Tobin Davis9102cd12006-12-15 10:02:12 +01005576/* Mac Pro test */
5577static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5578 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5579 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5583 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5584 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5585 { } /* end */
5586};
5587
5588static struct hda_verb alc882_macpro_init_verbs[] = {
5589 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 /* Front Pin: output 0 (0x0c) */
5594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5597 /* Front Mic pin: input vref at 80% */
5598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5600 /* Speaker: output */
5601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5603 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5604 /* Headphone output (output 0 - 0x0c) */
5605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5607 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5608
5609 /* FIXME: use matrix-type input source selection */
5610 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5611 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5615 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5616 /* Input mixer2 */
5617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5621 /* Input mixer3 */
5622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5626 /* ADC1: mute amp left and right */
5627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5628 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5629 /* ADC2: mute amp left and right */
5630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5631 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5632 /* ADC3: mute amp left and right */
5633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5634 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5635
5636 { }
5637};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005638
Takashi Iwai87350ad2007-08-16 18:19:38 +02005639/* Macbook Pro rev3 */
5640static struct hda_verb alc885_mbp3_init_verbs[] = {
5641 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5645 /* Rear mixer */
5646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5649 /* Front Pin: output 0 (0x0c) */
5650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5652 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5653 /* HP Pin: output 0 (0x0d) */
5654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5658 /* Mic (rear) pin: input vref at 80% */
5659 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5660 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5661 /* Front Mic pin: input vref at 80% */
5662 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5663 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5664 /* Line In pin: use output 1 when in LineOut mode */
5665 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5667 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5668
5669 /* FIXME: use matrix-type input source selection */
5670 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5671 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5676 /* Input mixer2 */
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5681 /* Input mixer3 */
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5686 /* ADC1: mute amp left and right */
5687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5688 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5689 /* ADC2: mute amp left and right */
5690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5691 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5692 /* ADC3: mute amp left and right */
5693 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5694 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5695
5696 { }
5697};
5698
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005699/* iMac 24 mixer. */
5700static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5701 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5702 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5703 { } /* end */
5704};
5705
5706/* iMac 24 init verbs. */
5707static struct hda_verb alc885_imac24_init_verbs[] = {
5708 /* Internal speakers: output 0 (0x0c) */
5709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5711 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5712 /* Internal speakers: output 0 (0x0c) */
5713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5715 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5716 /* Headphone: output 0 (0x0c) */
5717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5719 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5720 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5721 /* Front Mic: input vref at 80% */
5722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5724 { }
5725};
5726
5727/* Toggle speaker-output according to the hp-jack state */
5728static void alc885_imac24_automute(struct hda_codec *codec)
5729{
5730 unsigned int present;
5731
5732 present = snd_hda_codec_read(codec, 0x14, 0,
5733 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005734 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5735 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5736 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5737 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005738}
5739
5740/* Processes unsolicited events. */
5741static void alc885_imac24_unsol_event(struct hda_codec *codec,
5742 unsigned int res)
5743{
5744 /* Headphone insertion or removal. */
5745 if ((res >> 26) == ALC880_HP_EVENT)
5746 alc885_imac24_automute(codec);
5747}
5748
Takashi Iwai87350ad2007-08-16 18:19:38 +02005749static void alc885_mbp3_automute(struct hda_codec *codec)
5750{
5751 unsigned int present;
5752
5753 present = snd_hda_codec_read(codec, 0x15, 0,
5754 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5755 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5756 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5757 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5758 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5759
5760}
5761static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5762 unsigned int res)
5763{
5764 /* Headphone insertion or removal. */
5765 if ((res >> 26) == ALC880_HP_EVENT)
5766 alc885_mbp3_automute(codec);
5767}
5768
5769
Kailang Yang272a5272007-05-14 11:00:38 +02005770static struct hda_verb alc882_targa_verbs[] = {
5771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5773
5774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5776
5777 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5778 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5779 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5780
5781 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5782 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5783 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5784 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5785 { } /* end */
5786};
5787
5788/* toggle speaker-output according to the hp-jack state */
5789static void alc882_targa_automute(struct hda_codec *codec)
5790{
5791 unsigned int present;
5792
5793 present = snd_hda_codec_read(codec, 0x14, 0,
5794 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005795 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5796 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005797 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5798 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005799}
5800
5801static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5802{
5803 /* Looks like the unsol event is incompatible with the standard
5804 * definition. 4bit tag is placed at 26 bit!
5805 */
5806 if (((res >> 26) == ALC880_HP_EVENT)) {
5807 alc882_targa_automute(codec);
5808 }
5809}
5810
5811static struct hda_verb alc882_asus_a7j_verbs[] = {
5812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5814
5815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5816 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5817 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5818
5819 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5821 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5822
5823 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5824 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5825 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5826 { } /* end */
5827};
5828
Takashi Iwai914759b2007-09-06 14:52:04 +02005829static struct hda_verb alc882_asus_a7m_verbs[] = {
5830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5832
5833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5836
5837 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5839 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5840
5841 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5842 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5843 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5844 { } /* end */
5845};
5846
Tobin Davis9102cd12006-12-15 10:02:12 +01005847static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5848{
5849 unsigned int gpiostate, gpiomask, gpiodir;
5850
5851 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5852 AC_VERB_GET_GPIO_DATA, 0);
5853
5854 if (!muted)
5855 gpiostate |= (1 << pin);
5856 else
5857 gpiostate &= ~(1 << pin);
5858
5859 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5860 AC_VERB_GET_GPIO_MASK, 0);
5861 gpiomask |= (1 << pin);
5862
5863 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5864 AC_VERB_GET_GPIO_DIRECTION, 0);
5865 gpiodir |= (1 << pin);
5866
5867
5868 snd_hda_codec_write(codec, codec->afg, 0,
5869 AC_VERB_SET_GPIO_MASK, gpiomask);
5870 snd_hda_codec_write(codec, codec->afg, 0,
5871 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5872
5873 msleep(1);
5874
5875 snd_hda_codec_write(codec, codec->afg, 0,
5876 AC_VERB_SET_GPIO_DATA, gpiostate);
5877}
5878
Takashi Iwai7debbe52007-08-16 15:01:03 +02005879/* set up GPIO at initialization */
5880static void alc885_macpro_init_hook(struct hda_codec *codec)
5881{
5882 alc882_gpio_mute(codec, 0, 0);
5883 alc882_gpio_mute(codec, 1, 0);
5884}
5885
5886/* set up GPIO and update auto-muting at initialization */
5887static void alc885_imac24_init_hook(struct hda_codec *codec)
5888{
5889 alc885_macpro_init_hook(codec);
5890 alc885_imac24_automute(codec);
5891}
5892
Kailang Yangdf694da2005-12-05 19:42:22 +01005893/*
5894 * generic initialization of ADC, input mixers and output mixers
5895 */
5896static struct hda_verb alc882_auto_init_verbs[] = {
5897 /*
5898 * Unmute ADC0-2 and set the default input to mic-in
5899 */
5900 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5902 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5904 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5906
Takashi Iwaicb53c622007-08-10 17:21:45 +02005907 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005909 * Note: PASD motherboards uses the Line In 2 as the input for
5910 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005911 */
5912 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005918
5919 /*
5920 * Set up output mixers (0x0c - 0x0f)
5921 */
5922 /* set vol=0 to output mixers */
5923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5927 /* set up input amps for analog loopback */
5928 /* Amp Indices: DAC = 0, mixer = 1 */
5929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5931 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5932 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5933 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5934 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5936 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5937 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5938 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5939
5940 /* FIXME: use matrix-type input source selection */
5941 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5942 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5947 /* Input mixer2 */
5948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5952 /* Input mixer3 */
5953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5957
5958 { }
5959};
5960
5961/* capture mixer elements */
5962static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5963 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5964 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5965 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5966 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5967 {
5968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5969 /* The multiple "Capture Source" controls confuse alsamixer
5970 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 */
5972 /* .name = "Capture Source", */
5973 .name = "Input Source",
5974 .count = 2,
5975 .info = alc882_mux_enum_info,
5976 .get = alc882_mux_enum_get,
5977 .put = alc882_mux_enum_put,
5978 },
5979 { } /* end */
5980};
5981
5982static struct snd_kcontrol_new alc882_capture_mixer[] = {
5983 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5984 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5985 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5986 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5987 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5988 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5989 {
5990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5991 /* The multiple "Capture Source" controls confuse alsamixer
5992 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01005993 */
5994 /* .name = "Capture Source", */
5995 .name = "Input Source",
5996 .count = 3,
5997 .info = alc882_mux_enum_info,
5998 .get = alc882_mux_enum_get,
5999 .put = alc882_mux_enum_put,
6000 },
6001 { } /* end */
6002};
6003
Takashi Iwaicb53c622007-08-10 17:21:45 +02006004#ifdef CONFIG_SND_HDA_POWER_SAVE
6005#define alc882_loopbacks alc880_loopbacks
6006#endif
6007
Kailang Yangdf694da2005-12-05 19:42:22 +01006008/* pcm configuration: identiacal with ALC880 */
6009#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6010#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6011#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6012#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6013
6014/*
6015 * configuration and preset
6016 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006017static const char *alc882_models[ALC882_MODEL_LAST] = {
6018 [ALC882_3ST_DIG] = "3stack-dig",
6019 [ALC882_6ST_DIG] = "6stack-dig",
6020 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006021 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006022 [ALC882_TARGA] = "targa",
6023 [ALC882_ASUS_A7J] = "asus-a7j",
6024 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006025 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006026 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006027 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006028 [ALC882_AUTO] = "auto",
6029};
6030
6031static struct snd_pci_quirk alc882_cfg_tbl[] = {
6032 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006033 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006034 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006035 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006036 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006037 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006038 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006039 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006040 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006041 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6042 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6043 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006044 {}
6045};
6046
6047static struct alc_config_preset alc882_presets[] = {
6048 [ALC882_3ST_DIG] = {
6049 .mixers = { alc882_base_mixer },
6050 .init_verbs = { alc882_init_verbs },
6051 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6052 .dac_nids = alc882_dac_nids,
6053 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 .dig_in_nid = ALC882_DIGIN_NID,
6055 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6056 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006057 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006058 .input_mux = &alc882_capture_source,
6059 },
6060 [ALC882_6ST_DIG] = {
6061 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6062 .init_verbs = { alc882_init_verbs },
6063 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6064 .dac_nids = alc882_dac_nids,
6065 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 .dig_in_nid = ALC882_DIGIN_NID,
6067 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6068 .channel_mode = alc882_sixstack_modes,
6069 .input_mux = &alc882_capture_source,
6070 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006071 [ALC882_ARIMA] = {
6072 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6073 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6074 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6075 .dac_nids = alc882_dac_nids,
6076 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6077 .channel_mode = alc882_sixstack_modes,
6078 .input_mux = &alc882_capture_source,
6079 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006080 [ALC882_W2JC] = {
6081 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6082 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6083 alc880_gpio1_init_verbs },
6084 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6085 .dac_nids = alc882_dac_nids,
6086 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6087 .channel_mode = alc880_threestack_modes,
6088 .need_dac_fix = 1,
6089 .input_mux = &alc882_capture_source,
6090 .dig_out_nid = ALC882_DIGOUT_NID,
6091 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006092 [ALC885_MBP3] = {
6093 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6094 .init_verbs = { alc885_mbp3_init_verbs,
6095 alc880_gpio1_init_verbs },
6096 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6097 .dac_nids = alc882_dac_nids,
6098 .channel_mode = alc885_mbp_6ch_modes,
6099 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6100 .input_mux = &alc882_capture_source,
6101 .dig_out_nid = ALC882_DIGOUT_NID,
6102 .dig_in_nid = ALC882_DIGIN_NID,
6103 .unsol_event = alc885_mbp3_unsol_event,
6104 .init_hook = alc885_mbp3_automute,
6105 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006106 [ALC885_MACPRO] = {
6107 .mixers = { alc882_macpro_mixer },
6108 .init_verbs = { alc882_macpro_init_verbs },
6109 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6110 .dac_nids = alc882_dac_nids,
6111 .dig_out_nid = ALC882_DIGOUT_NID,
6112 .dig_in_nid = ALC882_DIGIN_NID,
6113 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6114 .channel_mode = alc882_ch_modes,
6115 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006116 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006117 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006118 [ALC885_IMAC24] = {
6119 .mixers = { alc885_imac24_mixer },
6120 .init_verbs = { alc885_imac24_init_verbs },
6121 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6122 .dac_nids = alc882_dac_nids,
6123 .dig_out_nid = ALC882_DIGOUT_NID,
6124 .dig_in_nid = ALC882_DIGIN_NID,
6125 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6126 .channel_mode = alc882_ch_modes,
6127 .input_mux = &alc882_capture_source,
6128 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006129 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006130 },
Kailang Yang272a5272007-05-14 11:00:38 +02006131 [ALC882_TARGA] = {
6132 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6133 alc882_capture_mixer },
6134 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6135 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6136 .dac_nids = alc882_dac_nids,
6137 .dig_out_nid = ALC882_DIGOUT_NID,
6138 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6139 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006140 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006141 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6142 .channel_mode = alc882_3ST_6ch_modes,
6143 .need_dac_fix = 1,
6144 .input_mux = &alc882_capture_source,
6145 .unsol_event = alc882_targa_unsol_event,
6146 .init_hook = alc882_targa_automute,
6147 },
6148 [ALC882_ASUS_A7J] = {
6149 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6150 alc882_capture_mixer },
6151 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6152 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6153 .dac_nids = alc882_dac_nids,
6154 .dig_out_nid = ALC882_DIGOUT_NID,
6155 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6156 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006157 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006158 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6159 .channel_mode = alc882_3ST_6ch_modes,
6160 .need_dac_fix = 1,
6161 .input_mux = &alc882_capture_source,
6162 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006163 [ALC882_ASUS_A7M] = {
6164 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6165 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6166 alc880_gpio1_init_verbs,
6167 alc882_asus_a7m_verbs },
6168 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6169 .dac_nids = alc882_dac_nids,
6170 .dig_out_nid = ALC882_DIGOUT_NID,
6171 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6172 .channel_mode = alc880_threestack_modes,
6173 .need_dac_fix = 1,
6174 .input_mux = &alc882_capture_source,
6175 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006176};
6177
6178
6179/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006180 * Pin config fixes
6181 */
6182enum {
6183 PINFIX_ABIT_AW9D_MAX
6184};
6185
6186static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6187 { 0x15, 0x01080104 }, /* side */
6188 { 0x16, 0x01011012 }, /* rear */
6189 { 0x17, 0x01016011 }, /* clfe */
6190 { }
6191};
6192
6193static const struct alc_pincfg *alc882_pin_fixes[] = {
6194 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6195};
6196
6197static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6198 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6199 {}
6200};
6201
6202/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006203 * BIOS auto configuration
6204 */
6205static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6206 hda_nid_t nid, int pin_type,
6207 int dac_idx)
6208{
6209 /* set as output */
6210 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006211 int idx;
6212
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006213 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006214 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6215 idx = 4;
6216 else
6217 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006218 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6219
6220}
6221
6222static void alc882_auto_init_multi_out(struct hda_codec *codec)
6223{
6224 struct alc_spec *spec = codec->spec;
6225 int i;
6226
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006228 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006231 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006232 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006233 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006234 }
6235}
6236
6237static void alc882_auto_init_hp_out(struct hda_codec *codec)
6238{
6239 struct alc_spec *spec = codec->spec;
6240 hda_nid_t pin;
6241
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006242 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006244 /* use dac 0 */
6245 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006246 pin = spec->autocfg.speaker_pins[0];
6247 if (pin)
6248 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006249}
6250
6251#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6252#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6253
6254static void alc882_auto_init_analog_input(struct hda_codec *codec)
6255{
6256 struct alc_spec *spec = codec->spec;
6257 int i;
6258
6259 for (i = 0; i < AUTO_PIN_LAST; i++) {
6260 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006261 unsigned int vref;
6262 if (!nid)
6263 continue;
6264 vref = PIN_IN;
6265 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6266 if (snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) &
6267 AC_PINCAP_VREF_80)
6268 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006269 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006270 snd_hda_codec_write(codec, nid, 0,
6271 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6272 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6273 snd_hda_codec_write(codec, nid, 0,
6274 AC_VERB_SET_AMP_GAIN_MUTE,
6275 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006276 }
6277}
6278
Takashi Iwai776e1842007-08-29 15:07:11 +02006279/* add mic boosts if needed */
6280static int alc_auto_add_mic_boost(struct hda_codec *codec)
6281{
6282 struct alc_spec *spec = codec->spec;
6283 int err;
6284 hda_nid_t nid;
6285
6286 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006287 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006288 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6289 "Mic Boost",
6290 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6291 if (err < 0)
6292 return err;
6293 }
6294 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006295 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006296 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6297 "Front Mic Boost",
6298 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6299 if (err < 0)
6300 return err;
6301 }
6302 return 0;
6303}
6304
Kailang Yangdf694da2005-12-05 19:42:22 +01006305/* almost identical with ALC880 parser... */
6306static int alc882_parse_auto_config(struct hda_codec *codec)
6307{
6308 struct alc_spec *spec = codec->spec;
6309 int err = alc880_parse_auto_config(codec);
6310
6311 if (err < 0)
6312 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006313 else if (!err)
6314 return 0; /* no config found */
6315
6316 err = alc_auto_add_mic_boost(codec);
6317 if (err < 0)
6318 return err;
6319
6320 /* hack - override the init verbs */
6321 spec->init_verbs[0] = alc882_auto_init_verbs;
6322
6323 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006324}
6325
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006326/* additional initialization for auto-configuration model */
6327static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006328{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006329 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006330 alc882_auto_init_multi_out(codec);
6331 alc882_auto_init_hp_out(codec);
6332 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006333 if (spec->unsol_event)
6334 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006335}
6336
Linus Torvalds1da177e2005-04-16 15:20:36 -07006337static int patch_alc882(struct hda_codec *codec)
6338{
6339 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006340 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006341
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006342 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006343 if (spec == NULL)
6344 return -ENOMEM;
6345
Linus Torvalds1da177e2005-04-16 15:20:36 -07006346 codec->spec = spec;
6347
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006348 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6349 alc882_models,
6350 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006351
Kailang Yangdf694da2005-12-05 19:42:22 +01006352 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006353 /* Pick up systems that don't supply PCI SSID */
6354 switch (codec->subsystem_id) {
6355 case 0x106b0c00: /* Mac Pro */
6356 board_config = ALC885_MACPRO;
6357 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006358 case 0x106b1000: /* iMac 24 */
6359 board_config = ALC885_IMAC24;
6360 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006361 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006362 case 0x106b2c00: /* Macbook Pro rev3 */
6363 board_config = ALC885_MBP3;
6364 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006365 default:
6366 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6367 "trying auto-probe from BIOS...\n");
6368 board_config = ALC882_AUTO;
6369 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006370 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006371
Takashi Iwaif95474e2007-07-10 00:47:43 +02006372 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6373
Kailang Yangdf694da2005-12-05 19:42:22 +01006374 if (board_config == ALC882_AUTO) {
6375 /* automatic parse from the BIOS config */
6376 err = alc882_parse_auto_config(codec);
6377 if (err < 0) {
6378 alc_free(codec);
6379 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006380 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006381 printk(KERN_INFO
6382 "hda_codec: Cannot set up configuration "
6383 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006384 board_config = ALC882_3ST_DIG;
6385 }
6386 }
6387
6388 if (board_config != ALC882_AUTO)
6389 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390
6391 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006392 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6393 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006394 /* FIXME: setup DAC5 */
6395 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6396 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006397
6398 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006399 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6400 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006401
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006402 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006403 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006404 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006405 /* get type */
6406 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006407 if (wcap != AC_WID_AUD_IN) {
6408 spec->adc_nids = alc882_adc_nids_alt;
6409 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006410 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006411 spec->mixers[spec->num_mixers] =
6412 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 spec->num_mixers++;
6414 } else {
6415 spec->adc_nids = alc882_adc_nids;
6416 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006417 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006418 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6419 spec->num_mixers++;
6420 }
6421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006422
Takashi Iwai2134ea42008-01-10 16:53:55 +01006423 spec->vmaster_nid = 0x0c;
6424
Linus Torvalds1da177e2005-04-16 15:20:36 -07006425 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006427 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006428#ifdef CONFIG_SND_HDA_POWER_SAVE
6429 if (!spec->loopback.amplist)
6430 spec->loopback.amplist = alc882_loopbacks;
6431#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006432
6433 return 0;
6434}
6435
6436/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006437 * ALC883 support
6438 *
6439 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6440 * configuration. Each pin widget can choose any input DACs and a mixer.
6441 * Each ADC is connected from a mixer of all inputs. This makes possible
6442 * 6-channel independent captures.
6443 *
6444 * In addition, an independent DAC for the multi-playback (not used in this
6445 * driver yet).
6446 */
6447#define ALC883_DIGOUT_NID 0x06
6448#define ALC883_DIGIN_NID 0x0a
6449
6450static hda_nid_t alc883_dac_nids[4] = {
6451 /* front, rear, clfe, rear_surr */
6452 0x02, 0x04, 0x03, 0x05
6453};
6454
6455static hda_nid_t alc883_adc_nids[2] = {
6456 /* ADC1-2 */
6457 0x08, 0x09,
6458};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006459
Takashi Iwaie1406342008-02-11 18:32:32 +01006460static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6461
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006462/* input MUX */
6463/* FIXME: should be a matrix-type input source selection */
6464
6465static struct hda_input_mux alc883_capture_source = {
6466 .num_items = 4,
6467 .items = {
6468 { "Mic", 0x0 },
6469 { "Front Mic", 0x1 },
6470 { "Line", 0x2 },
6471 { "CD", 0x4 },
6472 },
6473};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006474
6475static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6476 .num_items = 2,
6477 .items = {
6478 { "Mic", 0x1 },
6479 { "Line", 0x2 },
6480 },
6481};
6482
Kailang Yang272a5272007-05-14 11:00:38 +02006483static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6484 .num_items = 4,
6485 .items = {
6486 { "Mic", 0x0 },
6487 { "iMic", 0x1 },
6488 { "Line", 0x2 },
6489 { "CD", 0x4 },
6490 },
6491};
6492
Jiang zhefb97dc62008-03-06 11:07:11 +01006493static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6494 .num_items = 2,
6495 .items = {
6496 { "Mic", 0x0 },
6497 { "Int Mic", 0x1 },
6498 },
6499};
6500
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006501#define alc883_mux_enum_info alc_mux_enum_info
6502#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006503/* ALC883 has the ALC882-type input selection */
6504#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006506/*
6507 * 2ch mode
6508 */
6509static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6510 { 2, NULL }
6511};
6512
6513/*
6514 * 2ch mode
6515 */
6516static struct hda_verb alc883_3ST_ch2_init[] = {
6517 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6518 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6519 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6520 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6521 { } /* end */
6522};
6523
6524/*
Tobin Davisb2011312007-09-17 12:45:11 +02006525 * 4ch mode
6526 */
6527static struct hda_verb alc883_3ST_ch4_init[] = {
6528 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6529 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6530 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6531 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6532 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6533 { } /* end */
6534};
6535
6536/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006537 * 6ch mode
6538 */
6539static struct hda_verb alc883_3ST_ch6_init[] = {
6540 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6541 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6542 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6543 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6544 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6545 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6546 { } /* end */
6547};
6548
Tobin Davisb2011312007-09-17 12:45:11 +02006549static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006550 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006551 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006552 { 6, alc883_3ST_ch6_init },
6553};
6554
6555/*
6556 * 6ch mode
6557 */
6558static struct hda_verb alc883_sixstack_ch6_init[] = {
6559 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6560 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6561 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6562 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6563 { } /* end */
6564};
6565
6566/*
6567 * 8ch mode
6568 */
6569static struct hda_verb alc883_sixstack_ch8_init[] = {
6570 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6571 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6572 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6573 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6574 { } /* end */
6575};
6576
6577static struct hda_channel_mode alc883_sixstack_modes[2] = {
6578 { 6, alc883_sixstack_ch6_init },
6579 { 8, alc883_sixstack_ch8_init },
6580};
6581
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006582static struct hda_verb alc883_medion_eapd_verbs[] = {
6583 /* eanable EAPD on medion laptop */
6584 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6585 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6586 { }
6587};
6588
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006589/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6590 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6591 */
6592
6593static struct snd_kcontrol_new alc883_base_mixer[] = {
6594 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6595 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6596 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6597 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6598 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6599 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6600 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6601 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6602 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6603 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006610 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006613 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6615 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6616 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6617 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6618 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6619 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6620 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6621 {
6622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6623 /* .name = "Capture Source", */
6624 .name = "Input Source",
6625 .count = 2,
6626 .info = alc883_mux_enum_info,
6627 .get = alc883_mux_enum_get,
6628 .put = alc883_mux_enum_put,
6629 },
6630 { } /* end */
6631};
6632
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006633static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6637 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6638 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6639 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6642 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6644 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6645 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6646 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6648 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6649 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6650 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6651 {
6652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6653 /* .name = "Capture Source", */
6654 .name = "Input Source",
6655 .count = 2,
6656 .info = alc883_mux_enum_info,
6657 .get = alc883_mux_enum_get,
6658 .put = alc883_mux_enum_put,
6659 },
6660 { } /* end */
6661};
6662
Jiang zhe368c7a92008-03-04 11:20:33 +01006663static struct snd_kcontrol_new alc883_clevo_m720r_mixer[] = {
6664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6665 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6666 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6667 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6671 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6672 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6673 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6674 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6675 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6676 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6677 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6678 {
6679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6680 /* .name = "Capture Source", */
6681 .name = "Input Source",
6682 .count = 2,
6683 .info = alc883_mux_enum_info,
6684 .get = alc883_mux_enum_get,
6685 .put = alc883_mux_enum_put,
6686 },
6687 { } /* end */
6688};
6689
Jiang zhefb97dc62008-03-06 11:07:11 +01006690static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6691 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6692 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6693 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6694 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6698 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6699 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6700 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6701 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6702 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6703 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6704 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6705 {
6706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6707 /* .name = "Capture Source", */
6708 .name = "Input Source",
6709 .count = 2,
6710 .info = alc883_mux_enum_info,
6711 .get = alc883_mux_enum_get,
6712 .put = alc883_mux_enum_put,
6713 },
6714 { } /* end */
6715};
6716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6722 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006726 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6728 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006729 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6731 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6732 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6735 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6736 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6737 {
6738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6739 /* .name = "Capture Source", */
6740 .name = "Input Source",
6741 .count = 2,
6742 .info = alc883_mux_enum_info,
6743 .get = alc883_mux_enum_get,
6744 .put = alc883_mux_enum_put,
6745 },
6746 { } /* end */
6747};
6748
6749static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6752 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6754 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6755 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6757 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006767 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6769 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6770 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6772 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6773 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6774 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6775 {
6776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6777 /* .name = "Capture Source", */
6778 .name = "Input Source",
6779 .count = 2,
6780 .info = alc883_mux_enum_info,
6781 .get = alc883_mux_enum_get,
6782 .put = alc883_mux_enum_put,
6783 },
6784 { } /* end */
6785};
6786
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006787static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6789 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6790 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6793 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6794 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6795 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006802 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6804 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006805 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006806 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6807 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6808 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6809 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6810 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6811
6812 {
6813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6814 /* .name = "Capture Source", */
6815 .name = "Input Source",
6816 .count = 1,
6817 .info = alc883_mux_enum_info,
6818 .get = alc883_mux_enum_get,
6819 .put = alc883_mux_enum_put,
6820 },
6821 { } /* end */
6822};
6823
Kailang Yangccc656c2006-10-17 12:32:26 +02006824static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6828 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6829 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6830 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006839 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6841 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6845 {
6846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6847 /* .name = "Capture Source", */
6848 .name = "Input Source",
6849 .count = 2,
6850 .info = alc883_mux_enum_info,
6851 .get = alc883_mux_enum_get,
6852 .put = alc883_mux_enum_put,
6853 },
6854 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006855};
Kailang Yangccc656c2006-10-17 12:32:26 +02006856
6857static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6860 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6867 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6868 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6869 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6870 {
6871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6872 /* .name = "Capture Source", */
6873 .name = "Input Source",
6874 .count = 2,
6875 .info = alc883_mux_enum_info,
6876 .get = alc883_mux_enum_get,
6877 .put = alc883_mux_enum_put,
6878 },
6879 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006880};
Kailang Yangccc656c2006-10-17 12:32:26 +02006881
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006882static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006885 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6886 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6891 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6892 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6893 {
6894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6895 /* .name = "Capture Source", */
6896 .name = "Input Source",
6897 .count = 1,
6898 .info = alc883_mux_enum_info,
6899 .get = alc883_mux_enum_get,
6900 .put = alc883_mux_enum_put,
6901 },
6902 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006903};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006904
Kailang Yang272a5272007-05-14 11:00:38 +02006905static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6906 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6907 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6913 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6914 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6915 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6916 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6917 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6918 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6919 {
6920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6921 /* .name = "Capture Source", */
6922 .name = "Input Source",
6923 .count = 2,
6924 .info = alc883_mux_enum_info,
6925 .get = alc883_mux_enum_get,
6926 .put = alc883_mux_enum_put,
6927 },
6928 { } /* end */
6929};
6930
6931static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6934 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6935 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6936 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6942 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6943 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6945 {
6946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6947 /* .name = "Capture Source", */
6948 .name = "Input Source",
6949 .count = 2,
6950 .info = alc883_mux_enum_info,
6951 .get = alc883_mux_enum_get,
6952 .put = alc883_mux_enum_put,
6953 },
6954 { } /* end */
6955};
6956
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006957static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6966 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6980 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6981 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6982 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6983 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6985 {
6986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6987 /* .name = "Capture Source", */
6988 .name = "Input Source",
6989 .count = 2,
6990 .info = alc883_mux_enum_info,
6991 .get = alc883_mux_enum_get,
6992 .put = alc883_mux_enum_put,
6993 },
6994 { } /* end */
6995};
6996
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006997static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7000 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7001 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7002 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
7003 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7004 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7005 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7017 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7018 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7019 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7020 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7021 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7023 {
7024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7025 /* .name = "Capture Source", */
7026 .name = "Input Source",
7027 .count = 2,
7028 .info = alc883_mux_enum_info,
7029 .get = alc883_mux_enum_get,
7030 .put = alc883_mux_enum_put,
7031 },
7032 { } /* end */
7033};
7034
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007035static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
7036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7037 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7039 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
7041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7045 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7057 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7058 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7060 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7061 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7062 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7063 {
7064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7065 /* .name = "Capture Source", */
7066 .name = "Input Source",
7067 .count = 2,
7068 .info = alc883_mux_enum_info,
7069 .get = alc883_mux_enum_get,
7070 .put = alc883_mux_enum_put,
7071 },
7072 { } /* end */
7073};
7074
Tobin Davis2880a862007-08-07 11:50:26 +02007075static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007076 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7077 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007079 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7080 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007084 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7085 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7086 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7087 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7088 {
7089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7090 /* .name = "Capture Source", */
7091 .name = "Input Source",
7092 .count = 2,
7093 .info = alc883_mux_enum_info,
7094 .get = alc883_mux_enum_get,
7095 .put = alc883_mux_enum_put,
7096 },
7097 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007098};
Tobin Davis2880a862007-08-07 11:50:26 +02007099
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007100static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7101 {
7102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7103 .name = "Channel Mode",
7104 .info = alc_ch_mode_info,
7105 .get = alc_ch_mode_get,
7106 .put = alc_ch_mode_put,
7107 },
7108 { } /* end */
7109};
7110
7111static struct hda_verb alc883_init_verbs[] = {
7112 /* ADC1: mute amp left and right */
7113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7114 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7115 /* ADC2: mute amp left and right */
7116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7118 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7119 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7122 /* Rear mixer */
7123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7125 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7126 /* CLFE mixer */
7127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7130 /* Side mixer */
7131 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7132 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7134
Takashi Iwaicb53c622007-08-10 17:21:45 +02007135 /* mute analog input loopbacks */
7136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007141
7142 /* Front Pin: output 0 (0x0c) */
7143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7144 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7145 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7146 /* Rear Pin: output 1 (0x0d) */
7147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7149 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7150 /* CLFE Pin: output 2 (0x0e) */
7151 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7152 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7153 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7154 /* Side Pin: output 3 (0x0f) */
7155 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7156 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7157 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7158 /* Mic (rear) pin: input vref at 80% */
7159 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7160 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7161 /* Front Mic pin: input vref at 80% */
7162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7164 /* Line In pin: input */
7165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7167 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7169 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7170 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7171 /* CD pin widget for input */
7172 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7173
7174 /* FIXME: use matrix-type input source selection */
7175 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7176 /* Input mixer2 */
7177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7181 /* Input mixer3 */
7182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7186 { }
7187};
7188
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007189/* toggle speaker-output according to the hp-jack state */
7190static void alc883_mitac_hp_automute(struct hda_codec *codec)
7191{
7192 unsigned int present;
7193
7194 present = snd_hda_codec_read(codec, 0x15, 0,
7195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7196 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7197 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7198 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7199 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7200}
7201
7202/* auto-toggle front mic */
7203/*
7204static void alc883_mitac_mic_automute(struct hda_codec *codec)
7205{
7206 unsigned int present;
7207 unsigned char bits;
7208
7209 present = snd_hda_codec_read(codec, 0x18, 0,
7210 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7211 bits = present ? HDA_AMP_MUTE : 0;
7212 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7213}
7214*/
7215
7216static void alc883_mitac_automute(struct hda_codec *codec)
7217{
7218 alc883_mitac_hp_automute(codec);
7219 /* alc883_mitac_mic_automute(codec); */
7220}
7221
7222static void alc883_mitac_unsol_event(struct hda_codec *codec,
7223 unsigned int res)
7224{
7225 switch (res >> 26) {
7226 case ALC880_HP_EVENT:
7227 alc883_mitac_hp_automute(codec);
7228 break;
7229 case ALC880_MIC_EVENT:
7230 /* alc883_mitac_mic_automute(codec); */
7231 break;
7232 }
7233}
7234
7235static struct hda_verb alc883_mitac_verbs[] = {
7236 /* HP */
7237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7239 /* Subwoofer */
7240 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7241 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7242
7243 /* enable unsolicited event */
7244 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7245 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7246
7247 { } /* end */
7248};
7249
Jiang zhe368c7a92008-03-04 11:20:33 +01007250static struct hda_verb alc883_clevo_m720r_verbs[] = {
7251 /* HP */
7252 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7254 /* Int speaker */
7255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7257
7258 /* enable unsolicited event */
7259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7260
7261 { } /* end */
7262};
7263
Jiang zhefb97dc62008-03-06 11:07:11 +01007264static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7265 /* HP */
7266 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7268 /* Subwoofer */
7269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7271
7272 /* enable unsolicited event */
7273 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7274
7275 { } /* end */
7276};
7277
Kailang Yangccc656c2006-10-17 12:32:26 +02007278static struct hda_verb alc883_tagra_verbs[] = {
7279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7281
7282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7284
7285 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7286 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7287 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7288
7289 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007290 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7291 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7292 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007293
7294 { } /* end */
7295};
7296
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007297static struct hda_verb alc883_lenovo_101e_verbs[] = {
7298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7300 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7301 { } /* end */
7302};
7303
Kailang Yang272a5272007-05-14 11:00:38 +02007304static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7306 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7307 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7309 { } /* end */
7310};
7311
7312static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7318 { } /* end */
7319};
7320
Kailang Yang189609a2007-08-20 11:31:23 +02007321static struct hda_verb alc883_haier_w66_verbs[] = {
7322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7324
7325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7326
7327 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7329 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7331 { } /* end */
7332};
7333
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007334static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7337 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7338 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7339 { }
7340};
7341
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007342static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007343 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7344 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7345 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7346 { }
7347};
7348
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007349static struct hda_verb alc888_6st_dell_verbs[] = {
7350 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7352 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7353 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7354 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7355 { }
7356};
7357
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007358static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7361 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7362 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7363 { }
7364};
7365
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007366static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007367 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7368 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7369 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7370 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7371 { }
7372};
7373
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007374static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7375 { 2, alc888_3st_hp_2ch_init },
7376 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007377};
7378
Kailang Yang272a5272007-05-14 11:00:38 +02007379/* toggle front-jack and RCA according to the hp-jack state */
7380static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7381{
7382 unsigned int present;
7383
7384 present = snd_hda_codec_read(codec, 0x1b, 0,
7385 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007386 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7387 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7388 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7389 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007390}
7391
7392/* toggle RCA according to the front-jack state */
7393static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7394{
7395 unsigned int present;
7396
7397 present = snd_hda_codec_read(codec, 0x14, 0,
7398 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007399 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7400 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007401}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007402
Kailang Yang272a5272007-05-14 11:00:38 +02007403static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7404 unsigned int res)
7405{
7406 if ((res >> 26) == ALC880_HP_EVENT)
7407 alc888_lenovo_ms7195_front_automute(codec);
7408 if ((res >> 26) == ALC880_FRONT_EVENT)
7409 alc888_lenovo_ms7195_rca_automute(codec);
7410}
7411
7412static struct hda_verb alc883_medion_md2_verbs[] = {
7413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7415
7416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7417
7418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7419 { } /* end */
7420};
7421
7422/* toggle speaker-output according to the hp-jack state */
7423static void alc883_medion_md2_automute(struct hda_codec *codec)
7424{
7425 unsigned int present;
7426
7427 present = snd_hda_codec_read(codec, 0x14, 0,
7428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007429 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7430 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007431}
7432
7433static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7434 unsigned int res)
7435{
7436 if ((res >> 26) == ALC880_HP_EVENT)
7437 alc883_medion_md2_automute(codec);
7438}
7439
Kailang Yangccc656c2006-10-17 12:32:26 +02007440/* toggle speaker-output according to the hp-jack state */
7441static void alc883_tagra_automute(struct hda_codec *codec)
7442{
7443 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007444 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007445
7446 present = snd_hda_codec_read(codec, 0x14, 0,
7447 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007448 bits = present ? HDA_AMP_MUTE : 0;
7449 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7450 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007451 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7452 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007453}
7454
7455static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7456{
7457 if ((res >> 26) == ALC880_HP_EVENT)
7458 alc883_tagra_automute(codec);
7459}
7460
Jiang zhe368c7a92008-03-04 11:20:33 +01007461/* toggle speaker-output according to the hp-jack state */
7462static void alc883_clevo_m720r_automute(struct hda_codec *codec)
7463{
7464 unsigned int present;
7465 unsigned char bits;
7466
7467 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7468 & AC_PINSENSE_PRESENCE;
7469 bits = present ? HDA_AMP_MUTE : 0;
7470 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7471 HDA_AMP_MUTE, bits);
7472}
7473
7474static void alc883_clevo_m720r_unsol_event(struct hda_codec *codec,
7475 unsigned int res)
7476{
7477 if ((res >> 26) == ALC880_HP_EVENT)
7478 alc883_clevo_m720r_automute(codec);
7479}
7480
Jiang zhefb97dc62008-03-06 11:07:11 +01007481/* toggle speaker-output according to the hp-jack state */
7482static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7483{
7484 unsigned int present;
7485 unsigned char bits;
7486
7487 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7488 & AC_PINSENSE_PRESENCE;
7489 bits = present ? HDA_AMP_MUTE : 0;
7490 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7491 HDA_AMP_MUTE, bits);
7492}
7493
7494static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7495 unsigned int res)
7496{
7497 if ((res >> 26) == ALC880_HP_EVENT)
7498 alc883_2ch_fujitsu_pi2515_automute(codec);
7499}
7500
Kailang Yang189609a2007-08-20 11:31:23 +02007501static void alc883_haier_w66_automute(struct hda_codec *codec)
7502{
7503 unsigned int present;
7504 unsigned char bits;
7505
7506 present = snd_hda_codec_read(codec, 0x1b, 0,
7507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7508 bits = present ? 0x80 : 0;
7509 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7510 0x80, bits);
7511}
7512
7513static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7514 unsigned int res)
7515{
7516 if ((res >> 26) == ALC880_HP_EVENT)
7517 alc883_haier_w66_automute(codec);
7518}
7519
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007520static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7521{
7522 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007523 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007524
7525 present = snd_hda_codec_read(codec, 0x14, 0,
7526 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007527 bits = present ? HDA_AMP_MUTE : 0;
7528 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7529 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007530}
7531
7532static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7533{
7534 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007535 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007536
7537 present = snd_hda_codec_read(codec, 0x1b, 0,
7538 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007539 bits = present ? HDA_AMP_MUTE : 0;
7540 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7541 HDA_AMP_MUTE, bits);
7542 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7543 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007544}
7545
7546static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7547 unsigned int res)
7548{
7549 if ((res >> 26) == ALC880_HP_EVENT)
7550 alc883_lenovo_101e_all_automute(codec);
7551 if ((res >> 26) == ALC880_FRONT_EVENT)
7552 alc883_lenovo_101e_ispeaker_automute(codec);
7553}
7554
Takashi Iwai676a9b52007-08-16 15:23:35 +02007555/* toggle speaker-output according to the hp-jack state */
7556static void alc883_acer_aspire_automute(struct hda_codec *codec)
7557{
7558 unsigned int present;
7559
7560 present = snd_hda_codec_read(codec, 0x14, 0,
7561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7562 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7563 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7564 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7565 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7566}
7567
7568static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7569 unsigned int res)
7570{
7571 if ((res >> 26) == ALC880_HP_EVENT)
7572 alc883_acer_aspire_automute(codec);
7573}
7574
Kailang Yangd1a991a2007-08-15 16:21:59 +02007575static struct hda_verb alc883_acer_eapd_verbs[] = {
7576 /* HP Pin: output 0 (0x0c) */
7577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7579 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7580 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7582 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007583 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007584 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7585 /* eanable EAPD on medion laptop */
7586 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7587 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007588 /* enable unsolicited event */
7589 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007590 { }
7591};
7592
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007593static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7594{
7595 unsigned int present;
7596
7597 present = snd_hda_codec_read(codec, 0x1b, 0,
7598 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7599 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7600 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7601 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7602 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7603 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7604 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7605 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7606 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7607}
7608
7609static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7610 unsigned int res)
7611{
7612 switch (res >> 26) {
7613 case ALC880_HP_EVENT:
7614 printk("hp_event\n");
7615 alc888_6st_dell_front_automute(codec);
7616 break;
7617 }
7618}
7619
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007620/*
7621 * generic initialization of ADC, input mixers and output mixers
7622 */
7623static struct hda_verb alc883_auto_init_verbs[] = {
7624 /*
7625 * Unmute ADC0-2 and set the default input to mic-in
7626 */
7627 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7629 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7631
Takashi Iwaicb53c622007-08-10 17:21:45 +02007632 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007633 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007634 * Note: PASD motherboards uses the Line In 2 as the input for
7635 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007636 */
7637 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007643
7644 /*
7645 * Set up output mixers (0x0c - 0x0f)
7646 */
7647 /* set vol=0 to output mixers */
7648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7651 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7652 /* set up input amps for analog loopback */
7653 /* Amp Indices: DAC = 0, mixer = 1 */
7654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7662 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7663 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7664
7665 /* FIXME: use matrix-type input source selection */
7666 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7667 /* Input mixer1 */
7668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007671 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7673 /* Input mixer2 */
7674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007677 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007679
7680 { }
7681};
7682
7683/* capture mixer elements */
7684static struct snd_kcontrol_new alc883_capture_mixer[] = {
7685 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7686 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7687 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7688 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7689 {
7690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7691 /* The multiple "Capture Source" controls confuse alsamixer
7692 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007693 */
7694 /* .name = "Capture Source", */
7695 .name = "Input Source",
7696 .count = 2,
7697 .info = alc882_mux_enum_info,
7698 .get = alc882_mux_enum_get,
7699 .put = alc882_mux_enum_put,
7700 },
7701 { } /* end */
7702};
7703
Takashi Iwaicb53c622007-08-10 17:21:45 +02007704#ifdef CONFIG_SND_HDA_POWER_SAVE
7705#define alc883_loopbacks alc880_loopbacks
7706#endif
7707
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007708/* pcm configuration: identiacal with ALC880 */
7709#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7710#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007711#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007712#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7713#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7714
7715/*
7716 * configuration and preset
7717 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007718static const char *alc883_models[ALC883_MODEL_LAST] = {
7719 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7720 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7721 [ALC883_3ST_6ch] = "3stack-6ch",
7722 [ALC883_6ST_DIG] = "6stack-dig",
7723 [ALC883_TARGA_DIG] = "targa-dig",
7724 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007725 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007726 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007727 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007728 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007729 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007730 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007731 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7732 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007733 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007734 [ALC888_6ST_HP] = "6stack-hp",
7735 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007736 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007737 [ALC883_MITAC] = "mitac",
Jiang zhe368c7a92008-03-04 11:20:33 +01007738 [ALC883_CLEVO_M720R] = "clevo-m720r",
Jiang zhefb97dc62008-03-06 11:07:11 +01007739 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007740 [ALC883_AUTO] = "auto",
7741};
7742
7743static struct snd_pci_quirk alc883_cfg_tbl[] = {
7744 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007745 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7746 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7747 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7748 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007749 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007750 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007751 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7752 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7753 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7754 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007755 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007756 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7757 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7758 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007759 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007760 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7761 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7762 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7763 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007764 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007765 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7766 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7767 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7768 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7769 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7770 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7771 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7772 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7773 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007774 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7775 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007776 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007777 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007778 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007779 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007780 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Jiang zhe368c7a92008-03-04 11:20:33 +01007781 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720R),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007782 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007783 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007784 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007785 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007786 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007787 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007788 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7789 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007790 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007791 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007792 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007793 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007794 {}
7795};
7796
7797static struct alc_config_preset alc883_presets[] = {
7798 [ALC883_3ST_2ch_DIG] = {
7799 .mixers = { alc883_3ST_2ch_mixer },
7800 .init_verbs = { alc883_init_verbs },
7801 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7802 .dac_nids = alc883_dac_nids,
7803 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007804 .dig_in_nid = ALC883_DIGIN_NID,
7805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7806 .channel_mode = alc883_3ST_2ch_modes,
7807 .input_mux = &alc883_capture_source,
7808 },
7809 [ALC883_3ST_6ch_DIG] = {
7810 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7811 .init_verbs = { alc883_init_verbs },
7812 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7813 .dac_nids = alc883_dac_nids,
7814 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007815 .dig_in_nid = ALC883_DIGIN_NID,
7816 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7817 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007818 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007819 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007820 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007821 [ALC883_3ST_6ch] = {
7822 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7823 .init_verbs = { alc883_init_verbs },
7824 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7825 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007826 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7827 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007828 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007829 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007830 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831 [ALC883_6ST_DIG] = {
7832 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7833 .init_verbs = { alc883_init_verbs },
7834 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7835 .dac_nids = alc883_dac_nids,
7836 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007837 .dig_in_nid = ALC883_DIGIN_NID,
7838 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7839 .channel_mode = alc883_sixstack_modes,
7840 .input_mux = &alc883_capture_source,
7841 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007842 [ALC883_TARGA_DIG] = {
7843 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7844 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7846 .dac_nids = alc883_dac_nids,
7847 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7849 .channel_mode = alc883_3ST_6ch_modes,
7850 .need_dac_fix = 1,
7851 .input_mux = &alc883_capture_source,
7852 .unsol_event = alc883_tagra_unsol_event,
7853 .init_hook = alc883_tagra_automute,
7854 },
7855 [ALC883_TARGA_2ch_DIG] = {
7856 .mixers = { alc883_tagra_2ch_mixer},
7857 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7859 .dac_nids = alc883_dac_nids,
7860 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7862 .channel_mode = alc883_3ST_2ch_modes,
7863 .input_mux = &alc883_capture_source,
7864 .unsol_event = alc883_tagra_unsol_event,
7865 .init_hook = alc883_tagra_automute,
7866 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007867 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007868 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007869 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7870 * and the headphone jack. Turn this on and rely on the
7871 * standard mute methods whenever the user wants to turn
7872 * these outputs off.
7873 */
7874 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7876 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007877 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7878 .channel_mode = alc883_3ST_2ch_modes,
7879 .input_mux = &alc883_capture_source,
7880 },
Tobin Davis2880a862007-08-07 11:50:26 +02007881 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007882 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007883 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007884 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7885 .dac_nids = alc883_dac_nids,
7886 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02007887 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7888 .channel_mode = alc883_3ST_2ch_modes,
7889 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007890 .unsol_event = alc883_acer_aspire_unsol_event,
7891 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007892 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007893 [ALC883_MEDION] = {
7894 .mixers = { alc883_fivestack_mixer,
7895 alc883_chmode_mixer },
7896 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007897 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7899 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02007900 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7901 .channel_mode = alc883_sixstack_modes,
7902 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007903 },
Kailang Yang272a5272007-05-14 11:00:38 +02007904 [ALC883_MEDION_MD2] = {
7905 .mixers = { alc883_medion_md2_mixer},
7906 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7908 .dac_nids = alc883_dac_nids,
7909 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007910 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7911 .channel_mode = alc883_3ST_2ch_modes,
7912 .input_mux = &alc883_capture_source,
7913 .unsol_event = alc883_medion_md2_unsol_event,
7914 .init_hook = alc883_medion_md2_automute,
7915 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007916 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007917 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007918 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7919 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7920 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007921 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7922 .channel_mode = alc883_3ST_2ch_modes,
7923 .input_mux = &alc883_capture_source,
7924 },
Jiang zhe368c7a92008-03-04 11:20:33 +01007925 [ALC883_CLEVO_M720R] = {
7926 .mixers = { alc883_clevo_m720r_mixer },
7927 .init_verbs = { alc883_init_verbs, alc883_clevo_m720r_verbs },
7928 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7929 .dac_nids = alc883_dac_nids,
7930 .dig_out_nid = ALC883_DIGOUT_NID,
7931 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7932 .channel_mode = alc883_3ST_2ch_modes,
7933 .input_mux = &alc883_capture_source,
7934 .unsol_event = alc883_clevo_m720r_unsol_event,
7935 .init_hook = alc883_clevo_m720r_automute,
7936 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007937 [ALC883_LENOVO_101E_2ch] = {
7938 .mixers = { alc883_lenovo_101e_2ch_mixer},
7939 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7940 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7941 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007942 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7943 .channel_mode = alc883_3ST_2ch_modes,
7944 .input_mux = &alc883_lenovo_101e_capture_source,
7945 .unsol_event = alc883_lenovo_101e_unsol_event,
7946 .init_hook = alc883_lenovo_101e_all_automute,
7947 },
Kailang Yang272a5272007-05-14 11:00:38 +02007948 [ALC883_LENOVO_NB0763] = {
7949 .mixers = { alc883_lenovo_nb0763_mixer },
7950 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7951 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7952 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007953 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7954 .channel_mode = alc883_3ST_2ch_modes,
7955 .need_dac_fix = 1,
7956 .input_mux = &alc883_lenovo_nb0763_capture_source,
7957 .unsol_event = alc883_medion_md2_unsol_event,
7958 .init_hook = alc883_medion_md2_automute,
7959 },
7960 [ALC888_LENOVO_MS7195_DIG] = {
7961 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7962 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7964 .dac_nids = alc883_dac_nids,
7965 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007966 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7967 .channel_mode = alc883_3ST_6ch_modes,
7968 .need_dac_fix = 1,
7969 .input_mux = &alc883_capture_source,
7970 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7971 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007972 },
7973 [ALC883_HAIER_W66] = {
7974 .mixers = { alc883_tagra_2ch_mixer},
7975 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7976 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7977 .dac_nids = alc883_dac_nids,
7978 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02007979 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7980 .channel_mode = alc883_3ST_2ch_modes,
7981 .input_mux = &alc883_capture_source,
7982 .unsol_event = alc883_haier_w66_unsol_event,
7983 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007984 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007985 [ALC888_6ST_HP] = {
7986 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7987 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007988 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7989 .dac_nids = alc883_dac_nids,
7990 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007991 .dig_in_nid = ALC883_DIGIN_NID,
7992 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7993 .channel_mode = alc883_sixstack_modes,
7994 .input_mux = &alc883_capture_source,
7995 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007996 [ALC888_3ST_HP] = {
7997 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7998 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007999 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8000 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008001 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8002 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008003 .need_dac_fix = 1,
8004 .input_mux = &alc883_capture_source,
8005 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008006 [ALC888_6ST_DELL] = {
8007 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
8008 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8009 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8010 .dac_nids = alc883_dac_nids,
8011 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008012 .dig_in_nid = ALC883_DIGIN_NID,
8013 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8014 .channel_mode = alc883_sixstack_modes,
8015 .input_mux = &alc883_capture_source,
8016 .unsol_event = alc888_6st_dell_unsol_event,
8017 .init_hook = alc888_6st_dell_front_automute,
8018 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008019 [ALC883_MITAC] = {
8020 .mixers = { alc883_mitac_mixer },
8021 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8022 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8023 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008024 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8025 .channel_mode = alc883_3ST_2ch_modes,
8026 .input_mux = &alc883_capture_source,
8027 .unsol_event = alc883_mitac_unsol_event,
8028 .init_hook = alc883_mitac_automute,
8029 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008030 [ALC883_FUJITSU_PI2515] = {
8031 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8032 .init_verbs = { alc883_init_verbs,
8033 alc883_2ch_fujitsu_pi2515_verbs},
8034 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8035 .dac_nids = alc883_dac_nids,
8036 .dig_out_nid = ALC883_DIGOUT_NID,
8037 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8038 .channel_mode = alc883_3ST_2ch_modes,
8039 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8040 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8041 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8042 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008043};
8044
8045
8046/*
8047 * BIOS auto configuration
8048 */
8049static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8050 hda_nid_t nid, int pin_type,
8051 int dac_idx)
8052{
8053 /* set as output */
8054 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008055 int idx;
8056
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008057 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008058 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8059 idx = 4;
8060 else
8061 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008062 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8063
8064}
8065
8066static void alc883_auto_init_multi_out(struct hda_codec *codec)
8067{
8068 struct alc_spec *spec = codec->spec;
8069 int i;
8070
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008071 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008072 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008073 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008074 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008075 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008076 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008077 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008078 }
8079}
8080
8081static void alc883_auto_init_hp_out(struct hda_codec *codec)
8082{
8083 struct alc_spec *spec = codec->spec;
8084 hda_nid_t pin;
8085
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008086 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008087 if (pin) /* connect to front */
8088 /* use dac 0 */
8089 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008090 pin = spec->autocfg.speaker_pins[0];
8091 if (pin)
8092 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008093}
8094
8095#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8096#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8097
8098static void alc883_auto_init_analog_input(struct hda_codec *codec)
8099{
8100 struct alc_spec *spec = codec->spec;
8101 int i;
8102
8103 for (i = 0; i < AUTO_PIN_LAST; i++) {
8104 hda_nid_t nid = spec->autocfg.input_pins[i];
8105 if (alc883_is_input_pin(nid)) {
8106 snd_hda_codec_write(codec, nid, 0,
8107 AC_VERB_SET_PIN_WIDGET_CONTROL,
8108 (i <= AUTO_PIN_FRONT_MIC ?
8109 PIN_VREF80 : PIN_IN));
8110 if (nid != ALC883_PIN_CD_NID)
8111 snd_hda_codec_write(codec, nid, 0,
8112 AC_VERB_SET_AMP_GAIN_MUTE,
8113 AMP_OUT_MUTE);
8114 }
8115 }
8116}
8117
8118/* almost identical with ALC880 parser... */
8119static int alc883_parse_auto_config(struct hda_codec *codec)
8120{
8121 struct alc_spec *spec = codec->spec;
8122 int err = alc880_parse_auto_config(codec);
8123
8124 if (err < 0)
8125 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008126 else if (!err)
8127 return 0; /* no config found */
8128
8129 err = alc_auto_add_mic_boost(codec);
8130 if (err < 0)
8131 return err;
8132
8133 /* hack - override the init verbs */
8134 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008135 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8136 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008137
8138 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008139}
8140
8141/* additional initialization for auto-configuration model */
8142static void alc883_auto_init(struct hda_codec *codec)
8143{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008144 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008145 alc883_auto_init_multi_out(codec);
8146 alc883_auto_init_hp_out(codec);
8147 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008148 if (spec->unsol_event)
8149 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008150}
8151
8152static int patch_alc883(struct hda_codec *codec)
8153{
8154 struct alc_spec *spec;
8155 int err, board_config;
8156
8157 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8158 if (spec == NULL)
8159 return -ENOMEM;
8160
8161 codec->spec = spec;
8162
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008163 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8164 alc883_models,
8165 alc883_cfg_tbl);
8166 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008167 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8168 "trying auto-probe from BIOS...\n");
8169 board_config = ALC883_AUTO;
8170 }
8171
8172 if (board_config == ALC883_AUTO) {
8173 /* automatic parse from the BIOS config */
8174 err = alc883_parse_auto_config(codec);
8175 if (err < 0) {
8176 alc_free(codec);
8177 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008178 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008179 printk(KERN_INFO
8180 "hda_codec: Cannot set up configuration "
8181 "from BIOS. Using base mode...\n");
8182 board_config = ALC883_3ST_2ch_DIG;
8183 }
8184 }
8185
8186 if (board_config != ALC883_AUTO)
8187 setup_preset(spec, &alc883_presets[board_config]);
8188
8189 spec->stream_name_analog = "ALC883 Analog";
8190 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8191 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008192 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008193
8194 spec->stream_name_digital = "ALC883 Digital";
8195 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8196 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8197
Takashi Iwaie1406342008-02-11 18:32:32 +01008198 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8199 spec->adc_nids = alc883_adc_nids;
8200 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008201
Takashi Iwai2134ea42008-01-10 16:53:55 +01008202 spec->vmaster_nid = 0x0c;
8203
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008204 codec->patch_ops = alc_patch_ops;
8205 if (board_config == ALC883_AUTO)
8206 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008207#ifdef CONFIG_SND_HDA_POWER_SAVE
8208 if (!spec->loopback.amplist)
8209 spec->loopback.amplist = alc883_loopbacks;
8210#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008211
8212 return 0;
8213}
8214
8215/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008216 * ALC262 support
8217 */
8218
8219#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8220#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8221
8222#define alc262_dac_nids alc260_dac_nids
8223#define alc262_adc_nids alc882_adc_nids
8224#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008225#define alc262_capsrc_nids alc882_capsrc_nids
8226#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008227
8228#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008229#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008230
8231static struct snd_kcontrol_new alc262_base_mixer[] = {
8232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8233 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8237 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008241 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8242 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008243 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008244 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008245 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008246 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8248 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8249 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008250 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008251};
8252
Kailang Yangccc656c2006-10-17 12:32:26 +02008253static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8254 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8256 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8257 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8258 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8259 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008263 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8264 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008265 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008266 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008267 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008268 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8270 { } /* end */
8271};
8272
Takashi Iwaice875f02008-01-28 18:17:43 +01008273/* update HP, line and mono-out pins according to the master switch */
8274static void alc262_hp_master_update(struct hda_codec *codec)
8275{
8276 struct alc_spec *spec = codec->spec;
8277 int val = spec->master_sw;
8278
8279 /* HP & line-out */
8280 snd_hda_codec_write_cache(codec, 0x1b, 0,
8281 AC_VERB_SET_PIN_WIDGET_CONTROL,
8282 val ? PIN_HP : 0);
8283 snd_hda_codec_write_cache(codec, 0x15, 0,
8284 AC_VERB_SET_PIN_WIDGET_CONTROL,
8285 val ? PIN_HP : 0);
8286 /* mono (speaker) depending on the HP jack sense */
8287 val = val && !spec->jack_present;
8288 snd_hda_codec_write_cache(codec, 0x16, 0,
8289 AC_VERB_SET_PIN_WIDGET_CONTROL,
8290 val ? PIN_OUT : 0);
8291}
8292
8293static void alc262_hp_bpc_automute(struct hda_codec *codec)
8294{
8295 struct alc_spec *spec = codec->spec;
8296 unsigned int presence;
8297 presence = snd_hda_codec_read(codec, 0x1b, 0,
8298 AC_VERB_GET_PIN_SENSE, 0);
8299 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8300 alc262_hp_master_update(codec);
8301}
8302
8303static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8304{
8305 if ((res >> 26) != ALC880_HP_EVENT)
8306 return;
8307 alc262_hp_bpc_automute(codec);
8308}
8309
8310static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8311{
8312 struct alc_spec *spec = codec->spec;
8313 unsigned int presence;
8314 presence = snd_hda_codec_read(codec, 0x15, 0,
8315 AC_VERB_GET_PIN_SENSE, 0);
8316 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8317 alc262_hp_master_update(codec);
8318}
8319
8320static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8321 unsigned int res)
8322{
8323 if ((res >> 26) != ALC880_HP_EVENT)
8324 return;
8325 alc262_hp_wildwest_automute(codec);
8326}
8327
8328static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8329 struct snd_ctl_elem_value *ucontrol)
8330{
8331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8332 struct alc_spec *spec = codec->spec;
8333 *ucontrol->value.integer.value = spec->master_sw;
8334 return 0;
8335}
8336
8337static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8338 struct snd_ctl_elem_value *ucontrol)
8339{
8340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8341 struct alc_spec *spec = codec->spec;
8342 int val = !!*ucontrol->value.integer.value;
8343
8344 if (val == spec->master_sw)
8345 return 0;
8346 spec->master_sw = val;
8347 alc262_hp_master_update(codec);
8348 return 1;
8349}
8350
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008351static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008352 {
8353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8354 .name = "Master Playback Switch",
8355 .info = snd_ctl_boolean_mono_info,
8356 .get = alc262_hp_master_sw_get,
8357 .put = alc262_hp_master_sw_put,
8358 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008359 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8360 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008362 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8363 HDA_OUTPUT),
8364 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8365 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008371 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8376 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8377 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8378 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8379 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8380 { } /* end */
8381};
8382
Kailang Yangcd7509a2007-01-26 18:33:17 +01008383static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008384 {
8385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8386 .name = "Master Playback Switch",
8387 .info = snd_ctl_boolean_mono_info,
8388 .get = alc262_hp_master_sw_get,
8389 .put = alc262_hp_master_sw_put,
8390 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008391 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8392 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008395 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8396 HDA_OUTPUT),
8397 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8398 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008399 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8400 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008401 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008402 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8403 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8404 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8405 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8406 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8407 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8408 { } /* end */
8409};
8410
8411static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8412 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8413 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008414 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008415 { } /* end */
8416};
8417
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008418/* mute/unmute internal speaker according to the hp jack and mute state */
8419static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8420{
8421 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008422
8423 if (force || !spec->sense_updated) {
8424 unsigned int present;
8425 present = snd_hda_codec_read(codec, 0x15, 0,
8426 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008427 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008428 spec->sense_updated = 1;
8429 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008430 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8431 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008432}
8433
8434static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8435 unsigned int res)
8436{
8437 if ((res >> 26) != ALC880_HP_EVENT)
8438 return;
8439 alc262_hp_t5735_automute(codec, 1);
8440}
8441
8442static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8443{
8444 alc262_hp_t5735_automute(codec, 1);
8445}
8446
8447static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008448 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8449 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008450 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8455 { } /* end */
8456};
8457
8458static struct hda_verb alc262_hp_t5735_verbs[] = {
8459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8461
8462 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8463 { }
8464};
8465
Kailang Yang8c427222008-01-10 13:03:59 +01008466static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008467 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008469 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8470 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8473 { } /* end */
8474};
8475
8476static struct hda_verb alc262_hp_rp5700_verbs[] = {
8477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8482 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8487 {}
8488};
8489
8490static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8491 .num_items = 1,
8492 .items = {
8493 { "Line", 0x1 },
8494 },
8495};
8496
Takashi Iwai0724ea22007-08-23 00:31:43 +02008497/* bind hp and internal speaker mute (with plug check) */
8498static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8499 struct snd_ctl_elem_value *ucontrol)
8500{
8501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8502 long *valp = ucontrol->value.integer.value;
8503 int change;
8504
8505 /* change hp mute */
8506 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8507 HDA_AMP_MUTE,
8508 valp[0] ? 0 : HDA_AMP_MUTE);
8509 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8510 HDA_AMP_MUTE,
8511 valp[1] ? 0 : HDA_AMP_MUTE);
8512 if (change) {
8513 /* change speaker according to HP jack state */
8514 struct alc_spec *spec = codec->spec;
8515 unsigned int mute;
8516 if (spec->jack_present)
8517 mute = HDA_AMP_MUTE;
8518 else
8519 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8520 HDA_OUTPUT, 0);
8521 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8522 HDA_AMP_MUTE, mute);
8523 }
8524 return change;
8525}
Takashi Iwai5b319542007-07-26 11:49:22 +02008526
Kailang Yang272a5272007-05-14 11:00:38 +02008527static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008528 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8529 {
8530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8531 .name = "Master Playback Switch",
8532 .info = snd_hda_mixer_amp_switch_info,
8533 .get = snd_hda_mixer_amp_switch_get,
8534 .put = alc262_sony_master_sw_put,
8535 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8536 },
Kailang Yang272a5272007-05-14 11:00:38 +02008537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8539 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8540 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8541 { } /* end */
8542};
8543
Kailang Yang83c34212007-07-05 11:43:05 +02008544static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8546 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8550 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8551 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8552 { } /* end */
8553};
Kailang Yang272a5272007-05-14 11:00:38 +02008554
Kailang Yangdf694da2005-12-05 19:42:22 +01008555#define alc262_capture_mixer alc882_capture_mixer
8556#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8557
8558/*
8559 * generic initialization of ADC, input mixers and output mixers
8560 */
8561static struct hda_verb alc262_init_verbs[] = {
8562 /*
8563 * Unmute ADC0-2 and set the default input to mic-in
8564 */
8565 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8567 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8569 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8570 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8571
Takashi Iwaicb53c622007-08-10 17:21:45 +02008572 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008573 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008574 * Note: PASD motherboards uses the Line In 2 as the input for
8575 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008576 */
8577 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008583
8584 /*
8585 * Set up output mixers (0x0c - 0x0e)
8586 */
8587 /* set vol=0 to output mixers */
8588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8591 /* set up input amps for analog loopback */
8592 /* Amp Indices: DAC = 0, mixer = 1 */
8593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8599
8600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8602 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8603 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8606
8607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8612
8613 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8614 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8615
8616 /* FIXME: use matrix-type input source selection */
8617 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8618 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8619 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8622 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8623 /* Input mixer2 */
8624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8628 /* Input mixer3 */
8629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008633
8634 { }
8635};
8636
Kailang Yangccc656c2006-10-17 12:32:26 +02008637static struct hda_verb alc262_hippo_unsol_verbs[] = {
8638 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8640 {}
8641};
8642
8643static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8645 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8647
8648 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {}
8651};
8652
Kailang Yang272a5272007-05-14 11:00:38 +02008653static struct hda_verb alc262_sony_unsol_verbs[] = {
8654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8657
8658 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8660};
8661
Kailang Yangccc656c2006-10-17 12:32:26 +02008662/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008663static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008664{
8665 struct alc_spec *spec = codec->spec;
8666 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008667 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008668
Takashi Iwai5b319542007-07-26 11:49:22 +02008669 /* need to execute and sync at first */
8670 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8671 present = snd_hda_codec_read(codec, 0x15, 0,
8672 AC_VERB_GET_PIN_SENSE, 0);
8673 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008674 if (spec->jack_present) {
8675 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008676 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8677 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008678 } else {
8679 /* unmute internal speaker if necessary */
8680 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008681 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8682 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008683 }
8684}
8685
8686/* unsolicited event for HP jack sensing */
8687static void alc262_hippo_unsol_event(struct hda_codec *codec,
8688 unsigned int res)
8689{
8690 if ((res >> 26) != ALC880_HP_EVENT)
8691 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008692 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008693}
8694
Takashi Iwai5b319542007-07-26 11:49:22 +02008695static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008696{
Kailang Yangccc656c2006-10-17 12:32:26 +02008697 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008698 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008699
Takashi Iwai5b319542007-07-26 11:49:22 +02008700 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8701 present = snd_hda_codec_read(codec, 0x1b, 0,
8702 AC_VERB_GET_PIN_SENSE, 0);
8703 present = (present & 0x80000000) != 0;
8704 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008705 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008706 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8707 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008708 } else {
8709 /* unmute internal speaker if necessary */
8710 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008711 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8712 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008713 }
8714}
8715
8716/* unsolicited event for HP jack sensing */
8717static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8718 unsigned int res)
8719{
8720 if ((res >> 26) != ALC880_HP_EVENT)
8721 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008722 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008723}
8724
Takashi Iwai834be882006-03-01 14:16:17 +01008725/*
8726 * fujitsu model
8727 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8728 */
8729
8730#define ALC_HP_EVENT 0x37
8731
8732static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8733 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8735 {}
8736};
8737
8738static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008739 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008740 .items = {
8741 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008742 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008743 { "CD", 0x4 },
8744 },
8745};
8746
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008747static struct hda_input_mux alc262_HP_capture_source = {
8748 .num_items = 5,
8749 .items = {
8750 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008751 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008752 { "Line", 0x2 },
8753 { "CD", 0x4 },
8754 { "AUX IN", 0x6 },
8755 },
8756};
8757
zhejiangaccbe492007-08-31 12:36:05 +02008758static struct hda_input_mux alc262_HP_D7000_capture_source = {
8759 .num_items = 4,
8760 .items = {
8761 { "Mic", 0x0 },
8762 { "Front Mic", 0x2 },
8763 { "Line", 0x1 },
8764 { "CD", 0x4 },
8765 },
8766};
8767
Takashi Iwai834be882006-03-01 14:16:17 +01008768/* mute/unmute internal speaker according to the hp jack and mute state */
8769static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8770{
8771 struct alc_spec *spec = codec->spec;
8772 unsigned int mute;
8773
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008774 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01008775 unsigned int present;
8776 /* need to execute and sync at first */
8777 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8778 present = snd_hda_codec_read(codec, 0x14, 0,
8779 AC_VERB_GET_PIN_SENSE, 0);
8780 spec->jack_present = (present & 0x80000000) != 0;
8781 spec->sense_updated = 1;
8782 }
8783 if (spec->jack_present) {
8784 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008785 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8786 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008787 } else {
8788 /* unmute internal speaker if necessary */
8789 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008790 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8791 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008792 }
8793}
8794
8795/* unsolicited event for HP jack sensing */
8796static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8797 unsigned int res)
8798{
8799 if ((res >> 26) != ALC_HP_EVENT)
8800 return;
8801 alc262_fujitsu_automute(codec, 1);
8802}
8803
8804/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008805static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8806 .ops = &snd_hda_bind_vol,
8807 .values = {
8808 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8809 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8810 0
8811 },
8812};
Takashi Iwai834be882006-03-01 14:16:17 +01008813
8814/* bind hp and internal speaker mute (with plug check) */
8815static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8816 struct snd_ctl_elem_value *ucontrol)
8817{
8818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8819 long *valp = ucontrol->value.integer.value;
8820 int change;
8821
8822 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008823 HDA_AMP_MUTE,
8824 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01008825 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02008826 HDA_AMP_MUTE,
8827 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008828 if (change)
8829 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008830 return change;
8831}
8832
8833static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008834 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008835 {
8836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8837 .name = "Master Playback Switch",
8838 .info = snd_hda_mixer_amp_switch_info,
8839 .get = snd_hda_mixer_amp_switch_get,
8840 .put = alc262_fujitsu_master_sw_put,
8841 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8842 },
8843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008848 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8849 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8850 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008851 { } /* end */
8852};
8853
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008854/* additional init verbs for Benq laptops */
8855static struct hda_verb alc262_EAPD_verbs[] = {
8856 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8857 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8858 {}
8859};
8860
Kailang Yang83c34212007-07-05 11:43:05 +02008861static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8864
8865 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8866 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8867 {}
8868};
8869
Tobin Davisf651b502007-10-26 12:40:47 +02008870/* Samsung Q1 Ultra Vista model setup */
8871static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8873 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8877 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8878 { } /* end */
8879};
8880
8881static struct hda_verb alc262_ultra_verbs[] = {
8882 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8885 /* Mic is on Node 0x19 */
8886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8887 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8889 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8891 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8893 {}
8894};
8895
8896static struct hda_input_mux alc262_ultra_capture_source = {
8897 .num_items = 1,
8898 .items = {
8899 { "Mic", 0x1 },
8900 },
8901};
8902
8903/* mute/unmute internal speaker according to the hp jack and mute state */
8904static void alc262_ultra_automute(struct hda_codec *codec)
8905{
8906 struct alc_spec *spec = codec->spec;
8907 unsigned int mute;
8908 unsigned int present;
8909
8910 /* need to execute and sync at first */
8911 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8912 present = snd_hda_codec_read(codec, 0x15, 0,
8913 AC_VERB_GET_PIN_SENSE, 0);
8914 spec->jack_present = (present & 0x80000000) != 0;
8915 if (spec->jack_present) {
8916 /* mute internal speaker */
8917 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8918 HDA_AMP_MUTE, HDA_AMP_MUTE);
8919 } else {
8920 /* unmute internal speaker if necessary */
8921 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8922 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8923 HDA_AMP_MUTE, mute);
8924 }
8925}
8926
8927/* unsolicited event for HP jack sensing */
8928static void alc262_ultra_unsol_event(struct hda_codec *codec,
8929 unsigned int res)
8930{
8931 if ((res >> 26) != ALC880_HP_EVENT)
8932 return;
8933 alc262_ultra_automute(codec);
8934}
8935
Kailang Yangdf694da2005-12-05 19:42:22 +01008936/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008937static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8938 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008939{
8940 hda_nid_t nid;
8941 int err;
8942
8943 spec->multiout.num_dacs = 1; /* only use one dac */
8944 spec->multiout.dac_nids = spec->private_dac_nids;
8945 spec->multiout.dac_nids[0] = 2;
8946
8947 nid = cfg->line_out_pins[0];
8948 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008949 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8950 "Front Playback Volume",
8951 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8952 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008953 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008954 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8955 "Front Playback Switch",
8956 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8957 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008958 return err;
8959 }
8960
Takashi Iwai82bc9552006-03-21 11:24:42 +01008961 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008962 if (nid) {
8963 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008964 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8965 "Speaker Playback Volume",
8966 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8967 HDA_OUTPUT));
8968 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008969 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008970 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8971 "Speaker Playback Switch",
8972 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8973 HDA_OUTPUT));
8974 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008975 return err;
8976 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008977 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8978 "Speaker Playback Switch",
8979 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8980 HDA_OUTPUT));
8981 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008982 return err;
8983 }
8984 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008985 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008986 if (nid) {
8987 /* spec->multiout.hp_nid = 2; */
8988 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008989 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8990 "Headphone Playback Volume",
8991 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8992 HDA_OUTPUT));
8993 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008994 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008995 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8996 "Headphone Playback Switch",
8997 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8998 HDA_OUTPUT));
8999 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009000 return err;
9001 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009002 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9003 "Headphone Playback Switch",
9004 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9005 HDA_OUTPUT));
9006 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009007 return err;
9008 }
9009 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009010 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009011}
9012
9013/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009014#define alc262_auto_create_analog_input_ctls \
9015 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009016
9017/*
9018 * generic initialization of ADC, input mixers and output mixers
9019 */
9020static struct hda_verb alc262_volume_init_verbs[] = {
9021 /*
9022 * Unmute ADC0-2 and set the default input to mic-in
9023 */
9024 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9026 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9027 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9028 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9030
Takashi Iwaicb53c622007-08-10 17:21:45 +02009031 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009032 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009033 * Note: PASD motherboards uses the Line In 2 as the input for
9034 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009035 */
9036 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009042
9043 /*
9044 * Set up output mixers (0x0c - 0x0f)
9045 */
9046 /* set vol=0 to output mixers */
9047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9050
9051 /* set up input amps for analog loopback */
9052 /* Amp Indices: DAC = 0, mixer = 1 */
9053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9059
9060 /* FIXME: use matrix-type input source selection */
9061 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9062 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9067 /* Input mixer2 */
9068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9072 /* Input mixer3 */
9073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9077
9078 { }
9079};
9080
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009081static struct hda_verb alc262_HP_BPC_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
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009093 * 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)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009096 */
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)},
9103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009105
9106 /*
9107 * Set up output mixers (0x0c - 0x0e)
9108 */
9109 /* set vol=0 to output mixers */
9110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9113
9114 /* set up input amps for analog loopback */
9115 /* Amp Indices: DAC = 0, mixer = 1 */
9116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9122
Takashi Iwaice875f02008-01-28 18:17:43 +01009123 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9125 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9126
9127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9129
9130 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9132
9133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9134 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9135 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9137 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9138
9139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9143 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9144 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9145
9146
9147 /* FIXME: use matrix-type input source selection */
9148 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9149 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9154 /* Input mixer2 */
9155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9159 /* Input mixer3 */
9160 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9164
Takashi Iwaice875f02008-01-28 18:17:43 +01009165 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9166
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009167 { }
9168};
9169
Kailang Yangcd7509a2007-01-26 18:33:17 +01009170static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9171 /*
9172 * Unmute ADC0-2 and set the default input to mic-in
9173 */
9174 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9180
Takashi Iwaicb53c622007-08-10 17:21:45 +02009181 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009182 * mixer widget
9183 * Note: PASD motherboards uses the Line In 2 as the input for front
9184 * panel mic (mic 2)
9185 */
9186 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009195 /*
9196 * Set up output mixers (0x0c - 0x0e)
9197 */
9198 /* set vol=0 to output mixers */
9199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9202
9203 /* set up input amps for analog loopback */
9204 /* Amp Indices: DAC = 0, mixer = 1 */
9205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9211
9212
9213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9219 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9220
9221 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9223
9224 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9226
9227 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9231 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9232 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9233
9234 /* FIXME: use matrix-type input source selection */
9235 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9236 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9242 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9244 /* Input mixer2 */
9245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9250 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9252 /* Input mixer3 */
9253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9258 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9260
Takashi Iwaice875f02008-01-28 18:17:43 +01009261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9262
Kailang Yangcd7509a2007-01-26 18:33:17 +01009263 { }
9264};
9265
Takashi Iwaicb53c622007-08-10 17:21:45 +02009266#ifdef CONFIG_SND_HDA_POWER_SAVE
9267#define alc262_loopbacks alc880_loopbacks
9268#endif
9269
Kailang Yangdf694da2005-12-05 19:42:22 +01009270/* pcm configuration: identiacal with ALC880 */
9271#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9272#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9273#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9274#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9275
9276/*
9277 * BIOS auto configuration
9278 */
9279static int alc262_parse_auto_config(struct hda_codec *codec)
9280{
9281 struct alc_spec *spec = codec->spec;
9282 int err;
9283 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9284
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009285 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9286 alc262_ignore);
9287 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009288 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009289 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009290 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009291 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9292 if (err < 0)
9293 return err;
9294 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9295 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009296 return err;
9297
9298 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9299
9300 if (spec->autocfg.dig_out_pin)
9301 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9302 if (spec->autocfg.dig_in_pin)
9303 spec->dig_in_nid = ALC262_DIGIN_NID;
9304
9305 if (spec->kctl_alloc)
9306 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9307
9308 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009309 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009310 spec->input_mux = &spec->private_imux;
9311
Takashi Iwai776e1842007-08-29 15:07:11 +02009312 err = alc_auto_add_mic_boost(codec);
9313 if (err < 0)
9314 return err;
9315
Kailang Yangdf694da2005-12-05 19:42:22 +01009316 return 1;
9317}
9318
9319#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9320#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9321#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9322
9323
9324/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009325static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009326{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009327 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009328 alc262_auto_init_multi_out(codec);
9329 alc262_auto_init_hp_out(codec);
9330 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009331 if (spec->unsol_event)
9332 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009333}
9334
9335/*
9336 * configuration and preset
9337 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009338static const char *alc262_models[ALC262_MODEL_LAST] = {
9339 [ALC262_BASIC] = "basic",
9340 [ALC262_HIPPO] = "hippo",
9341 [ALC262_HIPPO_1] = "hippo_1",
9342 [ALC262_FUJITSU] = "fujitsu",
9343 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009344 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009345 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009346 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009347 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009348 [ALC262_BENQ_T31] = "benq-t31",
9349 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009350 [ALC262_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009351 [ALC262_AUTO] = "auto",
9352};
9353
9354static struct snd_pci_quirk alc262_cfg_tbl[] = {
9355 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9356 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009357 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009358 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9359 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009360 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009361 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009362 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009363 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009364 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009365 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009366 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009367 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009368 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009369 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009370 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009371 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009372 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9373 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9374 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009375 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9376 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009377 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009378 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009379 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009380 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9381 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9382 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009383 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009384 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009385 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009386 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009387 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009388 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009389 {}
9390};
9391
9392static struct alc_config_preset alc262_presets[] = {
9393 [ALC262_BASIC] = {
9394 .mixers = { alc262_base_mixer },
9395 .init_verbs = { alc262_init_verbs },
9396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9397 .dac_nids = alc262_dac_nids,
9398 .hp_nid = 0x03,
9399 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9400 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009401 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009402 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009403 [ALC262_HIPPO] = {
9404 .mixers = { alc262_base_mixer },
9405 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9407 .dac_nids = alc262_dac_nids,
9408 .hp_nid = 0x03,
9409 .dig_out_nid = ALC262_DIGOUT_NID,
9410 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9411 .channel_mode = alc262_modes,
9412 .input_mux = &alc262_capture_source,
9413 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009414 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009415 },
9416 [ALC262_HIPPO_1] = {
9417 .mixers = { alc262_hippo1_mixer },
9418 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9420 .dac_nids = alc262_dac_nids,
9421 .hp_nid = 0x02,
9422 .dig_out_nid = ALC262_DIGOUT_NID,
9423 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9424 .channel_mode = alc262_modes,
9425 .input_mux = &alc262_capture_source,
9426 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009427 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009428 },
Takashi Iwai834be882006-03-01 14:16:17 +01009429 [ALC262_FUJITSU] = {
9430 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009431 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9432 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009433 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9434 .dac_nids = alc262_dac_nids,
9435 .hp_nid = 0x03,
9436 .dig_out_nid = ALC262_DIGOUT_NID,
9437 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9438 .channel_mode = alc262_modes,
9439 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009440 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01009441 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009442 [ALC262_HP_BPC] = {
9443 .mixers = { alc262_HP_BPC_mixer },
9444 .init_verbs = { alc262_HP_BPC_init_verbs },
9445 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9446 .dac_nids = alc262_dac_nids,
9447 .hp_nid = 0x03,
9448 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9449 .channel_mode = alc262_modes,
9450 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009451 .unsol_event = alc262_hp_bpc_unsol_event,
9452 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009453 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009454 [ALC262_HP_BPC_D7000_WF] = {
9455 .mixers = { alc262_HP_BPC_WildWest_mixer },
9456 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9457 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9458 .dac_nids = alc262_dac_nids,
9459 .hp_nid = 0x03,
9460 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9461 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009462 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009463 .unsol_event = alc262_hp_wildwest_unsol_event,
9464 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009465 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009466 [ALC262_HP_BPC_D7000_WL] = {
9467 .mixers = { alc262_HP_BPC_WildWest_mixer,
9468 alc262_HP_BPC_WildWest_option_mixer },
9469 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9471 .dac_nids = alc262_dac_nids,
9472 .hp_nid = 0x03,
9473 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9474 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009475 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009476 .unsol_event = alc262_hp_wildwest_unsol_event,
9477 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009478 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009479 [ALC262_HP_TC_T5735] = {
9480 .mixers = { alc262_hp_t5735_mixer },
9481 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9482 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9483 .dac_nids = alc262_dac_nids,
9484 .hp_nid = 0x03,
9485 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9486 .channel_mode = alc262_modes,
9487 .input_mux = &alc262_capture_source,
9488 .unsol_event = alc262_hp_t5735_unsol_event,
9489 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009490 },
9491 [ALC262_HP_RP5700] = {
9492 .mixers = { alc262_hp_rp5700_mixer },
9493 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9494 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9495 .dac_nids = alc262_dac_nids,
9496 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9497 .channel_mode = alc262_modes,
9498 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009499 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009500 [ALC262_BENQ_ED8] = {
9501 .mixers = { alc262_base_mixer },
9502 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9503 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9504 .dac_nids = alc262_dac_nids,
9505 .hp_nid = 0x03,
9506 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9507 .channel_mode = alc262_modes,
9508 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009509 },
Kailang Yang272a5272007-05-14 11:00:38 +02009510 [ALC262_SONY_ASSAMD] = {
9511 .mixers = { alc262_sony_mixer },
9512 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9513 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9514 .dac_nids = alc262_dac_nids,
9515 .hp_nid = 0x02,
9516 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9517 .channel_mode = alc262_modes,
9518 .input_mux = &alc262_capture_source,
9519 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009520 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009521 },
9522 [ALC262_BENQ_T31] = {
9523 .mixers = { alc262_benq_t31_mixer },
9524 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9525 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9526 .dac_nids = alc262_dac_nids,
9527 .hp_nid = 0x03,
9528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9529 .channel_mode = alc262_modes,
9530 .input_mux = &alc262_capture_source,
9531 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009532 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009533 },
Tobin Davisf651b502007-10-26 12:40:47 +02009534 [ALC262_ULTRA] = {
9535 .mixers = { alc262_ultra_mixer },
9536 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9538 .dac_nids = alc262_dac_nids,
9539 .hp_nid = 0x03,
9540 .dig_out_nid = ALC262_DIGOUT_NID,
9541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9542 .channel_mode = alc262_modes,
9543 .input_mux = &alc262_ultra_capture_source,
9544 .unsol_event = alc262_ultra_unsol_event,
9545 .init_hook = alc262_ultra_automute,
9546 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009547};
9548
9549static int patch_alc262(struct hda_codec *codec)
9550{
9551 struct alc_spec *spec;
9552 int board_config;
9553 int err;
9554
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009555 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 if (spec == NULL)
9557 return -ENOMEM;
9558
9559 codec->spec = spec;
9560#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009561 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9562 * under-run
9563 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009564 {
9565 int tmp;
9566 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9567 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9568 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9569 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9570 }
9571#endif
9572
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009573 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9574 alc262_models,
9575 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009576
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009577 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009578 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9579 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009580 board_config = ALC262_AUTO;
9581 }
9582
9583 if (board_config == ALC262_AUTO) {
9584 /* automatic parse from the BIOS config */
9585 err = alc262_parse_auto_config(codec);
9586 if (err < 0) {
9587 alc_free(codec);
9588 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009589 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009590 printk(KERN_INFO
9591 "hda_codec: Cannot set up configuration "
9592 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009593 board_config = ALC262_BASIC;
9594 }
9595 }
9596
9597 if (board_config != ALC262_AUTO)
9598 setup_preset(spec, &alc262_presets[board_config]);
9599
9600 spec->stream_name_analog = "ALC262 Analog";
9601 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9602 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9603
9604 spec->stream_name_digital = "ALC262 Digital";
9605 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9606 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9607
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009608 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009610 unsigned int wcap = get_wcaps(codec, 0x07);
9611
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009612 /* get type */
9613 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009614 if (wcap != AC_WID_AUD_IN) {
9615 spec->adc_nids = alc262_adc_nids_alt;
9616 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009617 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009618 spec->mixers[spec->num_mixers] =
9619 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009620 spec->num_mixers++;
9621 } else {
9622 spec->adc_nids = alc262_adc_nids;
9623 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009624 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009625 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9626 spec->num_mixers++;
9627 }
9628 }
9629
Takashi Iwai2134ea42008-01-10 16:53:55 +01009630 spec->vmaster_nid = 0x0c;
9631
Kailang Yangdf694da2005-12-05 19:42:22 +01009632 codec->patch_ops = alc_patch_ops;
9633 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009634 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009635#ifdef CONFIG_SND_HDA_POWER_SAVE
9636 if (!spec->loopback.amplist)
9637 spec->loopback.amplist = alc262_loopbacks;
9638#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009639
Kailang Yangdf694da2005-12-05 19:42:22 +01009640 return 0;
9641}
9642
Kailang Yangdf694da2005-12-05 19:42:22 +01009643/*
Kailang Yanga361d842007-06-05 12:30:55 +02009644 * ALC268 channel source setting (2 channel)
9645 */
9646#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9647#define alc268_modes alc260_modes
9648
9649static hda_nid_t alc268_dac_nids[2] = {
9650 /* front, hp */
9651 0x02, 0x03
9652};
9653
9654static hda_nid_t alc268_adc_nids[2] = {
9655 /* ADC0-1 */
9656 0x08, 0x07
9657};
9658
9659static hda_nid_t alc268_adc_nids_alt[1] = {
9660 /* ADC0 */
9661 0x08
9662};
9663
Takashi Iwaie1406342008-02-11 18:32:32 +01009664static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9665
Kailang Yanga361d842007-06-05 12:30:55 +02009666static struct snd_kcontrol_new alc268_base_mixer[] = {
9667 /* output mixer control */
9668 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9669 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9670 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9673 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9674 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009675 { }
9676};
9677
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009678/* bind Beep switches of both NID 0x0f and 0x10 */
9679static struct hda_bind_ctls alc268_bind_beep_sw = {
9680 .ops = &snd_hda_bind_sw,
9681 .values = {
9682 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9683 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
9684 0
9685 },
9686};
9687
9688static struct snd_kcontrol_new alc268_beep_mixer[] = {
9689 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
9690 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
9691 { }
9692};
9693
Kailang Yangd1a991a2007-08-15 16:21:59 +02009694static struct hda_verb alc268_eapd_verbs[] = {
9695 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9696 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9697 { }
9698};
9699
Takashi Iwaid2738092007-08-16 14:59:45 +02009700/* Toshiba specific */
9701#define alc268_toshiba_automute alc262_hippo_automute
9702
9703static struct hda_verb alc268_toshiba_verbs[] = {
9704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9705 { } /* end */
9706};
9707
9708/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009709/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009710static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9711 .ops = &snd_hda_bind_vol,
9712 .values = {
9713 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9714 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9715 0
9716 },
9717};
9718
Takashi Iwai889c4392007-08-23 18:56:52 +02009719/* mute/unmute internal speaker according to the hp jack and mute state */
9720static void alc268_acer_automute(struct hda_codec *codec, int force)
9721{
9722 struct alc_spec *spec = codec->spec;
9723 unsigned int mute;
9724
9725 if (force || !spec->sense_updated) {
9726 unsigned int present;
9727 present = snd_hda_codec_read(codec, 0x14, 0,
9728 AC_VERB_GET_PIN_SENSE, 0);
9729 spec->jack_present = (present & 0x80000000) != 0;
9730 spec->sense_updated = 1;
9731 }
9732 if (spec->jack_present)
9733 mute = HDA_AMP_MUTE; /* mute internal speaker */
9734 else /* unmute internal speaker if necessary */
9735 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9736 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9737 HDA_AMP_MUTE, mute);
9738}
9739
9740
9741/* bind hp and internal speaker mute (with plug check) */
9742static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9743 struct snd_ctl_elem_value *ucontrol)
9744{
9745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9746 long *valp = ucontrol->value.integer.value;
9747 int change;
9748
9749 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9750 HDA_AMP_MUTE,
9751 valp[0] ? 0 : HDA_AMP_MUTE);
9752 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9753 HDA_AMP_MUTE,
9754 valp[1] ? 0 : HDA_AMP_MUTE);
9755 if (change)
9756 alc268_acer_automute(codec, 0);
9757 return change;
9758}
Takashi Iwaid2738092007-08-16 14:59:45 +02009759
9760static struct snd_kcontrol_new alc268_acer_mixer[] = {
9761 /* output mixer control */
9762 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9763 {
9764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9765 .name = "Master Playback Switch",
9766 .info = snd_hda_mixer_amp_switch_info,
9767 .get = snd_hda_mixer_amp_switch_get,
9768 .put = alc268_acer_master_sw_put,
9769 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9770 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9772 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9773 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009774 { }
9775};
9776
9777static struct hda_verb alc268_acer_verbs[] = {
9778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9780
9781 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9782 { }
9783};
9784
9785/* unsolicited event for HP jack sensing */
9786static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9787 unsigned int res)
9788{
Takashi Iwai889c4392007-08-23 18:56:52 +02009789 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009790 return;
9791 alc268_toshiba_automute(codec);
9792}
9793
9794static void alc268_acer_unsol_event(struct hda_codec *codec,
9795 unsigned int res)
9796{
Takashi Iwai889c4392007-08-23 18:56:52 +02009797 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009798 return;
9799 alc268_acer_automute(codec, 1);
9800}
9801
Takashi Iwai889c4392007-08-23 18:56:52 +02009802static void alc268_acer_init_hook(struct hda_codec *codec)
9803{
9804 alc268_acer_automute(codec, 1);
9805}
9806
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009807static struct snd_kcontrol_new alc268_dell_mixer[] = {
9808 /* output mixer control */
9809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9810 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9814 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9815 { }
9816};
9817
9818static struct hda_verb alc268_dell_verbs[] = {
9819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9821 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9822 { }
9823};
9824
9825/* mute/unmute internal speaker according to the hp jack and mute state */
9826static void alc268_dell_automute(struct hda_codec *codec)
9827{
9828 unsigned int present;
9829 unsigned int mute;
9830
9831 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9832 if (present & 0x80000000)
9833 mute = HDA_AMP_MUTE;
9834 else
9835 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9836 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9837 HDA_AMP_MUTE, mute);
9838}
9839
9840static void alc268_dell_unsol_event(struct hda_codec *codec,
9841 unsigned int res)
9842{
9843 if ((res >> 26) != ALC880_HP_EVENT)
9844 return;
9845 alc268_dell_automute(codec);
9846}
9847
9848#define alc268_dell_init_hook alc268_dell_automute
9849
Kailang Yanga361d842007-06-05 12:30:55 +02009850/*
9851 * generic initialization of ADC, input mixers and output mixers
9852 */
9853static struct hda_verb alc268_base_init_verbs[] = {
9854 /* Unmute DAC0-1 and set vol = 0 */
9855 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9856 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9857 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9858 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9859 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9860 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9861
9862 /*
9863 * Set up output mixers (0x0c - 0x0e)
9864 */
9865 /* set vol=0 to output mixers */
9866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9869 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9870
9871 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9872 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9873
9874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9878 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9880 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9881 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9882
9883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9885 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9886 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9888 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9889 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009890
9891 /* set PCBEEP vol = 0, mute connections */
9892 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9894 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +02009895
Jiang Zhea9b3aa82007-12-20 13:13:13 +01009896 /* Unmute Selector 23h,24h and set the default input to mic-in */
9897
9898 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9900 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +02009902
Kailang Yanga361d842007-06-05 12:30:55 +02009903 { }
9904};
9905
9906/*
9907 * generic initialization of ADC, input mixers and output mixers
9908 */
9909static struct hda_verb alc268_volume_init_verbs[] = {
9910 /* set output DAC */
9911 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9912 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9913 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9914 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9915
9916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9917 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9919 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9920 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9921
9922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9926 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9927
9928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9931 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9932
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009933 /* set PCBEEP vol = 0, mute connections */
9934 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9936 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +02009937
9938 { }
9939};
9940
9941#define alc268_mux_enum_info alc_mux_enum_info
9942#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01009943#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +02009944
9945static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9946 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9947 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9948 {
9949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9950 /* The multiple "Capture Source" controls confuse alsamixer
9951 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009952 */
9953 /* .name = "Capture Source", */
9954 .name = "Input Source",
9955 .count = 1,
9956 .info = alc268_mux_enum_info,
9957 .get = alc268_mux_enum_get,
9958 .put = alc268_mux_enum_put,
9959 },
9960 { } /* end */
9961};
9962
9963static struct snd_kcontrol_new alc268_capture_mixer[] = {
9964 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9965 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9966 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9967 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9968 {
9969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9970 /* The multiple "Capture Source" controls confuse alsamixer
9971 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +02009972 */
9973 /* .name = "Capture Source", */
9974 .name = "Input Source",
9975 .count = 2,
9976 .info = alc268_mux_enum_info,
9977 .get = alc268_mux_enum_get,
9978 .put = alc268_mux_enum_put,
9979 },
9980 { } /* end */
9981};
9982
9983static struct hda_input_mux alc268_capture_source = {
9984 .num_items = 4,
9985 .items = {
9986 { "Mic", 0x0 },
9987 { "Front Mic", 0x1 },
9988 { "Line", 0x2 },
9989 { "CD", 0x3 },
9990 },
9991};
9992
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009993#ifdef CONFIG_SND_DEBUG
9994static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +01009995 /* Volume widgets */
9996 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9997 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9998 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9999 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10000 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10001 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10002 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10003 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10004 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10005 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10006 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10007 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10008 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010009 /* The below appears problematic on some hardwares */
10010 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010011 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10012 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10013 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10014 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10015
10016 /* Modes for retasking pin widgets */
10017 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10018 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10019 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10020 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10021
10022 /* Controls for GPIO pins, assuming they are configured as outputs */
10023 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10024 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10025 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10026 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10027
10028 /* Switches to allow the digital SPDIF output pin to be enabled.
10029 * The ALC268 does not have an SPDIF input.
10030 */
10031 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10032
10033 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10034 * this output to turn on an external amplifier.
10035 */
10036 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10037 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10038
10039 { } /* end */
10040};
10041#endif
10042
Kailang Yanga361d842007-06-05 12:30:55 +020010043/* create input playback/capture controls for the given pin */
10044static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10045 const char *ctlname, int idx)
10046{
10047 char name[32];
10048 int err;
10049
10050 sprintf(name, "%s Playback Volume", ctlname);
10051 if (nid == 0x14) {
10052 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10053 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10054 HDA_OUTPUT));
10055 if (err < 0)
10056 return err;
10057 } else if (nid == 0x15) {
10058 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10059 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10060 HDA_OUTPUT));
10061 if (err < 0)
10062 return err;
10063 } else
10064 return -1;
10065 sprintf(name, "%s Playback Switch", ctlname);
10066 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10067 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10068 if (err < 0)
10069 return err;
10070 return 0;
10071}
10072
10073/* add playback controls from the parsed DAC table */
10074static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10075 const struct auto_pin_cfg *cfg)
10076{
10077 hda_nid_t nid;
10078 int err;
10079
10080 spec->multiout.num_dacs = 2; /* only use one dac */
10081 spec->multiout.dac_nids = spec->private_dac_nids;
10082 spec->multiout.dac_nids[0] = 2;
10083 spec->multiout.dac_nids[1] = 3;
10084
10085 nid = cfg->line_out_pins[0];
10086 if (nid)
10087 alc268_new_analog_output(spec, nid, "Front", 0);
10088
10089 nid = cfg->speaker_pins[0];
10090 if (nid == 0x1d) {
10091 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10092 "Speaker Playback Volume",
10093 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10094 if (err < 0)
10095 return err;
10096 }
10097 nid = cfg->hp_pins[0];
10098 if (nid)
10099 alc268_new_analog_output(spec, nid, "Headphone", 0);
10100
10101 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10102 if (nid == 0x16) {
10103 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10104 "Mono Playback Switch",
10105 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10106 if (err < 0)
10107 return err;
10108 }
10109 return 0;
10110}
10111
10112/* create playback/capture controls for input pins */
10113static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10114 const struct auto_pin_cfg *cfg)
10115{
10116 struct hda_input_mux *imux = &spec->private_imux;
10117 int i, idx1;
10118
10119 for (i = 0; i < AUTO_PIN_LAST; i++) {
10120 switch(cfg->input_pins[i]) {
10121 case 0x18:
10122 idx1 = 0; /* Mic 1 */
10123 break;
10124 case 0x19:
10125 idx1 = 1; /* Mic 2 */
10126 break;
10127 case 0x1a:
10128 idx1 = 2; /* Line In */
10129 break;
10130 case 0x1c:
10131 idx1 = 3; /* CD */
10132 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010133 case 0x12:
10134 case 0x13:
10135 idx1 = 6; /* digital mics */
10136 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010137 default:
10138 continue;
10139 }
10140 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10141 imux->items[imux->num_items].index = idx1;
10142 imux->num_items++;
10143 }
10144 return 0;
10145}
10146
10147static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10148{
10149 struct alc_spec *spec = codec->spec;
10150 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10151 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10152 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10153 unsigned int dac_vol1, dac_vol2;
10154
10155 if (speaker_nid) {
10156 snd_hda_codec_write(codec, speaker_nid, 0,
10157 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10158 snd_hda_codec_write(codec, 0x0f, 0,
10159 AC_VERB_SET_AMP_GAIN_MUTE,
10160 AMP_IN_UNMUTE(1));
10161 snd_hda_codec_write(codec, 0x10, 0,
10162 AC_VERB_SET_AMP_GAIN_MUTE,
10163 AMP_IN_UNMUTE(1));
10164 } else {
10165 snd_hda_codec_write(codec, 0x0f, 0,
10166 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10167 snd_hda_codec_write(codec, 0x10, 0,
10168 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10169 }
10170
10171 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10172 if (line_nid == 0x14)
10173 dac_vol2 = AMP_OUT_ZERO;
10174 else if (line_nid == 0x15)
10175 dac_vol1 = AMP_OUT_ZERO;
10176 if (hp_nid == 0x14)
10177 dac_vol2 = AMP_OUT_ZERO;
10178 else if (hp_nid == 0x15)
10179 dac_vol1 = AMP_OUT_ZERO;
10180 if (line_nid != 0x16 || hp_nid != 0x16 ||
10181 spec->autocfg.line_out_pins[1] != 0x16 ||
10182 spec->autocfg.line_out_pins[2] != 0x16)
10183 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10184
10185 snd_hda_codec_write(codec, 0x02, 0,
10186 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10187 snd_hda_codec_write(codec, 0x03, 0,
10188 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10189}
10190
10191/* pcm configuration: identiacal with ALC880 */
10192#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10193#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010194#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010195#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10196
10197/*
10198 * BIOS auto configuration
10199 */
10200static int alc268_parse_auto_config(struct hda_codec *codec)
10201{
10202 struct alc_spec *spec = codec->spec;
10203 int err;
10204 static hda_nid_t alc268_ignore[] = { 0 };
10205
10206 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10207 alc268_ignore);
10208 if (err < 0)
10209 return err;
10210 if (!spec->autocfg.line_outs)
10211 return 0; /* can't find valid BIOS pin config */
10212
10213 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10214 if (err < 0)
10215 return err;
10216 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10217 if (err < 0)
10218 return err;
10219
10220 spec->multiout.max_channels = 2;
10221
10222 /* digital only support output */
10223 if (spec->autocfg.dig_out_pin)
10224 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10225
10226 if (spec->kctl_alloc)
10227 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10228
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010229 if (spec->autocfg.speaker_pins[0] != 0x1d)
10230 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10231
Kailang Yanga361d842007-06-05 12:30:55 +020010232 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10233 spec->num_mux_defs = 1;
10234 spec->input_mux = &spec->private_imux;
10235
Takashi Iwai776e1842007-08-29 15:07:11 +020010236 err = alc_auto_add_mic_boost(codec);
10237 if (err < 0)
10238 return err;
10239
Kailang Yanga361d842007-06-05 12:30:55 +020010240 return 1;
10241}
10242
10243#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10244#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10245#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10246
10247/* init callback for auto-configuration model -- overriding the default init */
10248static void alc268_auto_init(struct hda_codec *codec)
10249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010250 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010251 alc268_auto_init_multi_out(codec);
10252 alc268_auto_init_hp_out(codec);
10253 alc268_auto_init_mono_speaker_out(codec);
10254 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010255 if (spec->unsol_event)
10256 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010257}
10258
10259/*
10260 * configuration and preset
10261 */
10262static const char *alc268_models[ALC268_MODEL_LAST] = {
10263 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010264 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010265 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010266 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010267 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010268#ifdef CONFIG_SND_DEBUG
10269 [ALC268_TEST] = "test",
10270#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010271 [ALC268_AUTO] = "auto",
10272};
10273
10274static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010275 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010276 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010277 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010278 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010279 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010280 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010281 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010282 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010283 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010284 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010285 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010286 {}
10287};
10288
10289static struct alc_config_preset alc268_presets[] = {
10290 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010291 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10292 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010293 .init_verbs = { alc268_base_init_verbs },
10294 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10295 .dac_nids = alc268_dac_nids,
10296 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10297 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010298 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010299 .hp_nid = 0x03,
10300 .dig_out_nid = ALC268_DIGOUT_NID,
10301 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10302 .channel_mode = alc268_modes,
10303 .input_mux = &alc268_capture_source,
10304 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010305 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010306 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10307 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010308 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10309 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010310 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10311 .dac_nids = alc268_dac_nids,
10312 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10313 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010314 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010315 .hp_nid = 0x03,
10316 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10317 .channel_mode = alc268_modes,
10318 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010319 .unsol_event = alc268_toshiba_unsol_event,
10320 .init_hook = alc268_toshiba_automute,
10321 },
10322 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010323 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10324 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010325 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10326 alc268_acer_verbs },
10327 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10328 .dac_nids = alc268_dac_nids,
10329 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10330 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010331 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010332 .hp_nid = 0x02,
10333 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10334 .channel_mode = alc268_modes,
10335 .input_mux = &alc268_capture_source,
10336 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010337 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010338 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010339 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010340 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010341 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10342 alc268_dell_verbs },
10343 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10344 .dac_nids = alc268_dac_nids,
10345 .hp_nid = 0x02,
10346 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10347 .channel_mode = alc268_modes,
10348 .unsol_event = alc268_dell_unsol_event,
10349 .init_hook = alc268_dell_init_hook,
10350 .input_mux = &alc268_capture_source,
10351 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010352 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010353 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10354 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010355 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10356 alc268_toshiba_verbs },
10357 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10358 .dac_nids = alc268_dac_nids,
10359 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10360 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010361 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010362 .hp_nid = 0x03,
10363 .dig_out_nid = ALC268_DIGOUT_NID,
10364 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10365 .channel_mode = alc268_modes,
10366 .input_mux = &alc268_capture_source,
10367 .unsol_event = alc268_toshiba_unsol_event,
10368 .init_hook = alc268_toshiba_automute
10369 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010370#ifdef CONFIG_SND_DEBUG
10371 [ALC268_TEST] = {
10372 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10373 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10374 alc268_volume_init_verbs },
10375 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10376 .dac_nids = alc268_dac_nids,
10377 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10378 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010379 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010380 .hp_nid = 0x03,
10381 .dig_out_nid = ALC268_DIGOUT_NID,
10382 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10383 .channel_mode = alc268_modes,
10384 .input_mux = &alc268_capture_source,
10385 },
10386#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010387};
10388
10389static int patch_alc268(struct hda_codec *codec)
10390{
10391 struct alc_spec *spec;
10392 int board_config;
10393 int err;
10394
10395 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10396 if (spec == NULL)
10397 return -ENOMEM;
10398
10399 codec->spec = spec;
10400
10401 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10402 alc268_models,
10403 alc268_cfg_tbl);
10404
10405 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10406 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10407 "trying auto-probe from BIOS...\n");
10408 board_config = ALC268_AUTO;
10409 }
10410
10411 if (board_config == ALC268_AUTO) {
10412 /* automatic parse from the BIOS config */
10413 err = alc268_parse_auto_config(codec);
10414 if (err < 0) {
10415 alc_free(codec);
10416 return err;
10417 } else if (!err) {
10418 printk(KERN_INFO
10419 "hda_codec: Cannot set up configuration "
10420 "from BIOS. Using base mode...\n");
10421 board_config = ALC268_3ST;
10422 }
10423 }
10424
10425 if (board_config != ALC268_AUTO)
10426 setup_preset(spec, &alc268_presets[board_config]);
10427
10428 spec->stream_name_analog = "ALC268 Analog";
10429 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10430 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010431 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010432
10433 spec->stream_name_digital = "ALC268 Digital";
10434 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10435
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010436 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10437 /* override the amp caps for beep generator */
10438 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10439 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10440 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10441 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10442 (0 << AC_AMPCAP_MUTE_SHIFT));
10443
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010444 if (!spec->adc_nids && spec->input_mux) {
10445 /* check whether NID 0x07 is valid */
10446 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010447 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010448
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010449 /* get type */
10450 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010451 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010452 spec->adc_nids = alc268_adc_nids_alt;
10453 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10454 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010455 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010456 spec->num_mixers++;
10457 } else {
10458 spec->adc_nids = alc268_adc_nids;
10459 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10460 spec->mixers[spec->num_mixers] =
10461 alc268_capture_mixer;
10462 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010463 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010464 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010465 /* set default input source */
10466 for (i = 0; i < spec->num_adc_nids; i++)
10467 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10468 0, AC_VERB_SET_CONNECT_SEL,
10469 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010470 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010471
10472 spec->vmaster_nid = 0x02;
10473
Kailang Yanga361d842007-06-05 12:30:55 +020010474 codec->patch_ops = alc_patch_ops;
10475 if (board_config == ALC268_AUTO)
10476 spec->init_hook = alc268_auto_init;
10477
10478 return 0;
10479}
10480
10481/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010482 * ALC269 channel source setting (2 channel)
10483 */
10484#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10485
10486#define alc269_dac_nids alc260_dac_nids
10487
10488static hda_nid_t alc269_adc_nids[1] = {
10489 /* ADC1 */
10490 0x07,
10491};
10492
10493#define alc269_modes alc260_modes
10494#define alc269_capture_source alc880_lg_lw_capture_source
10495
10496static struct snd_kcontrol_new alc269_base_mixer[] = {
10497 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10498 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10503 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10504 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10506 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10508 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10509 { } /* end */
10510};
10511
10512/* capture mixer elements */
10513static struct snd_kcontrol_new alc269_capture_mixer[] = {
10514 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10515 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10516 {
10517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10518 /* The multiple "Capture Source" controls confuse alsamixer
10519 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010520 */
10521 /* .name = "Capture Source", */
10522 .name = "Input Source",
10523 .count = 1,
10524 .info = alc_mux_enum_info,
10525 .get = alc_mux_enum_get,
10526 .put = alc_mux_enum_put,
10527 },
10528 { } /* end */
10529};
10530
10531/*
10532 * generic initialization of ADC, input mixers and output mixers
10533 */
10534static struct hda_verb alc269_init_verbs[] = {
10535 /*
10536 * Unmute ADC0 and set the default input to mic-in
10537 */
10538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10539
10540 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10541 * analog-loopback mixer widget
10542 * Note: PASD motherboards uses the Line In 2 as the input for
10543 * front panel mic (mic 2)
10544 */
10545 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10551
10552 /*
10553 * Set up output mixers (0x0c - 0x0e)
10554 */
10555 /* set vol=0 to output mixers */
10556 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10557 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10558
10559 /* set up input amps for analog loopback */
10560 /* Amp Indices: DAC = 0, mixer = 1 */
10561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10567
10568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10570 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10571 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10572 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10575
10576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10579 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10583
10584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10586
10587 /* FIXME: use matrix-type input source selection */
10588 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10589 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10594
10595 /* set EAPD */
10596 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10597 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10598 { }
10599};
10600
10601/* add playback controls from the parsed DAC table */
10602static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10603 const struct auto_pin_cfg *cfg)
10604{
10605 hda_nid_t nid;
10606 int err;
10607
10608 spec->multiout.num_dacs = 1; /* only use one dac */
10609 spec->multiout.dac_nids = spec->private_dac_nids;
10610 spec->multiout.dac_nids[0] = 2;
10611
10612 nid = cfg->line_out_pins[0];
10613 if (nid) {
10614 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10615 "Front Playback Volume",
10616 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10617 if (err < 0)
10618 return err;
10619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10620 "Front Playback Switch",
10621 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10622 if (err < 0)
10623 return err;
10624 }
10625
10626 nid = cfg->speaker_pins[0];
10627 if (nid) {
10628 if (!cfg->line_out_pins[0]) {
10629 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10630 "Speaker Playback Volume",
10631 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10632 HDA_OUTPUT));
10633 if (err < 0)
10634 return err;
10635 }
10636 if (nid == 0x16) {
10637 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10638 "Speaker Playback Switch",
10639 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10640 HDA_OUTPUT));
10641 if (err < 0)
10642 return err;
10643 } else {
10644 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10645 "Speaker Playback Switch",
10646 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10647 HDA_OUTPUT));
10648 if (err < 0)
10649 return err;
10650 }
10651 }
10652 nid = cfg->hp_pins[0];
10653 if (nid) {
10654 /* spec->multiout.hp_nid = 2; */
10655 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10656 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10657 "Headphone Playback Volume",
10658 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10659 HDA_OUTPUT));
10660 if (err < 0)
10661 return err;
10662 }
10663 if (nid == 0x16) {
10664 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10665 "Headphone Playback Switch",
10666 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10667 HDA_OUTPUT));
10668 if (err < 0)
10669 return err;
10670 } else {
10671 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10672 "Headphone Playback Switch",
10673 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10674 HDA_OUTPUT));
10675 if (err < 0)
10676 return err;
10677 }
10678 }
10679 return 0;
10680}
10681
10682#define alc269_auto_create_analog_input_ctls \
10683 alc880_auto_create_analog_input_ctls
10684
10685#ifdef CONFIG_SND_HDA_POWER_SAVE
10686#define alc269_loopbacks alc880_loopbacks
10687#endif
10688
10689/* pcm configuration: identiacal with ALC880 */
10690#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10691#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10692#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10693#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10694
10695/*
10696 * BIOS auto configuration
10697 */
10698static int alc269_parse_auto_config(struct hda_codec *codec)
10699{
10700 struct alc_spec *spec = codec->spec;
10701 int err;
10702 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10703
10704 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10705 alc269_ignore);
10706 if (err < 0)
10707 return err;
10708
10709 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10710 if (err < 0)
10711 return err;
10712 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10713 if (err < 0)
10714 return err;
10715
10716 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10717
10718 if (spec->autocfg.dig_out_pin)
10719 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10720
10721 if (spec->kctl_alloc)
10722 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10723
10724 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10725 spec->num_mux_defs = 1;
10726 spec->input_mux = &spec->private_imux;
10727
10728 err = alc_auto_add_mic_boost(codec);
10729 if (err < 0)
10730 return err;
10731
10732 return 1;
10733}
10734
10735#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10736#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10737#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10738
10739
10740/* init callback for auto-configuration model -- overriding the default init */
10741static void alc269_auto_init(struct hda_codec *codec)
10742{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010743 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010010744 alc269_auto_init_multi_out(codec);
10745 alc269_auto_init_hp_out(codec);
10746 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010747 if (spec->unsol_event)
10748 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010010749}
10750
10751/*
10752 * configuration and preset
10753 */
10754static const char *alc269_models[ALC269_MODEL_LAST] = {
10755 [ALC269_BASIC] = "basic",
10756};
10757
10758static struct snd_pci_quirk alc269_cfg_tbl[] = {
10759 {}
10760};
10761
10762static struct alc_config_preset alc269_presets[] = {
10763 [ALC269_BASIC] = {
10764 .mixers = { alc269_base_mixer },
10765 .init_verbs = { alc269_init_verbs },
10766 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10767 .dac_nids = alc269_dac_nids,
10768 .hp_nid = 0x03,
10769 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10770 .channel_mode = alc269_modes,
10771 .input_mux = &alc269_capture_source,
10772 },
10773};
10774
10775static int patch_alc269(struct hda_codec *codec)
10776{
10777 struct alc_spec *spec;
10778 int board_config;
10779 int err;
10780
10781 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10782 if (spec == NULL)
10783 return -ENOMEM;
10784
10785 codec->spec = spec;
10786
10787 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10788 alc269_models,
10789 alc269_cfg_tbl);
10790
10791 if (board_config < 0) {
10792 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10793 "trying auto-probe from BIOS...\n");
10794 board_config = ALC269_AUTO;
10795 }
10796
10797 if (board_config == ALC269_AUTO) {
10798 /* automatic parse from the BIOS config */
10799 err = alc269_parse_auto_config(codec);
10800 if (err < 0) {
10801 alc_free(codec);
10802 return err;
10803 } else if (!err) {
10804 printk(KERN_INFO
10805 "hda_codec: Cannot set up configuration "
10806 "from BIOS. Using base mode...\n");
10807 board_config = ALC269_BASIC;
10808 }
10809 }
10810
10811 if (board_config != ALC269_AUTO)
10812 setup_preset(spec, &alc269_presets[board_config]);
10813
10814 spec->stream_name_analog = "ALC269 Analog";
10815 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10816 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10817
10818 spec->stream_name_digital = "ALC269 Digital";
10819 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10820 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10821
10822 spec->adc_nids = alc269_adc_nids;
10823 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10824 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10825 spec->num_mixers++;
10826
10827 codec->patch_ops = alc_patch_ops;
10828 if (board_config == ALC269_AUTO)
10829 spec->init_hook = alc269_auto_init;
10830#ifdef CONFIG_SND_HDA_POWER_SAVE
10831 if (!spec->loopback.amplist)
10832 spec->loopback.amplist = alc269_loopbacks;
10833#endif
10834
10835 return 0;
10836}
10837
10838/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010839 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10840 */
10841
10842/*
10843 * set the path ways for 2 channel output
10844 * need to set the codec line out and mic 1 pin widgets to inputs
10845 */
10846static struct hda_verb alc861_threestack_ch2_init[] = {
10847 /* set pin widget 1Ah (line in) for input */
10848 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010849 /* set pin widget 18h (mic1/2) for input, for mic also enable
10850 * the vref
10851 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010852 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10853
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010854 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10855#if 0
10856 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10857 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10858#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010859 { } /* end */
10860};
10861/*
10862 * 6ch mode
10863 * need to set the codec line out and mic 1 pin widgets to outputs
10864 */
10865static struct hda_verb alc861_threestack_ch6_init[] = {
10866 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10867 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10868 /* set pin widget 18h (mic1) for output (CLFE)*/
10869 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10870
10871 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010872 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010873
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010874 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10875#if 0
10876 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10877 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10878#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010879 { } /* end */
10880};
10881
10882static struct hda_channel_mode alc861_threestack_modes[2] = {
10883 { 2, alc861_threestack_ch2_init },
10884 { 6, alc861_threestack_ch6_init },
10885};
Takashi Iwai22309c32006-08-09 16:57:28 +020010886/* Set mic1 as input and unmute the mixer */
10887static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10888 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10889 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10890 { } /* end */
10891};
10892/* Set mic1 as output and mute mixer */
10893static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10894 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10895 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10896 { } /* end */
10897};
10898
10899static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10900 { 2, alc861_uniwill_m31_ch2_init },
10901 { 4, alc861_uniwill_m31_ch4_init },
10902};
Kailang Yangdf694da2005-12-05 19:42:22 +010010903
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010904/* Set mic1 and line-in as input and unmute the mixer */
10905static struct hda_verb alc861_asus_ch2_init[] = {
10906 /* set pin widget 1Ah (line in) for input */
10907 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010908 /* set pin widget 18h (mic1/2) for input, for mic also enable
10909 * the vref
10910 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010911 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10912
10913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10914#if 0
10915 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10916 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10917#endif
10918 { } /* end */
10919};
10920/* Set mic1 nad line-in as output and mute mixer */
10921static struct hda_verb alc861_asus_ch6_init[] = {
10922 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10923 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10924 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10925 /* set pin widget 18h (mic1) for output (CLFE)*/
10926 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10927 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10928 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10929 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10930
10931 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10932#if 0
10933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10934 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10935#endif
10936 { } /* end */
10937};
10938
10939static struct hda_channel_mode alc861_asus_modes[2] = {
10940 { 2, alc861_asus_ch2_init },
10941 { 6, alc861_asus_ch6_init },
10942};
10943
Kailang Yangdf694da2005-12-05 19:42:22 +010010944/* patch-ALC861 */
10945
10946static struct snd_kcontrol_new alc861_base_mixer[] = {
10947 /* output mixer control */
10948 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10949 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10950 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10951 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10953
10954 /*Input mixer control */
10955 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10956 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10957 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10958 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10960 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10962 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010965
Kailang Yangdf694da2005-12-05 19:42:22 +010010966 /* Capture mixer control */
10967 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10968 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10969 {
10970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10971 .name = "Capture Source",
10972 .count = 1,
10973 .info = alc_mux_enum_info,
10974 .get = alc_mux_enum_get,
10975 .put = alc_mux_enum_put,
10976 },
10977 { } /* end */
10978};
10979
10980static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10981 /* output mixer control */
10982 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10983 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10984 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10985 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10986 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10987
10988 /* Input mixer control */
10989 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10990 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10991 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10992 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10993 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10994 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10996 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010999
Kailang Yangdf694da2005-12-05 19:42:22 +010011000 /* Capture mixer control */
11001 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11002 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11003 {
11004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11005 .name = "Capture Source",
11006 .count = 1,
11007 .info = alc_mux_enum_info,
11008 .get = alc_mux_enum_get,
11009 .put = alc_mux_enum_put,
11010 },
11011 {
11012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11013 .name = "Channel Mode",
11014 .info = alc_ch_mode_info,
11015 .get = alc_ch_mode_get,
11016 .put = alc_ch_mode_put,
11017 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11018 },
11019 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011020};
11021
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011022static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011023 /* output mixer control */
11024 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11026 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11027
11028 /*Capture mixer control */
11029 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11030 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11031 {
11032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11033 .name = "Capture Source",
11034 .count = 1,
11035 .info = alc_mux_enum_info,
11036 .get = alc_mux_enum_get,
11037 .put = alc_mux_enum_put,
11038 },
11039
11040 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011041};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011042
Takashi Iwai22309c32006-08-09 16:57:28 +020011043static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11044 /* output mixer control */
11045 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11046 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11047 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11048 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11049 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11050
11051 /* Input mixer control */
11052 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11053 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11054 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11055 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11056 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11057 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11059 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11060 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011062
Takashi Iwai22309c32006-08-09 16:57:28 +020011063 /* Capture mixer control */
11064 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11065 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11066 {
11067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11068 .name = "Capture Source",
11069 .count = 1,
11070 .info = alc_mux_enum_info,
11071 .get = alc_mux_enum_get,
11072 .put = alc_mux_enum_put,
11073 },
11074 {
11075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11076 .name = "Channel Mode",
11077 .info = alc_ch_mode_info,
11078 .get = alc_ch_mode_get,
11079 .put = alc_ch_mode_put,
11080 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11081 },
11082 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011083};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011084
11085static struct snd_kcontrol_new alc861_asus_mixer[] = {
11086 /* output mixer control */
11087 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11088 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11089 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11090 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11091 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11092
11093 /* Input mixer control */
11094 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11095 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11096 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11097 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11098 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11099 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11101 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11104
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011105 /* Capture mixer control */
11106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11108 {
11109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11110 .name = "Capture Source",
11111 .count = 1,
11112 .info = alc_mux_enum_info,
11113 .get = alc_mux_enum_get,
11114 .put = alc_mux_enum_put,
11115 },
11116 {
11117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11118 .name = "Channel Mode",
11119 .info = alc_ch_mode_info,
11120 .get = alc_ch_mode_get,
11121 .put = alc_ch_mode_put,
11122 .private_value = ARRAY_SIZE(alc861_asus_modes),
11123 },
11124 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011125};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011126
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011127/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011128static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011129 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11130 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11131 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11132 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11133 { }
11134};
11135
Kailang Yangdf694da2005-12-05 19:42:22 +010011136/*
11137 * generic initialization of ADC, input mixers and output mixers
11138 */
11139static struct hda_verb alc861_base_init_verbs[] = {
11140 /*
11141 * Unmute ADC0 and set the default input to mic-in
11142 */
11143 /* port-A for surround (rear panel) */
11144 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11145 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11146 /* port-B for mic-in (rear panel) with vref */
11147 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11148 /* port-C for line-in (rear panel) */
11149 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11150 /* port-D for Front */
11151 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11152 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11153 /* port-E for HP out (front panel) */
11154 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11155 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011156 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011157 /* port-F for mic-in (front panel) with vref */
11158 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11159 /* port-G for CLFE (rear panel) */
11160 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11161 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11162 /* port-H for side (rear panel) */
11163 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11164 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11165 /* CD-in */
11166 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11167 /* route front mic to ADC1*/
11168 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11169 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11170
11171 /* Unmute DAC0~3 & spdif out*/
11172 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11174 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11175 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11177
11178 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11179 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11180 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11181 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11182 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11183
11184 /* Unmute Stereo Mixer 15 */
11185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011189
11190 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11192 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11194 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011198 /* hp used DAC 3 (Front) */
11199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011200 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11201
11202 { }
11203};
11204
11205static struct hda_verb alc861_threestack_init_verbs[] = {
11206 /*
11207 * Unmute ADC0 and set the default input to mic-in
11208 */
11209 /* port-A for surround (rear panel) */
11210 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11211 /* port-B for mic-in (rear panel) with vref */
11212 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11213 /* port-C for line-in (rear panel) */
11214 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11215 /* port-D for Front */
11216 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11217 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11218 /* port-E for HP out (front panel) */
11219 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11220 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011221 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011222 /* port-F for mic-in (front panel) with vref */
11223 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11224 /* port-G for CLFE (rear panel) */
11225 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11226 /* port-H for side (rear panel) */
11227 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11228 /* CD-in */
11229 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11230 /* route front mic to ADC1*/
11231 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11232 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11233 /* Unmute DAC0~3 & spdif out*/
11234 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11235 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11236 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11237 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11239
11240 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11241 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11242 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11243 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11244 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11245
11246 /* Unmute Stereo Mixer 15 */
11247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011251
11252 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11259 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011260 /* hp used DAC 3 (Front) */
11261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11263 { }
11264};
Takashi Iwai22309c32006-08-09 16:57:28 +020011265
11266static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11267 /*
11268 * Unmute ADC0 and set the default input to mic-in
11269 */
11270 /* port-A for surround (rear panel) */
11271 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11272 /* port-B for mic-in (rear panel) with vref */
11273 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11274 /* port-C for line-in (rear panel) */
11275 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11276 /* port-D for Front */
11277 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11278 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11279 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011280 /* this has to be set to VREF80 */
11281 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011282 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011283 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011284 /* port-F for mic-in (front panel) with vref */
11285 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11286 /* port-G for CLFE (rear panel) */
11287 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11288 /* port-H for side (rear panel) */
11289 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11290 /* CD-in */
11291 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11292 /* route front mic to ADC1*/
11293 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11295 /* Unmute DAC0~3 & spdif out*/
11296 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11297 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11298 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11299 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11301
11302 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11303 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11304 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11305 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11306 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11307
11308 /* Unmute Stereo Mixer 15 */
11309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011313
11314 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11315 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11316 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11317 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011322 /* hp used DAC 3 (Front) */
11323 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011324 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11325 { }
11326};
11327
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011328static struct hda_verb alc861_asus_init_verbs[] = {
11329 /*
11330 * Unmute ADC0 and set the default input to mic-in
11331 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011332 /* port-A for surround (rear panel)
11333 * according to codec#0 this is the HP jack
11334 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011335 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11336 /* route front PCM to HP */
11337 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11338 /* port-B for mic-in (rear panel) with vref */
11339 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11340 /* port-C for line-in (rear panel) */
11341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11342 /* port-D for Front */
11343 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11344 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11345 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011346 /* this has to be set to VREF80 */
11347 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011348 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011349 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011350 /* port-F for mic-in (front panel) with vref */
11351 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11352 /* port-G for CLFE (rear panel) */
11353 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11354 /* port-H for side (rear panel) */
11355 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11356 /* CD-in */
11357 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11358 /* route front mic to ADC1*/
11359 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11361 /* Unmute DAC0~3 & spdif out*/
11362 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11363 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11364 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11365 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11367 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11368 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11369 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11370 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11371 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11372
11373 /* Unmute Stereo Mixer 15 */
11374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011378
11379 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11380 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11381 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11382 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11384 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 /* hp used DAC 3 (Front) */
11388 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11390 { }
11391};
11392
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011393/* additional init verbs for ASUS laptops */
11394static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11395 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11396 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11397 { }
11398};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011399
Kailang Yangdf694da2005-12-05 19:42:22 +010011400/*
11401 * generic initialization of ADC, input mixers and output mixers
11402 */
11403static struct hda_verb alc861_auto_init_verbs[] = {
11404 /*
11405 * Unmute ADC0 and set the default input to mic-in
11406 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011407 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11409
11410 /* Unmute DAC0~3 & spdif out*/
11411 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11412 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11413 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11414 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11416
11417 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11418 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11419 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11420 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11421 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11422
11423 /* Unmute Stereo Mixer 15 */
11424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11428
11429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11431 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11432 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11434 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11437
11438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11439 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011442 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11443 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011447 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011448
11449 { }
11450};
11451
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011452static struct hda_verb alc861_toshiba_init_verbs[] = {
11453 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011454
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011455 { }
11456};
11457
11458/* toggle speaker-output according to the hp-jack state */
11459static void alc861_toshiba_automute(struct hda_codec *codec)
11460{
11461 unsigned int present;
11462
11463 present = snd_hda_codec_read(codec, 0x0f, 0,
11464 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011465 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11466 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11467 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11468 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011469}
11470
11471static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11472 unsigned int res)
11473{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011474 if ((res >> 26) == ALC880_HP_EVENT)
11475 alc861_toshiba_automute(codec);
11476}
11477
Kailang Yangdf694da2005-12-05 19:42:22 +010011478/* pcm configuration: identiacal with ALC880 */
11479#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11480#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11481#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11482#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11483
11484
11485#define ALC861_DIGOUT_NID 0x07
11486
11487static struct hda_channel_mode alc861_8ch_modes[1] = {
11488 { 8, NULL }
11489};
11490
11491static hda_nid_t alc861_dac_nids[4] = {
11492 /* front, surround, clfe, side */
11493 0x03, 0x06, 0x05, 0x04
11494};
11495
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011496static hda_nid_t alc660_dac_nids[3] = {
11497 /* front, clfe, surround */
11498 0x03, 0x05, 0x06
11499};
11500
Kailang Yangdf694da2005-12-05 19:42:22 +010011501static hda_nid_t alc861_adc_nids[1] = {
11502 /* ADC0-2 */
11503 0x08,
11504};
11505
11506static struct hda_input_mux alc861_capture_source = {
11507 .num_items = 5,
11508 .items = {
11509 { "Mic", 0x0 },
11510 { "Front Mic", 0x3 },
11511 { "Line", 0x1 },
11512 { "CD", 0x4 },
11513 { "Mixer", 0x5 },
11514 },
11515};
11516
11517/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011518static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11519 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011520{
11521 int i;
11522 hda_nid_t nid;
11523
11524 spec->multiout.dac_nids = spec->private_dac_nids;
11525 for (i = 0; i < cfg->line_outs; i++) {
11526 nid = cfg->line_out_pins[i];
11527 if (nid) {
11528 if (i >= ARRAY_SIZE(alc861_dac_nids))
11529 continue;
11530 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11531 }
11532 }
11533 spec->multiout.num_dacs = cfg->line_outs;
11534 return 0;
11535}
11536
11537/* add playback controls from the parsed DAC table */
11538static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11539 const struct auto_pin_cfg *cfg)
11540{
11541 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011542 static const char *chname[4] = {
11543 "Front", "Surround", NULL /*CLFE*/, "Side"
11544 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011545 hda_nid_t nid;
11546 int i, idx, err;
11547
11548 for (i = 0; i < cfg->line_outs; i++) {
11549 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011550 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011551 continue;
11552 if (nid == 0x05) {
11553 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011554 err = add_control(spec, ALC_CTL_BIND_MUTE,
11555 "Center Playback Switch",
11556 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11557 HDA_OUTPUT));
11558 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011559 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011560 err = add_control(spec, ALC_CTL_BIND_MUTE,
11561 "LFE Playback Switch",
11562 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11563 HDA_OUTPUT));
11564 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011565 return err;
11566 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011567 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11568 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011569 if (nid == alc861_dac_nids[idx])
11570 break;
11571 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011572 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11573 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11574 HDA_OUTPUT));
11575 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011576 return err;
11577 }
11578 }
11579 return 0;
11580}
11581
11582static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11583{
11584 int err;
11585 hda_nid_t nid;
11586
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011587 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011588 return 0;
11589
11590 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11591 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011592 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11593 "Headphone Playback Switch",
11594 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11595 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011596 return err;
11597 spec->multiout.hp_nid = nid;
11598 }
11599 return 0;
11600}
11601
11602/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011603static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11604 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011605{
Kailang Yangdf694da2005-12-05 19:42:22 +010011606 struct hda_input_mux *imux = &spec->private_imux;
11607 int i, err, idx, idx1;
11608
11609 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011610 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011611 case 0x0c:
11612 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011613 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011614 break;
11615 case 0x0f:
11616 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011617 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011618 break;
11619 case 0x0d:
11620 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011621 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011622 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011623 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011624 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011625 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011626 break;
11627 case 0x11:
11628 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011629 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011630 break;
11631 default:
11632 continue;
11633 }
11634
Takashi Iwai4a471b72005-12-07 13:56:29 +010011635 err = new_analog_input(spec, cfg->input_pins[i],
11636 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011637 if (err < 0)
11638 return err;
11639
Takashi Iwai4a471b72005-12-07 13:56:29 +010011640 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011641 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011642 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011643 }
11644 return 0;
11645}
11646
11647static struct snd_kcontrol_new alc861_capture_mixer[] = {
11648 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11649 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11650
11651 {
11652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11653 /* The multiple "Capture Source" controls confuse alsamixer
11654 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011655 */
11656 /* .name = "Capture Source", */
11657 .name = "Input Source",
11658 .count = 1,
11659 .info = alc_mux_enum_info,
11660 .get = alc_mux_enum_get,
11661 .put = alc_mux_enum_put,
11662 },
11663 { } /* end */
11664};
11665
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011666static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11667 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011668 int pin_type, int dac_idx)
11669{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011670 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011671}
11672
11673static void alc861_auto_init_multi_out(struct hda_codec *codec)
11674{
11675 struct alc_spec *spec = codec->spec;
11676 int i;
11677
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011678 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011679 for (i = 0; i < spec->autocfg.line_outs; i++) {
11680 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011681 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011682 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011683 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011684 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011685 }
11686}
11687
11688static void alc861_auto_init_hp_out(struct hda_codec *codec)
11689{
11690 struct alc_spec *spec = codec->spec;
11691 hda_nid_t pin;
11692
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011693 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011694 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011695 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11696 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011697 pin = spec->autocfg.speaker_pins[0];
11698 if (pin)
11699 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010011700}
11701
11702static void alc861_auto_init_analog_input(struct hda_codec *codec)
11703{
11704 struct alc_spec *spec = codec->spec;
11705 int i;
11706
11707 for (i = 0; i < AUTO_PIN_LAST; i++) {
11708 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011709 if (nid >= 0x0c && nid <= 0x11) {
11710 snd_hda_codec_write(codec, nid, 0,
11711 AC_VERB_SET_PIN_WIDGET_CONTROL,
11712 i <= AUTO_PIN_FRONT_MIC ?
11713 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011714 }
11715 }
11716}
11717
11718/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011719/* return 1 if successful, 0 if the proper config is not found,
11720 * or a negative error code
11721 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011722static int alc861_parse_auto_config(struct hda_codec *codec)
11723{
11724 struct alc_spec *spec = codec->spec;
11725 int err;
11726 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11727
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011728 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11729 alc861_ignore);
11730 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011731 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011732 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011733 return 0; /* can't find valid BIOS pin config */
11734
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011735 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11736 if (err < 0)
11737 return err;
11738 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11739 if (err < 0)
11740 return err;
11741 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11742 if (err < 0)
11743 return err;
11744 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11745 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011746 return err;
11747
11748 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11749
11750 if (spec->autocfg.dig_out_pin)
11751 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11752
11753 if (spec->kctl_alloc)
11754 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11755
11756 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11757
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011758 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010011759 spec->input_mux = &spec->private_imux;
11760
11761 spec->adc_nids = alc861_adc_nids;
11762 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11763 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11764 spec->num_mixers++;
11765
11766 return 1;
11767}
11768
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011769/* additional initialization for auto-configuration model */
11770static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011771{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011772 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011773 alc861_auto_init_multi_out(codec);
11774 alc861_auto_init_hp_out(codec);
11775 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011776 if (spec->unsol_event)
11777 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011778}
11779
Takashi Iwaicb53c622007-08-10 17:21:45 +020011780#ifdef CONFIG_SND_HDA_POWER_SAVE
11781static struct hda_amp_list alc861_loopbacks[] = {
11782 { 0x15, HDA_INPUT, 0 },
11783 { 0x15, HDA_INPUT, 1 },
11784 { 0x15, HDA_INPUT, 2 },
11785 { 0x15, HDA_INPUT, 3 },
11786 { } /* end */
11787};
11788#endif
11789
Kailang Yangdf694da2005-12-05 19:42:22 +010011790
11791/*
11792 * configuration and preset
11793 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011794static const char *alc861_models[ALC861_MODEL_LAST] = {
11795 [ALC861_3ST] = "3stack",
11796 [ALC660_3ST] = "3stack-660",
11797 [ALC861_3ST_DIG] = "3stack-dig",
11798 [ALC861_6ST_DIG] = "6stack-dig",
11799 [ALC861_UNIWILL_M31] = "uniwill-m31",
11800 [ALC861_TOSHIBA] = "toshiba",
11801 [ALC861_ASUS] = "asus",
11802 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11803 [ALC861_AUTO] = "auto",
11804};
11805
11806static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010011807 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011808 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11809 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11810 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011811 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020011812 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010011813 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020011814 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11815 * Any other models that need this preset?
11816 */
11817 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020011818 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11819 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011820 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11821 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11822 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11823 /* FIXME: the below seems conflict */
11824 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11825 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11826 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010011827 {}
11828};
11829
11830static struct alc_config_preset alc861_presets[] = {
11831 [ALC861_3ST] = {
11832 .mixers = { alc861_3ST_mixer },
11833 .init_verbs = { alc861_threestack_init_verbs },
11834 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11835 .dac_nids = alc861_dac_nids,
11836 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11837 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011838 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011839 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11840 .adc_nids = alc861_adc_nids,
11841 .input_mux = &alc861_capture_source,
11842 },
11843 [ALC861_3ST_DIG] = {
11844 .mixers = { alc861_base_mixer },
11845 .init_verbs = { alc861_threestack_init_verbs },
11846 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11847 .dac_nids = alc861_dac_nids,
11848 .dig_out_nid = ALC861_DIGOUT_NID,
11849 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11850 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011851 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010011852 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11853 .adc_nids = alc861_adc_nids,
11854 .input_mux = &alc861_capture_source,
11855 },
11856 [ALC861_6ST_DIG] = {
11857 .mixers = { alc861_base_mixer },
11858 .init_verbs = { alc861_base_init_verbs },
11859 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11860 .dac_nids = alc861_dac_nids,
11861 .dig_out_nid = ALC861_DIGOUT_NID,
11862 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11863 .channel_mode = alc861_8ch_modes,
11864 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11865 .adc_nids = alc861_adc_nids,
11866 .input_mux = &alc861_capture_source,
11867 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011868 [ALC660_3ST] = {
11869 .mixers = { alc861_3ST_mixer },
11870 .init_verbs = { alc861_threestack_init_verbs },
11871 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11872 .dac_nids = alc660_dac_nids,
11873 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11874 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020011875 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011876 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11877 .adc_nids = alc861_adc_nids,
11878 .input_mux = &alc861_capture_source,
11879 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011880 [ALC861_UNIWILL_M31] = {
11881 .mixers = { alc861_uniwill_m31_mixer },
11882 .init_verbs = { alc861_uniwill_m31_init_verbs },
11883 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11884 .dac_nids = alc861_dac_nids,
11885 .dig_out_nid = ALC861_DIGOUT_NID,
11886 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11887 .channel_mode = alc861_uniwill_m31_modes,
11888 .need_dac_fix = 1,
11889 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11890 .adc_nids = alc861_adc_nids,
11891 .input_mux = &alc861_capture_source,
11892 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011893 [ALC861_TOSHIBA] = {
11894 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011895 .init_verbs = { alc861_base_init_verbs,
11896 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011897 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11898 .dac_nids = alc861_dac_nids,
11899 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11900 .channel_mode = alc883_3ST_2ch_modes,
11901 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11902 .adc_nids = alc861_adc_nids,
11903 .input_mux = &alc861_capture_source,
11904 .unsol_event = alc861_toshiba_unsol_event,
11905 .init_hook = alc861_toshiba_automute,
11906 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011907 [ALC861_ASUS] = {
11908 .mixers = { alc861_asus_mixer },
11909 .init_verbs = { alc861_asus_init_verbs },
11910 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11911 .dac_nids = alc861_dac_nids,
11912 .dig_out_nid = ALC861_DIGOUT_NID,
11913 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11914 .channel_mode = alc861_asus_modes,
11915 .need_dac_fix = 1,
11916 .hp_nid = 0x06,
11917 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11918 .adc_nids = alc861_adc_nids,
11919 .input_mux = &alc861_capture_source,
11920 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011921 [ALC861_ASUS_LAPTOP] = {
11922 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11923 .init_verbs = { alc861_asus_init_verbs,
11924 alc861_asus_laptop_init_verbs },
11925 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11926 .dac_nids = alc861_dac_nids,
11927 .dig_out_nid = ALC861_DIGOUT_NID,
11928 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11929 .channel_mode = alc883_3ST_2ch_modes,
11930 .need_dac_fix = 1,
11931 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11932 .adc_nids = alc861_adc_nids,
11933 .input_mux = &alc861_capture_source,
11934 },
11935};
Kailang Yangdf694da2005-12-05 19:42:22 +010011936
11937
11938static int patch_alc861(struct hda_codec *codec)
11939{
11940 struct alc_spec *spec;
11941 int board_config;
11942 int err;
11943
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011944 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011945 if (spec == NULL)
11946 return -ENOMEM;
11947
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011948 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011949
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011950 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11951 alc861_models,
11952 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011953
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011954 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011955 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11956 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011957 board_config = ALC861_AUTO;
11958 }
11959
11960 if (board_config == ALC861_AUTO) {
11961 /* automatic parse from the BIOS config */
11962 err = alc861_parse_auto_config(codec);
11963 if (err < 0) {
11964 alc_free(codec);
11965 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011966 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011967 printk(KERN_INFO
11968 "hda_codec: Cannot set up configuration "
11969 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011970 board_config = ALC861_3ST_DIG;
11971 }
11972 }
11973
11974 if (board_config != ALC861_AUTO)
11975 setup_preset(spec, &alc861_presets[board_config]);
11976
11977 spec->stream_name_analog = "ALC861 Analog";
11978 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11979 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11980
11981 spec->stream_name_digital = "ALC861 Digital";
11982 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11983 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11984
Takashi Iwai2134ea42008-01-10 16:53:55 +010011985 spec->vmaster_nid = 0x03;
11986
Kailang Yangdf694da2005-12-05 19:42:22 +010011987 codec->patch_ops = alc_patch_ops;
11988 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011989 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011990#ifdef CONFIG_SND_HDA_POWER_SAVE
11991 if (!spec->loopback.amplist)
11992 spec->loopback.amplist = alc861_loopbacks;
11993#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011994
11995 return 0;
11996}
11997
11998/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011999 * ALC861-VD support
12000 *
12001 * Based on ALC882
12002 *
12003 * In addition, an independent DAC
12004 */
12005#define ALC861VD_DIGOUT_NID 0x06
12006
12007static hda_nid_t alc861vd_dac_nids[4] = {
12008 /* front, surr, clfe, side surr */
12009 0x02, 0x03, 0x04, 0x05
12010};
12011
12012/* dac_nids for ALC660vd are in a different order - according to
12013 * Realtek's driver.
12014 * This should probably tesult in a different mixer for 6stack models
12015 * of ALC660vd codecs, but for now there is only 3stack mixer
12016 * - and it is the same as in 861vd.
12017 * adc_nids in ALC660vd are (is) the same as in 861vd
12018 */
12019static hda_nid_t alc660vd_dac_nids[3] = {
12020 /* front, rear, clfe, rear_surr */
12021 0x02, 0x04, 0x03
12022};
12023
12024static hda_nid_t alc861vd_adc_nids[1] = {
12025 /* ADC0 */
12026 0x09,
12027};
12028
Takashi Iwaie1406342008-02-11 18:32:32 +010012029static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12030
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012031/* input MUX */
12032/* FIXME: should be a matrix-type input source selection */
12033static struct hda_input_mux alc861vd_capture_source = {
12034 .num_items = 4,
12035 .items = {
12036 { "Mic", 0x0 },
12037 { "Front Mic", 0x1 },
12038 { "Line", 0x2 },
12039 { "CD", 0x4 },
12040 },
12041};
12042
Kailang Yang272a5272007-05-14 11:00:38 +020012043static struct hda_input_mux alc861vd_dallas_capture_source = {
12044 .num_items = 3,
12045 .items = {
12046 { "Front Mic", 0x0 },
12047 { "ATAPI Mic", 0x1 },
12048 { "Line In", 0x5 },
12049 },
12050};
12051
Kailang Yangd1a991a2007-08-15 16:21:59 +020012052static struct hda_input_mux alc861vd_hp_capture_source = {
12053 .num_items = 2,
12054 .items = {
12055 { "Front Mic", 0x0 },
12056 { "ATAPI Mic", 0x1 },
12057 },
12058};
12059
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012060#define alc861vd_mux_enum_info alc_mux_enum_info
12061#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012062/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12063#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012064
12065/*
12066 * 2ch mode
12067 */
12068static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12069 { 2, NULL }
12070};
12071
12072/*
12073 * 6ch mode
12074 */
12075static struct hda_verb alc861vd_6stack_ch6_init[] = {
12076 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12077 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12078 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12079 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12080 { } /* end */
12081};
12082
12083/*
12084 * 8ch mode
12085 */
12086static struct hda_verb alc861vd_6stack_ch8_init[] = {
12087 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12088 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12089 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12090 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12091 { } /* end */
12092};
12093
12094static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12095 { 6, alc861vd_6stack_ch6_init },
12096 { 8, alc861vd_6stack_ch8_init },
12097};
12098
12099static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12100 {
12101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12102 .name = "Channel Mode",
12103 .info = alc_ch_mode_info,
12104 .get = alc_ch_mode_get,
12105 .put = alc_ch_mode_put,
12106 },
12107 { } /* end */
12108};
12109
12110static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12111 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12112 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12113
12114 {
12115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12116 /* The multiple "Capture Source" controls confuse alsamixer
12117 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012118 */
12119 /* .name = "Capture Source", */
12120 .name = "Input Source",
12121 .count = 1,
12122 .info = alc861vd_mux_enum_info,
12123 .get = alc861vd_mux_enum_get,
12124 .put = alc861vd_mux_enum_put,
12125 },
12126 { } /* end */
12127};
12128
12129/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12130 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12131 */
12132static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12133 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12134 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12135
12136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12137 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12138
12139 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12140 HDA_OUTPUT),
12141 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12142 HDA_OUTPUT),
12143 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12144 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12145
12146 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12147 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12148
12149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12150
12151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12154
12155 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12156 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12157 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12158
12159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12161
12162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12164
12165 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12166 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12167
12168 { } /* end */
12169};
12170
12171static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12174
12175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12176
12177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12180
12181 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12182 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12184
12185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12187
12188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12190
12191 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12192 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12193
12194 { } /* end */
12195};
12196
Kailang Yangbdd148a2007-05-08 15:19:08 +020012197static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12198 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12199 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12200 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12201
12202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12203
12204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12207
12208 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12210 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12211
12212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12214
12215 { } /* end */
12216};
12217
Kailang Yang272a5272007-05-14 11:00:38 +020012218/* Pin assignment: Front=0x14, HP = 0x15,
12219 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12220 */
12221static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12222 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12224 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12225 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12228 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12229 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012232 { } /* end */
12233};
12234
Kailang Yangd1a991a2007-08-15 16:21:59 +020012235/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12236 * Front Mic=0x18, ATAPI Mic = 0x19,
12237 */
12238static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12239 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12242 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12245 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12246 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12247
12248 { } /* end */
12249};
12250
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012251/*
12252 * generic initialization of ADC, input mixers and output mixers
12253 */
12254static struct hda_verb alc861vd_volume_init_verbs[] = {
12255 /*
12256 * Unmute ADC0 and set the default input to mic-in
12257 */
12258 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12260
12261 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12262 * the analog-loopback mixer widget
12263 */
12264 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012270
12271 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012276
12277 /*
12278 * Set up output mixers (0x02 - 0x05)
12279 */
12280 /* set vol=0 to output mixers */
12281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12283 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12285
12286 /* set up input amps for analog loopback */
12287 /* Amp Indices: DAC = 0, mixer = 1 */
12288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12296
12297 { }
12298};
12299
12300/*
12301 * 3-stack pin configuration:
12302 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12303 */
12304static struct hda_verb alc861vd_3stack_init_verbs[] = {
12305 /*
12306 * Set pin mode and muting
12307 */
12308 /* set front pin widgets 0x14 for output */
12309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12311 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12312
12313 /* Mic (rear) pin: input vref at 80% */
12314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12316 /* Front Mic pin: input vref at 80% */
12317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12319 /* Line In pin: input */
12320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12322 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12324 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12325 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12326 /* CD pin widget for input */
12327 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12328
12329 { }
12330};
12331
12332/*
12333 * 6-stack pin configuration:
12334 */
12335static struct hda_verb alc861vd_6stack_init_verbs[] = {
12336 /*
12337 * Set pin mode and muting
12338 */
12339 /* set front pin widgets 0x14 for output */
12340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12342 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12343
12344 /* Rear Pin: output 1 (0x0d) */
12345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12348 /* CLFE Pin: output 2 (0x0e) */
12349 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12350 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12351 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12352 /* Side Pin: output 3 (0x0f) */
12353 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12354 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12355 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12356
12357 /* Mic (rear) pin: input vref at 80% */
12358 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12359 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12360 /* Front Mic pin: input vref at 80% */
12361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12363 /* Line In pin: input */
12364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12365 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12366 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12369 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12370 /* CD pin widget for input */
12371 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12372
12373 { }
12374};
12375
Kailang Yangbdd148a2007-05-08 15:19:08 +020012376static struct hda_verb alc861vd_eapd_verbs[] = {
12377 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12378 { }
12379};
12380
12381static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12385 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12386 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12387 {}
12388};
12389
12390/* toggle speaker-output according to the hp-jack state */
12391static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12392{
12393 unsigned int present;
12394 unsigned char bits;
12395
12396 present = snd_hda_codec_read(codec, 0x1b, 0,
12397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012398 bits = present ? HDA_AMP_MUTE : 0;
12399 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12400 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012401}
12402
12403static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12404{
12405 unsigned int present;
12406 unsigned char bits;
12407
12408 present = snd_hda_codec_read(codec, 0x18, 0,
12409 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012410 bits = present ? HDA_AMP_MUTE : 0;
12411 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12412 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012413}
12414
12415static void alc861vd_lenovo_automute(struct hda_codec *codec)
12416{
12417 alc861vd_lenovo_hp_automute(codec);
12418 alc861vd_lenovo_mic_automute(codec);
12419}
12420
12421static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12422 unsigned int res)
12423{
12424 switch (res >> 26) {
12425 case ALC880_HP_EVENT:
12426 alc861vd_lenovo_hp_automute(codec);
12427 break;
12428 case ALC880_MIC_EVENT:
12429 alc861vd_lenovo_mic_automute(codec);
12430 break;
12431 }
12432}
12433
Kailang Yang272a5272007-05-14 11:00:38 +020012434static struct hda_verb alc861vd_dallas_verbs[] = {
12435 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12438 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12439
12440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12448
12449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12455 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12457
12458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12464 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12465 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12466
12467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12471
12472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12473 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12475
12476 { } /* end */
12477};
12478
12479/* toggle speaker-output according to the hp-jack state */
12480static void alc861vd_dallas_automute(struct hda_codec *codec)
12481{
12482 unsigned int present;
12483
12484 present = snd_hda_codec_read(codec, 0x15, 0,
12485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12487 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012488}
12489
12490static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12491{
12492 if ((res >> 26) == ALC880_HP_EVENT)
12493 alc861vd_dallas_automute(codec);
12494}
12495
Takashi Iwaicb53c622007-08-10 17:21:45 +020012496#ifdef CONFIG_SND_HDA_POWER_SAVE
12497#define alc861vd_loopbacks alc880_loopbacks
12498#endif
12499
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012500/* pcm configuration: identiacal with ALC880 */
12501#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12502#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12503#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12504#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12505
12506/*
12507 * configuration and preset
12508 */
12509static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12510 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012511 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012512 [ALC861VD_3ST] = "3stack",
12513 [ALC861VD_3ST_DIG] = "3stack-digout",
12514 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012515 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012516 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012517 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012518 [ALC861VD_AUTO] = "auto",
12519};
12520
12521static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012522 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12523 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012524 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012525 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012526 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012527 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012528 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012529 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012530 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012531 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012532 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012533 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12534 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012535 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012536 {}
12537};
12538
12539static struct alc_config_preset alc861vd_presets[] = {
12540 [ALC660VD_3ST] = {
12541 .mixers = { alc861vd_3st_mixer },
12542 .init_verbs = { alc861vd_volume_init_verbs,
12543 alc861vd_3stack_init_verbs },
12544 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12545 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012546 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12547 .channel_mode = alc861vd_3stack_2ch_modes,
12548 .input_mux = &alc861vd_capture_source,
12549 },
Mike Crash6963f842007-06-25 12:12:51 +020012550 [ALC660VD_3ST_DIG] = {
12551 .mixers = { alc861vd_3st_mixer },
12552 .init_verbs = { alc861vd_volume_init_verbs,
12553 alc861vd_3stack_init_verbs },
12554 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12555 .dac_nids = alc660vd_dac_nids,
12556 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020012557 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12558 .channel_mode = alc861vd_3stack_2ch_modes,
12559 .input_mux = &alc861vd_capture_source,
12560 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012561 [ALC861VD_3ST] = {
12562 .mixers = { alc861vd_3st_mixer },
12563 .init_verbs = { alc861vd_volume_init_verbs,
12564 alc861vd_3stack_init_verbs },
12565 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12566 .dac_nids = alc861vd_dac_nids,
12567 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12568 .channel_mode = alc861vd_3stack_2ch_modes,
12569 .input_mux = &alc861vd_capture_source,
12570 },
12571 [ALC861VD_3ST_DIG] = {
12572 .mixers = { alc861vd_3st_mixer },
12573 .init_verbs = { alc861vd_volume_init_verbs,
12574 alc861vd_3stack_init_verbs },
12575 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12576 .dac_nids = alc861vd_dac_nids,
12577 .dig_out_nid = ALC861VD_DIGOUT_NID,
12578 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12579 .channel_mode = alc861vd_3stack_2ch_modes,
12580 .input_mux = &alc861vd_capture_source,
12581 },
12582 [ALC861VD_6ST_DIG] = {
12583 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12584 .init_verbs = { alc861vd_volume_init_verbs,
12585 alc861vd_6stack_init_verbs },
12586 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12587 .dac_nids = alc861vd_dac_nids,
12588 .dig_out_nid = ALC861VD_DIGOUT_NID,
12589 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12590 .channel_mode = alc861vd_6stack_modes,
12591 .input_mux = &alc861vd_capture_source,
12592 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012593 [ALC861VD_LENOVO] = {
12594 .mixers = { alc861vd_lenovo_mixer },
12595 .init_verbs = { alc861vd_volume_init_verbs,
12596 alc861vd_3stack_init_verbs,
12597 alc861vd_eapd_verbs,
12598 alc861vd_lenovo_unsol_verbs },
12599 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12600 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012601 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12602 .channel_mode = alc861vd_3stack_2ch_modes,
12603 .input_mux = &alc861vd_capture_source,
12604 .unsol_event = alc861vd_lenovo_unsol_event,
12605 .init_hook = alc861vd_lenovo_automute,
12606 },
Kailang Yang272a5272007-05-14 11:00:38 +020012607 [ALC861VD_DALLAS] = {
12608 .mixers = { alc861vd_dallas_mixer },
12609 .init_verbs = { alc861vd_dallas_verbs },
12610 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12611 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020012612 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12613 .channel_mode = alc861vd_3stack_2ch_modes,
12614 .input_mux = &alc861vd_dallas_capture_source,
12615 .unsol_event = alc861vd_dallas_unsol_event,
12616 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012617 },
12618 [ALC861VD_HP] = {
12619 .mixers = { alc861vd_hp_mixer },
12620 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12621 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12622 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012623 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012624 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12625 .channel_mode = alc861vd_3stack_2ch_modes,
12626 .input_mux = &alc861vd_hp_capture_source,
12627 .unsol_event = alc861vd_dallas_unsol_event,
12628 .init_hook = alc861vd_dallas_automute,
12629 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012630};
12631
12632/*
12633 * BIOS auto configuration
12634 */
12635static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12636 hda_nid_t nid, int pin_type, int dac_idx)
12637{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012638 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012639}
12640
12641static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12642{
12643 struct alc_spec *spec = codec->spec;
12644 int i;
12645
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012646 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012647 for (i = 0; i <= HDA_SIDE; i++) {
12648 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012649 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012650 if (nid)
12651 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012652 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012653 }
12654}
12655
12656
12657static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12658{
12659 struct alc_spec *spec = codec->spec;
12660 hda_nid_t pin;
12661
12662 pin = spec->autocfg.hp_pins[0];
12663 if (pin) /* connect to front and use dac 0 */
12664 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012665 pin = spec->autocfg.speaker_pins[0];
12666 if (pin)
12667 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012668}
12669
12670#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12671#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12672
12673static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12674{
12675 struct alc_spec *spec = codec->spec;
12676 int i;
12677
12678 for (i = 0; i < AUTO_PIN_LAST; i++) {
12679 hda_nid_t nid = spec->autocfg.input_pins[i];
12680 if (alc861vd_is_input_pin(nid)) {
12681 snd_hda_codec_write(codec, nid, 0,
12682 AC_VERB_SET_PIN_WIDGET_CONTROL,
12683 i <= AUTO_PIN_FRONT_MIC ?
12684 PIN_VREF80 : PIN_IN);
12685 if (nid != ALC861VD_PIN_CD_NID)
12686 snd_hda_codec_write(codec, nid, 0,
12687 AC_VERB_SET_AMP_GAIN_MUTE,
12688 AMP_OUT_MUTE);
12689 }
12690 }
12691}
12692
12693#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12694#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12695
12696/* add playback controls from the parsed DAC table */
12697/* Based on ALC880 version. But ALC861VD has separate,
12698 * different NIDs for mute/unmute switch and volume control */
12699static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12700 const struct auto_pin_cfg *cfg)
12701{
12702 char name[32];
12703 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12704 hda_nid_t nid_v, nid_s;
12705 int i, err;
12706
12707 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012708 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012709 continue;
12710 nid_v = alc861vd_idx_to_mixer_vol(
12711 alc880_dac_to_idx(
12712 spec->multiout.dac_nids[i]));
12713 nid_s = alc861vd_idx_to_mixer_switch(
12714 alc880_dac_to_idx(
12715 spec->multiout.dac_nids[i]));
12716
12717 if (i == 2) {
12718 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012719 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12720 "Center Playback Volume",
12721 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12722 HDA_OUTPUT));
12723 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012724 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012725 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12726 "LFE Playback Volume",
12727 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12728 HDA_OUTPUT));
12729 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012730 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012731 err = add_control(spec, ALC_CTL_BIND_MUTE,
12732 "Center Playback Switch",
12733 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12734 HDA_INPUT));
12735 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012736 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012737 err = add_control(spec, ALC_CTL_BIND_MUTE,
12738 "LFE Playback Switch",
12739 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12740 HDA_INPUT));
12741 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012742 return err;
12743 } else {
12744 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012745 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12746 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12747 HDA_OUTPUT));
12748 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012749 return err;
12750 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012751 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012752 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012753 HDA_INPUT));
12754 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012755 return err;
12756 }
12757 }
12758 return 0;
12759}
12760
12761/* add playback controls for speaker and HP outputs */
12762/* Based on ALC880 version. But ALC861VD has separate,
12763 * different NIDs for mute/unmute switch and volume control */
12764static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12765 hda_nid_t pin, const char *pfx)
12766{
12767 hda_nid_t nid_v, nid_s;
12768 int err;
12769 char name[32];
12770
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012771 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012772 return 0;
12773
12774 if (alc880_is_fixed_pin(pin)) {
12775 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12776 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012777 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012778 spec->multiout.hp_nid = nid_v;
12779 else
12780 spec->multiout.extra_out_nid[0] = nid_v;
12781 /* control HP volume/switch on the output mixer amp */
12782 nid_v = alc861vd_idx_to_mixer_vol(
12783 alc880_fixed_pin_idx(pin));
12784 nid_s = alc861vd_idx_to_mixer_switch(
12785 alc880_fixed_pin_idx(pin));
12786
12787 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012788 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12789 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12790 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012791 return err;
12792 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012793 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12794 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12795 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012796 return err;
12797 } else if (alc880_is_multi_pin(pin)) {
12798 /* set manual connection */
12799 /* we have only a switch on HP-out PIN */
12800 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012801 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12802 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12803 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012804 return err;
12805 }
12806 return 0;
12807}
12808
12809/* parse the BIOS configuration and set up the alc_spec
12810 * return 1 if successful, 0 if the proper config is not found,
12811 * or a negative error code
12812 * Based on ALC880 version - had to change it to override
12813 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12814static int alc861vd_parse_auto_config(struct hda_codec *codec)
12815{
12816 struct alc_spec *spec = codec->spec;
12817 int err;
12818 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12819
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012820 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12821 alc861vd_ignore);
12822 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012823 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012824 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012825 return 0; /* can't find valid BIOS pin config */
12826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012827 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12828 if (err < 0)
12829 return err;
12830 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12831 if (err < 0)
12832 return err;
12833 err = alc861vd_auto_create_extra_out(spec,
12834 spec->autocfg.speaker_pins[0],
12835 "Speaker");
12836 if (err < 0)
12837 return err;
12838 err = alc861vd_auto_create_extra_out(spec,
12839 spec->autocfg.hp_pins[0],
12840 "Headphone");
12841 if (err < 0)
12842 return err;
12843 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12844 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012845 return err;
12846
12847 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12848
12849 if (spec->autocfg.dig_out_pin)
12850 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12851
12852 if (spec->kctl_alloc)
12853 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12854
12855 spec->init_verbs[spec->num_init_verbs++]
12856 = alc861vd_volume_init_verbs;
12857
12858 spec->num_mux_defs = 1;
12859 spec->input_mux = &spec->private_imux;
12860
Takashi Iwai776e1842007-08-29 15:07:11 +020012861 err = alc_auto_add_mic_boost(codec);
12862 if (err < 0)
12863 return err;
12864
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012865 return 1;
12866}
12867
12868/* additional initialization for auto-configuration model */
12869static void alc861vd_auto_init(struct hda_codec *codec)
12870{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012871 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012872 alc861vd_auto_init_multi_out(codec);
12873 alc861vd_auto_init_hp_out(codec);
12874 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012875 if (spec->unsol_event)
12876 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012877}
12878
12879static int patch_alc861vd(struct hda_codec *codec)
12880{
12881 struct alc_spec *spec;
12882 int err, board_config;
12883
12884 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12885 if (spec == NULL)
12886 return -ENOMEM;
12887
12888 codec->spec = spec;
12889
12890 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12891 alc861vd_models,
12892 alc861vd_cfg_tbl);
12893
12894 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12895 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12896 "ALC861VD, trying auto-probe from BIOS...\n");
12897 board_config = ALC861VD_AUTO;
12898 }
12899
12900 if (board_config == ALC861VD_AUTO) {
12901 /* automatic parse from the BIOS config */
12902 err = alc861vd_parse_auto_config(codec);
12903 if (err < 0) {
12904 alc_free(codec);
12905 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012906 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012907 printk(KERN_INFO
12908 "hda_codec: Cannot set up configuration "
12909 "from BIOS. Using base mode...\n");
12910 board_config = ALC861VD_3ST;
12911 }
12912 }
12913
12914 if (board_config != ALC861VD_AUTO)
12915 setup_preset(spec, &alc861vd_presets[board_config]);
12916
12917 spec->stream_name_analog = "ALC861VD Analog";
12918 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12919 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12920
12921 spec->stream_name_digital = "ALC861VD Digital";
12922 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12923 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12924
12925 spec->adc_nids = alc861vd_adc_nids;
12926 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010012927 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012928
12929 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12930 spec->num_mixers++;
12931
Takashi Iwai2134ea42008-01-10 16:53:55 +010012932 spec->vmaster_nid = 0x02;
12933
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012934 codec->patch_ops = alc_patch_ops;
12935
12936 if (board_config == ALC861VD_AUTO)
12937 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012938#ifdef CONFIG_SND_HDA_POWER_SAVE
12939 if (!spec->loopback.amplist)
12940 spec->loopback.amplist = alc861vd_loopbacks;
12941#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012942
12943 return 0;
12944}
12945
12946/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012947 * ALC662 support
12948 *
12949 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12950 * configuration. Each pin widget can choose any input DACs and a mixer.
12951 * Each ADC is connected from a mixer of all inputs. This makes possible
12952 * 6-channel independent captures.
12953 *
12954 * In addition, an independent DAC for the multi-playback (not used in this
12955 * driver yet).
12956 */
12957#define ALC662_DIGOUT_NID 0x06
12958#define ALC662_DIGIN_NID 0x0a
12959
12960static hda_nid_t alc662_dac_nids[4] = {
12961 /* front, rear, clfe, rear_surr */
12962 0x02, 0x03, 0x04
12963};
12964
12965static hda_nid_t alc662_adc_nids[1] = {
12966 /* ADC1-2 */
12967 0x09,
12968};
Takashi Iwaie1406342008-02-11 18:32:32 +010012969
Kailang Yang77a261b2008-02-19 11:38:05 +010012970static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010012971
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012972/* input MUX */
12973/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012974static struct hda_input_mux alc662_capture_source = {
12975 .num_items = 4,
12976 .items = {
12977 { "Mic", 0x0 },
12978 { "Front Mic", 0x1 },
12979 { "Line", 0x2 },
12980 { "CD", 0x4 },
12981 },
12982};
12983
12984static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12985 .num_items = 2,
12986 .items = {
12987 { "Mic", 0x1 },
12988 { "Line", 0x2 },
12989 },
12990};
Kailang Yang291702f2007-10-16 14:28:03 +020012991
12992static struct hda_input_mux alc662_eeepc_capture_source = {
12993 .num_items = 2,
12994 .items = {
12995 { "i-Mic", 0x1 },
12996 { "e-Mic", 0x0 },
12997 },
12998};
12999
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013000#define alc662_mux_enum_info alc_mux_enum_info
13001#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013002#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013003
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013004/*
13005 * 2ch mode
13006 */
13007static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13008 { 2, NULL }
13009};
13010
13011/*
13012 * 2ch mode
13013 */
13014static struct hda_verb alc662_3ST_ch2_init[] = {
13015 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13016 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13017 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13018 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13019 { } /* end */
13020};
13021
13022/*
13023 * 6ch mode
13024 */
13025static struct hda_verb alc662_3ST_ch6_init[] = {
13026 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13027 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13028 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13029 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13030 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13031 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13032 { } /* end */
13033};
13034
13035static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13036 { 2, alc662_3ST_ch2_init },
13037 { 6, alc662_3ST_ch6_init },
13038};
13039
13040/*
13041 * 2ch mode
13042 */
13043static struct hda_verb alc662_sixstack_ch6_init[] = {
13044 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13045 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13046 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13047 { } /* end */
13048};
13049
13050/*
13051 * 6ch mode
13052 */
13053static struct hda_verb alc662_sixstack_ch8_init[] = {
13054 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13055 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13056 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13057 { } /* end */
13058};
13059
13060static struct hda_channel_mode alc662_5stack_modes[2] = {
13061 { 2, alc662_sixstack_ch6_init },
13062 { 6, alc662_sixstack_ch8_init },
13063};
13064
13065/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13066 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13067 */
13068
13069static struct snd_kcontrol_new alc662_base_mixer[] = {
13070 /* output mixer control */
13071 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13072 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
13073 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13074 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13075 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13076 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13077 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13078 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13080
13081 /*Input mixer control */
13082 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13083 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13084 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13085 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13086 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13087 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13088 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13089 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013090 { } /* end */
13091};
13092
13093static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13094 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13095 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13105 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13106 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013107 { } /* end */
13108};
13109
13110static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13111 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13112 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13113 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13114 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13115 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13116 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13117 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13118 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13120 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13121 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13126 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13127 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13128 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13129 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013130 { } /* end */
13131};
13132
13133static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13134 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13135 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013136 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13137 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013143 { } /* end */
13144};
13145
Kailang Yang291702f2007-10-16 14:28:03 +020013146static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013147 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013148
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013149 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13150 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013151
13152 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13153 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13154 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13155
13156 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13157 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13158 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13159 { } /* end */
13160};
13161
Kailang Yang8c427222008-01-10 13:03:59 +010013162static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013163 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13164 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013165 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13166 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13167 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13169 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13170 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013171 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013172 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13177 { } /* end */
13178};
13179
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013180static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13181 {
13182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13183 .name = "Channel Mode",
13184 .info = alc_ch_mode_info,
13185 .get = alc_ch_mode_get,
13186 .put = alc_ch_mode_put,
13187 },
13188 { } /* end */
13189};
13190
13191static struct hda_verb alc662_init_verbs[] = {
13192 /* ADC: mute amp left and right */
13193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13194 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13195 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13196
Takashi Iwaicb53c622007-08-10 17:21:45 +020013197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013202
Kailang Yangb60dd392007-09-20 12:50:29 +020013203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013209
13210 /* Front Pin: output 0 (0x0c) */
13211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13213
13214 /* Rear Pin: output 1 (0x0d) */
13215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13217
13218 /* CLFE Pin: output 2 (0x0e) */
13219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13220 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13221
13222 /* Mic (rear) pin: input vref at 80% */
13223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13225 /* Front Mic pin: input vref at 80% */
13226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13228 /* Line In pin: input */
13229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13231 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13235 /* CD pin widget for input */
13236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13237
13238 /* FIXME: use matrix-type input source selection */
13239 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13240 /* Input mixer */
13241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013245
13246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013250 { }
13251};
13252
13253static struct hda_verb alc662_sue_init_verbs[] = {
13254 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13255 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013256 {}
13257};
13258
13259static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13261 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13262 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013263};
13264
Kailang Yang8c427222008-01-10 13:03:59 +010013265/* Set Unsolicited Event*/
13266static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13267 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13268 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13269 {}
13270};
13271
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013272/*
13273 * generic initialization of ADC, input mixers and output mixers
13274 */
13275static struct hda_verb alc662_auto_init_verbs[] = {
13276 /*
13277 * Unmute ADC and set the default input to mic-in
13278 */
13279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13281
13282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13283 * mixer widget
13284 * Note: PASD motherboards uses the Line In 2 as the input for front
13285 * panel mic (mic 2)
13286 */
13287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013293
13294 /*
13295 * Set up output mixers (0x0c - 0x0f)
13296 */
13297 /* set vol=0 to output mixers */
13298 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13299 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13300 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13301
13302 /* set up input amps for analog loopback */
13303 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013310
13311
13312 /* FIXME: use matrix-type input source selection */
13313 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13314 /* Input mixer */
13315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013317 { }
13318};
13319
13320/* capture mixer elements */
13321static struct snd_kcontrol_new alc662_capture_mixer[] = {
13322 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13323 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13324 {
13325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13326 /* The multiple "Capture Source" controls confuse alsamixer
13327 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013328 */
13329 /* .name = "Capture Source", */
13330 .name = "Input Source",
13331 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013332 .info = alc662_mux_enum_info,
13333 .get = alc662_mux_enum_get,
13334 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013335 },
13336 { } /* end */
13337};
13338
13339static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13340{
13341 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013342 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013343
13344 present = snd_hda_codec_read(codec, 0x14, 0,
13345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013346 bits = present ? HDA_AMP_MUTE : 0;
13347 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13348 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013349}
13350
13351static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13352{
13353 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013354 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013355
13356 present = snd_hda_codec_read(codec, 0x1b, 0,
13357 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013358 bits = present ? HDA_AMP_MUTE : 0;
13359 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13360 HDA_AMP_MUTE, bits);
13361 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13362 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013363}
13364
13365static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13366 unsigned int res)
13367{
13368 if ((res >> 26) == ALC880_HP_EVENT)
13369 alc662_lenovo_101e_all_automute(codec);
13370 if ((res >> 26) == ALC880_FRONT_EVENT)
13371 alc662_lenovo_101e_ispeaker_automute(codec);
13372}
13373
Kailang Yang291702f2007-10-16 14:28:03 +020013374static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13375{
13376 unsigned int present;
13377
13378 present = snd_hda_codec_read(codec, 0x18, 0,
13379 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13380 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13381 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13382 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13383 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13384 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13385 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13386 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13387 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13388}
13389
13390/* unsolicited event for HP jack sensing */
13391static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13392 unsigned int res)
13393{
13394 if ((res >> 26) == ALC880_HP_EVENT)
13395 alc262_hippo1_automute( codec );
13396
13397 if ((res >> 26) == ALC880_MIC_EVENT)
13398 alc662_eeepc_mic_automute(codec);
13399}
13400
13401static void alc662_eeepc_inithook(struct hda_codec *codec)
13402{
13403 alc262_hippo1_automute( codec );
13404 alc662_eeepc_mic_automute(codec);
13405}
13406
Kailang Yang8c427222008-01-10 13:03:59 +010013407static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13408{
13409 unsigned int mute;
13410 unsigned int present;
13411
13412 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13413 present = snd_hda_codec_read(codec, 0x14, 0,
13414 AC_VERB_GET_PIN_SENSE, 0);
13415 present = (present & 0x80000000) != 0;
13416 if (present) {
13417 /* mute internal speaker */
13418 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13419 HDA_AMP_MUTE, HDA_AMP_MUTE);
13420 } else {
13421 /* unmute internal speaker if necessary */
13422 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13423 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13424 HDA_AMP_MUTE, mute);
13425 }
13426}
13427
13428/* unsolicited event for HP jack sensing */
13429static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13430 unsigned int res)
13431{
13432 if ((res >> 26) == ALC880_HP_EVENT)
13433 alc662_eeepc_ep20_automute(codec);
13434}
13435
13436static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13437{
13438 alc662_eeepc_ep20_automute(codec);
13439}
13440
Takashi Iwaicb53c622007-08-10 17:21:45 +020013441#ifdef CONFIG_SND_HDA_POWER_SAVE
13442#define alc662_loopbacks alc880_loopbacks
13443#endif
13444
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013445
13446/* pcm configuration: identiacal with ALC880 */
13447#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13448#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13449#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13450#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13451
13452/*
13453 * configuration and preset
13454 */
13455static const char *alc662_models[ALC662_MODEL_LAST] = {
13456 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13457 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13458 [ALC662_3ST_6ch] = "3stack-6ch",
13459 [ALC662_5ST_DIG] = "6stack-dig",
13460 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013461 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013462 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013463 [ALC662_AUTO] = "auto",
13464};
13465
13466static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013467 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013468 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013469 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013470 {}
13471};
13472
13473static struct alc_config_preset alc662_presets[] = {
13474 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013475 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013476 .init_verbs = { alc662_init_verbs },
13477 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13478 .dac_nids = alc662_dac_nids,
13479 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013480 .dig_in_nid = ALC662_DIGIN_NID,
13481 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13482 .channel_mode = alc662_3ST_2ch_modes,
13483 .input_mux = &alc662_capture_source,
13484 },
13485 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013486 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13487 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013488 .init_verbs = { alc662_init_verbs },
13489 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13490 .dac_nids = alc662_dac_nids,
13491 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013492 .dig_in_nid = ALC662_DIGIN_NID,
13493 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13494 .channel_mode = alc662_3ST_6ch_modes,
13495 .need_dac_fix = 1,
13496 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013497 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013498 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013499 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13500 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013501 .init_verbs = { alc662_init_verbs },
13502 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13503 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13505 .channel_mode = alc662_3ST_6ch_modes,
13506 .need_dac_fix = 1,
13507 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013508 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013509 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013510 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13511 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013512 .init_verbs = { alc662_init_verbs },
13513 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13514 .dac_nids = alc662_dac_nids,
13515 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013516 .dig_in_nid = ALC662_DIGIN_NID,
13517 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13518 .channel_mode = alc662_5stack_modes,
13519 .input_mux = &alc662_capture_source,
13520 },
13521 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013522 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013523 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13524 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13525 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013526 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13527 .channel_mode = alc662_3ST_2ch_modes,
13528 .input_mux = &alc662_lenovo_101e_capture_source,
13529 .unsol_event = alc662_lenovo_101e_unsol_event,
13530 .init_hook = alc662_lenovo_101e_all_automute,
13531 },
Kailang Yang291702f2007-10-16 14:28:03 +020013532 [ALC662_ASUS_EEEPC_P701] = {
13533 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13534 .init_verbs = { alc662_init_verbs,
13535 alc662_eeepc_sue_init_verbs },
13536 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13537 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020013538 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13539 .channel_mode = alc662_3ST_2ch_modes,
13540 .input_mux = &alc662_eeepc_capture_source,
13541 .unsol_event = alc662_eeepc_unsol_event,
13542 .init_hook = alc662_eeepc_inithook,
13543 },
Kailang Yang8c427222008-01-10 13:03:59 +010013544 [ALC662_ASUS_EEEPC_EP20] = {
13545 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13546 alc662_chmode_mixer },
13547 .init_verbs = { alc662_init_verbs,
13548 alc662_eeepc_ep20_sue_init_verbs },
13549 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13550 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010013551 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13552 .channel_mode = alc662_3ST_6ch_modes,
13553 .input_mux = &alc662_lenovo_101e_capture_source,
13554 .unsol_event = alc662_eeepc_ep20_unsol_event,
13555 .init_hook = alc662_eeepc_ep20_inithook,
13556 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013557
13558};
13559
13560
13561/*
13562 * BIOS auto configuration
13563 */
13564
13565/* add playback controls from the parsed DAC table */
13566static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13567 const struct auto_pin_cfg *cfg)
13568{
13569 char name[32];
13570 static const char *chname[4] = {
13571 "Front", "Surround", NULL /*CLFE*/, "Side"
13572 };
13573 hda_nid_t nid;
13574 int i, err;
13575
13576 for (i = 0; i < cfg->line_outs; i++) {
13577 if (!spec->multiout.dac_nids[i])
13578 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020013579 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013580 if (i == 2) {
13581 /* Center/LFE */
13582 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13583 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013584 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13585 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013586 if (err < 0)
13587 return err;
13588 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13589 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013590 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13591 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013592 if (err < 0)
13593 return err;
13594 err = add_control(spec, ALC_CTL_BIND_MUTE,
13595 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013596 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13597 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013598 if (err < 0)
13599 return err;
13600 err = add_control(spec, ALC_CTL_BIND_MUTE,
13601 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013602 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13603 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013604 if (err < 0)
13605 return err;
13606 } else {
13607 sprintf(name, "%s Playback Volume", chname[i]);
13608 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013609 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13610 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013611 if (err < 0)
13612 return err;
13613 sprintf(name, "%s Playback Switch", chname[i]);
13614 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013615 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13616 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013617 if (err < 0)
13618 return err;
13619 }
13620 }
13621 return 0;
13622}
13623
13624/* add playback controls for speaker and HP outputs */
13625static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13626 const char *pfx)
13627{
13628 hda_nid_t nid;
13629 int err;
13630 char name[32];
13631
13632 if (!pin)
13633 return 0;
13634
13635 if (alc880_is_fixed_pin(pin)) {
13636 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13637 /* printk("DAC nid=%x\n",nid); */
13638 /* specify the DAC as the extra output */
13639 if (!spec->multiout.hp_nid)
13640 spec->multiout.hp_nid = nid;
13641 else
13642 spec->multiout.extra_out_nid[0] = nid;
13643 /* control HP volume/switch on the output mixer amp */
13644 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13645 sprintf(name, "%s Playback Volume", pfx);
13646 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13647 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13648 if (err < 0)
13649 return err;
13650 sprintf(name, "%s Playback Switch", pfx);
13651 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13652 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13653 if (err < 0)
13654 return err;
13655 } else if (alc880_is_multi_pin(pin)) {
13656 /* set manual connection */
13657 /* we have only a switch on HP-out PIN */
13658 sprintf(name, "%s Playback Switch", pfx);
13659 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13660 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13661 if (err < 0)
13662 return err;
13663 }
13664 return 0;
13665}
13666
13667/* create playback/capture controls for input pins */
13668static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13669 const struct auto_pin_cfg *cfg)
13670{
13671 struct hda_input_mux *imux = &spec->private_imux;
13672 int i, err, idx;
13673
13674 for (i = 0; i < AUTO_PIN_LAST; i++) {
13675 if (alc880_is_input_pin(cfg->input_pins[i])) {
13676 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13677 err = new_analog_input(spec, cfg->input_pins[i],
13678 auto_pin_cfg_labels[i],
13679 idx, 0x0b);
13680 if (err < 0)
13681 return err;
13682 imux->items[imux->num_items].label =
13683 auto_pin_cfg_labels[i];
13684 imux->items[imux->num_items].index =
13685 alc880_input_pin_idx(cfg->input_pins[i]);
13686 imux->num_items++;
13687 }
13688 }
13689 return 0;
13690}
13691
13692static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13693 hda_nid_t nid, int pin_type,
13694 int dac_idx)
13695{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013696 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013697 /* need the manual connection? */
13698 if (alc880_is_multi_pin(nid)) {
13699 struct alc_spec *spec = codec->spec;
13700 int idx = alc880_multi_pin_idx(nid);
13701 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13702 AC_VERB_SET_CONNECT_SEL,
13703 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13704 }
13705}
13706
13707static void alc662_auto_init_multi_out(struct hda_codec *codec)
13708{
13709 struct alc_spec *spec = codec->spec;
13710 int i;
13711
Kailang Yang8c427222008-01-10 13:03:59 +010013712 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013713 for (i = 0; i <= HDA_SIDE; i++) {
13714 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013715 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013716 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013717 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013718 i);
13719 }
13720}
13721
13722static void alc662_auto_init_hp_out(struct hda_codec *codec)
13723{
13724 struct alc_spec *spec = codec->spec;
13725 hda_nid_t pin;
13726
13727 pin = spec->autocfg.hp_pins[0];
13728 if (pin) /* connect to front */
13729 /* use dac 0 */
13730 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013731 pin = spec->autocfg.speaker_pins[0];
13732 if (pin)
13733 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013734}
13735
13736#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13737#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13738
13739static void alc662_auto_init_analog_input(struct hda_codec *codec)
13740{
13741 struct alc_spec *spec = codec->spec;
13742 int i;
13743
13744 for (i = 0; i < AUTO_PIN_LAST; i++) {
13745 hda_nid_t nid = spec->autocfg.input_pins[i];
13746 if (alc662_is_input_pin(nid)) {
13747 snd_hda_codec_write(codec, nid, 0,
13748 AC_VERB_SET_PIN_WIDGET_CONTROL,
13749 (i <= AUTO_PIN_FRONT_MIC ?
13750 PIN_VREF80 : PIN_IN));
13751 if (nid != ALC662_PIN_CD_NID)
13752 snd_hda_codec_write(codec, nid, 0,
13753 AC_VERB_SET_AMP_GAIN_MUTE,
13754 AMP_OUT_MUTE);
13755 }
13756 }
13757}
13758
13759static int alc662_parse_auto_config(struct hda_codec *codec)
13760{
13761 struct alc_spec *spec = codec->spec;
13762 int err;
13763 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13764
13765 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13766 alc662_ignore);
13767 if (err < 0)
13768 return err;
13769 if (!spec->autocfg.line_outs)
13770 return 0; /* can't find valid BIOS pin config */
13771
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013772 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13773 if (err < 0)
13774 return err;
13775 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13776 if (err < 0)
13777 return err;
13778 err = alc662_auto_create_extra_out(spec,
13779 spec->autocfg.speaker_pins[0],
13780 "Speaker");
13781 if (err < 0)
13782 return err;
13783 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13784 "Headphone");
13785 if (err < 0)
13786 return err;
13787 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13788 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013789 return err;
13790
13791 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13792
13793 if (spec->autocfg.dig_out_pin)
13794 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13795
13796 if (spec->kctl_alloc)
13797 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13798
13799 spec->num_mux_defs = 1;
13800 spec->input_mux = &spec->private_imux;
13801
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013802 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013803 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13804 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013805 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013806}
13807
13808/* additional initialization for auto-configuration model */
13809static void alc662_auto_init(struct hda_codec *codec)
13810{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013811 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013812 alc662_auto_init_multi_out(codec);
13813 alc662_auto_init_hp_out(codec);
13814 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013815 if (spec->unsol_event)
13816 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013817}
13818
13819static int patch_alc662(struct hda_codec *codec)
13820{
13821 struct alc_spec *spec;
13822 int err, board_config;
13823
13824 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13825 if (!spec)
13826 return -ENOMEM;
13827
13828 codec->spec = spec;
13829
13830 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13831 alc662_models,
13832 alc662_cfg_tbl);
13833 if (board_config < 0) {
13834 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13835 "trying auto-probe from BIOS...\n");
13836 board_config = ALC662_AUTO;
13837 }
13838
13839 if (board_config == ALC662_AUTO) {
13840 /* automatic parse from the BIOS config */
13841 err = alc662_parse_auto_config(codec);
13842 if (err < 0) {
13843 alc_free(codec);
13844 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020013845 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013846 printk(KERN_INFO
13847 "hda_codec: Cannot set up configuration "
13848 "from BIOS. Using base mode...\n");
13849 board_config = ALC662_3ST_2ch_DIG;
13850 }
13851 }
13852
13853 if (board_config != ALC662_AUTO)
13854 setup_preset(spec, &alc662_presets[board_config]);
13855
13856 spec->stream_name_analog = "ALC662 Analog";
13857 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13858 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13859
13860 spec->stream_name_digital = "ALC662 Digital";
13861 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13862 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13863
Takashi Iwaie1406342008-02-11 18:32:32 +010013864 spec->adc_nids = alc662_adc_nids;
13865 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13866 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013867
Takashi Iwai2134ea42008-01-10 16:53:55 +010013868 spec->vmaster_nid = 0x02;
13869
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013870 codec->patch_ops = alc_patch_ops;
13871 if (board_config == ALC662_AUTO)
13872 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013873#ifdef CONFIG_SND_HDA_POWER_SAVE
13874 if (!spec->loopback.amplist)
13875 spec->loopback.amplist = alc662_loopbacks;
13876#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013877
13878 return 0;
13879}
13880
13881/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013882 * patch entries
13883 */
13884struct hda_codec_preset snd_hda_preset_realtek[] = {
13885 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013886 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013887 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020013888 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013889 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013890 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013891 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013892 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13893 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13894 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013895 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13896 .patch = patch_alc883 },
13897 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13898 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013899 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013900 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013901 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013902 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013903 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013904 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070013905 {} /* terminator */
13906};